Module: vkd3d Branch: master Commit: dfce1e7f4a8a9cad5a5b92232b10311852f7ea67 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/dfce1e7f4a8a9cad5a5b92232b1031...
Author: Francisco Casas fcasas@codeweavers.com Date: Fri Jun 9 16:55:21 2023 -0400
vkd3d-shader/hlsl: Make regset an output argument in hlsl_type_get_component_offset().
Components only span across a single regset, so instead of expecting the regset as input for the offset, hlsl_type_get_component_offset() can actually retrieve it.
---
libs/vkd3d-shader/hlsl.c | 26 +++++++++++++++----------- libs/vkd3d-shader/hlsl.h | 2 +- libs/vkd3d-shader/tpf.c | 3 +-- 3 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 5fe9047b..ca1dca0c 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -452,11 +452,11 @@ struct hlsl_type *hlsl_type_get_component_type(struct hlsl_ctx *ctx, struct hlsl }
unsigned int hlsl_type_get_component_offset(struct hlsl_ctx *ctx, struct hlsl_type *type, - enum hlsl_regset regset, unsigned int index) + unsigned int index, enum hlsl_regset *regset) { + unsigned int offset[HLSL_REGSET_LAST + 1] = {0}; struct hlsl_type *next_type; - unsigned int offset = 0; - unsigned int idx; + unsigned int idx, r;
while (!type_is_single_component(type)) { @@ -468,19 +468,22 @@ unsigned int hlsl_type_get_component_offset(struct hlsl_ctx *ctx, struct hlsl_ty case HLSL_CLASS_SCALAR: case HLSL_CLASS_VECTOR: case HLSL_CLASS_MATRIX: - if (regset == HLSL_REGSET_NUMERIC) - offset += idx; + offset[HLSL_REGSET_NUMERIC] += idx; break;
case HLSL_CLASS_STRUCT: - offset += type->e.record.fields[idx].reg_offset[regset]; + for (r = 0; r <= HLSL_REGSET_LAST; ++r) + offset[r] += type->e.record.fields[idx].reg_offset[r]; break;
case HLSL_CLASS_ARRAY: - if (regset == HLSL_REGSET_NUMERIC) - offset += idx * align(type->e.array.type->reg_size[regset], 4); - else - offset += idx * type->e.array.type->reg_size[regset]; + for (r = 0; r <= HLSL_REGSET_LAST; ++r) + { + if (r == HLSL_REGSET_NUMERIC) + offset[r] += idx * align(type->e.array.type->reg_size[r], 4); + else + offset[r] += idx * type->e.array.type->reg_size[r]; + } break;
case HLSL_CLASS_OBJECT: @@ -493,7 +496,8 @@ unsigned int hlsl_type_get_component_offset(struct hlsl_ctx *ctx, struct hlsl_ty type = next_type; }
- return offset; + *regset = hlsl_type_get_regset(type); + return offset[*regset]; }
static bool init_deref(struct hlsl_ctx *ctx, struct hlsl_deref *deref, struct hlsl_ir_var *var, diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index f81083c0..2981fd92 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1232,7 +1232,7 @@ unsigned int hlsl_type_get_array_element_reg_size(const struct hlsl_type *type, struct hlsl_type *hlsl_type_get_component_type(struct hlsl_ctx *ctx, struct hlsl_type *type, unsigned int index); unsigned int hlsl_type_get_component_offset(struct hlsl_ctx *ctx, struct hlsl_type *type, - enum hlsl_regset regset, unsigned int index); + unsigned int index, enum hlsl_regset *regset); bool hlsl_type_is_row_major(const struct hlsl_type *type); unsigned int hlsl_type_minor_size(const struct hlsl_type *type); unsigned int hlsl_type_major_size(const struct hlsl_type *type); diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index fbd84583..de31bbcb 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -3250,8 +3250,7 @@ static struct extern_resource *sm4_get_extern_resources(struct hlsl_ctx *ctx, un if (!hlsl_type_is_resource(component_type)) continue;
- regset = hlsl_type_get_regset(component_type); - regset_offset = hlsl_type_get_component_offset(ctx, var->data_type, regset, k); + regset_offset = hlsl_type_get_component_offset(ctx, var->data_type, k, ®set);
if (regset_offset > var->regs[regset].allocation_size) continue;