Mesa (main): spirv: Add plumbing for ray_cull_mask
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jun 8 20:56:25 UTC 2022
Module: Mesa
Branch: main
Commit: 2e0e150e69475c7446c999623d23d60ae3715290
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2e0e150e69475c7446c999623d23d60ae3715290
Author: Konstantin Seurer <konstantin.seurer at gmail.com>
Date: Tue May 10 16:10:31 2022 +0200
spirv: Add plumbing for ray_cull_mask
Add a new cull_mask system value that is exposed
by the ray_cull_mask capability of
SPV_KHR_ray_cull_mask.
Signed-off-by: Konstantin Seurer <konstantin.seurer at gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16430>
---
src/compiler/nir/nir.c | 4 ++++
src/compiler/nir/nir_intrinsics.py | 1 +
src/compiler/shader_enums.c | 1 +
src/compiler/shader_enums.h | 1 +
src/compiler/shader_info.h | 1 +
src/compiler/spirv/spirv_to_nir.c | 4 ++++
src/compiler/spirv/vtn_variables.c | 4 ++++
7 files changed, 16 insertions(+)
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index be5bbfc993a..657de0b9d41 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -2507,6 +2507,8 @@ nir_intrinsic_from_system_value(gl_system_value val)
return nir_intrinsic_load_ray_geometry_index;
case SYSTEM_VALUE_RAY_INSTANCE_CUSTOM_INDEX:
return nir_intrinsic_load_ray_instance_custom_index;
+ case SYSTEM_VALUE_CULL_MASK:
+ return nir_intrinsic_load_cull_mask;
case SYSTEM_VALUE_MESH_VIEW_COUNT:
return nir_intrinsic_load_mesh_view_count;
case SYSTEM_VALUE_FRAG_SHADING_RATE:
@@ -2652,6 +2654,8 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
return SYSTEM_VALUE_RAY_GEOMETRY_INDEX;
case nir_intrinsic_load_ray_instance_custom_index:
return SYSTEM_VALUE_RAY_INSTANCE_CUSTOM_INDEX;
+ case nir_intrinsic_load_cull_mask:
+ return SYSTEM_VALUE_CULL_MASK;
case nir_intrinsic_load_frag_shading_rate:
return SYSTEM_VALUE_FRAG_SHADING_RATE;
case nir_intrinsic_load_mesh_view_count:
diff --git a/src/compiler/nir/nir_intrinsics.py b/src/compiler/nir/nir_intrinsics.py
index 2276f424a8c..e264a8171fa 100644
--- a/src/compiler/nir/nir_intrinsics.py
+++ b/src/compiler/nir/nir_intrinsics.py
@@ -856,6 +856,7 @@ system_value("ray_flags", 1)
system_value("ray_geometry_index", 1)
system_value("ray_instance_custom_index", 1)
system_value("shader_record_ptr", 1, bit_sizes=[64])
+system_value("cull_mask", 1)
# Driver-specific viewport scale/offset parameters.
#
diff --git a/src/compiler/shader_enums.c b/src/compiler/shader_enums.c
index c90906c5790..65b2164b024 100644
--- a/src/compiler/shader_enums.c
+++ b/src/compiler/shader_enums.c
@@ -331,6 +331,7 @@ gl_system_value_name(gl_system_value sysval)
ENUM(SYSTEM_VALUE_RAY_HIT_KIND),
ENUM(SYSTEM_VALUE_RAY_FLAGS),
ENUM(SYSTEM_VALUE_RAY_GEOMETRY_INDEX),
+ ENUM(SYSTEM_VALUE_CULL_MASK),
ENUM(SYSTEM_VALUE_MESH_VIEW_COUNT),
ENUM(SYSTEM_VALUE_MESH_VIEW_INDICES),
ENUM(SYSTEM_VALUE_GS_HEADER_IR3),
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index 6301b4b02ba..0d93726d9e6 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -825,6 +825,7 @@ typedef enum
SYSTEM_VALUE_RAY_FLAGS,
SYSTEM_VALUE_RAY_GEOMETRY_INDEX,
SYSTEM_VALUE_RAY_INSTANCE_CUSTOM_INDEX,
+ SYSTEM_VALUE_CULL_MASK,
/*@}*/
/**
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index 20974ad8dd6..186cef2619c 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -81,6 +81,7 @@ struct spirv_supported_capabilities {
bool physical_storage_buffer_address;
bool post_depth_coverage;
bool printf;
+ bool ray_cull_mask;
bool ray_tracing;
bool ray_query;
bool ray_traversal_primitive_culling;
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index cb5f99f3fb2..ca2e92ab148 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -4789,6 +4789,10 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
spv_check_supported(intel_subgroup_buffer_block_io, cap);
break;
+ case SpvCapabilityRayCullMaskKHR:
+ spv_check_supported(ray_cull_mask, cap);
+ break;
+
case SpvCapabilityRayTracingKHR:
spv_check_supported(ray_tracing, cap);
break;
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index b2586114480..e8161e2e565 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1121,6 +1121,10 @@ vtn_get_builtin_location(struct vtn_builder *b,
*location = SYSTEM_VALUE_RAY_GEOMETRY_INDEX;
set_mode_system_value(b, mode);
break;
+ case SpvBuiltInCullMaskKHR:
+ *location = SYSTEM_VALUE_CULL_MASK;
+ set_mode_system_value(b, mode);
+ break;
case SpvBuiltInShadingRateKHR:
*location = SYSTEM_VALUE_FRAG_SHADING_RATE;
set_mode_system_value(b, mode);
More information about the mesa-commit
mailing list