From 28ef3317040730924c69e4b94f070939eabd8f73 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Sat, 27 Apr 2024 00:37:48 +0200 Subject: [PATCH] vkd3d-shader/glsl: Implement support for VKD3DSPSM_NEG modifiers. --- libs/vkd3d-shader/glsl.c | 3 +++ tests/hlsl/arithmetic-float-uniform.shader_test | 2 +- tests/hlsl/cross.shader_test | 4 ++-- tests/hlsl/determinant.shader_test | 2 +- tests/hlsl/lerp.shader_test | 2 +- tests/hlsl/math.shader_test | 2 +- tests/hlsl/reflect.shader_test | 2 +- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libs/vkd3d-shader/glsl.c b/libs/vkd3d-shader/glsl.c index d5b873ed..50c321dd 100644 --- a/libs/vkd3d-shader/glsl.c +++ b/libs/vkd3d-shader/glsl.c @@ -305,6 +305,9 @@ static void glsl_src_init(struct glsl_src *glsl_src, struct vkd3d_glsl_generator { case VKD3DSPSM_NONE: break; + case VKD3DSPSM_NEG: + vkd3d_string_buffer_printf(glsl_src->str, "-%s", str->buffer); + break; case VKD3DSPSM_ABS: vkd3d_string_buffer_printf(glsl_src->str, "abs(%s)", str->buffer); break; diff --git a/tests/hlsl/arithmetic-float-uniform.shader_test b/tests/hlsl/arithmetic-float-uniform.shader_test index 5f8235bc..8556a22f 100644 --- a/tests/hlsl/arithmetic-float-uniform.shader_test +++ b/tests/hlsl/arithmetic-float-uniform.shader_test @@ -10,7 +10,7 @@ float4 main() : SV_TARGET [test] uniform 0 float4 5.0 15.0 0.0 0.0 -todo(glsl) draw quad +draw quad probe (0, 0) rgba (20.0, -10.0, 75.0, 0.33333333) 1 [pixel shader] diff --git a/tests/hlsl/cross.shader_test b/tests/hlsl/cross.shader_test index 83314d43..3b16c632 100644 --- a/tests/hlsl/cross.shader_test +++ b/tests/hlsl/cross.shader_test @@ -12,7 +12,7 @@ float4 main() : sv_target [test] uniform 0 float4 1 -2 3 4 uniform 4 float4 10 100 1000 10000 -todo(glsl) draw quad +draw quad probe (0, 0) rgba (-2300, -970, 120, 0) @@ -29,5 +29,5 @@ float4 main() : sv_target [test] uniform 0 float4 1 -2 3 4 -todo(glsl) draw quad +draw quad probe (0, 0) rgba (-20, 8, 12, 3.5) diff --git a/tests/hlsl/determinant.shader_test b/tests/hlsl/determinant.shader_test index 19ca9c0c..4b6ce7d1 100644 --- a/tests/hlsl/determinant.shader_test +++ b/tests/hlsl/determinant.shader_test @@ -35,7 +35,7 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 3.0 4.0 uniform 4 float4 5.0 6.0 7.0 8.0 -todo(glsl) draw quad +draw quad probe (0, 0) rgba (-4.0, -4.0, -4.0, -4.0) [pixel shader] diff --git a/tests/hlsl/lerp.shader_test b/tests/hlsl/lerp.shader_test index 8a7c7bd2..17ffca77 100644 --- a/tests/hlsl/lerp.shader_test +++ b/tests/hlsl/lerp.shader_test @@ -12,7 +12,7 @@ float4 main() : SV_TARGET uniform 0 float4 2.0 3.0 4.0 5.0 uniform 4 float4 0.0 -10.0 10.0 100.0 uniform 8 float4 0.0 1.0 -1.0 0.75 -todo(glsl) draw quad +draw quad probe (0, 0) rgba (2.0, -10.0, -2.0, 76.25) diff --git a/tests/hlsl/math.shader_test b/tests/hlsl/math.shader_test index 32b5a832..7ab2a36f 100644 --- a/tests/hlsl/math.shader_test +++ b/tests/hlsl/math.shader_test @@ -14,5 +14,5 @@ float4 main() : SV_TARGET [test] uniform 0 float4 2.5 0.3 0.2 0.7 uniform 4 float4 0.1 1.5 0.0 0.0 -todo(glsl) draw quad +draw quad probe (0, 0) rgba (-12.43, 9.833333, 1.6, 35.0) 1 diff --git a/tests/hlsl/reflect.shader_test b/tests/hlsl/reflect.shader_test index 95810d59..9fd82931 100644 --- a/tests/hlsl/reflect.shader_test +++ b/tests/hlsl/reflect.shader_test @@ -62,7 +62,7 @@ float4 main() : sv_target [test] uniform 0 float4 0.5 0.0 0.0 0.0 uniform 4 float4 0.6 0.0 0.0 0.0 -todo(glsl) draw quad +draw quad probe (0, 0) rgba (0.14, 0.14, 0.14, 0.14) 4 [pixel shader]