intel/nir/rt: change scratch check validation

It's very unfortunate that we have the RT scratch being conflated with
the usual scratch. In our implementation those are 2 different buffers.

The usual scratch access are done through the scratch surface state
(delivered through thread payload), while RT scratch (which outlives
thread dispatch with shader calls) is its own buffer.

So checking the NIR scratch size makes no sense as we can have normal
scratch accesses completely unrelated to RT scratch accesses.

This change switches the validation by looking at whether the scratch
base pointer intrinsic is being used (which is what we use/abuse to
implement RT scratch).

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: c78be5da30 ("intel/fs: lower ray query intrinsics")
Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17396>
This commit is contained in:
Lionel Landwerlin
2022-07-19 22:04:35 +03:00
committed by Marge Bot
parent 259b1647e6
commit f7fab09a07

View File

@@ -25,6 +25,28 @@
#include "brw_nir_rt_builder.h"
#include "nir_phi_builder.h"
UNUSED static bool
no_load_scratch_base_ptr_intrinsic(nir_shader *shader)
{
nir_foreach_function(func, shader) {
if (!func->impl)
continue;
nir_foreach_block(block, func->impl) {
nir_foreach_instr(instr, block) {
if (instr->type != nir_instr_type_intrinsic)
continue;
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
if (intrin->intrinsic == nir_intrinsic_load_scratch_base_ptr)
return false;
}
}
}
return true;
}
/** Insert the appropriate return instruction at the end of the shader */
void
brw_nir_lower_shader_returns(nir_shader *shader)
@@ -46,7 +68,7 @@ brw_nir_lower_shader_returns(nir_shader *shader)
* This isn't needed for ray-gen shaders because they end the thread and
* never return to the calling trampoline shader.
*/
assert(shader->scratch_size == 0);
assert(no_load_scratch_base_ptr_intrinsic(shader));
if (shader->info.stage != MESA_SHADER_RAYGEN)
shader->scratch_size = BRW_BTD_STACK_CALLEE_DATA_SIZE;