vkd3d-shader/hlsl: Move the "dimx" and "dimy" fields to the type-specific union.

This commit is contained in:
Elizabeth Figura 2024-10-30 11:51:05 -05:00 committed by Henri Verbeet
parent 392398794f
commit 29bac62ba2
Notes: Henri Verbeet 2025-01-10 20:14:49 +01:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1326
7 changed files with 304 additions and 280 deletions

View File

@ -610,8 +610,8 @@ static uint32_t get_fx_4_numeric_type_description(const struct hlsl_type *type,
return 0;
}
value |= (type->dimy & 0x7) << FX_4_NUMERIC_ROWS_SHIFT;
value |= (type->dimx & 0x7) << FX_4_NUMERIC_COLUMNS_SHIFT;
value |= (type->e.numeric.dimy & 0x7) << FX_4_NUMERIC_ROWS_SHIFT;
value |= (type->e.numeric.dimx & 0x7) << FX_4_NUMERIC_COLUMNS_SHIFT;
if (type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR)
value |= FX_4_NUMERIC_COLUMN_MAJOR_MASK;
@ -1047,13 +1047,13 @@ static uint32_t write_fx_2_parameter(const struct hlsl_type *type, const char *n
switch (type->class)
{
case HLSL_CLASS_VECTOR:
put_u32(buffer, type->dimx);
put_u32(buffer, type->dimy);
put_u32(buffer, type->e.numeric.dimx);
put_u32(buffer, type->e.numeric.dimy);
break;
case HLSL_CLASS_SCALAR:
case HLSL_CLASS_MATRIX:
put_u32(buffer, type->dimy);
put_u32(buffer, type->dimx);
put_u32(buffer, type->e.numeric.dimy);
put_u32(buffer, type->e.numeric.dimx);
break;
case HLSL_CLASS_STRUCT:
put_u32(buffer, type->e.record.field_count);

View File

@ -192,18 +192,20 @@ bool hlsl_type_is_row_major(const struct hlsl_type *type)
unsigned int hlsl_type_minor_size(const struct hlsl_type *type)
{
VKD3D_ASSERT(hlsl_is_numeric_type(type));
if (type->class != HLSL_CLASS_MATRIX || hlsl_type_is_row_major(type))
return type->dimx;
return type->e.numeric.dimx;
else
return type->dimy;
return type->e.numeric.dimy;
}
unsigned int hlsl_type_major_size(const struct hlsl_type *type)
{
VKD3D_ASSERT(hlsl_is_numeric_type(type));
if (type->class != HLSL_CLASS_MATRIX || hlsl_type_is_row_major(type))
return type->dimy;
return type->e.numeric.dimy;
else
return type->dimx;
return type->e.numeric.dimx;
}
unsigned int hlsl_type_element_count(const struct hlsl_type *type)
@ -211,7 +213,7 @@ unsigned int hlsl_type_element_count(const struct hlsl_type *type)
switch (type->class)
{
case HLSL_CLASS_VECTOR:
return type->dimx;
return type->e.numeric.dimx;
case HLSL_CLASS_MATRIX:
return hlsl_type_major_size(type);
case HLSL_CLASS_ARRAY:
@ -355,14 +357,24 @@ static void hlsl_type_calculate_reg_size(struct hlsl_ctx *ctx, struct hlsl_type
{
case HLSL_CLASS_SCALAR:
case HLSL_CLASS_VECTOR:
type->reg_size[HLSL_REGSET_NUMERIC] = is_sm4 ? type->dimx : 4;
type->reg_size[HLSL_REGSET_NUMERIC] = is_sm4 ? type->e.numeric.dimx : 4;
break;
case HLSL_CLASS_MATRIX:
if (hlsl_type_is_row_major(type))
type->reg_size[HLSL_REGSET_NUMERIC] = is_sm4 ? (4 * (type->dimy - 1) + type->dimx) : (4 * type->dimy);
{
if (is_sm4)
type->reg_size[HLSL_REGSET_NUMERIC] = 4 * (type->e.numeric.dimy - 1) + type->e.numeric.dimx;
else
type->reg_size[HLSL_REGSET_NUMERIC] = is_sm4 ? (4 * (type->dimx - 1) + type->dimy) : (4 * type->dimx);
type->reg_size[HLSL_REGSET_NUMERIC] = 4 * type->e.numeric.dimy;
}
else
{
if (is_sm4)
type->reg_size[HLSL_REGSET_NUMERIC] = 4 * (type->e.numeric.dimx - 1) + type->e.numeric.dimy;
else
type->reg_size[HLSL_REGSET_NUMERIC] = 4 * type->e.numeric.dimx;
}
break;
case HLSL_CLASS_ARRAY:
@ -387,7 +399,6 @@ static void hlsl_type_calculate_reg_size(struct hlsl_ctx *ctx, struct hlsl_type
{
unsigned int i;
type->dimx = 0;
for (i = 0; i < type->e.record.field_count; ++i)
{
struct hlsl_struct_field *field = &type->e.record.fields[i];
@ -399,8 +410,6 @@ static void hlsl_type_calculate_reg_size(struct hlsl_ctx *ctx, struct hlsl_type
field->reg_offset[k] = type->reg_size[k];
type->reg_size[k] += field->type->reg_size[k];
}
type->dimx += field->type->dimx * field->type->dimy * hlsl_get_multiarray_size(field->type);
}
break;
}
@ -483,8 +492,8 @@ static struct hlsl_type *hlsl_new_type(struct hlsl_ctx *ctx, const char *name, e
}
type->class = type_class;
type->e.numeric.type = base_type;
type->dimx = dimx;
type->dimy = dimy;
type->e.numeric.dimx = dimx;
type->e.numeric.dimy = dimy;
hlsl_type_calculate_reg_size(ctx, type);
list_add_tail(&ctx->types, &type->entry);
@ -552,18 +561,19 @@ static unsigned int traverse_path_from_component_index(struct hlsl_ctx *ctx,
switch (type->class)
{
case HLSL_CLASS_VECTOR:
VKD3D_ASSERT(index < type->dimx);
VKD3D_ASSERT(index < type->e.numeric.dimx);
*type_ptr = hlsl_get_scalar_type(ctx, type->e.numeric.type);
*index_ptr = 0;
return index;
case HLSL_CLASS_MATRIX:
{
unsigned int y = index / type->dimx, x = index % type->dimx;
unsigned int y = index / type->e.numeric.dimx, x = index % type->e.numeric.dimx;
bool row_major = hlsl_type_is_row_major(type);
VKD3D_ASSERT(index < type->dimx * type->dimy);
*type_ptr = hlsl_get_vector_type(ctx, type->e.numeric.type, row_major ? type->dimx : type->dimy);
VKD3D_ASSERT(index < type->e.numeric.dimx * type->e.numeric.dimy);
*type_ptr = hlsl_get_vector_type(ctx, type->e.numeric.type,
row_major ? type->e.numeric.dimx : type->e.numeric.dimy);
*index_ptr = row_major ? x : y;
return row_major ? y : x;
}
@ -861,9 +871,9 @@ struct hlsl_type *hlsl_get_element_type_from_path_index(struct hlsl_ctx *ctx, co
case HLSL_CLASS_MATRIX:
if (hlsl_type_is_row_major(type))
return hlsl_get_vector_type(ctx, type->e.numeric.type, type->dimx);
return hlsl_get_vector_type(ctx, type->e.numeric.type, type->e.numeric.dimx);
else
return hlsl_get_vector_type(ctx, type->e.numeric.type, type->dimy);
return hlsl_get_vector_type(ctx, type->e.numeric.type, type->e.numeric.dimy);
case HLSL_CLASS_ARRAY:
return type->e.array.type;
@ -892,8 +902,6 @@ struct hlsl_type *hlsl_new_array_type(struct hlsl_ctx *ctx, struct hlsl_type *ba
type->modifiers = basic_type->modifiers;
type->e.array.elements_count = array_size;
type->e.array.type = basic_type;
type->dimx = basic_type->dimx;
type->dimy = basic_type->dimy;
type->sampler_dim = basic_type->sampler_dim;
hlsl_type_calculate_reg_size(ctx, type);
@ -927,7 +935,6 @@ struct hlsl_type *hlsl_new_struct_type(struct hlsl_ctx *ctx, const char *name,
return NULL;
type->class = HLSL_CLASS_STRUCT;
type->name = name;
type->dimy = 1;
type->e.record.fields = fields;
type->e.record.field_count = field_count;
hlsl_type_calculate_reg_size(ctx, type);
@ -945,8 +952,6 @@ struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_
if (!(type = hlsl_alloc(ctx, sizeof(*type))))
return NULL;
type->class = HLSL_CLASS_TEXTURE;
type->dimx = 4;
type->dimy = 1;
type->sampler_dim = dim;
type->e.resource.format = format;
type->sample_count = sample_count;
@ -963,8 +968,6 @@ struct hlsl_type *hlsl_new_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim
if (!(type = hlsl_alloc(ctx, sizeof(*type))))
return NULL;
type->class = HLSL_CLASS_UAV;
type->dimx = format->dimx;
type->dimy = 1;
type->sampler_dim = dim;
type->e.resource.format = format;
type->e.resource.rasteriser_ordered = rasteriser_ordered;
@ -980,7 +983,6 @@ struct hlsl_type *hlsl_new_cb_type(struct hlsl_ctx *ctx, struct hlsl_type *forma
if (!(type = hlsl_alloc(ctx, sizeof(*type))))
return NULL;
type->class = HLSL_CLASS_CONSTANT_BUFFER;
type->dimy = 1;
type->e.resource.format = format;
hlsl_type_calculate_reg_size(ctx, type);
list_add_tail(&ctx->types, &type->entry);
@ -1066,7 +1068,7 @@ unsigned int hlsl_type_component_count(const struct hlsl_type *type)
case HLSL_CLASS_SCALAR:
case HLSL_CLASS_VECTOR:
case HLSL_CLASS_MATRIX:
return type->dimx * type->dimy;
return type->e.numeric.dimx * type->e.numeric.dimy;
case HLSL_CLASS_STRUCT:
{
@ -1131,9 +1133,9 @@ bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2
if ((t1->modifiers & HLSL_MODIFIER_ROW_MAJOR)
!= (t2->modifiers & HLSL_MODIFIER_ROW_MAJOR))
return false;
if (t1->dimx != t2->dimx)
if (t1->e.numeric.dimx != t2->e.numeric.dimx)
return false;
if (t1->dimy != t2->dimy)
if (t1->e.numeric.dimy != t2->e.numeric.dimy)
return false;
return true;
@ -1224,8 +1226,6 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old,
}
}
type->class = old->class;
type->dimx = old->dimx;
type->dimy = old->dimy;
type->modifiers = old->modifiers | modifiers;
if (!(type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK))
type->modifiers |= default_majority;
@ -1238,6 +1238,8 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old,
case HLSL_CLASS_SCALAR:
case HLSL_CLASS_VECTOR:
case HLSL_CLASS_MATRIX:
type->e.numeric.dimx = old->e.numeric.dimx;
type->e.numeric.dimy = old->e.numeric.dimy;
type->e.numeric.type = old->e.numeric.type;
break;
@ -1497,7 +1499,7 @@ struct hlsl_ir_node *hlsl_new_store_index(struct hlsl_ctx *ctx, const struct hls
hlsl_src_from_node(&store->rhs, rhs);
if (!writemask && type_is_single_reg(rhs->data_type))
writemask = (1 << rhs->data_type->dimx) - 1;
writemask = (1 << rhs->data_type->e.numeric.dimx) - 1;
store->writemask = writemask;
return &store->node;
@ -1524,7 +1526,7 @@ bool hlsl_new_store_component(struct hlsl_ctx *ctx, struct hlsl_block *block,
hlsl_src_from_node(&store->rhs, rhs);
if (type_is_single_reg(rhs->data_type))
store->writemask = (1 << rhs->data_type->dimx) - 1;
store->writemask = (1 << rhs->data_type->e.numeric.dimx) - 1;
hlsl_block_add_instr(block, &store->node);
@ -2064,7 +2066,7 @@ struct hlsl_ir_node *hlsl_new_index(struct hlsl_ctx *ctx, struct hlsl_ir_node *v
if (type->class == HLSL_CLASS_TEXTURE || type->class == HLSL_CLASS_UAV)
type = type->e.resource.format;
else if (type->class == HLSL_CLASS_MATRIX)
type = hlsl_get_vector_type(ctx, type->e.numeric.type, type->dimx);
type = hlsl_get_vector_type(ctx, type->e.numeric.type, type->e.numeric.dimx);
else
type = hlsl_get_element_type_from_path_index(ctx, type, idx);
@ -2355,10 +2357,10 @@ static struct hlsl_ir_node *clone_swizzle(struct hlsl_ctx *ctx,
struct clone_instr_map *map, struct hlsl_ir_swizzle *src)
{
if (src->val.node->data_type->class == HLSL_CLASS_MATRIX)
return hlsl_new_matrix_swizzle(ctx, src->u.matrix, src->node.data_type->dimx,
return hlsl_new_matrix_swizzle(ctx, src->u.matrix, src->node.data_type->e.numeric.dimx,
map_instr(map, src->val.node), &src->node.loc);
else
return hlsl_new_swizzle(ctx, src->u.vector, src->node.data_type->dimx,
return hlsl_new_swizzle(ctx, src->u.vector, src->node.data_type->e.numeric.dimx,
map_instr(map, src->val.node), &src->node.loc);
}
@ -2778,12 +2780,13 @@ static void hlsl_dump_type(struct vkd3d_string_buffer *buffer, const struct hlsl
case HLSL_CLASS_VECTOR:
VKD3D_ASSERT(type->e.numeric.type < ARRAY_SIZE(base_types));
vkd3d_string_buffer_printf(buffer, "%s%u", base_types[type->e.numeric.type], type->dimx);
vkd3d_string_buffer_printf(buffer, "%s%u", base_types[type->e.numeric.type], type->e.numeric.dimx);
return;
case HLSL_CLASS_MATRIX:
VKD3D_ASSERT(type->e.numeric.type < ARRAY_SIZE(base_types));
vkd3d_string_buffer_printf(buffer, "%s%ux%u", base_types[type->e.numeric.type], type->dimy, type->dimx);
vkd3d_string_buffer_printf(buffer, "%s%ux%u", base_types[type->e.numeric.type],
type->e.numeric.dimy, type->e.numeric.dimx);
return;
case HLSL_CLASS_ARRAY:
@ -3176,9 +3179,9 @@ static void dump_ir_constant(struct vkd3d_string_buffer *buffer, const struct hl
struct hlsl_type *type = constant->node.data_type;
unsigned int x;
if (type->dimx != 1)
if (type->e.numeric.dimx != 1)
vkd3d_string_buffer_printf(buffer, "{");
for (x = 0; x < type->dimx; ++x)
for (x = 0; x < type->e.numeric.dimx; ++x)
{
const union hlsl_constant_value_component *value = &constant->value.u[x];
@ -3206,7 +3209,7 @@ static void dump_ir_constant(struct vkd3d_string_buffer *buffer, const struct hl
break;
}
}
if (type->dimx != 1)
if (type->e.numeric.dimx != 1)
vkd3d_string_buffer_printf(buffer, "}");
}
@ -3432,16 +3435,17 @@ static void dump_ir_swizzle(struct vkd3d_string_buffer *buffer, const struct hls
unsigned int i;
dump_src(buffer, &swizzle->val);
if (swizzle->val.node->data_type->dimy > 1)
if (swizzle->val.node->data_type->e.numeric.dimy > 1)
{
vkd3d_string_buffer_printf(buffer, ".");
for (i = 0; i < swizzle->node.data_type->dimx; ++i)
for (i = 0; i < swizzle->node.data_type->e.numeric.dimx; ++i)
vkd3d_string_buffer_printf(buffer, "_m%u%u",
swizzle->u.matrix.components[i].y, swizzle->u.matrix.components[i].x);
}
else
{
vkd3d_string_buffer_printf(buffer, "%s", debug_hlsl_swizzle(swizzle->u.vector, swizzle->node.data_type->dimx));
vkd3d_string_buffer_printf(buffer, "%s",
debug_hlsl_swizzle(swizzle->u.vector, swizzle->node.data_type->e.numeric.dimx));
}
}
@ -3655,10 +3659,15 @@ void hlsl_dump_var_default_values(const struct hlsl_ir_var *var)
void hlsl_replace_node(struct hlsl_ir_node *old, struct hlsl_ir_node *new)
{
const struct hlsl_type *old_type = old->data_type, *new_type = new->data_type;
struct hlsl_src *src, *next;
VKD3D_ASSERT(old->data_type == new->data_type || old->data_type->dimx == new->data_type->dimx);
VKD3D_ASSERT(old->data_type == new->data_type || old->data_type->dimy == new->data_type->dimy);
if (hlsl_is_numeric_type(old_type))
{
VKD3D_ASSERT(hlsl_is_numeric_type(new_type));
VKD3D_ASSERT(old_type->e.numeric.dimx == new_type->e.numeric.dimx);
VKD3D_ASSERT(old_type->e.numeric.dimy == new_type->e.numeric.dimy);
}
LIST_FOR_EACH_ENTRY_SAFE(src, next, &old->uses, struct hlsl_src, entry)
{
@ -4328,7 +4337,7 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
}
ctx->builtin_types.Void = hlsl_new_simple_type(ctx, "void", HLSL_CLASS_VOID);
ctx->builtin_types.null = hlsl_new_type(ctx, "NULL", HLSL_CLASS_NULL, HLSL_TYPE_UINT, 1, 1);
ctx->builtin_types.null = hlsl_new_simple_type(ctx, "NULL", HLSL_CLASS_NULL);
ctx->builtin_types.string = hlsl_new_simple_type(ctx, "string", HLSL_CLASS_STRING);
ctx->builtin_types.error = hlsl_new_simple_type(ctx, "<error type>", HLSL_CLASS_ERROR);
hlsl_scope_add_type(ctx->globals, ctx->builtin_types.string);

View File

@ -169,16 +169,6 @@ struct hlsl_type
* Modifiers that don't fall inside this mask are to be stored in the variable in
* hlsl_ir_var.modifiers, or in the struct field in hlsl_ir_field.modifiers. */
uint32_t modifiers;
/* Size of the type values on each dimension. For non-numeric types, they are set for the
* convenience of the sm1/sm4 backends.
* If type is HLSL_CLASS_SCALAR, then both dimx = 1 and dimy = 1.
* If type is HLSL_CLASS_VECTOR, then dimx is the size of the vector, and dimy = 1.
* If type is HLSL_CLASS_MATRIX, then dimx is the number of columns, and dimy the number of rows.
* If type is HLSL_CLASS_ARRAY, then dimx and dimy have the same value as in the type of the array elements.
* If type is HLSL_CLASS_STRUCT, then dimx is the sum of (dimx * dimy) of every component, and dimy = 1.
*/
unsigned int dimx;
unsigned int dimy;
/* Sample count for HLSL_SAMPLER_DIM_2DMS or HLSL_SAMPLER_DIM_2DMSARRAY. */
unsigned int sample_count;
@ -188,6 +178,10 @@ struct hlsl_type
struct
{
enum hlsl_base_type type;
/* For scalars, dimx == dimy == 1.
* For vectors, dimx == vector width; dimy == 1.
* For matrices, dimx == column count; dimy == row count. */
unsigned int dimx, dimy;
} numeric;
/* Additional information if type is HLSL_CLASS_STRUCT. */
struct

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@ static bool fold_abs(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
VKD3D_ASSERT(type == src->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -121,7 +121,7 @@ static bool fold_bit_not(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
VKD3D_ASSERT(type == src->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -148,15 +148,15 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
float f = 0.0f;
int32_t i = 0;
if (dst_type->dimx != src->node.data_type->dimx
|| dst_type->dimy != src->node.data_type->dimy)
if (dst_type->e.numeric.dimx != src->node.data_type->e.numeric.dimx
|| dst_type->e.numeric.dimy != src->node.data_type->e.numeric.dimy)
{
FIXME("Cast from %s to %s.\n", debug_hlsl_type(ctx, src->node.data_type),
debug_hlsl_type(ctx, dst_type));
return false;
}
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (src->node.data_type->e.numeric.type)
{
@ -232,7 +232,7 @@ static bool fold_ceil(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
VKD3D_ASSERT(type == src->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -258,7 +258,7 @@ static bool fold_exp2(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
VKD3D_ASSERT(type == src->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -284,7 +284,7 @@ static bool fold_floor(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
VKD3D_ASSERT(type == src->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -311,7 +311,7 @@ static bool fold_fract(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
VKD3D_ASSERT(type == src->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -337,7 +337,7 @@ static bool fold_log2(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, con
VKD3D_ASSERT(type == src->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -382,7 +382,7 @@ static bool fold_neg(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
VKD3D_ASSERT(type == src->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -416,7 +416,7 @@ static bool fold_not(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
VKD3D_ASSERT(type == src->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -440,7 +440,7 @@ static bool fold_rcp(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
VKD3D_ASSERT(type == src->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -485,7 +485,7 @@ static bool fold_rsq(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
VKD3D_ASSERT(type == src->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -525,7 +525,7 @@ static bool fold_sat(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
VKD3D_ASSERT(type == src->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -551,7 +551,7 @@ static bool fold_sqrt(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, con
VKD3D_ASSERT(type == src->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -597,7 +597,7 @@ static bool fold_add(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
VKD3D_ASSERT(type == src1->node.data_type->e.numeric.type);
VKD3D_ASSERT(type == src2->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -634,7 +634,7 @@ static bool fold_and(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
VKD3D_ASSERT(type == src1->node.data_type->e.numeric.type);
VKD3D_ASSERT(type == src2->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -661,7 +661,7 @@ static bool fold_or(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const
VKD3D_ASSERT(type == src1->node.data_type->e.numeric.type);
VKD3D_ASSERT(type == src2->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -688,7 +688,7 @@ static bool fold_bit_xor(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
VKD3D_ASSERT(type == src1->node.data_type->e.numeric.type);
VKD3D_ASSERT(type == src2->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -713,10 +713,10 @@ static bool fold_dot(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
VKD3D_ASSERT(type == src1->node.data_type->e.numeric.type);
VKD3D_ASSERT(type == src2->node.data_type->e.numeric.type);
VKD3D_ASSERT(src1->node.data_type->dimx == src2->node.data_type->dimx);
VKD3D_ASSERT(src1->node.data_type->e.numeric.dimx == src2->node.data_type->e.numeric.dimx);
dst->u[0].f = 0.0f;
for (k = 0; k < src1->node.data_type->dimx; ++k)
for (k = 0; k < src1->node.data_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -742,11 +742,11 @@ static bool fold_dp2add(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, c
VKD3D_ASSERT(type == src1->node.data_type->e.numeric.type);
VKD3D_ASSERT(type == src2->node.data_type->e.numeric.type);
VKD3D_ASSERT(type == src3->node.data_type->e.numeric.type);
VKD3D_ASSERT(src1->node.data_type->dimx == src2->node.data_type->dimx);
VKD3D_ASSERT(src3->node.data_type->dimx == 1);
VKD3D_ASSERT(src1->node.data_type->e.numeric.dimx == src2->node.data_type->e.numeric.dimx);
VKD3D_ASSERT(src3->node.data_type->e.numeric.dimx == 1);
dst->u[0].f = src3->value.u[0].f;
for (k = 0; k < src1->node.data_type->dimx; ++k)
for (k = 0; k < src1->node.data_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -773,7 +773,7 @@ static bool fold_div(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
VKD3D_ASSERT(type == src1->node.data_type->e.numeric.type);
VKD3D_ASSERT(type == src2->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -840,7 +840,7 @@ static bool fold_equal(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, co
VKD3D_ASSERT(dst_type->e.numeric.type == HLSL_TYPE_BOOL);
VKD3D_ASSERT(src1->node.data_type->e.numeric.type == src2->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (src1->node.data_type->e.numeric.type)
{
@ -873,7 +873,7 @@ static bool fold_gequal(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, c
VKD3D_ASSERT(dst_type->e.numeric.type == HLSL_TYPE_BOOL);
VKD3D_ASSERT(src1->node.data_type->e.numeric.type == src2->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (src1->node.data_type->e.numeric.type)
{
@ -909,7 +909,7 @@ static bool fold_less(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, con
VKD3D_ASSERT(dst_type->e.numeric.type == HLSL_TYPE_BOOL);
VKD3D_ASSERT(src1->node.data_type->e.numeric.type == src2->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (src1->node.data_type->e.numeric.type)
{
@ -945,7 +945,7 @@ static bool fold_lshift(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, c
VKD3D_ASSERT(dst_type->e.numeric.type == src1->node.data_type->e.numeric.type);
VKD3D_ASSERT(src2->node.data_type->e.numeric.type == HLSL_TYPE_INT);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
unsigned int shift = src2->value.u[k].u % 32;
@ -976,7 +976,7 @@ static bool fold_max(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
VKD3D_ASSERT(type == src1->node.data_type->e.numeric.type);
VKD3D_ASSERT(type == src2->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -1014,7 +1014,7 @@ static bool fold_min(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
VKD3D_ASSERT(type == src1->node.data_type->e.numeric.type);
VKD3D_ASSERT(type == src2->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -1053,7 +1053,7 @@ static bool fold_mod(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
VKD3D_ASSERT(type == src1->node.data_type->e.numeric.type);
VKD3D_ASSERT(type == src2->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -1095,7 +1095,7 @@ static bool fold_mul(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
VKD3D_ASSERT(type == src1->node.data_type->e.numeric.type);
VKD3D_ASSERT(type == src2->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (type)
{
@ -1129,7 +1129,7 @@ static bool fold_nequal(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, c
VKD3D_ASSERT(dst_type->e.numeric.type == HLSL_TYPE_BOOL);
VKD3D_ASSERT(src1->node.data_type->e.numeric.type == src2->node.data_type->e.numeric.type);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
switch (src1->node.data_type->e.numeric.type)
{
@ -1163,7 +1163,7 @@ static bool fold_ternary(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
VKD3D_ASSERT(dst_type->e.numeric.type == src3->node.data_type->e.numeric.type);
VKD3D_ASSERT(src1->node.data_type->e.numeric.type == HLSL_TYPE_BOOL);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
dst->u[k] = src1->value.u[k].u ? src2->value.u[k] : src3->value.u[k];
return true;
@ -1177,7 +1177,7 @@ static bool fold_rshift(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, c
VKD3D_ASSERT(dst_type->e.numeric.type == src1->node.data_type->e.numeric.type);
VKD3D_ASSERT(src2->node.data_type->e.numeric.type == HLSL_TYPE_INT);
for (k = 0; k < dst_type->dimx; ++k)
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
{
unsigned int shift = src2->value.u[k].u % 32;
@ -1385,7 +1385,7 @@ static bool constant_is_zero(struct hlsl_ir_constant *const_arg)
struct hlsl_type *data_type = const_arg->node.data_type;
unsigned int k;
for (k = 0; k < data_type->dimx; ++k)
for (k = 0; k < data_type->e.numeric.dimx; ++k)
{
switch (data_type->e.numeric.type)
{
@ -1416,7 +1416,7 @@ static bool constant_is_one(struct hlsl_ir_constant *const_arg)
struct hlsl_type *data_type = const_arg->node.data_type;
unsigned int k;
for (k = 0; k < data_type->dimx; ++k)
for (k = 0; k < data_type->e.numeric.dimx; ++k)
{
switch (data_type->e.numeric.type)
{
@ -1781,7 +1781,7 @@ bool hlsl_fold_constant_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
return false;
src = hlsl_ir_constant(swizzle->val.node);
for (i = 0; i < swizzle->node.data_type->dimx; ++i)
for (i = 0; i < swizzle->node.data_type->e.numeric.dimx; ++i)
value.u[i] = src->value.u[hlsl_swizzle_get_component(swizzle->u.vector, i)];
if (!(dst = hlsl_new_constant(ctx, instr->data_type, &value, &instr->loc)))

View File

@ -3389,7 +3389,7 @@ static void write_sm4_type(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b
{
VKD3D_ASSERT(array_type->class <= HLSL_CLASS_LAST_NUMERIC);
type->bytecode_offset = put_u32(buffer, vkd3d_make_u32(sm4_class(array_type), sm4_base_type(array_type)));
put_u32(buffer, vkd3d_make_u32(array_type->dimy, array_type->dimx));
put_u32(buffer, vkd3d_make_u32(array_type->e.numeric.dimy, array_type->e.numeric.dimx));
put_u32(buffer, vkd3d_make_u32(array_size, 0));
put_u32(buffer, 1);
}
@ -3495,9 +3495,9 @@ static unsigned int get_component_index_from_default_initializer_index(struct hl
switch (type->class)
{
case HLSL_CLASS_MATRIX:
x = index / type->dimy;
y = index % type->dimy;
return y * type->dimx + x;
x = index / type->e.numeric.dimy;
y = index % type->e.numeric.dimy;
return y * type->e.numeric.dimx + x;
case HLSL_CLASS_ARRAY:
element_comp_count = hlsl_type_component_count(type->e.array.type);
@ -3594,7 +3594,7 @@ void sm4_generate_rdef(struct hlsl_ctx *ctx, struct vkd3d_shader_code *rdef)
put_u32(&buffer, sm4_resource_type(resource->component_type));
if (resource->regset == HLSL_REGSET_TEXTURES || resource->regset == HLSL_REGSET_UAVS)
{
unsigned int dimx = resource->component_type->e.resource.format->dimx;
unsigned int dimx = resource->component_type->e.resource.format->e.numeric.dimx;
put_u32(&buffer, sm4_data_type(resource->component_type));
put_u32(&buffer, sm4_rdef_resource_dimension(resource->component_type));