mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/sm4: Use the instruction array interface in compile_dxbc_tpf().
This commit is contained in:
parent
2d3f05184f
commit
2a5ae0a8c6
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
@ -874,8 +874,6 @@ static bool shader_sm1_is_end(struct vkd3d_shader_parser *parser)
|
|||||||
const struct vkd3d_shader_parser_ops shader_sm1_parser_ops =
|
const struct vkd3d_shader_parser_ops shader_sm1_parser_ops =
|
||||||
{
|
{
|
||||||
.parser_destroy = shader_sm1_destroy,
|
.parser_destroy = shader_sm1_destroy,
|
||||||
.parser_read_instruction = shader_parser_read_instruction,
|
|
||||||
.parser_is_end = shader_parser_is_end,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum vkd3d_result shader_sm1_init(struct vkd3d_shader_sm1_parser *sm1,
|
static enum vkd3d_result shader_sm1_init(struct vkd3d_shader_sm1_parser *sm1,
|
||||||
|
@ -1588,8 +1588,6 @@ static bool shader_sm4_is_end(struct vkd3d_shader_parser *parser)
|
|||||||
static const struct vkd3d_shader_parser_ops shader_sm4_parser_ops =
|
static const struct vkd3d_shader_parser_ops shader_sm4_parser_ops =
|
||||||
{
|
{
|
||||||
.parser_destroy = shader_sm4_destroy,
|
.parser_destroy = shader_sm4_destroy,
|
||||||
.parser_read_instruction = shader_parser_read_instruction,
|
|
||||||
.parser_is_end = shader_parser_is_end,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool shader_sm4_init(struct vkd3d_shader_sm4_parser *sm4, const uint32_t *byte_code,
|
static bool shader_sm4_init(struct vkd3d_shader_sm4_parser *sm4, const uint32_t *byte_code,
|
||||||
|
@ -463,16 +463,6 @@ void VKD3D_PRINTF_FUNC(3, 4) vkd3d_shader_parser_warning(struct vkd3d_shader_par
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shader_parser_read_instruction(struct vkd3d_shader_parser *parser, struct vkd3d_shader_instruction *ins)
|
|
||||||
{
|
|
||||||
*ins = parser->instructions.elements[parser->instruction_idx++];
|
|
||||||
}
|
|
||||||
|
|
||||||
bool shader_parser_is_end(struct vkd3d_shader_parser *parser)
|
|
||||||
{
|
|
||||||
return parser->instruction_idx >= parser->instructions.count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int vkd3d_shader_validate_compile_info(const struct vkd3d_shader_compile_info *compile_info,
|
static int vkd3d_shader_validate_compile_info(const struct vkd3d_shader_compile_info *compile_info,
|
||||||
bool validate_target_type)
|
bool validate_target_type)
|
||||||
{
|
{
|
||||||
@ -1183,10 +1173,10 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info
|
|||||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
|
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
|
||||||
{
|
{
|
||||||
struct vkd3d_shader_scan_descriptor_info scan_descriptor_info;
|
struct vkd3d_shader_scan_descriptor_info scan_descriptor_info;
|
||||||
struct vkd3d_shader_instruction instruction;
|
|
||||||
struct vkd3d_shader_compile_info scan_info;
|
struct vkd3d_shader_compile_info scan_info;
|
||||||
struct spirv_compiler *spirv_compiler;
|
struct spirv_compiler *spirv_compiler;
|
||||||
struct vkd3d_shader_parser *parser;
|
struct vkd3d_shader_parser *parser;
|
||||||
|
unsigned int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
scan_info = *compile_info;
|
scan_info = *compile_info;
|
||||||
@ -1244,24 +1234,11 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info
|
|||||||
return VKD3D_ERROR;
|
return VKD3D_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!vkd3d_shader_parser_is_end(parser))
|
for (i = 0; i < parser->instructions.count && ret >= 0; ++i)
|
||||||
{
|
{
|
||||||
vkd3d_shader_parser_read_instruction(parser, &instruction);
|
ret = spirv_compiler_handle_instruction(spirv_compiler, &parser->instructions.elements[i]);
|
||||||
|
|
||||||
if (instruction.handler_idx == VKD3DSIH_INVALID)
|
|
||||||
{
|
|
||||||
WARN("Encountered unrecognized or invalid instruction.\n");
|
|
||||||
ret = VKD3D_ERROR_INVALID_SHADER;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = spirv_compiler_handle_instruction(spirv_compiler, &instruction)) < 0)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser->failed)
|
|
||||||
ret = VKD3D_ERROR_INVALID_SHADER;
|
|
||||||
|
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
ret = spirv_compiler_generate_spirv(spirv_compiler, compile_info, out);
|
ret = spirv_compiler_generate_spirv(spirv_compiler, compile_info, out);
|
||||||
|
|
||||||
|
@ -997,8 +997,6 @@ struct vkd3d_shader_parser
|
|||||||
struct vkd3d_shader_parser_ops
|
struct vkd3d_shader_parser_ops
|
||||||
{
|
{
|
||||||
void (*parser_destroy)(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);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void vkd3d_shader_parser_error(struct vkd3d_shader_parser *parser,
|
void vkd3d_shader_parser_error(struct vkd3d_shader_parser *parser,
|
||||||
@ -1009,8 +1007,6 @@ bool vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser,
|
|||||||
unsigned int instruction_reserve);
|
unsigned int instruction_reserve);
|
||||||
void vkd3d_shader_parser_warning(struct vkd3d_shader_parser *parser,
|
void vkd3d_shader_parser_warning(struct vkd3d_shader_parser *parser,
|
||||||
enum vkd3d_shader_error error, const char *format, ...) VKD3D_PRINTF_FUNC(3, 4);
|
enum vkd3d_shader_error error, const char *format, ...) VKD3D_PRINTF_FUNC(3, 4);
|
||||||
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);
|
|
||||||
|
|
||||||
static inline struct vkd3d_shader_dst_param *shader_parser_get_dst_params(
|
static inline struct vkd3d_shader_dst_param *shader_parser_get_dst_params(
|
||||||
struct vkd3d_shader_parser *parser, unsigned int count)
|
struct vkd3d_shader_parser *parser, unsigned int count)
|
||||||
@ -1029,17 +1025,6 @@ static inline void vkd3d_shader_parser_destroy(struct vkd3d_shader_parser *parse
|
|||||||
parser->ops->parser_destroy(parser);
|
parser->ops->parser_destroy(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool vkd3d_shader_parser_is_end(struct vkd3d_shader_parser *parser)
|
|
||||||
{
|
|
||||||
return parser->ops->parser_is_end(parser);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void vkd3d_shader_parser_read_instruction(struct vkd3d_shader_parser *parser,
|
|
||||||
struct vkd3d_shader_instruction *instruction)
|
|
||||||
{
|
|
||||||
parser->ops->parser_read_instruction(parser, instruction);
|
|
||||||
}
|
|
||||||
|
|
||||||
void vkd3d_shader_trace(struct vkd3d_shader_parser *parser);
|
void vkd3d_shader_trace(struct vkd3d_shader_parser *parser);
|
||||||
|
|
||||||
const char *shader_get_type_prefix(enum vkd3d_shader_type type);
|
const char *shader_get_type_prefix(enum vkd3d_shader_type type);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user