vkd3d-shader/trace: Trace the normalised instruction array after tracing the input.

This commit is contained in:
Conor McCarthy 2023-02-23 13:47:03 +10:00 committed by Alexandre Julliard
parent eabdccb117
commit 16a7de4b38
Notes: Alexandre Julliard 2023-04-03 22:08:13 +02:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/84
4 changed files with 20 additions and 14 deletions

View File

@ -9892,6 +9892,9 @@ int spirv_compiler_generate_spirv(struct spirv_compiler *compiler,
shader_normaliser_init(&normaliser, instructions);
result = shader_normaliser_flatten_hull_shader_phases(&normaliser);
instructions = &normaliser.instructions;
if (result >= 0 && TRACE_ON())
vkd3d_shader_trace(instructions, &parser->shader_version);
}
for (i = 0; i < instructions->count && result >= 0; ++i)

View File

@ -1857,11 +1857,11 @@ static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler,
shader_addline(buffer, "\n");
}
enum vkd3d_result vkd3d_dxbc_binary_to_text(struct vkd3d_shader_parser *parser,
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out)
enum vkd3d_result vkd3d_dxbc_binary_to_text(const struct vkd3d_shader_instruction_array *instructions,
const struct vkd3d_shader_version *shader_version, const struct vkd3d_shader_compile_info *compile_info,
struct vkd3d_shader_code *out)
{
enum vkd3d_shader_compile_option_formatting_flags formatting;
struct vkd3d_shader_version *shader_version;
struct vkd3d_d3d_asm_compiler compiler;
enum vkd3d_result result = VKD3D_OK;
struct vkd3d_string_buffer *buffer;
@ -1919,16 +1919,16 @@ enum vkd3d_result vkd3d_dxbc_binary_to_text(struct vkd3d_shader_parser *parser,
buffer = &compiler.buffer;
vkd3d_string_buffer_init(buffer);
compiler.shader_version = *shader_version;
shader_version = &compiler.shader_version;
*shader_version = parser->shader_version;
vkd3d_string_buffer_printf(buffer, "%s%s_%u_%u%s\n", compiler.colours.version,
shader_get_type_prefix(shader_version->type), shader_version->major,
shader_version->minor, compiler.colours.reset);
indent = 0;
for (i = 0; i < parser->instructions.count; ++i)
for (i = 0; i < instructions->count; ++i)
{
struct vkd3d_shader_instruction *ins = &parser->instructions.elements[i];
struct vkd3d_shader_instruction *ins = &instructions->elements[i];
switch (ins->handler_idx)
{
@ -1981,12 +1981,13 @@ enum vkd3d_result vkd3d_dxbc_binary_to_text(struct vkd3d_shader_parser *parser,
return result;
}
void vkd3d_shader_trace(struct vkd3d_shader_parser *parser)
void vkd3d_shader_trace(const struct vkd3d_shader_instruction_array *instructions,
const struct vkd3d_shader_version *shader_version)
{
const char *p, *q, *end;
struct vkd3d_shader_code code;
if (vkd3d_dxbc_binary_to_text(parser, NULL, &code) != VKD3D_OK)
if (vkd3d_dxbc_binary_to_text(instructions, shader_version, NULL, &code) != VKD3D_OK)
return;
end = (const char *)code.code + code.size;

View File

@ -1072,7 +1072,7 @@ static int scan_with_parser(const struct vkd3d_shader_compile_info *compile_info
if (TRACE_ON())
{
vkd3d_shader_trace(parser);
vkd3d_shader_trace(&parser->instructions, &parser->shader_version);
}
for (i = 0; i < parser->instructions.count; ++i)
@ -1198,7 +1198,7 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info
if (compile_info->target_type == VKD3D_SHADER_TARGET_D3D_ASM)
{
vkd3d_shader_free_scan_descriptor_info(&scan_descriptor_info);
ret = vkd3d_dxbc_binary_to_text(parser, compile_info, out);
ret = vkd3d_dxbc_binary_to_text(&parser->instructions, &parser->shader_version, compile_info, out);
vkd3d_shader_parser_destroy(parser);
return ret;
}
@ -1272,7 +1272,7 @@ static int compile_d3d_bytecode(const struct vkd3d_shader_compile_info *compile_
if (compile_info->target_type == VKD3D_SHADER_TARGET_D3D_ASM)
{
ret = vkd3d_dxbc_binary_to_text(parser, compile_info, out);
ret = vkd3d_dxbc_binary_to_text(&parser->instructions, &parser->shader_version, compile_info, out);
vkd3d_shader_parser_destroy(parser);
return ret;
}

View File

@ -1030,7 +1030,8 @@ static inline void vkd3d_shader_parser_destroy(struct vkd3d_shader_parser *parse
parser->ops->parser_destroy(parser);
}
void vkd3d_shader_trace(struct vkd3d_shader_parser *parser);
void vkd3d_shader_trace(const struct vkd3d_shader_instruction_array *instructions,
const struct vkd3d_shader_version *shader_version);
const char *shader_get_type_prefix(enum vkd3d_shader_type type);
@ -1046,8 +1047,9 @@ struct vkd3d_string_buffer_cache
size_t count, max_count, capacity;
};
enum vkd3d_result vkd3d_dxbc_binary_to_text(struct vkd3d_shader_parser *parser,
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out);
enum vkd3d_result vkd3d_dxbc_binary_to_text(const struct vkd3d_shader_instruction_array *instructions,
const struct vkd3d_shader_version *shader_version, const struct vkd3d_shader_compile_info *compile_info,
struct vkd3d_shader_code *out);
void vkd3d_string_buffer_cleanup(struct vkd3d_string_buffer *buffer);
struct vkd3d_string_buffer *vkd3d_string_buffer_get(struct vkd3d_string_buffer_cache *list);
void vkd3d_string_buffer_init(struct vkd3d_string_buffer *buffer);