From 1fc55d80cd5508e3c467cc725dcf0fb2214e4e93 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 7 Mar 2024 20:55:39 +0100 Subject: [PATCH] vkd3d-shader: Enable GLSL target support when VKD3D_SHADER_UNSUPPORTED_GLSL is defined. --- gitlab/build-linux | 2 +- libs/vkd3d-shader/glsl.c | 2 ++ libs/vkd3d-shader/vkd3d_shader_main.c | 22 ++++++++++++++++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/gitlab/build-linux b/gitlab/build-linux index a060eadc..532a462a 100755 --- a/gitlab/build-linux +++ b/gitlab/build-linux @@ -12,7 +12,7 @@ rm -fr build mkdir build cd build export LD_LIBRARY_PATH=/usr/local/lib -if ../configure --enable-demos --with-spirv-tools DXCOMPILER_LIBS="-L/usr/local/lib" CFLAGS="-g -O2 -Werror" CPPFLAGS="-DVKD3D_SHADER_UNSUPPORTED_DXIL" && \ +if ../configure --enable-demos --with-spirv-tools DXCOMPILER_LIBS="-L/usr/local/lib" CFLAGS="-g -O2 -Werror" CPPFLAGS="-DVKD3D_SHADER_UNSUPPORTED_DXIL -DVKD3D_SHADER_UNSUPPORTED_GLSL" && \ make -j$(nproc) ; then make -j$(nproc) AM_COLOR_TESTS=always check || \ touch ../tests_failed diff --git a/libs/vkd3d-shader/glsl.c b/libs/vkd3d-shader/glsl.c index bdd03c1e..c234caf8 100644 --- a/libs/vkd3d-shader/glsl.c +++ b/libs/vkd3d-shader/glsl.c @@ -96,6 +96,8 @@ int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *generator, unsigned int i; void *code; + ERR("Generating a GLSL shader. This is unsupported; you get to keep all the pieces if it breaks.\n"); + vkd3d_string_buffer_printf(&generator->buffer, "#version 440\n\n"); vkd3d_string_buffer_printf(&generator->buffer, "void main()\n{\n"); diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 5ecba0be..96f2bf26 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -1874,7 +1874,7 @@ const enum vkd3d_shader_target_type *vkd3d_shader_get_supported_target_types( VKD3D_SHADER_TARGET_SPIRV_TEXT, #endif VKD3D_SHADER_TARGET_D3D_ASM, -#if 0 +#ifdef VKD3D_SHADER_UNSUPPORTED_GLSL VKD3D_SHADER_TARGET_GLSL, #endif }; @@ -1895,13 +1895,21 @@ const enum vkd3d_shader_target_type *vkd3d_shader_get_supported_target_types( VKD3D_SHADER_TARGET_D3D_ASM, }; +#ifdef VKD3D_SHADER_UNSUPPORTED_DXIL + static const enum vkd3d_shader_target_type dxbc_dxil_types[] = + { + VKD3D_SHADER_TARGET_SPIRV_BINARY, +# ifdef HAVE_SPIRV_TOOLS + VKD3D_SHADER_TARGET_SPIRV_TEXT, +# endif + VKD3D_SHADER_TARGET_D3D_ASM, + }; +#endif + TRACE("source_type %#x, count %p.\n", source_type, count); switch (source_type) { -#ifdef VKD3D_SHADER_UNSUPPORTED_DXIL - case VKD3D_SHADER_SOURCE_DXBC_DXIL: -#endif case VKD3D_SHADER_SOURCE_DXBC_TPF: *count = ARRAY_SIZE(dxbc_tpf_types); return dxbc_tpf_types; @@ -1914,6 +1922,12 @@ const enum vkd3d_shader_target_type *vkd3d_shader_get_supported_target_types( *count = ARRAY_SIZE(d3dbc_types); return d3dbc_types; +#ifdef VKD3D_SHADER_UNSUPPORTED_DXIL + case VKD3D_SHADER_SOURCE_DXBC_DXIL: + *count = ARRAY_SIZE(dxbc_dxil_types); + return dxbc_dxil_types; +#endif + default: *count = 0; return NULL;