mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
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.
This commit is contained in:
committed by
Alexandre Julliard
parent
b5c0c9c22f
commit
dfce1e7f4a
Notes:
Alexandre Julliard
2023-10-05 22:36:55 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/342
@ -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,
|
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;
|
struct hlsl_type *next_type;
|
||||||
unsigned int offset = 0;
|
unsigned int idx, r;
|
||||||
unsigned int idx;
|
|
||||||
|
|
||||||
while (!type_is_single_component(type))
|
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_SCALAR:
|
||||||
case HLSL_CLASS_VECTOR:
|
case HLSL_CLASS_VECTOR:
|
||||||
case HLSL_CLASS_MATRIX:
|
case HLSL_CLASS_MATRIX:
|
||||||
if (regset == HLSL_REGSET_NUMERIC)
|
offset[HLSL_REGSET_NUMERIC] += idx;
|
||||||
offset += idx;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HLSL_CLASS_STRUCT:
|
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;
|
break;
|
||||||
|
|
||||||
case HLSL_CLASS_ARRAY:
|
case HLSL_CLASS_ARRAY:
|
||||||
if (regset == HLSL_REGSET_NUMERIC)
|
for (r = 0; r <= HLSL_REGSET_LAST; ++r)
|
||||||
offset += idx * align(type->e.array.type->reg_size[regset], 4);
|
{
|
||||||
else
|
if (r == HLSL_REGSET_NUMERIC)
|
||||||
offset += idx * type->e.array.type->reg_size[regset];
|
offset[r] += idx * align(type->e.array.type->reg_size[r], 4);
|
||||||
|
else
|
||||||
|
offset[r] += idx * type->e.array.type->reg_size[r];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HLSL_CLASS_OBJECT:
|
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;
|
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,
|
static bool init_deref(struct hlsl_ctx *ctx, struct hlsl_deref *deref, struct hlsl_ir_var *var,
|
||||||
|
@ -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,
|
struct hlsl_type *hlsl_type_get_component_type(struct hlsl_ctx *ctx, struct hlsl_type *type,
|
||||||
unsigned int index);
|
unsigned int index);
|
||||||
unsigned int hlsl_type_get_component_offset(struct hlsl_ctx *ctx, struct hlsl_type *type,
|
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);
|
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_minor_size(const struct hlsl_type *type);
|
||||||
unsigned int hlsl_type_major_size(const struct hlsl_type *type);
|
unsigned int hlsl_type_major_size(const struct hlsl_type *type);
|
||||||
|
@ -3250,8 +3250,7 @@ static struct extern_resource *sm4_get_extern_resources(struct hlsl_ctx *ctx, un
|
|||||||
if (!hlsl_type_is_resource(component_type))
|
if (!hlsl_type_is_resource(component_type))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
regset = hlsl_type_get_regset(component_type);
|
regset_offset = hlsl_type_get_component_offset(ctx, var->data_type, k, ®set);
|
||||||
regset_offset = hlsl_type_get_component_offset(ctx, var->data_type, regset, k);
|
|
||||||
|
|
||||||
if (regset_offset > var->regs[regset].allocation_size)
|
if (regset_offset > var->regs[regset].allocation_size)
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user