Signed-off-by: Isabella Bosia ibosia@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 30 +++++++++++++++--------- libs/vkd3d-shader/trace.c | 22 ++++++++++------- libs/vkd3d-shader/vkd3d_shader_private.h | 4 ++++ 3 files changed, 36 insertions(+), 20 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 398cd9f..371ea13 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -433,11 +433,15 @@ enum vkd3d_sm4_resource_type
enum vkd3d_sm4_data_type { - VKD3D_SM4_DATA_UNORM = 0x1, - VKD3D_SM4_DATA_SNORM = 0x2, - VKD3D_SM4_DATA_INT = 0x3, - VKD3D_SM4_DATA_UINT = 0x4, - VKD3D_SM4_DATA_FLOAT = 0x5, + VKD3D_SM4_DATA_UNORM = 0x1, + VKD3D_SM4_DATA_SNORM = 0x2, + VKD3D_SM4_DATA_INT = 0x3, + VKD3D_SM4_DATA_UINT = 0x4, + VKD3D_SM4_DATA_FLOAT = 0x5, + VKD3D_SM4_DATA_MIXED = 0x6, + VKD3D_SM4_DATA_DOUBLE = 0x7, + VKD3D_SM4_DATA_CONTINUED = 0x8, + VKD3D_SM4_DATA_UNUSED = 0x9, };
enum vkd3d_sm4_sampler_mode @@ -522,12 +526,16 @@ static const enum vkd3d_shader_resource_type resource_type_table[] =
static const enum vkd3d_data_type data_type_table[] = { - /* 0 */ VKD3D_DATA_FLOAT, - /* VKD3D_SM4_DATA_UNORM */ VKD3D_DATA_UNORM, - /* VKD3D_SM4_DATA_SNORM */ VKD3D_DATA_SNORM, - /* VKD3D_SM4_DATA_INT */ VKD3D_DATA_INT, - /* VKD3D_SM4_DATA_UINT */ VKD3D_DATA_UINT, - /* VKD3D_SM4_DATA_FLOAT */ VKD3D_DATA_FLOAT, + /* 0 */ VKD3D_DATA_FLOAT, + /* VKD3D_SM4_DATA_UNORM */ VKD3D_DATA_UNORM, + /* VKD3D_SM4_DATA_SNORM */ VKD3D_DATA_SNORM, + /* VKD3D_SM4_DATA_INT */ VKD3D_DATA_INT, + /* VKD3D_SM4_DATA_UINT */ VKD3D_DATA_UINT, + /* VKD3D_SM4_DATA_FLOAT */ VKD3D_DATA_FLOAT, + /* VKD3D_SM4_DATA_MIXED */ VKD3D_DATA_MIXED, + /* VKD3D_SM4_DATA_DOUBLE */ VKD3D_DATA_DOUBLE, + /* VKD3D_SM4_DATA_CONTINUED */ VKD3D_DATA_CONTINUED, + /* VKD3D_SM4_DATA_UNUSED */ VKD3D_DATA_UNUSED, };
static bool shader_is_sm_5_1(const struct vkd3d_sm4_data *priv) diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index 2d758b6..6049ee1 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -530,15 +530,19 @@ static void shader_dump_data_type(struct vkd3d_string_buffer *buffer, enum vkd3d { static const char *const data_type_names[] = { - /* VKD3D_DATA_FLOAT */ "float", - /* VKD3D_DATA_INT */ "int", - /* VKD3D_DATA_RESOURCE */ "resource", - /* VKD3D_DATA_SAMPLER */ "sampler", - /* VKD3D_DATA_UAV */ "uav", - /* VKD3D_DATA_UINT */ "uint", - /* VKD3D_DATA_UNORM */ "unorm", - /* VKD3D_DATA_SNORM */ "snorm", - /* VKD3D_DATA_OPAQUE */ "opaque", + /* VKD3D_DATA_FLOAT */ "float", + /* VKD3D_DATA_INT */ "int", + /* VKD3D_DATA_RESOURCE */ "resource", + /* VKD3D_DATA_SAMPLER */ "sampler", + /* VKD3D_DATA_UAV */ "uav", + /* VKD3D_DATA_UINT */ "uint", + /* VKD3D_DATA_UNORM */ "unorm", + /* VKD3D_DATA_SNORM */ "snorm", + /* VKD3D_DATA_OPAQUE */ "opaque", + /* VKD3D_DATA_MIXED */ "mixed", + /* VKD3D_DATA_DOUBLE */ "double", + /* VKD3D_DATA_CONTINUED */ "<continued>", + /* VKD3D_DATA_UNUSED */ "<unused>", }; const char *name;
diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index ec0014e..71eb80d 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -394,6 +394,10 @@ enum vkd3d_data_type VKD3D_DATA_UNORM, VKD3D_DATA_SNORM, VKD3D_DATA_OPAQUE, + VKD3D_DATA_MIXED, + VKD3D_DATA_DOUBLE, + VKD3D_DATA_CONTINUED, + VKD3D_DATA_UNUSED, };
enum vkd3d_immconst_type
Signed-off-by: Isabella Bosia ibosia@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 52 +++++++++++++++--------- libs/vkd3d-shader/spirv.c | 2 +- libs/vkd3d-shader/trace.c | 24 +++++++---- libs/vkd3d-shader/vkd3d_shader_main.c | 13 +++++- libs/vkd3d-shader/vkd3d_shader_private.h | 4 +- 5 files changed, 63 insertions(+), 32 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 371ea13..93e7eaf 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -122,6 +122,8 @@
#define VKD3D_SM4_CONDITIONAL_NZ (0x1u << 18)
+#define VKD3D_SM4_TYPE_COMPONENT(com, i) (((com) >> (4 * (i))) & 0xfu) + enum vkd3d_sm4_opcode { VKD3D_SM4_OP_ADD = 0x00, @@ -623,6 +625,7 @@ static void shader_sm4_read_dcl_resource(struct vkd3d_shader_instruction *ins, enum vkd3d_sm4_data_type data_type; enum vkd3d_data_type reg_data_type; DWORD components; + unsigned int i;
resource_type = (opcode_token & VKD3D_SM4_RESOURCE_TYPE_MASK) >> VKD3D_SM4_RESOURCE_TYPE_SHIFT; if (!resource_type || (resource_type >= ARRAY_SIZE(resource_type_table))) @@ -639,18 +642,19 @@ static void shader_sm4_read_dcl_resource(struct vkd3d_shader_instruction *ins, semantic->resource.register_index = shader_sm4_map_resource_idx(&semantic->resource.reg.reg, priv);
components = *tokens++; - if ((components & 0xfff0) != (components & 0xf) * 0x1110) - FIXME("Components (%#x) have different data types.\n", components); - data_type = components & 0xf; - - if (!data_type || (data_type >= ARRAY_SIZE(data_type_table))) - { - FIXME("Unhandled data type %#x.\n", data_type); - semantic->resource_data_type = VKD3D_DATA_FLOAT; - } - else + for (i = 0; i < VKD3D_VEC4_SIZE; i++) { - semantic->resource_data_type = data_type_table[data_type]; + data_type = VKD3D_SM4_TYPE_COMPONENT(components, i); + + if (!data_type || (data_type >= ARRAY_SIZE(data_type_table))) + { + FIXME("Unhandled data type %#x.\n", data_type); + semantic->resource_data_type[i] = VKD3D_DATA_FLOAT; + } + else + { + semantic->resource_data_type[i] = data_type_table[data_type]; + } }
if (reg_data_type == VKD3D_DATA_UAV) @@ -1791,16 +1795,21 @@ static void shader_sm4_read_instruction_modifier(DWORD modifier, struct vkd3d_sh case VKD3D_SM5_MODIFIER_DATA_TYPE: { DWORD components = (modifier & VKD3D_SM5_MODIFIER_DATA_TYPE_MASK) >> VKD3D_SM5_MODIFIER_DATA_TYPE_SHIFT; - enum vkd3d_sm4_data_type data_type = components & 0xf; + unsigned int i;
- if ((components & 0xfff0) != (components & 0xf) * 0x1110) - FIXME("Components (%#x) have different data types.\n", components); - if (data_type < ARRAY_SIZE(data_type_table)) - ins->resource_data_type = data_type_table[data_type]; - else + for (i = 0; i < VKD3D_VEC4_SIZE; i++) { - FIXME("Unhandled data type %#x.\n", data_type); - ins->resource_data_type = VKD3D_DATA_FLOAT; + enum vkd3d_sm4_data_type data_type = VKD3D_SM4_TYPE_COMPONENT(components, i); + + if (!data_type || (data_type >= ARRAY_SIZE(data_type_table))) + { + FIXME("Unhandled data type %#x.\n", data_type); + ins->resource_data_type[i] = VKD3D_DATA_FLOAT; + } + else + { + ins->resource_data_type[i] = data_type_table[data_type]; + } } break; } @@ -1881,7 +1890,10 @@ void shader_sm4_read_instruction(void *data, const DWORD **ptr, struct vkd3d_sha ins->src_count = strlen(opcode_info->src_info); ins->src = priv->src_param; ins->resource_type = VKD3D_SHADER_RESOURCE_NONE; - ins->resource_data_type = VKD3D_DATA_FLOAT; + ins->resource_data_type[0] = VKD3D_DATA_FLOAT; + ins->resource_data_type[1] = VKD3D_DATA_FLOAT; + ins->resource_data_type[2] = VKD3D_DATA_FLOAT; + ins->resource_data_type[3] = VKD3D_DATA_FLOAT; memset(&ins->texel_offset, 0, sizeof(ins->texel_offset));
p = *ptr; diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 44fe35c..cb9c7a1 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -5625,7 +5625,7 @@ static void vkd3d_dxbc_compiler_emit_dcl_resource(struct vkd3d_dxbc_compiler *co FIXME("Unhandled UAV flags %#x.\n", instruction->flags);
vkd3d_dxbc_compiler_emit_resource_declaration(compiler, &semantic->resource, - semantic->resource_type, semantic->resource_data_type, 0, false); + semantic->resource_type, semantic->resource_data_type[0], 0, false); }
static void vkd3d_dxbc_compiler_emit_dcl_resource_raw(struct vkd3d_dxbc_compiler *compiler, diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index 6049ee1..9ff18e7 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -526,7 +526,7 @@ static void shader_dump_resource_type(struct vkd3d_string_buffer *buffer, enum v shader_addline(buffer, "unknown"); }
-static void shader_dump_data_type(struct vkd3d_string_buffer *buffer, enum vkd3d_data_type type) +static void shader_dump_data_type(struct vkd3d_string_buffer *buffer, const enum vkd3d_data_type *type) { static const char *const data_type_names[] = { @@ -545,13 +545,20 @@ static void shader_dump_data_type(struct vkd3d_string_buffer *buffer, enum vkd3d /* VKD3D_DATA_UNUSED */ "<unused>", }; const char *name; + int i;
- if (type <= ARRAY_SIZE(data_type_names)) - name = data_type_names[type]; - else - name = "unknown"; + shader_addline(buffer, "("); + + for (i = 0; i < 4; i++) + { + if (type[i] < ARRAY_SIZE(data_type_names)) + name = data_type_names[type[i]]; + else + name = "unknown"; + shader_addline(buffer, "%s%s", i == 0 ? "" : ",", name); + }
- shader_addline(buffer, "(%s,%s,%s,%s)", name, name, name, name); + shader_addline(buffer, ")"); }
static void shader_dump_decl_usage(struct vkd3d_string_buffer *buffer, @@ -1539,7 +1546,10 @@ static void shader_dump_instruction(struct vkd3d_string_buffer *buffer, shader_addline(buffer, ")"); }
- if (ins->resource_data_type != VKD3D_DATA_FLOAT) + if (ins->resource_data_type[0] != VKD3D_DATA_FLOAT || + ins->resource_data_type[1] != VKD3D_DATA_FLOAT || + ins->resource_data_type[2] != VKD3D_DATA_FLOAT || + ins->resource_data_type[3] != VKD3D_DATA_FLOAT) shader_dump_data_type(buffer, ins->resource_data_type);
for (i = 0; i < ins->dst_count; ++i) diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 0839cae..e5c5208 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -651,7 +651,16 @@ static void vkd3d_shader_scan_typed_resource_declaration(struct vkd3d_shader_sca const struct vkd3d_shader_semantic *semantic = &instruction->declaration.semantic; enum vkd3d_shader_resource_data_type resource_data_type;
- switch (semantic->resource_data_type) + if (semantic->resource_data_type[0] != semantic->resource_data_type[1] || + semantic->resource_data_type[0] != semantic->resource_data_type[2] || + semantic->resource_data_type[0] != semantic->resource_data_type[3]) + FIXME("Resource data types are different (%d, %d, %d, %d).\n", + semantic->resource_data_type[0], + semantic->resource_data_type[1], + semantic->resource_data_type[2], + semantic->resource_data_type[3]); + + switch (semantic->resource_data_type[0]) { case VKD3D_DATA_UNORM: resource_data_type = VKD3D_SHADER_RESOURCE_DATA_UNORM; @@ -669,7 +678,7 @@ static void vkd3d_shader_scan_typed_resource_declaration(struct vkd3d_shader_sca resource_data_type = VKD3D_SHADER_RESOURCE_DATA_FLOAT; break; default: - ERR("Invalid resource data type %#x.\n", semantic->resource_data_type); + ERR("Invalid resource data type %#x.\n", semantic->resource_data_type[0]); resource_data_type = VKD3D_SHADER_RESOURCE_DATA_FLOAT; break; } diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 71eb80d..f88ea69 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -631,7 +631,7 @@ struct vkd3d_shader_semantic enum vkd3d_decl_usage usage; unsigned int usage_idx; enum vkd3d_shader_resource_type resource_type; - enum vkd3d_data_type resource_data_type; + enum vkd3d_data_type resource_data_type[VKD3D_VEC4_SIZE]; struct vkd3d_shader_resource resource; };
@@ -770,7 +770,7 @@ struct vkd3d_shader_instruction const struct vkd3d_shader_src_param *src; struct vkd3d_shader_texel_offset texel_offset; enum vkd3d_shader_resource_type resource_type; - enum vkd3d_data_type resource_data_type; + enum vkd3d_data_type resource_data_type[VKD3D_VEC4_SIZE]; bool coissue; const struct vkd3d_shader_src_param *predicate; union
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com