vkd3d-shader/sm4: Store the message context pointer in the vkd3d_shader_parser structure.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2021-10-01 17:51:14 +02:00 committed by Alexandre Julliard
parent 6be802ac1f
commit aca39afd73
3 changed files with 25 additions and 13 deletions

View File

@ -97,7 +97,6 @@ struct vkd3d_shader_sm4_parser
struct list src; struct list src;
struct vkd3d_shader_immediate_constant_buffer icb; struct vkd3d_shader_immediate_constant_buffer icb;
struct vkd3d_shader_message_context *message_context;
struct vkd3d_shader_parser p; struct vkd3d_shader_parser p;
}; };
@ -176,13 +175,13 @@ static bool shader_is_sm_5_1(const struct vkd3d_shader_sm4_parser *sm4)
return version->major >= 5 && version->minor >= 1; return version->major >= 5 && version->minor >= 1;
} }
static void VKD3D_PRINTF_FUNC(3, 4) shader_sm4_error(struct vkd3d_shader_sm4_parser *priv, static void VKD3D_PRINTF_FUNC(3, 4) shader_sm4_error(struct vkd3d_shader_sm4_parser *sm4,
enum vkd3d_shader_error error, const char *format, ...) enum vkd3d_shader_error error, const char *format, ...)
{ {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
vkd3d_shader_verror(priv->message_context, NULL, error, format, args); vkd3d_shader_verror(sm4->p.message_context, NULL, error, format, args);
va_end(args); va_end(args);
} }
@ -974,6 +973,7 @@ static enum vkd3d_data_type map_data_type(char t)
static bool shader_sm4_init(struct vkd3d_shader_sm4_parser *sm4, const uint32_t *byte_code, size_t byte_code_size, static bool shader_sm4_init(struct vkd3d_shader_sm4_parser *sm4, const uint32_t *byte_code, size_t byte_code_size,
const struct vkd3d_shader_signature *output_signature, struct vkd3d_shader_message_context *message_context) const struct vkd3d_shader_signature *output_signature, struct vkd3d_shader_message_context *message_context)
{ {
struct vkd3d_shader_version version;
uint32_t version_token, token_count; uint32_t version_token, token_count;
unsigned int i; unsigned int i;
@ -1000,34 +1000,36 @@ static bool shader_sm4_init(struct vkd3d_shader_sm4_parser *sm4, const uint32_t
switch (version_token >> 16) switch (version_token >> 16)
{ {
case VKD3D_SM4_PS: case VKD3D_SM4_PS:
sm4->p.shader_version.type = VKD3D_SHADER_TYPE_PIXEL; version.type = VKD3D_SHADER_TYPE_PIXEL;
break; break;
case VKD3D_SM4_VS: case VKD3D_SM4_VS:
sm4->p.shader_version.type = VKD3D_SHADER_TYPE_VERTEX; version.type = VKD3D_SHADER_TYPE_VERTEX;
break; break;
case VKD3D_SM4_GS: case VKD3D_SM4_GS:
sm4->p.shader_version.type = VKD3D_SHADER_TYPE_GEOMETRY; version.type = VKD3D_SHADER_TYPE_GEOMETRY;
break; break;
case VKD3D_SM5_HS: case VKD3D_SM5_HS:
sm4->p.shader_version.type = VKD3D_SHADER_TYPE_HULL; version.type = VKD3D_SHADER_TYPE_HULL;
break; break;
case VKD3D_SM5_DS: case VKD3D_SM5_DS:
sm4->p.shader_version.type = VKD3D_SHADER_TYPE_DOMAIN; version.type = VKD3D_SHADER_TYPE_DOMAIN;
break; break;
case VKD3D_SM5_CS: case VKD3D_SM5_CS:
sm4->p.shader_version.type = VKD3D_SHADER_TYPE_COMPUTE; version.type = VKD3D_SHADER_TYPE_COMPUTE;
break; break;
default: default:
FIXME("Unrecognised shader type %#x.\n", version_token >> 16); FIXME("Unrecognised shader type %#x.\n", version_token >> 16);
} }
sm4->p.shader_version.major = VKD3D_SM4_VERSION_MAJOR(version_token); version.major = VKD3D_SM4_VERSION_MAJOR(version_token);
sm4->p.shader_version.minor = VKD3D_SM4_VERSION_MINOR(version_token); version.minor = VKD3D_SM4_VERSION_MINOR(version_token);
vkd3d_shader_parser_init(&sm4->p, message_context, &version);
sm4->p.ptr = sm4->start; sm4->p.ptr = sm4->start;
memset(sm4->output_map, 0xff, sizeof(sm4->output_map)); memset(sm4->output_map, 0xff, sizeof(sm4->output_map));
@ -1047,8 +1049,6 @@ static bool shader_sm4_init(struct vkd3d_shader_sm4_parser *sm4, const uint32_t
list_init(&sm4->src_free); list_init(&sm4->src_free);
list_init(&sm4->src); list_init(&sm4->src);
sm4->message_context = message_context;
return true; return true;
} }

View File

@ -362,6 +362,13 @@ void vkd3d_shader_dump_shader(enum vkd3d_shader_source_type source_type,
shader_get_source_type_suffix(source_type), shader->code, shader->size); shader_get_source_type_suffix(source_type), shader->code, shader->size);
} }
void vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser,
struct vkd3d_shader_message_context *message_context, const struct vkd3d_shader_version *version)
{
parser->message_context = message_context;
parser->shader_version = *version;
}
static void vkd3d_shader_parser_destroy(struct vkd3d_shader_parser *parser) static void vkd3d_shader_parser_destroy(struct vkd3d_shader_parser *parser)
{ {
shader_sm4_free(parser); shader_sm4_free(parser);

View File

@ -889,11 +889,16 @@ static inline bool vkd3d_shader_register_is_output(const struct vkd3d_shader_reg
struct vkd3d_shader_parser struct vkd3d_shader_parser
{ {
struct vkd3d_shader_message_context *message_context;
struct vkd3d_shader_desc shader_desc; struct vkd3d_shader_desc shader_desc;
struct vkd3d_shader_version shader_version; struct vkd3d_shader_version shader_version;
const uint32_t *ptr; const uint32_t *ptr;
}; };
void vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser,
struct vkd3d_shader_message_context *message_context, const struct vkd3d_shader_version *version);
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);