anv: support VK_PIPELINE_CREATE_RAY_TRACING_SKIP_*
VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR and VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR, when specified, make TraceRay behave as if the corresponding shader flags were set, but without affecting the value of IncomingRayFlags in shaders. v2 (Lionel): Improve comments Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19152>
This commit is contained in:
@@ -526,6 +526,12 @@ struct brw_cs_prog_key {
|
||||
|
||||
struct brw_bs_prog_key {
|
||||
struct brw_base_prog_key base;
|
||||
|
||||
/* Represents enum enum brw_rt_ray_flags values given at pipeline creation
|
||||
* to be combined with ray_flags handed to the traceRayEXT() calls by the
|
||||
* shader.
|
||||
*/
|
||||
uint32_t pipeline_ray_flags;
|
||||
};
|
||||
|
||||
struct brw_ff_gs_prog_key {
|
||||
|
@@ -221,7 +221,15 @@ lower_rt_intrinsics_impl(nir_function_impl *impl,
|
||||
}
|
||||
|
||||
case nir_intrinsic_load_ray_flags:
|
||||
sysval = nir_u2u32(b, world_ray_in.ray_flags);
|
||||
/* We need to fetch the original ray flags we stored in the
|
||||
* leaf pointer, because the actual ray flags we get here
|
||||
* will include any flags passed on the pipeline at creation
|
||||
* time, and the spec for IncomingRayFlagsKHR says:
|
||||
* Setting pipeline flags on the raytracing pipeline must not
|
||||
* cause any corresponding flags to be set in variables with
|
||||
* this decoration.
|
||||
*/
|
||||
sysval = nir_u2u32(b, world_ray_in.inst_leaf_ptr);
|
||||
break;
|
||||
|
||||
case nir_intrinsic_load_ray_geometry_index: {
|
||||
|
@@ -153,6 +153,8 @@ store_resume_addr(nir_builder *b, nir_intrinsic_instr *call)
|
||||
static bool
|
||||
lower_shader_trace_ray_instr(struct nir_builder *b, nir_instr *instr, void *data)
|
||||
{
|
||||
struct brw_bs_prog_key *key = data;
|
||||
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
return false;
|
||||
|
||||
@@ -223,7 +225,10 @@ lower_shader_trace_ray_instr(struct nir_builder *b, nir_instr *instr, void *data
|
||||
|
||||
struct brw_nir_rt_mem_ray_defs ray_defs = {
|
||||
.root_node_ptr = root_node_ptr,
|
||||
.ray_flags = nir_u2u16(b, ray_flags),
|
||||
/* Combine the shader value given to traceRayEXT() with the pipeline
|
||||
* creation value VkPipelineCreateFlags.
|
||||
*/
|
||||
.ray_flags = nir_ior_imm(b, nir_u2u16(b, ray_flags), key->pipeline_ray_flags),
|
||||
.ray_mask = cull_mask,
|
||||
.hit_group_sr_base_ptr = hit_sbt_addr,
|
||||
.hit_group_sr_stride = nir_u2u16(b, hit_sbt_stride_B),
|
||||
@@ -233,6 +238,13 @@ lower_shader_trace_ray_instr(struct nir_builder *b, nir_instr *instr, void *data
|
||||
.dir = ray_dir,
|
||||
.t_far = ray_t_max,
|
||||
.shader_index_multiplier = sbt_stride,
|
||||
/* The instance leaf pointer is unused in the top level BVH traversal
|
||||
* since we always start from the root node. We can reuse that field to
|
||||
* store the ray_flags handed to traceRayEXT(). This will be reloaded
|
||||
* when the shader accesses gl_IncomingRayFlagsEXT (see
|
||||
* nir_intrinsic_load_ray_flags brw_nir_lower_rt_intrinsic.c)
|
||||
*/
|
||||
.inst_leaf_ptr = nir_u2u64(b, ray_flags),
|
||||
};
|
||||
brw_nir_rt_store_mem_ray(b, &ray_defs, BRW_RT_BVH_LEVEL_WORLD);
|
||||
|
||||
@@ -272,13 +284,13 @@ lower_shader_call_instr(struct nir_builder *b, nir_instr *instr, void *data)
|
||||
}
|
||||
|
||||
bool
|
||||
brw_nir_lower_shader_calls(nir_shader *shader)
|
||||
brw_nir_lower_shader_calls(nir_shader *shader, struct brw_bs_prog_key *key)
|
||||
{
|
||||
return
|
||||
nir_shader_instructions_pass(shader,
|
||||
lower_shader_trace_ray_instr,
|
||||
nir_metadata_none,
|
||||
NULL) |
|
||||
key) |
|
||||
nir_shader_instructions_pass(shader,
|
||||
lower_shader_call_instr,
|
||||
nir_metadata_block_index |
|
||||
|
@@ -54,7 +54,7 @@ bool brw_nir_lower_ray_queries(nir_shader *shader,
|
||||
|
||||
void brw_nir_lower_shader_returns(nir_shader *shader);
|
||||
|
||||
bool brw_nir_lower_shader_calls(nir_shader *shader);
|
||||
bool brw_nir_lower_shader_calls(nir_shader *shader, struct brw_bs_prog_key *key);
|
||||
|
||||
void brw_nir_lower_rt_intrinsics(nir_shader *shader,
|
||||
const struct intel_device_info *devinfo);
|
||||
|
Reference in New Issue
Block a user