nir: fix slot calculations for compact variables with location_frac

a variable with a component offset may span multiple slots, and this cannot
be inferred from its type alone (e.g., compacted clip+cull distances)

cc: mesa-stable

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24163>
This commit is contained in:
Mike Blumenkrantz
2023-07-14 12:18:05 -04:00
committed by Marge Bot
parent 42021b4d13
commit 59396eefe6
5 changed files with 7 additions and 7 deletions

View File

@@ -211,7 +211,7 @@ mark_whole_variable(nir_shader *shader, nir_variable *var,
}
const unsigned slots =
var->data.compact ? DIV_ROUND_UP(glsl_get_length(type), 4)
var->data.compact ? DIV_ROUND_UP(var->data.location_frac + glsl_get_length(type), 4)
: glsl_count_attribute_slots(type, false);
set_io_mask(shader, var, 0, slots, deref, is_output_read);
@@ -288,7 +288,7 @@ try_mask_partial_io(nir_shader *shader, nir_variable *var,
return false;
const unsigned slots =
var->data.compact ? DIV_ROUND_UP(glsl_get_length(type), 4)
var->data.compact ? DIV_ROUND_UP(var->data.location_frac + glsl_get_length(type), 4)
: glsl_count_attribute_slots(type, false);
if (offset >= slots) {

View File

@@ -924,7 +924,7 @@ tu_gather_xfb_info(nir_shader *nir, struct ir3_stream_output_info *info)
nir_foreach_shader_out_variable(var, nir) {
unsigned slots =
var->data.compact ? DIV_ROUND_UP(glsl_get_length(var->type), 4)
var->data.compact ? DIV_ROUND_UP(var->data.location_frac + glsl_get_length(var->type), 4)
: glsl_count_attribute_slots(var->type, false);
for (unsigned i = 0; i < slots; i++)
output_map[var->data.location + i] = var->data.driver_location + i;

View File

@@ -335,7 +335,7 @@ void nir_tgsi_scan_shader(const struct nir_shader *nir,
type = glsl_get_array_element(type);
}
unsigned attrib_count = variable->data.compact ? DIV_ROUND_UP(glsl_get_length(type), 4) :
unsigned attrib_count = variable->data.compact ? DIV_ROUND_UP(variable->data.location_frac + glsl_get_length(type), 4) :
glsl_count_attribute_slots(type, nir->info.stage == MESA_SHADER_VERTEX);
i = variable->data.driver_location;
@@ -435,7 +435,7 @@ void nir_tgsi_scan_shader(const struct nir_shader *nir,
type = glsl_get_array_element(type);
}
unsigned attrib_count = variable->data.compact ? DIV_ROUND_UP(glsl_get_length(type), 4) :
unsigned attrib_count = variable->data.compact ? DIV_ROUND_UP(variable->data.location_frac + glsl_get_length(type), 4) :
glsl_count_attribute_slots(type, false);
for (unsigned k = 0; k < attrib_count; k++, i++) {

View File

@@ -544,7 +544,7 @@ lvp_shader_xfb_init(struct lvp_shader *shader)
memset(output_mapping, 0, sizeof(output_mapping));
nir_foreach_shader_out_variable(var, shader->pipeline_nir->nir) {
unsigned slots = var->data.compact ? DIV_ROUND_UP(glsl_get_length(var->type), 4)
unsigned slots = var->data.compact ? DIV_ROUND_UP(var->data.location_frac + glsl_get_length(var->type), 4)
: glsl_count_attribute_slots(var->type, false);
for (unsigned i = 0; i < slots; i++)
output_mapping[var->data.location + i] = var->data.driver_location + i;

View File

@@ -72,7 +72,7 @@ fs_visitor::nir_setup_outputs()
nir_foreach_shader_out_variable(var, nir) {
const int loc = var->data.driver_location;
const unsigned var_vec4s =
var->data.compact ? DIV_ROUND_UP(glsl_get_length(var->type), 4)
var->data.compact ? DIV_ROUND_UP(var->data.location_frac + glsl_get_length(var->type), 4)
: type_size_vec4(var->type, true);
vec4s[loc] = MAX2(vec4s[loc], var_vec4s);
}