libs/vkd3d-shader: Import shader tracing from wined3d.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-05-29 12:50:32 +02:00 committed by Alexandre Julliard
parent 2fa29dd823
commit a5808cfdd7
6 changed files with 1627 additions and 7 deletions

View File

@ -68,6 +68,7 @@ libvkd3d_shader_la_SOURCES = \
include/private/vkd3d_shader.h \
libs/vkd3d-shader/dxbc.c \
libs/vkd3d-shader/spirv.c \
libs/vkd3d-shader/trace.c \
libs/vkd3d-shader/vkd3d_shader.map \
libs/vkd3d-shader/vkd3d_shader_main.c \
libs/vkd3d-shader/vkd3d_shader_private.h

View File

@ -1485,18 +1485,18 @@ static BOOL shader_sm4_read_param(struct vkd3d_sm4_data *priv, const DWORD **ptr
WARN("Invalid ptr %p, end %p.\n", *ptr, end);
return FALSE;
}
memcpy(param->u.immconst_data, *ptr, 1 * sizeof(DWORD));
memcpy(param->u.immconst_uint, *ptr, 1 * sizeof(DWORD));
*ptr += 1;
break;
case VKD3D_SM4_IMMCONST_VEC4:
param->immconst_type = VKD3D_IMMCONST_VEC4;
if (end - *ptr < 4)
if (end - *ptr < VKD3D_VEC4_SIZE)
{
WARN("Invalid ptr %p, end %p.\n", *ptr, end);
return FALSE;
}
memcpy(param->u.immconst_data, *ptr, 4 * sizeof(DWORD));
memcpy(param->u.immconst_uint, *ptr, VKD3D_VEC4_SIZE * sizeof(DWORD));
*ptr += 4;
break;
@ -1692,6 +1692,8 @@ void shader_sm4_read_instruction(void *data, const DWORD **ptr, struct vkd3d_sha
ins->handler_idx = opcode_info->handler_idx;
ins->flags = 0;
ins->coissue = false;
ins->predicate = NULL;
ins->dst_count = strlen(opcode_info->dst_info);
ins->dst = priv->dst_param;
ins->src_count = strlen(opcode_info->src_info);

View File

@ -2386,14 +2386,14 @@ static uint32_t vkd3d_dxbc_compiler_emit_load_constant(struct vkd3d_dxbc_compile
if (reg->immconst_type == VKD3D_IMMCONST_SCALAR)
{
assert(component_count == 1);
values[0] = *reg->u.immconst_data;
values[0] = *reg->u.immconst_uint;
}
else
{
for (i = 0, j = 0; i < VKD3D_VEC4_SIZE; ++i)
{
if (write_mask & (VKD3DSP_WRITEMASK_0 << i))
values[j++] = reg->u.immconst_data[vkd3d_swizzle_get_component(swizzle, i)];
values[j++] = reg->u.immconst_uint[vkd3d_swizzle_get_component(swizzle, i)];
}
}
@ -4598,7 +4598,7 @@ static void vkd3d_dxbc_compiler_emit_control_flow_instruction(struct vkd3d_dxbc_
assert(cf_info->current_block == VKD3D_BLOCK_SWITCH);
assert(src->swizzle == VKD3D_NO_SWIZZLE && src->reg.type == VKD3DSPR_IMMCONST);
value = *src->reg.u.immconst_data;
value = *src->reg.u.immconst_uint;
if (!vkd3d_array_reserve((void **)&cf_info->u.switch_.case_blocks, &cf_info->u.switch_.case_blocks_size,
2 * (cf_info->u.switch_.case_block_count + 1), sizeof(*cf_info->u.switch_.case_blocks)))

1606
libs/vkd3d-shader/trace.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -76,6 +76,9 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
if ((ret = vkd3d_shader_parser_init(&parser, dxbc)) < 0)
return ret;
if (TRACE_ON())
vkd3d_shader_trace(parser.data);
if (!(spirv_compiler = vkd3d_dxbc_compiler_create(&parser.shader_version,
&parser.shader_desc, compiler_options, shader_interface, compile_args, &scan_info)))
{

View File

@ -479,6 +479,9 @@ enum vkd3d_tessellator_partitioning
VKD3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 4,
};
#define VKD3DSI_TEXLD_PROJECT 0x1
#define VKD3DSI_INDEXED_DYNAMIC 0x4
#define VKD3DSI_RESINFO_RCP_FLOAT 0x1
#define VKD3DSI_RESINFO_UINT 0x2
@ -573,7 +576,8 @@ struct vkd3d_shader_register
enum vkd3d_immconst_type immconst_type;
union
{
DWORD immconst_data[VKD3D_VEC4_SIZE];
DWORD immconst_uint[VKD3D_VEC4_SIZE];
float immconst_float[VKD3D_VEC4_SIZE];
unsigned fp_body_idx;
} u;
};
@ -743,6 +747,8 @@ struct vkd3d_shader_instruction
const struct vkd3d_shader_dst_param *dst;
const struct vkd3d_shader_src_param *src;
struct vkd3d_shader_texel_offset texel_offset;
bool coissue;
const struct vkd3d_shader_src_param *predicate;
union
{
struct vkd3d_shader_semantic semantic;
@ -772,6 +778,8 @@ static inline BOOL vkd3d_shader_instruction_has_texel_offset(const struct vkd3d_
return ins->texel_offset.u || ins->texel_offset.v || ins->texel_offset.w;
}
void vkd3d_shader_trace(void *data) DECLSPEC_HIDDEN;
void *shader_sm4_init(const DWORD *byte_code, size_t byte_code_size,
const struct vkd3d_shader_signature *output_signature) DECLSPEC_HIDDEN;
void shader_sm4_free(void *data) DECLSPEC_HIDDEN;