diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index fbfee92d5d4..1fc873050f2 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -179,6 +179,8 @@ nir_shader_add_variable(nir_shader *shader, nir_variable *var) case nir_var_system_value: case nir_var_mem_push_const: case nir_var_mem_constant: + case nir_var_shader_call_data: + case nir_var_ray_hit_attrib: break; case nir_var_mem_global: diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index de29aab1e27..f177de75e96 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -134,9 +134,13 @@ typedef enum { nir_var_mem_global), nir_var_mem_push_const = (1 << 10), /* not actually used for variables */ nir_var_mem_constant = (1 << 11), + /** Incoming call or ray payload data for ray-tracing shaders */ + nir_var_shader_call_data = (1 << 12), + /** Ray hit attributes */ + nir_var_ray_hit_attrib = (1 << 13), nir_var_read_only_modes = nir_var_shader_in | nir_var_uniform | nir_var_system_value | nir_var_mem_constant, - nir_num_variable_modes = 12, + nir_num_variable_modes = 14, nir_var_all = (1 << nir_num_variable_modes) - 1, } nir_variable_mode; MESA_DEFINE_CPP_ENUM_BITFIELD_OPERATORS(nir_variable_mode) @@ -345,7 +349,7 @@ typedef struct nir_variable { * * \sa nir_variable_mode */ - unsigned mode:12; + unsigned mode:14; /** * Is the variable read-only? diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index e1c17ccbb2b..8c62b1235d8 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -473,6 +473,10 @@ get_variable_mode_str(nir_variable_mode mode, bool want_local_global_mode) return want_local_global_mode ? "shader_temp" : ""; case nir_var_function_temp: return want_local_global_mode ? "function_temp" : ""; + case nir_var_shader_call_data: + return "shader_call_data"; + case nir_var_ray_hit_attrib: + return "ray_hit_attrib"; default: return ""; } diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c index 2617a731f9e..7f99d2fd138 100644 --- a/src/compiler/nir/nir_serialize.c +++ b/src/compiler/nir/nir_serialize.c @@ -637,9 +637,9 @@ union packed_instr { unsigned instr_type:4; unsigned deref_type:3; unsigned cast_type_same_as_last:1; - unsigned modes:12; /* deref_var redefines this */ + unsigned modes:14; /* deref_var redefines this */ unsigned packed_src_ssa_16bit:1; /* deref_var redefines this */ - unsigned _pad:3; /* deref_var redefines this */ + unsigned _pad:1; /* deref_var redefines this */ unsigned dest:8; } deref; struct { @@ -984,7 +984,7 @@ static void write_deref(write_ctx *ctx, const nir_deref_instr *deref) { assert(deref->deref_type < 8); - assert(deref->modes < (1 << 12)); + assert(deref->modes < (1 << 14)); union packed_instr header; header.u32 = 0; diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index b1b742c5080..808592c224d 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -1551,6 +1551,14 @@ nir_validate_shader(nir_shader *shader, const char *when) nir_var_mem_push_const | nir_var_mem_constant; + if (gl_shader_stage_is_callable(shader->info.stage)) + valid_modes |= nir_var_shader_call_data; + + if (shader->info.stage == MESA_SHADER_ANY_HIT || + shader->info.stage == MESA_SHADER_CLOSEST_HIT || + shader->info.stage == MESA_SHADER_INTERSECTION) + valid_modes |= nir_var_ray_hit_attrib; + exec_list_validate(&shader->variables); nir_foreach_variable_in_shader(var, shader) validate_var_decl(var, valid_modes, &state); diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h index 5bab7fed120..c6ea75c9570 100644 --- a/src/compiler/shader_enums.h +++ b/src/compiler/shader_enums.h @@ -72,6 +72,16 @@ gl_shader_stage_is_compute(gl_shader_stage stage) return stage == MESA_SHADER_COMPUTE || stage == MESA_SHADER_KERNEL; } +static inline bool +gl_shader_stage_is_callable(gl_shader_stage stage) +{ + return stage == MESA_SHADER_ANY_HIT || + stage == MESA_SHADER_CLOSEST_HIT || + stage == MESA_SHADER_MISS || + stage == MESA_SHADER_INTERSECTION || + stage == MESA_SHADER_CALLABLE; +} + /** * Number of STATE_* values we need to address any GL state. * Used to dimension arrays.