diff options
author | Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | 2023-07-14 12:18:05 -0400 |
---|---|---|
committer | Eric Engestrom <eric@engestrom.ch> | 2023-07-28 18:48:25 +0100 |
commit | 5555783012ef89f15a6fbe9469398f47fb0d9cbf (patch) | |
tree | bd04893f6a8b9dca4b015342a5452506d238f12e | |
parent | 14632e7dbe7fd27c7e0b7a67fd4ac384a649d4c7 (diff) | |
download | mesa-5555783012ef89f15a6fbe9469398f47fb0d9cbf.tar.gz mesa-5555783012ef89f15a6fbe9469398f47fb0d9cbf.tar.bz2 mesa-5555783012ef89f15a6fbe9469398f47fb0d9cbf.zip |
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>
(cherry picked from commit 59396eefe6440920532009e5cbfd17c0c09fdaa1)
-rw-r--r-- | .pick_status.json | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_gather_info.c | 4 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_shader.cc | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/nir/nir_to_tgsi_info.c | 4 | ||||
-rw-r--r-- | src/gallium/frontends/lavapipe/lvp_pipeline.c | 2 | ||||
-rw-r--r-- | src/intel/compiler/brw_fs_nir.cpp | 2 |
6 files changed, 8 insertions, 8 deletions
diff --git a/.pick_status.json b/.pick_status.json index bf4ab1d132d..a0810dd7576 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -103,7 +103,7 @@ "description": "nir: fix slot calculations for compact variables with location_frac", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c index 9fe631033d2..02ae72babee 100644 --- a/src/compiler/nir/nir_gather_info.c +++ b/src/compiler/nir/nir_gather_info.c @@ -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) { diff --git a/src/freedreno/vulkan/tu_shader.cc b/src/freedreno/vulkan/tu_shader.cc index 18e0a6ff115..bb4535c4a36 100644 --- a/src/freedreno/vulkan/tu_shader.cc +++ b/src/freedreno/vulkan/tu_shader.cc @@ -873,7 +873,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; diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi_info.c b/src/gallium/auxiliary/nir/nir_to_tgsi_info.c index 1f7dcb9e13f..1a030ada48a 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi_info.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi_info.c @@ -510,7 +510,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; @@ -610,7 +610,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++) { diff --git a/src/gallium/frontends/lavapipe/lvp_pipeline.c b/src/gallium/frontends/lavapipe/lvp_pipeline.c index 2b474db714d..ea01cb605c6 100644 --- a/src/gallium/frontends/lavapipe/lvp_pipeline.c +++ b/src/gallium/frontends/lavapipe/lvp_pipeline.c @@ -614,7 +614,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; diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp index 939245cf133..5ae83425408 100644 --- a/src/intel/compiler/brw_fs_nir.cpp +++ b/src/intel/compiler/brw_fs_nir.cpp @@ -68,7 +68,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); } |