vkd3d-shader: Parse all 4 data type components.

Signed-off-by: Isabella Bosia <ibosia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Isabella Bosia 2020-09-26 01:05:37 +01:00 committed by Alexandre Julliard
parent 8d9d20d47b
commit 9136e56435
5 changed files with 63 additions and 32 deletions

View File

@ -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;
for (i = 0; i < VKD3D_VEC4_SIZE; i++)
{
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 = VKD3D_DATA_FLOAT;
}
else
{
semantic->resource_data_type = data_type_table[data_type];
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;

View File

@ -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,

View File

@ -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, "(");
shader_addline(buffer, "(%s,%s,%s,%s)", name, name, name, name);
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, ")");
}
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)

View File

@ -563,7 +563,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;
@ -581,7 +590,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;
}

View File

@ -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