mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 05:08:08 +02:00
nir: store variable mode in nir_parameter
This will be used by the nir glsl linker in following patches. Acked-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137>
This commit is contained in:
parent
89a2411c54
commit
5645495156
3 changed files with 29 additions and 1 deletions
|
|
@ -50,6 +50,29 @@
|
|||
* pass.
|
||||
*/
|
||||
|
||||
static nir_variable_mode
|
||||
get_param_mode(ir_variable *param)
|
||||
{
|
||||
switch ((enum ir_variable_mode)(param->data.mode)) {
|
||||
case ir_var_const_in:
|
||||
case ir_var_function_in:
|
||||
return nir_var_function_in;
|
||||
|
||||
case ir_var_function_out:
|
||||
return nir_var_function_out;
|
||||
|
||||
case ir_var_function_inout:
|
||||
return nir_var_function_inout;
|
||||
|
||||
case ir_var_auto:
|
||||
case ir_var_uniform:
|
||||
case ir_var_shader_storage:
|
||||
case ir_var_temporary:
|
||||
default:
|
||||
unreachable("Unsupported function param mode");
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class nir_visitor : public ir_visitor
|
||||
|
|
@ -661,13 +684,13 @@ nir_visitor::create_function(ir_function_signature *ir)
|
|||
func->params = ralloc_array(shader, nir_parameter, func->num_params);
|
||||
|
||||
unsigned np = 0;
|
||||
|
||||
if (ir->return_type != &glsl_type_builtin_void) {
|
||||
/* The return value is a variable deref (basically an out parameter) */
|
||||
func->params[np].num_components = 1;
|
||||
func->params[np].bit_size = 32;
|
||||
func->params[np].type = ir->return_type;
|
||||
func->params[np].is_return = true;
|
||||
func->params[np].mode = nir_var_function_out;
|
||||
np++;
|
||||
}
|
||||
|
||||
|
|
@ -677,6 +700,7 @@ nir_visitor::create_function(ir_function_signature *ir)
|
|||
|
||||
func->params[np].type = param->type;
|
||||
func->params[np].is_return = false;
|
||||
func->params[np].mode = get_param_mode(param);
|
||||
np++;
|
||||
}
|
||||
assert(np == func->num_params);
|
||||
|
|
|
|||
|
|
@ -3626,6 +3626,8 @@ typedef struct {
|
|||
/* True if this paramater is actually the function return variable */
|
||||
bool is_return;
|
||||
|
||||
nir_variable_mode mode;
|
||||
|
||||
/* The type of the function param */
|
||||
const struct glsl_type *type;
|
||||
} nir_parameter;
|
||||
|
|
|
|||
|
|
@ -1984,6 +1984,7 @@ write_function(write_ctx *ctx, const nir_function *fxn)
|
|||
((uint32_t)fxn->params[i].bit_size) << 8;
|
||||
blob_write_uint32(ctx->blob, val);
|
||||
encode_type_to_blob(ctx->blob, fxn->params[i].type);
|
||||
blob_write_uint32(ctx->blob, encode_deref_modes(fxn->params[i].mode));
|
||||
}
|
||||
|
||||
/* At first glance, it looks like we should write the function_impl here.
|
||||
|
|
@ -2018,6 +2019,7 @@ read_function(read_ctx *ctx)
|
|||
fxn->params[i].num_components = val & 0xff;
|
||||
fxn->params[i].bit_size = (val >> 8) & 0xff;
|
||||
fxn->params[i].type = decode_type_from_blob(ctx->blob);
|
||||
fxn->params[i].mode = decode_deref_modes(blob_read_uint32(ctx->blob));
|
||||
}
|
||||
|
||||
fxn->is_entrypoint = flags & 0x1;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue