intel/rt: Add a helper to create a trivial return shader

These are required for ray-tracing.  There are many cases where the
ray-tracing hardware may decide to execute some but not all of our
shaders.  In these cases, it needs a shader to execute at the end which
will pop the stack back to the shader which called traceRay().

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7356>
This commit is contained in:
Jason Ekstrand
2020-08-06 15:16:26 -05:00
committed by Marge Bot
parent fad81a3968
commit 72354b0e9d
2 changed files with 27 additions and 0 deletions

View File

@@ -1181,3 +1181,26 @@ brw_nir_lower_shader_calls(nir_shader *shader,
return true;
}
/** Creates a trivial return shader
*
* This is a callable shader that doesn't really do anything. It just loads
* the resume address from the stack and does a return.
*/
nir_shader *
brw_nir_create_trivial_return_shader(const struct brw_compiler *compiler,
void *mem_ctx)
{
const nir_shader_compiler_options *nir_options =
compiler->glsl_compiler_options[MESA_SHADER_CALLABLE].NirOptions;
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_CALLABLE,
nir_options,
"RT Trivial Return");
ralloc_steal(mem_ctx, b.shader);
nir_shader *nir = b.shader;
NIR_PASS_V(nir, brw_nir_lower_shader_returns);
return nir;
}

View File

@@ -59,6 +59,10 @@ bool brw_nir_lower_shader_calls(nir_shader *shader,
void brw_nir_lower_rt_intrinsics(nir_shader *shader,
const struct gen_device_info *devinfo);
nir_shader *
brw_nir_create_trivial_return_shader(const struct brw_compiler *compiler,
void *mem_ctx);
#ifdef __cplusplus
}
#endif