From da7c9694f1058ee4ceb7c0ebdc372619cd99d5bd Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Fri, 27 Sep 2024 14:53:07 +0200 Subject: [PATCH] vkd3d-shader/dxil: Emit SAMPLER, UAV and RESOURCE registers with only 2 indices. DXIL handles are used to represent descriptors. Currently they are translated to registers of the appropriate type (depending on the descriptor type) and three indices. The first two indices are used to represent the descriptor itself (through its signature and array index), and are filled when the handle itself is created. The last index is used with constant buffers to address the data inside the buffer itself, and it goes unused with other descriptor types. As currently implemented, however, registers for descriptors other than constant buffers are still created with three indices, even if the last one is useless and set to -1. In the interest of creating more sensible VSIR code, this is now removed: DXIL handles are created with just two indices; a third one is added when accessing constant buffers, and nothing is changed for other descriptor types. --- libs/vkd3d-shader/dxil.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 165ab222..d4296ef4 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -4864,8 +4864,10 @@ static void sm6_parser_emit_dx_cbuffer_load(struct sm6_parser *sm6, enum dx_intr if (!(src_param = instruction_src_params_alloc(ins, 1, sm6))) return; src_param_init_vector_from_reg(src_param, &buffer->u.handle.reg); + /* Differently from other descriptors, constant buffers require an + * additional index, used to index within the constant buffer itself. */ + src_param->reg.idx_count = 3; register_index_address_init(&src_param->reg.idx[2], operands[1], sm6); - VKD3D_ASSERT(src_param->reg.idx_count == 3); type = sm6_type_get_scalar_type(dst->type, 0); VKD3D_ASSERT(type); @@ -4964,8 +4966,7 @@ static void sm6_parser_emit_dx_create_handle(struct sm6_parser *sm6, enum dx_int dst->u.handle.d = d; reg = &dst->u.handle.reg; - /* Set idx_count to 3 for use with load/store instructions. */ - vsir_register_init(reg, d->reg_type, d->reg_data_type, 3); + vsir_register_init(reg, d->reg_type, d->reg_data_type, 2); reg->dimension = VSIR_DIMENSION_VEC4; reg->idx[0].offset = id; register_index_address_init(®->idx[1], operands[2], sm6);