mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader: Refactor common code for vkd3d_shader_compile().
This commit is contained in:
parent
0e5d6a97cc
commit
172e7edf2d
Notes:
Alexandre Julliard
2024-03-08 23:47:38 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/679
@ -1598,24 +1598,6 @@ static int vkd3d_shader_parser_compile(struct vkd3d_shader_parser *parser,
|
||||
return ret;
|
||||
}
|
||||
|
||||
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_parser *parser;
|
||||
int ret;
|
||||
|
||||
if ((ret = vkd3d_shader_sm4_parser_create(compile_info, message_context, &parser)) < 0)
|
||||
{
|
||||
WARN("Failed to initialise shader parser.\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = vkd3d_shader_parser_compile(parser, compile_info, out, message_context);
|
||||
|
||||
vkd3d_shader_parser_destroy(parser);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int compile_hlsl(const struct vkd3d_shader_compile_info *compile_info,
|
||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
|
||||
{
|
||||
@ -1631,42 +1613,6 @@ static int compile_hlsl(const struct vkd3d_shader_compile_info *compile_info,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int compile_d3d_bytecode(const struct vkd3d_shader_compile_info *compile_info,
|
||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
|
||||
{
|
||||
struct vkd3d_shader_parser *parser;
|
||||
int ret;
|
||||
|
||||
if ((ret = vkd3d_shader_sm1_parser_create(compile_info, message_context, &parser)) < 0)
|
||||
{
|
||||
WARN("Failed to initialise shader parser.\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = vkd3d_shader_parser_compile(parser, compile_info, out, message_context);
|
||||
|
||||
vkd3d_shader_parser_destroy(parser);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int compile_dxbc_dxil(const struct vkd3d_shader_compile_info *compile_info,
|
||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
|
||||
{
|
||||
struct vkd3d_shader_parser *parser;
|
||||
int ret;
|
||||
|
||||
if ((ret = vkd3d_shader_sm6_parser_create(compile_info, message_context, &parser)) < 0)
|
||||
{
|
||||
WARN("Failed to initialise shader parser.\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = vkd3d_shader_parser_compile(parser, compile_info, out, message_context);
|
||||
|
||||
vkd3d_shader_parser_destroy(parser);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
|
||||
struct vkd3d_shader_code *out, char **messages)
|
||||
{
|
||||
@ -1693,18 +1639,20 @@ int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
|
||||
}
|
||||
else
|
||||
{
|
||||
struct vkd3d_shader_parser *parser;
|
||||
|
||||
switch (compile_info->source_type)
|
||||
{
|
||||
case VKD3D_SHADER_SOURCE_DXBC_TPF:
|
||||
ret = compile_dxbc_tpf(compile_info, out, &message_context);
|
||||
case VKD3D_SHADER_SOURCE_D3D_BYTECODE:
|
||||
ret = vkd3d_shader_sm1_parser_create(compile_info, &message_context, &parser);
|
||||
break;
|
||||
|
||||
case VKD3D_SHADER_SOURCE_D3D_BYTECODE:
|
||||
ret = compile_d3d_bytecode(compile_info, out, &message_context);
|
||||
case VKD3D_SHADER_SOURCE_DXBC_TPF:
|
||||
ret = vkd3d_shader_sm4_parser_create(compile_info, &message_context, &parser);
|
||||
break;
|
||||
|
||||
case VKD3D_SHADER_SOURCE_DXBC_DXIL:
|
||||
ret = compile_dxbc_dxil(compile_info, out, &message_context);
|
||||
ret = vkd3d_shader_sm6_parser_create(compile_info, &message_context, &parser);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1712,6 +1660,16 @@ int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
|
||||
ret = VKD3D_ERROR_INVALID_ARGUMENT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
WARN("Failed to create shader parser.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = vkd3d_shader_parser_compile(parser, compile_info, out, &message_context);
|
||||
vkd3d_shader_parser_destroy(parser);
|
||||
}
|
||||
}
|
||||
|
||||
vkd3d_shader_message_context_trace_messages(&message_context);
|
||||
|
Loading…
x
Reference in New Issue
Block a user