Module: Mesa
Branch: main
Commit: 5057eb90a13c0b42e0064252f34126a6713f8579
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5057eb90a13c0b42e0064252f34126a6713f8579

Author: Iago Toral Quiroga <ito...@igalia.com>
Date:   Mon Dec 11 10:13:43 2023 +0100

v3dv: implement VK_KHR_shader_terminate_invocation

The semantics for this matches those of discard.

Reviewed-by: Alejandro PiƱeiro <apinhe...@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26683>

---

 docs/features.txt                  | 2 +-
 src/broadcom/compiler/nir_to_vir.c | 4 +++-
 src/broadcom/vulkan/v3dv_device.c  | 4 ++++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/docs/features.txt b/docs/features.txt
index 93fc1e3ffa1..25e35563471 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -481,7 +481,7 @@ Vulkan 1.3 -- all DONE: anv, radv, tu, lvp, vn
   VK_KHR_maintenance4                                   DONE (anv, hasvk, lvp, 
nvk, radv, tu, v3dv, vn)
   VK_KHR_shader_integer_dot_product                     DONE (anv, dzn, hasvk, 
lvp, nvk, radv, tu, v3dv, vn)
   VK_KHR_shader_non_semantic_info                       DONE (anv, hasvk, nvk, 
radv, tu, v3dv, vn)
-  VK_KHR_shader_terminate_invocation                    DONE (anv, hasvk, lvp, 
nvk, radv, tu, vn)
+  VK_KHR_shader_terminate_invocation                    DONE (anv, hasvk, lvp, 
nvk, radv, tu, v3dv, vn)
   VK_KHR_synchronization2                               DONE (anv, dzn, hasvk, 
lvp, nvk, panvk, radv, tu, v3dv, vn)
   VK_KHR_zero_initialize_workgroup_memory               DONE (anv, hasvk, lvp, 
radv, tu, v3dv, vn)
   VK_EXT_4444_formats                                   DONE (anv, hasvk, lvp, 
nvk, radv, tu, v3dv, vn)
diff --git a/src/broadcom/compiler/nir_to_vir.c 
b/src/broadcom/compiler/nir_to_vir.c
index 724543b93a0..1346e566c4e 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -3428,6 +3428,7 @@ ntq_emit_intrinsic(struct v3d_compile *c, 
nir_intrinsic_instr *instr)
                 break;
 
         case nir_intrinsic_discard:
+        case nir_intrinsic_terminate:
                 ntq_flush_tmu(c);
 
                 if (vir_in_nonuniform_control_flow(c)) {
@@ -3443,7 +3444,8 @@ ntq_emit_intrinsic(struct v3d_compile *c, 
nir_intrinsic_instr *instr)
                 c->emitted_discard = true;
                 break;
 
-        case nir_intrinsic_discard_if: {
+        case nir_intrinsic_discard_if:
+        case nir_intrinsic_terminate_if: {
                 ntq_flush_tmu(c);
 
                 enum v3d_qpu_cond cond = ntq_emit_bool_to_cond(c, 
instr->src[0]);
diff --git a/src/broadcom/vulkan/v3dv_device.c 
b/src/broadcom/vulkan/v3dv_device.c
index 05d6ef42595..1b37529fc21 100644
--- a/src/broadcom/vulkan/v3dv_device.c
+++ b/src/broadcom/vulkan/v3dv_device.c
@@ -170,6 +170,7 @@ get_device_extensions(const struct v3dv_physical_device 
*device,
       .KHR_timeline_semaphore               = true,
       .KHR_uniform_buffer_standard_layout   = true,
       .KHR_shader_integer_dot_product       = true,
+      .KHR_shader_terminate_invocation      = true,
       .KHR_synchronization2                 = true,
       .KHR_workgroup_memory_explicit_layout = true,
 #ifdef V3DV_USE_WSI_PLATFORM
@@ -440,6 +441,9 @@ get_features(const struct v3dv_physical_device 
*physical_device,
 
       /* VK_EXT_multi_draw */
       .multiDraw = true,
+
+      /* VK_KHR_shader_terminate_invocation */
+      .shaderTerminateInvocation = true,
    };
 }
 

Reply via email to