vkd3d-shader/trace: Use the instruction array interface in vkd3d_dxbc_binary_to_text().

This commit is contained in:
Conor McCarthy 2023-01-20 12:08:22 +10:00 committed by Alexandre Julliard
parent e8cb90608d
commit e9a2642d6a
Notes: Alexandre Julliard 2023-01-24 22:28:12 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/60
5 changed files with 7 additions and 36 deletions

View File

@ -873,7 +873,6 @@ static bool shader_sm1_is_end(struct vkd3d_shader_parser *parser)
const struct vkd3d_shader_parser_ops shader_sm1_parser_ops =
{
.parser_reset = shader_parser_reset,
.parser_destroy = shader_sm1_destroy,
.parser_read_instruction = shader_parser_read_instruction,
.parser_is_end = shader_parser_is_end,

View File

@ -1587,7 +1587,6 @@ static bool shader_sm4_is_end(struct vkd3d_shader_parser *parser)
static const struct vkd3d_shader_parser_ops shader_sm4_parser_ops =
{
.parser_reset = shader_parser_reset,
.parser_destroy = shader_sm4_destroy,
.parser_read_instruction = shader_parser_read_instruction,
.parser_is_end = shader_parser_is_end,

View File

@ -1859,7 +1859,7 @@ enum vkd3d_result vkd3d_dxbc_binary_to_text(struct vkd3d_shader_parser *parser,
struct vkd3d_d3d_asm_compiler compiler;
enum vkd3d_result result = VKD3D_OK;
struct vkd3d_string_buffer *buffer;
unsigned int indent, i;
unsigned int indent, i, j;
const char *indent_str;
void *code;
@ -1920,21 +1920,11 @@ enum vkd3d_result vkd3d_dxbc_binary_to_text(struct vkd3d_shader_parser *parser,
shader_version->minor, compiler.colours.reset);
indent = 0;
vkd3d_shader_parser_reset(parser);
while (!vkd3d_shader_parser_is_end(parser))
for (i = 0; i < parser->instructions.count; ++i)
{
struct vkd3d_shader_instruction ins;
struct vkd3d_shader_instruction *ins = &parser->instructions.elements[i];
vkd3d_shader_parser_read_instruction(parser, &ins);
if (ins.handler_idx == VKD3DSIH_INVALID)
{
WARN("Skipping unrecognized instruction.\n");
vkd3d_string_buffer_printf(buffer, "<unrecognized instruction>\n");
result = VKD3D_ERROR;
continue;
}
switch (ins.handler_idx)
switch (ins->handler_idx)
{
case VKD3DSIH_ELSE:
case VKD3DSIH_ENDIF:
@ -1947,14 +1937,14 @@ enum vkd3d_result vkd3d_dxbc_binary_to_text(struct vkd3d_shader_parser *parser,
break;
}
for (i = 0; i < indent; ++i)
for (j = 0; j < indent; ++j)
{
vkd3d_string_buffer_printf(buffer, "%s", indent_str);
}
shader_dump_instruction(&compiler, &ins);
shader_dump_instruction(&compiler, ins);
switch (ins.handler_idx)
switch (ins->handler_idx)
{
case VKD3DSIH_ELSE:
case VKD3DSIH_IF:
@ -1968,9 +1958,6 @@ enum vkd3d_result vkd3d_dxbc_binary_to_text(struct vkd3d_shader_parser *parser,
}
}
if (parser->failed)
result = VKD3D_ERROR_INVALID_SHADER;
if ((code = vkd3d_malloc(buffer->content_size)))
{
memcpy(code, buffer->buffer, buffer->content_size);

View File

@ -463,12 +463,6 @@ void VKD3D_PRINTF_FUNC(3, 4) vkd3d_shader_parser_warning(struct vkd3d_shader_par
va_end(args);
}
void shader_parser_reset(struct vkd3d_shader_parser *parser)
{
parser->instruction_idx = 0;
parser->failed = false;
}
void shader_parser_read_instruction(struct vkd3d_shader_parser *parser, struct vkd3d_shader_instruction *ins)
{
*ins = parser->instructions.elements[parser->instruction_idx++];
@ -1088,7 +1082,6 @@ static int scan_with_parser(const struct vkd3d_shader_compile_info *compile_info
if (TRACE_ON())
{
vkd3d_shader_trace(parser);
vkd3d_shader_parser_reset(parser);
}
while (!vkd3d_shader_parser_is_end(parser))

View File

@ -996,7 +996,6 @@ struct vkd3d_shader_parser
struct vkd3d_shader_parser_ops
{
void (*parser_reset)(struct vkd3d_shader_parser *parser);
void (*parser_destroy)(struct vkd3d_shader_parser *parser);
void (*parser_read_instruction)(struct vkd3d_shader_parser *parser, struct vkd3d_shader_instruction *instruction);
bool (*parser_is_end)(struct vkd3d_shader_parser *parser);
@ -1010,7 +1009,6 @@ bool vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser,
unsigned int instruction_reserve);
void vkd3d_shader_parser_warning(struct vkd3d_shader_parser *parser,
enum vkd3d_shader_error error, const char *format, ...) VKD3D_PRINTF_FUNC(3, 4);
void shader_parser_reset(struct vkd3d_shader_parser *parser);
void shader_parser_read_instruction(struct vkd3d_shader_parser *parser, struct vkd3d_shader_instruction *ins);
bool shader_parser_is_end(struct vkd3d_shader_parser *parser);
@ -1042,11 +1040,6 @@ static inline void vkd3d_shader_parser_read_instruction(struct vkd3d_shader_pars
parser->ops->parser_read_instruction(parser, instruction);
}
static inline void vkd3d_shader_parser_reset(struct vkd3d_shader_parser *parser)
{
parser->ops->parser_reset(parser);
}
void vkd3d_shader_trace(struct vkd3d_shader_parser *parser);
const char *shader_get_type_prefix(enum vkd3d_shader_type type);