diff --git a/src/intel/compiler/brw_nir_lower_shader_calls.c b/src/intel/compiler/brw_nir_lower_shader_calls.c index 506a71933e5..c4f67a6c86b 100644 --- a/src/intel/compiler/brw_nir_lower_shader_calls.c +++ b/src/intel/compiler/brw_nir_lower_shader_calls.c @@ -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; +} diff --git a/src/intel/compiler/brw_nir_rt.h b/src/intel/compiler/brw_nir_rt.h index a474498be20..88763183875 100644 --- a/src/intel/compiler/brw_nir_rt.h +++ b/src/intel/compiler/brw_nir_rt.h @@ -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