mirror of https://gitlab.freedesktop.org/mesa/mesa
nir/serialize: Encode data for temporaries
the location has to be preserved when lowering them to scratch using nir_lower_vars_to_explicit_types and nir_lower_explicit_io. cc: mesa-stable Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28187>
This commit is contained in:
parent
1ff8659f41
commit
edc8e011eb
|
@ -202,8 +202,6 @@ read_constant(read_ctx *ctx, nir_variable *nvar)
|
||||||
|
|
||||||
enum var_data_encoding {
|
enum var_data_encoding {
|
||||||
var_encode_full,
|
var_encode_full,
|
||||||
var_encode_shader_temp,
|
|
||||||
var_encode_function_temp,
|
|
||||||
var_encode_location_diff,
|
var_encode_location_diff,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -264,12 +262,6 @@ write_variable(write_ctx *ctx, const nir_variable *var)
|
||||||
data.mode != nir_var_shader_out)
|
data.mode != nir_var_shader_out)
|
||||||
data.location = 0;
|
data.location = 0;
|
||||||
|
|
||||||
/* Temporary variables don't serialize var->data. */
|
|
||||||
if (data.mode == nir_var_shader_temp)
|
|
||||||
flags.u.data_encoding = var_encode_shader_temp;
|
|
||||||
else if (data.mode == nir_var_function_temp)
|
|
||||||
flags.u.data_encoding = var_encode_function_temp;
|
|
||||||
else {
|
|
||||||
struct nir_variable_data tmp = data;
|
struct nir_variable_data tmp = data;
|
||||||
|
|
||||||
tmp.location = ctx->last_var_data.location;
|
tmp.location = ctx->last_var_data.location;
|
||||||
|
@ -287,7 +279,6 @@ write_variable(write_ctx *ctx, const nir_variable *var)
|
||||||
flags.u.data_encoding = var_encode_location_diff;
|
flags.u.data_encoding = var_encode_location_diff;
|
||||||
else
|
else
|
||||||
flags.u.data_encoding = var_encode_full;
|
flags.u.data_encoding = var_encode_full;
|
||||||
}
|
|
||||||
|
|
||||||
flags.u.ray_query = var->data.ray_query;
|
flags.u.ray_query = var->data.ray_query;
|
||||||
|
|
||||||
|
@ -306,8 +297,6 @@ write_variable(write_ctx *ctx, const nir_variable *var)
|
||||||
if (flags.u.has_name)
|
if (flags.u.has_name)
|
||||||
blob_write_string(ctx->blob, var->name);
|
blob_write_string(ctx->blob, var->name);
|
||||||
|
|
||||||
if (flags.u.data_encoding == var_encode_full ||
|
|
||||||
flags.u.data_encoding == var_encode_location_diff) {
|
|
||||||
if (flags.u.data_encoding == var_encode_full) {
|
if (flags.u.data_encoding == var_encode_full) {
|
||||||
blob_write_bytes(ctx->blob, &data, sizeof(data));
|
blob_write_bytes(ctx->blob, &data, sizeof(data));
|
||||||
} else {
|
} else {
|
||||||
|
@ -325,7 +314,6 @@ write_variable(write_ctx *ctx, const nir_variable *var)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->last_var_data = data;
|
ctx->last_var_data = data;
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < var->num_state_slots; i++) {
|
for (unsigned i = 0; i < var->num_state_slots; i++) {
|
||||||
blob_write_bytes(ctx->blob, &var->state_slots[i],
|
blob_write_bytes(ctx->blob, &var->state_slots[i],
|
||||||
|
@ -374,11 +362,7 @@ read_variable(read_ctx *ctx)
|
||||||
var->name = NULL;
|
var->name = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags.u.data_encoding == var_encode_shader_temp)
|
if (flags.u.data_encoding == var_encode_full) {
|
||||||
var->data.mode = nir_var_shader_temp;
|
|
||||||
else if (flags.u.data_encoding == var_encode_function_temp)
|
|
||||||
var->data.mode = nir_var_function_temp;
|
|
||||||
else if (flags.u.data_encoding == var_encode_full) {
|
|
||||||
blob_copy_bytes(ctx->blob, (uint8_t *)&var->data, sizeof(var->data));
|
blob_copy_bytes(ctx->blob, (uint8_t *)&var->data, sizeof(var->data));
|
||||||
ctx->last_var_data = var->data;
|
ctx->last_var_data = var->data;
|
||||||
} else { /* var_encode_location_diff */
|
} else { /* var_encode_location_diff */
|
||||||
|
|
Loading…
Reference in New Issue