mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader/spirv: Support bool logic ops in spirv_compiler_emit_alu_instruction().
This commit is contained in:
committed by
Alexandre Julliard
parent
b43dab50c1
commit
5b87d6419a
Notes:
Alexandre Julliard
2023-11-10 00:09:32 +01: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/436
@ -1150,6 +1150,20 @@ static uint32_t vkd3d_spirv_get_op_type_pointer(struct vkd3d_spirv_builder *buil
|
|||||||
vkd3d_spirv_build_op_type_pointer);
|
vkd3d_spirv_build_op_type_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t vkd3d_spirv_build_op_constant_bool(struct vkd3d_spirv_builder *builder,
|
||||||
|
uint32_t result_type, uint32_t value)
|
||||||
|
{
|
||||||
|
return vkd3d_spirv_build_op_tr(builder, &builder->global_stream,
|
||||||
|
value ? SpvOpConstantTrue : SpvOpConstantFalse, result_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t vkd3d_spirv_get_op_constant_bool(struct vkd3d_spirv_builder *builder,
|
||||||
|
uint32_t result_type, uint32_t value)
|
||||||
|
{
|
||||||
|
return vkd3d_spirv_build_once2(builder, value ? SpvOpConstantTrue : SpvOpConstantFalse, result_type, value,
|
||||||
|
vkd3d_spirv_build_op_constant_bool);
|
||||||
|
}
|
||||||
|
|
||||||
/* Types larger than 32-bits are not supported. */
|
/* Types larger than 32-bits are not supported. */
|
||||||
static uint32_t vkd3d_spirv_build_op_constant(struct vkd3d_spirv_builder *builder,
|
static uint32_t vkd3d_spirv_build_op_constant(struct vkd3d_spirv_builder *builder,
|
||||||
uint32_t result_type, uint32_t value)
|
uint32_t result_type, uint32_t value)
|
||||||
@ -1802,6 +1816,8 @@ static uint32_t vkd3d_spirv_get_type_id_for_data_type(struct vkd3d_spirv_builder
|
|||||||
break;
|
break;
|
||||||
case VKD3D_DATA_DOUBLE:
|
case VKD3D_DATA_DOUBLE:
|
||||||
return vkd3d_spirv_get_op_type_float(builder, 64);
|
return vkd3d_spirv_get_op_type_float(builder, 64);
|
||||||
|
case VKD3D_DATA_BOOL:
|
||||||
|
return vkd3d_spirv_get_op_type_bool(builder);
|
||||||
default:
|
default:
|
||||||
FIXME("Unhandled data type %#x.\n", data_type);
|
FIXME("Unhandled data type %#x.\n", data_type);
|
||||||
return 0;
|
return 0;
|
||||||
@ -2897,6 +2913,13 @@ static uint32_t spirv_compiler_get_constant(struct spirv_compiler *compiler,
|
|||||||
case VKD3D_SHADER_COMPONENT_INT:
|
case VKD3D_SHADER_COMPONENT_INT:
|
||||||
case VKD3D_SHADER_COMPONENT_FLOAT:
|
case VKD3D_SHADER_COMPONENT_FLOAT:
|
||||||
break;
|
break;
|
||||||
|
case VKD3D_SHADER_COMPONENT_BOOL:
|
||||||
|
if (component_count == 1)
|
||||||
|
return vkd3d_spirv_get_op_constant_bool(builder, type_id, *values);
|
||||||
|
FIXME("Unsupported vector of bool.\n");
|
||||||
|
spirv_compiler_error(compiler, VKD3D_SHADER_ERROR_SPV_INVALID_TYPE,
|
||||||
|
"Vectors of bool type are not supported.");
|
||||||
|
return vkd3d_spirv_get_op_undef(builder, type_id);
|
||||||
default:
|
default:
|
||||||
FIXME("Unhandled component_type %#x.\n", component_type);
|
FIXME("Unhandled component_type %#x.\n", component_type);
|
||||||
return vkd3d_spirv_get_op_undef(builder, type_id);
|
return vkd3d_spirv_get_op_undef(builder, type_id);
|
||||||
@ -6618,6 +6641,21 @@ static SpvOp spirv_compiler_map_alu_instruction(const struct vkd3d_shader_instru
|
|||||||
return SpvOpMax;
|
return SpvOpMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SpvOp spirv_compiler_map_logical_instruction(const struct vkd3d_shader_instruction *instruction)
|
||||||
|
{
|
||||||
|
switch (instruction->handler_idx)
|
||||||
|
{
|
||||||
|
case VKD3DSIH_AND:
|
||||||
|
return SpvOpLogicalAnd;
|
||||||
|
case VKD3DSIH_OR:
|
||||||
|
return SpvOpLogicalOr;
|
||||||
|
case VKD3DSIH_XOR:
|
||||||
|
return SpvOpLogicalNotEqual;
|
||||||
|
default:
|
||||||
|
return SpvOpMax;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void spirv_compiler_emit_alu_instruction(struct spirv_compiler *compiler,
|
static void spirv_compiler_emit_alu_instruction(struct spirv_compiler *compiler,
|
||||||
const struct vkd3d_shader_instruction *instruction)
|
const struct vkd3d_shader_instruction *instruction)
|
||||||
{
|
{
|
||||||
@ -6629,7 +6667,16 @@ static void spirv_compiler_emit_alu_instruction(struct spirv_compiler *compiler,
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
SpvOp op;
|
SpvOp op;
|
||||||
|
|
||||||
op = spirv_compiler_map_alu_instruction(instruction);
|
if (src->reg.data_type == VKD3D_DATA_BOOL && dst->reg.data_type == VKD3D_DATA_BOOL)
|
||||||
|
{
|
||||||
|
/* VSIR supports logic ops AND/OR/XOR on bool values. */
|
||||||
|
op = spirv_compiler_map_logical_instruction(instruction);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
op = spirv_compiler_map_alu_instruction(instruction);
|
||||||
|
}
|
||||||
|
|
||||||
if (op == SpvOpMax)
|
if (op == SpvOpMax)
|
||||||
{
|
{
|
||||||
ERR("Unexpected instruction %#x.\n", instruction->handler_idx);
|
ERR("Unexpected instruction %#x.\n", instruction->handler_idx);
|
||||||
|
@ -93,6 +93,7 @@ enum vkd3d_shader_error
|
|||||||
VKD3D_SHADER_ERROR_SPV_DESCRIPTOR_IDX_UNSUPPORTED = 2003,
|
VKD3D_SHADER_ERROR_SPV_DESCRIPTOR_IDX_UNSUPPORTED = 2003,
|
||||||
VKD3D_SHADER_ERROR_SPV_STENCIL_EXPORT_UNSUPPORTED = 2004,
|
VKD3D_SHADER_ERROR_SPV_STENCIL_EXPORT_UNSUPPORTED = 2004,
|
||||||
VKD3D_SHADER_ERROR_SPV_OUT_OF_MEMORY = 2005,
|
VKD3D_SHADER_ERROR_SPV_OUT_OF_MEMORY = 2005,
|
||||||
|
VKD3D_SHADER_ERROR_SPV_INVALID_TYPE = 2006,
|
||||||
|
|
||||||
VKD3D_SHADER_WARNING_SPV_INVALID_SWIZZLE = 2300,
|
VKD3D_SHADER_WARNING_SPV_INVALID_SWIZZLE = 2300,
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user