vkd3d-shader: Turn vkd3d_shader_register.immconst_type into vkd3d_shader_register.dimension.

This commit is contained in:
Francisco Casas 2023-08-14 13:21:41 -04:00 committed by Alexandre Julliard
parent dc35125d73
commit e904660497
Notes: Alexandre Julliard 2023-09-26 22:47:43 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/319
7 changed files with 28 additions and 27 deletions

View File

@ -1082,9 +1082,9 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const
if (reg->type == VKD3DSPR_IMMCONST)
{
shader_addline(buffer, "%s(", compiler->colours.reset);
switch (reg->immconst_type)
switch (reg->dimension)
{
case VKD3D_IMMCONST_SCALAR:
case VSIR_DIMENSION_SCALAR:
switch (reg->data_type)
{
case VKD3D_DATA_FLOAT:
@ -1104,7 +1104,7 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const
}
break;
case VKD3D_IMMCONST_VEC4:
case VSIR_DIMENSION_VEC4:
switch (reg->data_type)
{
case VKD3D_DATA_FLOAT:
@ -1134,7 +1134,7 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const
break;
default:
shader_addline(buffer, "<unhandled immconst_type %#x>", reg->immconst_type);
shader_addline(buffer, "<unhandled immconst dimension %#x>", reg->dimension);
break;
}
shader_addline(buffer, ")");
@ -1142,13 +1142,13 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const
else if (reg->type == VKD3DSPR_IMMCONST64)
{
shader_addline(buffer, "%s(", compiler->colours.reset);
/* A double2 vector is treated as a float4 vector in enum vkd3d_immconst_type. */
if (reg->immconst_type == VKD3D_IMMCONST_SCALAR || reg->immconst_type == VKD3D_IMMCONST_VEC4)
/* A double2 vector is treated as a float4 vector in enum vsir_dimension. */
if (reg->dimension == VSIR_DIMENSION_SCALAR || reg->dimension == VSIR_DIMENSION_VEC4)
{
if (reg->data_type == VKD3D_DATA_DOUBLE)
{
shader_print_double_literal(compiler, "", reg->u.immconst_double[0], "");
if (reg->immconst_type == VKD3D_IMMCONST_VEC4)
if (reg->dimension == VSIR_DIMENSION_VEC4)
shader_print_double_literal(compiler, ", ", reg->u.immconst_double[1], "");
}
else
@ -1158,7 +1158,7 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const
}
else
{
shader_addline(buffer, "<unhandled immconst_type %#x>", reg->immconst_type);
shader_addline(buffer, "<unhandled immconst64 dimension %#x>", reg->dimension);
}
shader_addline(buffer, ")");
}

View File

@ -951,9 +951,9 @@ static void shader_sm1_read_semantic(struct vkd3d_shader_sm1_parser *sm1,
}
static void shader_sm1_read_immconst(struct vkd3d_shader_sm1_parser *sm1, const uint32_t **ptr,
struct vkd3d_shader_src_param *src_param, enum vkd3d_immconst_type type, enum vkd3d_data_type data_type)
struct vkd3d_shader_src_param *src_param, enum vsir_dimension dimension, enum vkd3d_data_type data_type)
{
unsigned int count = type == VKD3D_IMMCONST_VEC4 ? 4 : 1;
unsigned int count = dimension == VSIR_DIMENSION_VEC4 ? 4 : 1;
if (*ptr >= sm1->end || sm1->end - *ptr < count)
{
@ -975,7 +975,7 @@ static void shader_sm1_read_immconst(struct vkd3d_shader_sm1_parser *sm1, const
src_param->reg.idx[2].offset = ~0u;
src_param->reg.idx[2].rel_addr = NULL;
src_param->reg.idx_count = 0;
src_param->reg.immconst_type = type;
src_param->reg.dimension = dimension;
memcpy(src_param->reg.u.immconst_uint, *ptr, count * sizeof(uint32_t));
src_param->swizzle = VKD3D_SHADER_NO_SWIZZLE;
src_param->modifiers = 0;
@ -1132,19 +1132,19 @@ static void shader_sm1_read_instruction(struct vkd3d_shader_sm1_parser *sm1, str
else if (ins->handler_idx == VKD3DSIH_DEF)
{
shader_sm1_read_dst_param(sm1, &p, dst_param);
shader_sm1_read_immconst(sm1, &p, &src_params[0], VKD3D_IMMCONST_VEC4, VKD3D_DATA_FLOAT);
shader_sm1_read_immconst(sm1, &p, &src_params[0], VSIR_DIMENSION_VEC4, VKD3D_DATA_FLOAT);
shader_sm1_scan_register(sm1, &dst_param->reg, dst_param->write_mask, true);
}
else if (ins->handler_idx == VKD3DSIH_DEFB)
{
shader_sm1_read_dst_param(sm1, &p, dst_param);
shader_sm1_read_immconst(sm1, &p, &src_params[0], VKD3D_IMMCONST_SCALAR, VKD3D_DATA_UINT);
shader_sm1_read_immconst(sm1, &p, &src_params[0], VSIR_DIMENSION_SCALAR, VKD3D_DATA_UINT);
shader_sm1_scan_register(sm1, &dst_param->reg, dst_param->write_mask, true);
}
else if (ins->handler_idx == VKD3DSIH_DEFI)
{
shader_sm1_read_dst_param(sm1, &p, dst_param);
shader_sm1_read_immconst(sm1, &p, &src_params[0], VKD3D_IMMCONST_VEC4, VKD3D_DATA_INT);
shader_sm1_read_immconst(sm1, &p, &src_params[0], VSIR_DIMENSION_VEC4, VKD3D_DATA_INT);
shader_sm1_scan_register(sm1, &dst_param->reg, dst_param->write_mask, true);
}
else

View File

@ -1498,7 +1498,7 @@ static unsigned int register_get_uint_value(const struct vkd3d_shader_register *
if (!register_is_constant(reg) || !data_type_is_integer(reg->data_type))
return UINT_MAX;
if (reg->immconst_type == VKD3D_IMMCONST_VEC4)
if (reg->dimension == VSIR_DIMENSION_VEC4)
WARN("Returning vec4.x.\n");
if (reg->type == VKD3DSPR_IMMCONST64)
@ -1968,7 +1968,7 @@ static enum vkd3d_result sm6_parser_constants_init(struct sm6_parser *sm6, const
dst->type = type;
dst->value_type = VALUE_TYPE_REG;
dst->u.reg.type = reg_type;
dst->u.reg.immconst_type = VKD3D_IMMCONST_SCALAR;
dst->u.reg.dimension = VSIR_DIMENSION_SCALAR;
dst->u.reg.data_type = reg_data_type;
switch (record->code)

View File

@ -72,7 +72,7 @@ static void shader_instruction_eliminate_phase_instance_id(struct vkd3d_shader_i
reg->idx[2].offset = ~0u;
reg->idx[2].rel_addr = NULL;
reg->idx_count = 0;
reg->immconst_type = VKD3D_IMMCONST_SCALAR;
reg->dimension = VSIR_DIMENSION_SCALAR;
reg->u.immconst_uint[0] = instance_id;
continue;
}
@ -310,7 +310,7 @@ void vsir_register_init(struct vkd3d_shader_register *reg, enum vkd3d_shader_reg
reg->idx[2].offset = ~0u;
reg->idx[2].rel_addr = NULL;
reg->idx_count = idx_count;
reg->immconst_type = VKD3D_IMMCONST_SCALAR;
reg->dimension = VSIR_DIMENSION_SCALAR;
}
void vsir_instruction_init(struct vkd3d_shader_instruction *ins, const struct vkd3d_shader_location *location,
@ -1207,7 +1207,7 @@ static void shader_register_normalise_flat_constants(struct vkd3d_shader_src_par
{
param->reg.type = VKD3DSPR_IMMCONST;
param->reg.idx_count = 0;
param->reg.immconst_type = VKD3D_IMMCONST_VEC4;
param->reg.dimension = VSIR_DIMENSION_VEC4;
for (j = 0; j < 4; ++j)
param->reg.u.immconst_uint[j] = normaliser->defs[i].value[j];
return;

View File

@ -3600,7 +3600,7 @@ static uint32_t spirv_compiler_emit_load_constant(struct spirv_compiler *compile
assert(reg->type == VKD3DSPR_IMMCONST);
if (reg->immconst_type == VKD3D_IMMCONST_SCALAR)
if (reg->dimension == VSIR_DIMENSION_SCALAR)
{
for (i = 0; i < component_count; ++i)
values[i] = *reg->u.immconst_uint;
@ -3627,7 +3627,7 @@ static uint32_t spirv_compiler_emit_load_constant64(struct spirv_compiler *compi
assert(reg->type == VKD3DSPR_IMMCONST64);
if (reg->immconst_type == VKD3D_IMMCONST_SCALAR)
if (reg->dimension == VSIR_DIMENSION_SCALAR)
{
for (i = 0; i < component_count; ++i)
values[i] = *reg->u.immconst_uint64;

View File

@ -1857,7 +1857,7 @@ static bool shader_sm4_read_param(struct vkd3d_shader_sm4_parser *priv, const ui
switch (dimension)
{
case VKD3D_SM4_DIMENSION_SCALAR:
param->immconst_type = VKD3D_IMMCONST_SCALAR;
param->dimension = VSIR_DIMENSION_SCALAR;
dword_count = 1 + (register_type == VKD3D_SM4_RT_IMMCONST64);
if (end - *ptr < dword_count)
{
@ -1869,7 +1869,7 @@ static bool shader_sm4_read_param(struct vkd3d_shader_sm4_parser *priv, const ui
break;
case VKD3D_SM4_DIMENSION_VEC4:
param->immconst_type = VKD3D_IMMCONST_VEC4;
param->dimension = VSIR_DIMENSION_VEC4;
if (end - *ptr < VKD3D_VEC4_SIZE)
{
WARN("Invalid ptr %p, end %p.\n", *ptr, end);

View File

@ -571,10 +571,11 @@ static inline bool data_type_is_integer(enum vkd3d_data_type data_type)
return data_type == VKD3D_DATA_INT || data_type == VKD3D_DATA_UINT8 || data_type == VKD3D_DATA_UINT;
}
enum vkd3d_immconst_type
enum vsir_dimension
{
VKD3D_IMMCONST_SCALAR,
VKD3D_IMMCONST_VEC4,
VSIR_DIMENSION_NONE,
VSIR_DIMENSION_SCALAR,
VSIR_DIMENSION_VEC4,
};
enum vkd3d_shader_src_modifier
@ -740,7 +741,7 @@ struct vkd3d_shader_register
enum vkd3d_data_type data_type;
struct vkd3d_shader_register_index idx[3];
unsigned int idx_count;
enum vkd3d_immconst_type immconst_type;
enum vsir_dimension dimension;
union
{
DWORD immconst_uint[VKD3D_VEC4_SIZE];