From 95a46fb0f018daa78530813ae43814eb1f9c7c5b Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 3 Oct 2024 15:02:31 +0200 Subject: [PATCH] vkd3d-shader/glsl: Handle SV_POSITION inputs in fragment shaders. --- libs/vkd3d-shader/glsl.c | 15 ++++++++------- tests/hlsl/object-references.shader_test | 2 +- tests/hlsl/texture-load.shader_test | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/libs/vkd3d-shader/glsl.c b/libs/vkd3d-shader/glsl.c index 42c04f10..eab13738 100644 --- a/libs/vkd3d-shader/glsl.c +++ b/libs/vkd3d-shader/glsl.c @@ -931,19 +931,20 @@ static void shader_glsl_print_sysval_name(struct vkd3d_string_buffer *buffer, st switch (sysval) { case VKD3D_SHADER_SV_POSITION: - if (version->type == VKD3D_SHADER_TYPE_PIXEL || version->type == VKD3D_SHADER_TYPE_COMPUTE) + if (version->type == VKD3D_SHADER_TYPE_COMPUTE) { vkd3d_string_buffer_printf(buffer, "", sysval); vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL, - "Internal compiler error: Unhandled system value %#x.", sysval); + "Internal compiler error: Unhandled SV_POSITION in shader type #%x.", version->type); + break; } + if (idx) + vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL, + "Internal compiler error: Unhandled SV_POSITION index %u.", idx); + if (version->type == VKD3D_SHADER_TYPE_PIXEL) + vkd3d_string_buffer_printf(buffer, "gl_FragCoord"); else - { vkd3d_string_buffer_printf(buffer, "gl_Position"); - if (idx) - vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL, - "Internal compiler error: Unhandled SV_POSITION index %u.", idx); - } break; case VKD3D_SHADER_SV_VERTEX_ID: diff --git a/tests/hlsl/object-references.shader_test b/tests/hlsl/object-references.shader_test index a8f0a5d0..4409ba77 100644 --- a/tests/hlsl/object-references.shader_test +++ b/tests/hlsl/object-references.shader_test @@ -73,7 +73,7 @@ float4 main(float4 pos : sv_position) : sv_target } [test] -todo(glsl) draw quad +draw quad probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4) probe (1, 0) rgba (0.5, 0.7, 0.6, 0.8) probe (0, 1) rgba (0.6, 0.5, 0.2, 0.1) diff --git a/tests/hlsl/texture-load.shader_test b/tests/hlsl/texture-load.shader_test index 23be42b8..b1b3d852 100644 --- a/tests/hlsl/texture-load.shader_test +++ b/tests/hlsl/texture-load.shader_test @@ -15,7 +15,7 @@ float4 main(float4 pos : sv_position) : sv_target } [test] -todo(glsl) draw quad +draw quad probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4) probe (1, 0) rgba (0.5, 0.7, 0.6, 0.8) probe (0, 1) rgba (0.6, 0.5, 0.2, 0.1) @@ -30,7 +30,7 @@ float4 main(float4 pos : sv_position) : sv_target } [test] -todo(glsl) draw quad +draw quad probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4) probe (1, 0) rgba (0.6, 0.5, 0.2, 0.1) probe (0, 1) rgba (0.5, 0.7, 0.6, 0.8)