Based on vkd3d-proton patches. From: Joshua Ashton joshua@froggi.es
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- include/vkd3d_shader.h | 2 ++ libs/vkd3d-shader/dxbc.c | 3 +++ libs/vkd3d-shader/spirv.c | 10 +++++++--- libs/vkd3d-shader/vkd3d_shader_private.h | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 03225d37..0e011343 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -1177,6 +1177,8 @@ enum vkd3d_shader_component_type VKD3D_SHADER_COMPONENT_FLOAT = 0x3, /** Boolean. */ VKD3D_SHADER_COMPONENT_BOOL = 0x4, + /** 64-bit IEEE floating-point. */ + VKD3D_SHADER_COMPONENT_DOUBLE = 0x5,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPONENT_TYPE), }; diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index d2cf87e3..cd90354a 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -1001,6 +1001,7 @@ static void shader_sm5_read_sync(struct vkd3d_shader_instruction *ins, * R -> VKD3D_DATA_RESOURCE * S -> VKD3D_DATA_SAMPLER * U -> VKD3D_DATA_UAV + * d -> VKD3D_DATA_DOUBLE */ static const struct vkd3d_sm4_opcode_info opcode_table[] = { @@ -1335,6 +1336,8 @@ static enum vkd3d_data_type map_data_type(char t) return VKD3D_DATA_SAMPLER; case 'U': return VKD3D_DATA_UAV; + case 'd': + return VKD3D_DATA_DOUBLE; default: ERR("Invalid data type '%c'.\n", t); return VKD3D_DATA_FLOAT; diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 0e75b0ae..ca523cb5 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -1714,6 +1714,8 @@ static uint32_t vkd3d_spirv_get_type_id(struct vkd3d_spirv_builder *builder, case VKD3D_SHADER_COMPONENT_BOOL: return vkd3d_spirv_get_op_type_bool(builder); break; + case VKD3D_SHADER_COMPONENT_DOUBLE: + return vkd3d_spirv_get_op_type_float(builder, 64); default: FIXME("Unhandled component type %#x.\n", component_type); return 0; @@ -2680,7 +2682,7 @@ static uint32_t vkd3d_dxbc_compiler_get_type_id_for_reg(struct vkd3d_dxbc_compil
return vkd3d_spirv_get_type_id(builder, vkd3d_component_type_from_data_type(reg->data_type), - vkd3d_write_mask_component_count(write_mask)); + vkd3d_write_mask_component_count_typed(write_mask, reg->data_type)); }
static uint32_t vkd3d_dxbc_compiler_get_type_id_for_dst(struct vkd3d_dxbc_compiler *compiler, @@ -3343,7 +3345,8 @@ static uint32_t vkd3d_dxbc_compiler_emit_load_reg(struct vkd3d_dxbc_compiler *co
if (component_type != reg_info.component_type) { - type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count); + type_id = vkd3d_spirv_get_type_id(builder, component_type, + vkd3d_write_mask_component_count_typed(write_mask, reg->data_type)); val_id = vkd3d_spirv_build_op_bitcast(builder, type_id, val_id); }
@@ -3532,7 +3535,8 @@ static void vkd3d_dxbc_compiler_emit_store_reg(struct vkd3d_dxbc_compiler *compi component_type = vkd3d_component_type_from_data_type(reg->data_type); if (component_type != reg_info.component_type) { - unsigned int component_count = vkd3d_write_mask_component_count(write_mask); + unsigned int component_count = vkd3d_write_mask_component_count_typed(write_mask, + vkd3d_data_type_from_component_type(reg_info.component_type)); type_id = vkd3d_spirv_get_type_id(builder, reg_info.component_type, component_count); val_id = vkd3d_spirv_build_op_bitcast(builder, type_id, val_id); component_type = reg_info.component_type; diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 6d756e40..03bc2e1b 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -965,6 +965,8 @@ static inline enum vkd3d_shader_component_type vkd3d_component_type_from_data_ty return VKD3D_SHADER_COMPONENT_UINT; case VKD3D_DATA_INT: return VKD3D_SHADER_COMPONENT_INT; + case VKD3D_DATA_DOUBLE: + return VKD3D_SHADER_COMPONENT_DOUBLE; default: FIXME("Unhandled data type %#x.\n", data_type); return VKD3D_SHADER_COMPONENT_UINT; @@ -982,6 +984,8 @@ static inline enum vkd3d_data_type vkd3d_data_type_from_component_type( return VKD3D_DATA_UINT; case VKD3D_SHADER_COMPONENT_INT: return VKD3D_DATA_INT; + case VKD3D_SHADER_COMPONENT_DOUBLE: + return VKD3D_DATA_DOUBLE; default: FIXME("Unhandled component type %#x.\n", component_type); return VKD3D_DATA_FLOAT; @@ -1010,6 +1014,16 @@ static inline unsigned int vkd3d_write_mask_component_count(DWORD write_mask) return count; }
+static inline unsigned int vkd3d_write_mask_component_count_typed(DWORD write_mask, + enum vkd3d_data_type data_type) +{ + unsigned int component_count = vkd3d_write_mask_component_count(write_mask); + if (data_type == VKD3D_DATA_DOUBLE) + component_count /= 2u; + assert(component_count != 0); + return component_count; +} + static inline unsigned int vkd3d_write_mask_from_component_count(unsigned int component_count) { assert(component_count <= VKD3D_VEC4_SIZE);