microsoft/spirv_to_dxil: Fix the push_constant UBO size calculation

Right now, we just consider the size of the accessed portion of the
push constant array, but it doesn't necessarily reflect the size
of the UBO we should declare.

Fixes: de1e941c59 ("microsoft/spirv_to_dxil: Lower push constant loads to UBO loads")
Reviewed-by: Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16703>
This commit is contained in:
Boris Brezillon 2022-05-25 10:18:32 +02:00 committed by Marge Bot
parent 6783a88455
commit 2feef505c1
1 changed files with 4 additions and 10 deletions

View File

@ -177,8 +177,7 @@ struct lower_load_push_constant_data {
nir_address_format ubo_format;
unsigned desc_set;
unsigned binding;
uint32_t min;
uint32_t max;
unsigned size;
};
static bool
@ -199,8 +198,8 @@ lower_load_push_constant(struct nir_builder *builder, nir_instr *instr,
uint32_t base = nir_intrinsic_base(intrin);
uint32_t range = nir_intrinsic_range(intrin);
data->min = MIN2(data->min, base);
data->max = MAX2(data->max, base + range);
data->size = MAX2(base + range, data->size);
builder->cursor = nir_after_instr(instr);
nir_address_format ubo_format = data->ubo_format;
@ -239,8 +238,6 @@ dxil_spirv_nir_lower_load_push_constant(nir_shader *shader,
.ubo_format = ubo_format,
.desc_set = desc_set,
.binding = binding,
.min = UINT32_MAX,
.max = 0,
};
ret = nir_shader_instructions_pass(shader, lower_load_push_constant,
nir_metadata_block_index |
@ -248,10 +245,7 @@ dxil_spirv_nir_lower_load_push_constant(nir_shader *shader,
nir_metadata_loop_analysis,
&data);
if (data.min >= data.max)
*size = 0;
else
*size = (data.max - data.min);
*size = data.size;
assert(ret == (*size > 0));