mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/ir: Handle all component types in vsir_data_type_from_component_type().
This commit is contained in:
Notes:
Henri Verbeet
2025-09-10 12:04:00 +02:00
Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1719
@@ -53,7 +53,9 @@ const char *vsir_data_type_get_name(enum vsir_data_type t, const char *error)
|
|||||||
[VSIR_DATA_F16 ] = "half",
|
[VSIR_DATA_F16 ] = "half",
|
||||||
[VSIR_DATA_F32 ] = "float",
|
[VSIR_DATA_F32 ] = "float",
|
||||||
[VSIR_DATA_F64 ] = "double",
|
[VSIR_DATA_F64 ] = "double",
|
||||||
|
[VSIR_DATA_I16 ] = "i16",
|
||||||
[VSIR_DATA_I32 ] = "int",
|
[VSIR_DATA_I32 ] = "int",
|
||||||
|
[VSIR_DATA_I64 ] = "i64",
|
||||||
[VSIR_DATA_U8 ] = "uint8",
|
[VSIR_DATA_U8 ] = "uint8",
|
||||||
[VSIR_DATA_U16 ] = "uint16",
|
[VSIR_DATA_U16 ] = "uint16",
|
||||||
[VSIR_DATA_U32 ] = "uint",
|
[VSIR_DATA_U32 ] = "uint",
|
||||||
|
@@ -4499,7 +4499,7 @@ static uint32_t spirv_compiler_emit_int_to_bool(struct spirv_compiler *compiler,
|
|||||||
op = condition & VKD3D_SHADER_CONDITIONAL_OP_Z ? SpvOpIEqual : SpvOpINotEqual;
|
op = condition & VKD3D_SHADER_CONDITIONAL_OP_Z ? SpvOpIEqual : SpvOpINotEqual;
|
||||||
|
|
||||||
return vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, op, type_id, val_id,
|
return vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, op, type_id, val_id,
|
||||||
data_type == VSIR_DATA_U64
|
data_type_is_64_bit(data_type)
|
||||||
? spirv_compiler_get_constant_uint64_vector(compiler, 0, component_count)
|
? spirv_compiler_get_constant_uint64_vector(compiler, 0, component_count)
|
||||||
: spirv_compiler_get_constant_uint_vector(compiler, 0, component_count));
|
: spirv_compiler_get_constant_uint_vector(compiler, 0, component_count));
|
||||||
}
|
}
|
||||||
@@ -4729,6 +4729,7 @@ static uint32_t spirv_compiler_emit_constant_array(struct spirv_compiler *compil
|
|||||||
&icb->data[component_count * i]);
|
&icb->data[component_count * i]);
|
||||||
break;
|
break;
|
||||||
case VSIR_DATA_F64:
|
case VSIR_DATA_F64:
|
||||||
|
case VSIR_DATA_I64:
|
||||||
case VSIR_DATA_U64:
|
case VSIR_DATA_U64:
|
||||||
{
|
{
|
||||||
uint64_t *data = (uint64_t *)icb->data;
|
uint64_t *data = (uint64_t *)icb->data;
|
||||||
@@ -7631,11 +7632,12 @@ static void spirv_compiler_emit_bool_cast(struct spirv_compiler *compiler,
|
|||||||
/* ITOD is not supported. Frontends which emit bool casts must use ITOF for double. */
|
/* ITOD is not supported. Frontends which emit bool casts must use ITOF for double. */
|
||||||
val_id = spirv_compiler_emit_bool_to_double(compiler, 1, val_id, instruction->opcode == VSIR_OP_ITOF);
|
val_id = spirv_compiler_emit_bool_to_double(compiler, 1, val_id, instruction->opcode == VSIR_OP_ITOF);
|
||||||
}
|
}
|
||||||
else if (dst->reg.data_type == VSIR_DATA_U16 || dst->reg.data_type == VSIR_DATA_U32)
|
else if (dst->reg.data_type == VSIR_DATA_I16 || dst->reg.data_type == VSIR_DATA_I32
|
||||||
|
|| dst->reg.data_type == VSIR_DATA_U16 || dst->reg.data_type == VSIR_DATA_U32)
|
||||||
{
|
{
|
||||||
val_id = spirv_compiler_emit_bool_to_int(compiler, 1, val_id, instruction->opcode == VSIR_OP_ITOI);
|
val_id = spirv_compiler_emit_bool_to_int(compiler, 1, val_id, instruction->opcode == VSIR_OP_ITOI);
|
||||||
}
|
}
|
||||||
else if (dst->reg.data_type == VSIR_DATA_U64)
|
else if (dst->reg.data_type == VSIR_DATA_I64 || dst->reg.data_type == VSIR_DATA_U64)
|
||||||
{
|
{
|
||||||
val_id = spirv_compiler_emit_bool_to_int64(compiler, 1, val_id, instruction->opcode == VSIR_OP_ITOI);
|
val_id = spirv_compiler_emit_bool_to_int64(compiler, 1, val_id, instruction->opcode == VSIR_OP_ITOI);
|
||||||
}
|
}
|
||||||
@@ -7731,7 +7733,7 @@ static enum vkd3d_result spirv_compiler_emit_alu_instruction(struct spirv_compil
|
|||||||
condition_id = spirv_compiler_emit_int_to_bool(compiler,
|
condition_id = spirv_compiler_emit_int_to_bool(compiler,
|
||||||
VKD3D_SHADER_CONDITIONAL_OP_NZ, src[1].reg.data_type, component_count, src_ids[1]);
|
VKD3D_SHADER_CONDITIONAL_OP_NZ, src[1].reg.data_type, component_count, src_ids[1]);
|
||||||
|
|
||||||
if (dst[0].reg.data_type == VSIR_DATA_U64)
|
if (data_type_is_64_bit(dst[0].reg.data_type))
|
||||||
uint_max_id = spirv_compiler_get_constant_uint64_vector(compiler, UINT64_MAX, component_count);
|
uint_max_id = spirv_compiler_get_constant_uint64_vector(compiler, UINT64_MAX, component_count);
|
||||||
else
|
else
|
||||||
uint_max_id = spirv_compiler_get_constant_uint_vector(compiler, UINT_MAX, component_count);
|
uint_max_id = spirv_compiler_get_constant_uint_vector(compiler, UINT_MAX, component_count);
|
||||||
@@ -7846,7 +7848,7 @@ static void spirv_compiler_emit_ext_glsl_instruction(struct spirv_compiler *comp
|
|||||||
unsigned int i, component_count;
|
unsigned int i, component_count;
|
||||||
enum GLSLstd450 glsl_inst;
|
enum GLSLstd450 glsl_inst;
|
||||||
|
|
||||||
if (src[0].reg.data_type == VSIR_DATA_U64 && (instruction->opcode == VSIR_OP_FIRSTBIT_HI
|
if (data_type_is_64_bit(src[0].reg.data_type) && (instruction->opcode == VSIR_OP_FIRSTBIT_HI
|
||||||
|| instruction->opcode == VSIR_OP_FIRSTBIT_LO || instruction->opcode == VSIR_OP_FIRSTBIT_SHI))
|
|| instruction->opcode == VSIR_OP_FIRSTBIT_LO || instruction->opcode == VSIR_OP_FIRSTBIT_SHI))
|
||||||
{
|
{
|
||||||
/* At least some drivers support this anyway, but if validation is enabled it will fail. */
|
/* At least some drivers support this anyway, but if validation is enabled it will fail. */
|
||||||
@@ -8257,7 +8259,7 @@ static void spirv_compiler_emit_bitfield_instruction(struct spirv_compiler *comp
|
|||||||
|
|
||||||
component_type = vkd3d_component_type_from_data_type(dst->reg.data_type);
|
component_type = vkd3d_component_type_from_data_type(dst->reg.data_type);
|
||||||
type_id = spirv_get_type_id_for_component_type(builder, component_type, 1);
|
type_id = spirv_get_type_id_for_component_type(builder, component_type, 1);
|
||||||
size = (src[src_count - 1].reg.data_type == VSIR_DATA_U64) ? 0x40 : 0x20;
|
size = data_type_is_64_bit(src[src_count - 1].reg.data_type) ? 0x40 : 0x20;
|
||||||
mask_id = spirv_compiler_get_constant_uint(compiler, size - 1);
|
mask_id = spirv_compiler_get_constant_uint(compiler, size - 1);
|
||||||
size_id = spirv_compiler_get_constant_uint(compiler, size);
|
size_id = spirv_compiler_get_constant_uint(compiler, size);
|
||||||
|
|
||||||
|
@@ -716,7 +716,9 @@ enum vsir_data_type
|
|||||||
VSIR_DATA_F32,
|
VSIR_DATA_F32,
|
||||||
VSIR_DATA_F64,
|
VSIR_DATA_F64,
|
||||||
|
|
||||||
|
VSIR_DATA_I16,
|
||||||
VSIR_DATA_I32,
|
VSIR_DATA_I32,
|
||||||
|
VSIR_DATA_I64,
|
||||||
|
|
||||||
VSIR_DATA_U8,
|
VSIR_DATA_U8,
|
||||||
VSIR_DATA_U16,
|
VSIR_DATA_U16,
|
||||||
@@ -738,8 +740,9 @@ const char *vsir_data_type_get_name(enum vsir_data_type t, const char *error);
|
|||||||
|
|
||||||
static inline bool data_type_is_integer(enum vsir_data_type data_type)
|
static inline bool data_type_is_integer(enum vsir_data_type data_type)
|
||||||
{
|
{
|
||||||
return data_type == VSIR_DATA_I32 || data_type == VSIR_DATA_U8 || data_type == VSIR_DATA_U16
|
return data_type == VSIR_DATA_I16 || data_type == VSIR_DATA_I32 || data_type == VSIR_DATA_I64
|
||||||
|| data_type == VSIR_DATA_U32 || data_type == VSIR_DATA_U64;
|
|| data_type == VSIR_DATA_U8 || data_type == VSIR_DATA_U16 || data_type == VSIR_DATA_U32
|
||||||
|
|| data_type == VSIR_DATA_U64;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool data_type_is_bool(enum vsir_data_type data_type)
|
static inline bool data_type_is_bool(enum vsir_data_type data_type)
|
||||||
@@ -754,7 +757,7 @@ static inline bool data_type_is_floating_point(enum vsir_data_type data_type)
|
|||||||
|
|
||||||
static inline bool data_type_is_64_bit(enum vsir_data_type data_type)
|
static inline bool data_type_is_64_bit(enum vsir_data_type data_type)
|
||||||
{
|
{
|
||||||
return data_type == VSIR_DATA_F64 || data_type == VSIR_DATA_U64;
|
return data_type == VSIR_DATA_F64 || data_type == VSIR_DATA_I64 || data_type == VSIR_DATA_U64;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum vsir_dimension
|
enum vsir_dimension
|
||||||
@@ -1889,14 +1892,20 @@ static inline enum vkd3d_shader_component_type vkd3d_component_type_from_data_ty
|
|||||||
return VKD3D_SHADER_COMPONENT_FLOAT;
|
return VKD3D_SHADER_COMPONENT_FLOAT;
|
||||||
case VSIR_DATA_F64:
|
case VSIR_DATA_F64:
|
||||||
return VKD3D_SHADER_COMPONENT_DOUBLE;
|
return VKD3D_SHADER_COMPONENT_DOUBLE;
|
||||||
|
case VSIR_DATA_I16:
|
||||||
|
return VKD3D_SHADER_COMPONENT_INT16;
|
||||||
case VSIR_DATA_I32:
|
case VSIR_DATA_I32:
|
||||||
return VKD3D_SHADER_COMPONENT_INT;
|
return VKD3D_SHADER_COMPONENT_INT;
|
||||||
|
case VSIR_DATA_I64:
|
||||||
|
return VKD3D_SHADER_COMPONENT_INT64;
|
||||||
case VSIR_DATA_U16:
|
case VSIR_DATA_U16:
|
||||||
return VKD3D_SHADER_COMPONENT_UINT16;
|
return VKD3D_SHADER_COMPONENT_UINT16;
|
||||||
case VSIR_DATA_U32:
|
case VSIR_DATA_U32:
|
||||||
return VKD3D_SHADER_COMPONENT_UINT;
|
return VKD3D_SHADER_COMPONENT_UINT;
|
||||||
case VSIR_DATA_U64:
|
case VSIR_DATA_U64:
|
||||||
return VKD3D_SHADER_COMPONENT_UINT64;
|
return VKD3D_SHADER_COMPONENT_UINT64;
|
||||||
|
case VSIR_DATA_UNUSED:
|
||||||
|
return VKD3D_SHADER_COMPONENT_VOID;
|
||||||
default:
|
default:
|
||||||
FIXME("Unhandled data type %#x.\n", data_type);
|
FIXME("Unhandled data type %#x.\n", data_type);
|
||||||
/* fall-through */
|
/* fall-through */
|
||||||
@@ -1909,18 +1918,35 @@ static inline enum vsir_data_type vsir_data_type_from_component_type(enum vkd3d_
|
|||||||
{
|
{
|
||||||
switch (component_type)
|
switch (component_type)
|
||||||
{
|
{
|
||||||
case VKD3D_SHADER_COMPONENT_FLOAT:
|
case VKD3D_SHADER_COMPONENT_VOID:
|
||||||
return VSIR_DATA_F32;
|
return VSIR_DATA_UNUSED;
|
||||||
case VKD3D_SHADER_COMPONENT_UINT:
|
case VKD3D_SHADER_COMPONENT_UINT:
|
||||||
return VSIR_DATA_U32;
|
return VSIR_DATA_U32;
|
||||||
case VKD3D_SHADER_COMPONENT_INT:
|
case VKD3D_SHADER_COMPONENT_INT:
|
||||||
return VSIR_DATA_I32;
|
return VSIR_DATA_I32;
|
||||||
|
case VKD3D_SHADER_COMPONENT_FLOAT:
|
||||||
|
return VSIR_DATA_F32;
|
||||||
|
case VKD3D_SHADER_COMPONENT_BOOL:
|
||||||
|
return VSIR_DATA_BOOL;
|
||||||
case VKD3D_SHADER_COMPONENT_DOUBLE:
|
case VKD3D_SHADER_COMPONENT_DOUBLE:
|
||||||
return VSIR_DATA_F64;
|
return VSIR_DATA_F64;
|
||||||
default:
|
case VKD3D_SHADER_COMPONENT_UINT64:
|
||||||
FIXME("Unhandled component type %#x.\n", component_type);
|
return VSIR_DATA_U64;
|
||||||
return VSIR_DATA_F32;
|
case VKD3D_SHADER_COMPONENT_INT64:
|
||||||
|
return VSIR_DATA_I64;
|
||||||
|
case VKD3D_SHADER_COMPONENT_FLOAT16:
|
||||||
|
return VSIR_DATA_F16;
|
||||||
|
case VKD3D_SHADER_COMPONENT_UINT16:
|
||||||
|
return VSIR_DATA_U16;
|
||||||
|
case VKD3D_SHADER_COMPONENT_INT16:
|
||||||
|
return VSIR_DATA_I16;
|
||||||
|
case VKD3D_SHADER_COMPONENT_TYPE_FORCE_32BIT:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FIXME("Unhandled component type %#x.\n", component_type);
|
||||||
|
|
||||||
|
return VSIR_DATA_UNUSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool component_type_is_64_bit(enum vkd3d_shader_component_type component_type)
|
static inline bool component_type_is_64_bit(enum vkd3d_shader_component_type component_type)
|
||||||
|
Reference in New Issue
Block a user