zink, drirc: Add Borderlands 2 workaround to fix spir-v 1.6 translated discard
authorIllia Polishchuk <illia.a.polishchuk@globallogic.com>
Fri, 16 Jun 2023 12:53:36 +0000 (15:53 +0300)
committerMarge Bot <emma+marge@anholt.net>
Tue, 20 Jun 2023 08:48:02 +0000 (08:48 +0000)
The game expects HLSL discard behavour

But it fails only on Zink because GLSL discard translates to
nir_intrinsic_discard (BRW_PREDICATE_ALIGN1_ANY4H in native Intel asm)
but Zink replaces it with OpTerminateInvocation SPIR-V and it translates to
nir_intrinsic_terminate (BRW_PREDICATE_NORMAL in native Intel asm)

Bisected commit in ZINK: bd816084

On AMD it works because they enabled the
glsl_correct_derivatives_after_discard by default: !10522 (17861aff)

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9205
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Illia Polishchuk <illia.a.polishchuk@globallogic.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23694>

src/util/00-mesa-defaults.conf

index 843beae..24cc288 100644 (file)
@@ -1006,6 +1006,11 @@ TODO: document the other workarounds.
             <option name="mesa_glthread_app_profile" value="0"/>
         </application>
 
+        <application name="Borderlands 2 (Native, OpenGL, 32bit)" executable="Borderlands2">
+            <!-- https://gitlab.freedesktop.org/mesa/mesa/-/issues/9205 -->
+            <option name="glsl_correct_derivatives_after_discard" value="true" />
+        </application>
+
         <!-- GL_POINT_SMOOTH is used in Quake II to render particles -->
         <application name="Quake II" executable="quake2-engine">
             <option name="zink_emulate_point_smooth" value="true"/>