Module: Mesa Branch: main Commit: d6dea13231295c56b2d7bc671a32473efab50022 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d6dea13231295c56b2d7bc671a32473efab50022
Author: Jesse Natalie <[email protected]> Date: Thu Nov 9 12:38:52 2023 -0800 microsoft/compiler: When packing fractional inputs, find a row with space for it Enables vertex attributes to overlap (as GL requires) when using enhanced layouts with explicit component packing. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26156> --- src/microsoft/compiler/dxil_nir.c | 5 ++++- src/microsoft/compiler/dxil_signature.c | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/microsoft/compiler/dxil_nir.c b/src/microsoft/compiler/dxil_nir.c index 9e5f6cb6997..97a8508a0ee 100644 --- a/src/microsoft/compiler/dxil_nir.c +++ b/src/microsoft/compiler/dxil_nir.c @@ -1443,6 +1443,7 @@ static int variable_location_cmp(const nir_variable* a, const nir_variable* b) { // Sort by stream, driver_location, location, location_frac, then index + // If all else is equal, sort full vectors before partial ones unsigned a_location = a->data.location; if (a_location >= VARYING_SLOT_PATCH0) a_location -= VARYING_SLOT_PATCH0; @@ -1459,7 +1460,9 @@ variable_location_cmp(const nir_variable* a, const nir_variable* b) a_location - b_location : a->data.location_frac != b->data.location_frac ? a->data.location_frac - b->data.location_frac : - a->data.index - b->data.index; + a->data.index != b->data.index ? + a->data.index - b->data.index : + glsl_get_component_slots(b->type) - glsl_get_component_slots(a->type); } /* Order varyings according to driver location */ diff --git a/src/microsoft/compiler/dxil_signature.c b/src/microsoft/compiler/dxil_signature.c index a9efcb1449d..6735afd4ac3 100644 --- a/src/microsoft/compiler/dxil_signature.c +++ b/src/microsoft/compiler/dxil_signature.c @@ -571,8 +571,19 @@ get_input_signature_group(struct dxil_module *mod, get_semantics(var, &semantic, s->info.stage); mod->inputs[num_inputs].sysvalue = semantic.sysvalue_name; nir_variable *base_var = var; - if (var->data.location_frac) - base_var = nir_find_variable_with_location(s, modes, var->data.location); + if (var->data.location_frac) { + /* Note: Specifically search for a variable that has space for these additional components */ + nir_foreach_variable_with_modes(test_var, s, modes) { + if (var->data.location == test_var->data.location) { + base_var = test_var; + if (test_var->data.location_frac == 0 && + glsl_get_component_slots( + nir_is_arrayed_io(test_var, s->info.stage) ? + glsl_get_array_element(test_var->type) : test_var->type) <= var->data.location_frac) + break; + } + } + } if (base_var != var) /* Combine fractional vars into any already existing row */ get_additional_semantic_info(s, var, &semantic,
