Skip to content

Commit

Permalink
spirv: add an options to lower SpvOpTerminateInvocation to OpKill
Browse files Browse the repository at this point in the history
To workaround game bugs like Indiana Jones.

Original workaround found by Hans-Kristian.

Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32606>
(cherry picked from commit 4d4418d)
  • Loading branch information
hakzsam committed Dec 13, 2024
1 parent e5e063c commit 13df7a6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .pick_status.json
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@
"description": "spirv: add an options to lower SpvOpTerminateInvocation to OpKill",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null
Expand Down
5 changes: 5 additions & 0 deletions src/compiler/spirv/nir_spirv.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ struct spirv_to_nir_options {
/* Force SSBO accesses to be non-uniform. */
bool force_ssbo_non_uniform;

/* Whether OpTerminateInvocation should be lowered to OpKill to workaround
* game bugs.
*/
bool lower_terminate_to_discard;

/* In Debug Builds, instead of emitting an OS break on failure, just return NULL from
* spirv_to_nir(). This is useful for the unit tests that want to report a test failed
* but continue executing other tests.
Expand Down
5 changes: 4 additions & 1 deletion src/compiler/spirv/vtn_structured_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,10 @@ branch_type_for_terminator(struct vtn_builder *b, struct vtn_block *block)
case SpvOpKill:
return vtn_branch_type_discard;
case SpvOpTerminateInvocation:
return vtn_branch_type_terminate_invocation;
if (b->options->lower_terminate_to_discard)
return vtn_branch_type_discard;
else
return vtn_branch_type_terminate_invocation;
case SpvOpIgnoreIntersectionKHR:
return vtn_branch_type_ignore_intersection;
case SpvOpTerminateRayKHR:
Expand Down

0 comments on commit 13df7a6

Please sign in to comment.