mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader: Introduce shader_sm4_reset().
This allows us to drop the "ptr" argument to various functions. Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
26009069dd
commit
4509f089e5
@ -1110,12 +1110,11 @@ static struct vkd3d_shader_src_param *get_src_param(struct vkd3d_sm4_data *priv)
|
||||
return &e->param;
|
||||
}
|
||||
|
||||
void shader_sm4_read_header(struct vkd3d_shader_parser *parser,
|
||||
const uint32_t **ptr, struct vkd3d_shader_version *shader_version)
|
||||
void shader_sm4_read_header(struct vkd3d_shader_parser *parser, struct vkd3d_shader_version *shader_version)
|
||||
{
|
||||
struct vkd3d_sm4_data *sm4 = parser->data;
|
||||
|
||||
*ptr = sm4->start;
|
||||
parser->ptr = sm4->start;
|
||||
*shader_version = sm4->shader_version;
|
||||
}
|
||||
|
||||
@ -1527,12 +1526,12 @@ static void shader_sm4_read_instruction_modifier(DWORD modifier, struct vkd3d_sh
|
||||
}
|
||||
}
|
||||
|
||||
void shader_sm4_read_instruction(struct vkd3d_shader_parser *parser,
|
||||
const uint32_t **ptr, struct vkd3d_shader_instruction *ins)
|
||||
void shader_sm4_read_instruction(struct vkd3d_shader_parser *parser, struct vkd3d_shader_instruction *ins)
|
||||
{
|
||||
const struct vkd3d_sm4_opcode_info *opcode_info;
|
||||
uint32_t opcode_token, opcode, previous_token;
|
||||
struct vkd3d_sm4_data *sm4 = parser->data;
|
||||
const uint32_t **ptr = &parser->ptr;
|
||||
unsigned int i, len;
|
||||
size_t remaining;
|
||||
const DWORD *p;
|
||||
@ -1647,10 +1646,18 @@ fail:
|
||||
return;
|
||||
}
|
||||
|
||||
bool shader_sm4_is_end(struct vkd3d_shader_parser *parser, const uint32_t **ptr)
|
||||
bool shader_sm4_is_end(struct vkd3d_shader_parser *parser)
|
||||
{
|
||||
struct vkd3d_sm4_data *sm4 = parser->data;
|
||||
return *ptr == sm4->end;
|
||||
|
||||
return parser->ptr == sm4->end;
|
||||
}
|
||||
|
||||
void shader_sm4_reset(struct vkd3d_shader_parser *parser)
|
||||
{
|
||||
struct vkd3d_sm4_data *sm4 = parser->data;
|
||||
|
||||
parser->ptr = sm4->start;
|
||||
}
|
||||
|
||||
static bool require_space(size_t offset, size_t count, size_t size, size_t data_size)
|
||||
|
@ -104,9 +104,9 @@ int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *generator,
|
||||
vkd3d_string_buffer_printf(&generator->buffer, "#version 440\n\n");
|
||||
vkd3d_string_buffer_printf(&generator->buffer, "void main()\n{\n");
|
||||
|
||||
while (!shader_sm4_is_end(parser, &parser->ptr))
|
||||
while (!shader_sm4_is_end(parser))
|
||||
{
|
||||
shader_sm4_read_instruction(parser, &parser->ptr, &ins);
|
||||
shader_sm4_read_instruction(parser, &ins);
|
||||
|
||||
if (ins.handler_idx == VKD3DSIH_INVALID)
|
||||
{
|
||||
|
@ -1781,7 +1781,6 @@ enum vkd3d_result vkd3d_dxbc_binary_to_text(struct vkd3d_shader_parser *parser,
|
||||
struct vkd3d_string_buffer *buffer;
|
||||
unsigned int indent, i;
|
||||
const char *indent_str;
|
||||
const DWORD *ptr;
|
||||
void *code;
|
||||
|
||||
static const struct vkd3d_d3d_asm_colours no_colours =
|
||||
@ -1831,17 +1830,17 @@ enum vkd3d_result vkd3d_dxbc_binary_to_text(struct vkd3d_shader_parser *parser,
|
||||
vkd3d_string_buffer_init(buffer);
|
||||
|
||||
shader_version = &compiler.shader_version;
|
||||
shader_sm4_read_header(parser, &ptr, shader_version);
|
||||
shader_sm4_read_header(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;
|
||||
while (!shader_sm4_is_end(parser, &ptr))
|
||||
while (!shader_sm4_is_end(parser))
|
||||
{
|
||||
struct vkd3d_shader_instruction ins;
|
||||
|
||||
shader_sm4_read_instruction(parser, &ptr, &ins);
|
||||
shader_sm4_read_instruction(parser, &ins);
|
||||
if (ins.handler_idx == VKD3DSIH_INVALID)
|
||||
{
|
||||
WARN("Skipping unrecognized instruction.\n");
|
||||
|
@ -388,7 +388,7 @@ static int vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser,
|
||||
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
shader_sm4_read_header(parser, &parser->ptr, &parser->shader_version);
|
||||
shader_sm4_read_header(parser, &parser->shader_version);
|
||||
return VKD3D_OK;
|
||||
}
|
||||
|
||||
@ -952,11 +952,14 @@ static int scan_dxbc(const struct vkd3d_shader_compile_info *compile_info,
|
||||
}
|
||||
|
||||
if (TRACE_ON())
|
||||
vkd3d_shader_trace(&parser);
|
||||
|
||||
while (!shader_sm4_is_end(&parser, &parser.ptr))
|
||||
{
|
||||
shader_sm4_read_instruction(&parser, &parser.ptr, &instruction);
|
||||
vkd3d_shader_trace(&parser);
|
||||
shader_sm4_reset(&parser);
|
||||
}
|
||||
|
||||
while (!shader_sm4_is_end(&parser))
|
||||
{
|
||||
shader_sm4_read_instruction(&parser, &instruction);
|
||||
|
||||
if (instruction.handler_idx == VKD3DSIH_INVALID)
|
||||
{
|
||||
@ -1085,9 +1088,9 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info
|
||||
return VKD3D_ERROR;
|
||||
}
|
||||
|
||||
while (!shader_sm4_is_end(&parser, &parser.ptr))
|
||||
while (!shader_sm4_is_end(&parser))
|
||||
{
|
||||
shader_sm4_read_instruction(&parser, &parser.ptr, &instruction);
|
||||
shader_sm4_read_instruction(&parser, &instruction);
|
||||
|
||||
if (instruction.handler_idx == VKD3DSIH_INVALID)
|
||||
{
|
||||
|
@ -891,11 +891,10 @@ struct vkd3d_shader_message_context;
|
||||
void *shader_sm4_init(const DWORD *byte_code, size_t byte_code_size,
|
||||
const struct vkd3d_shader_signature *output_signature, struct vkd3d_shader_message_context *message_context);
|
||||
void shader_sm4_free(struct vkd3d_shader_parser *parser);
|
||||
void shader_sm4_read_header(struct vkd3d_shader_parser *parser,
|
||||
const uint32_t **ptr, struct vkd3d_shader_version *shader_version);
|
||||
void shader_sm4_read_instruction(struct vkd3d_shader_parser *parser,
|
||||
const uint32_t **ptr, struct vkd3d_shader_instruction *ins);
|
||||
bool shader_sm4_is_end(struct vkd3d_shader_parser *parser, const uint32_t **ptr);
|
||||
void shader_sm4_read_header(struct vkd3d_shader_parser *parser, struct vkd3d_shader_version *shader_version);
|
||||
void shader_sm4_read_instruction(struct vkd3d_shader_parser *parser, struct vkd3d_shader_instruction *ins);
|
||||
bool shader_sm4_is_end(struct vkd3d_shader_parser *parser);
|
||||
void shader_sm4_reset(struct vkd3d_shader_parser *parser);
|
||||
|
||||
struct vkd3d_string_buffer
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user