diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 948998ed..5ecba0be 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -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);