From 8c7704bb7863c54f9a265a4e570a021f84301eff Mon Sep 17 00:00:00 2001 From: Conor McCarthy Date: Tue, 15 Nov 2022 15:18:26 +1000 Subject: [PATCH] vkd3d-compiler: Introduce a dxbc-dxil source type. --- programs/vkd3d-compiler/main.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c index efb3b48d..b94272a5 100644 --- a/programs/vkd3d-compiler/main.c +++ b/programs/vkd3d-compiler/main.c @@ -30,6 +30,7 @@ #include "vkd3d_common.h" #include "vkd3d_shader.h" +#include "vkd3d_shader_utils.h" #ifdef HAVE_NCURSES #include #endif @@ -73,6 +74,10 @@ source_type_info[] = "d3dbc", "Legacy Direct3D byte-code.\n" " This is the format used for Direct3D shader model 1, 2, and 3 shaders.\n", true, VKD3D_SHADER_TARGET_SPIRV_BINARY}, + {VKD3D_SHADER_SOURCE_DXBC_DXIL, + "dxbc-dxil", "A 'DirectX Intermediate Language' shader embedded in a DXBC container.\n" + " This is the format used for Direct3D shader model 6 shaders.\n", + true, VKD3D_SHADER_TARGET_SPIRV_BINARY}, }; static const struct target_type_info @@ -356,6 +361,22 @@ static enum vkd3d_shader_target_type parse_target_type(const char *target) return VKD3D_SHADER_TARGET_NONE; } +static bool parse_dxbc_source_type(const struct vkd3d_shader_code *source, enum vkd3d_shader_source_type *type) +{ + char *messages; + int ret; + + if ((ret = vkd3d_shader_parse_dxbc_source_type(source, type, &messages)) < 0) + { + fprintf(stderr, "Failed to detect dxbc source type, ret %d.\n", ret); + if (messages) + fputs(messages, stderr); + vkd3d_shader_free_messages(messages); + return false; + } + return true; +} + static const struct source_type_info *get_source_type_info(enum vkd3d_shader_source_type type) { unsigned int i; @@ -671,7 +692,10 @@ int main(int argc, char **argv) { memcpy(&token, info.source.code, sizeof(token)); if (token == TAG_DXBC) - options.source_type = VKD3D_SHADER_SOURCE_DXBC_TPF; + { + if (!parse_dxbc_source_type(&info.source, &options.source_type)) + return 1; + } else if ((token & 0xfffe0000) == 0xfffe0000) options.source_type = VKD3D_SHADER_SOURCE_D3D_BYTECODE; else