From 013e354b460b97426b9d71d4b860dc1d19cb009c Mon Sep 17 00:00:00 2001 From: Shaun Ren Date: Mon, 7 Oct 2024 20:57:15 -0400 Subject: [PATCH] tests: Test struct single inheritance. --- Makefile.am | 1 + tests/hlsl/struct-inheritance.shader_test | 134 ++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 tests/hlsl/struct-inheritance.shader_test diff --git a/Makefile.am b/Makefile.am index f6e105e0..b8e4aa4b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -235,6 +235,7 @@ vkd3d_shader_tests = \ tests/hlsl/strings.shader_test \ tests/hlsl/struct-array.shader_test \ tests/hlsl/struct-assignment.shader_test \ + tests/hlsl/struct-inheritance.shader_test \ tests/hlsl/struct-semantics.shader_test \ tests/hlsl/switch.shader_test \ tests/hlsl/swizzle-constant-prop.shader_test \ diff --git a/tests/hlsl/struct-inheritance.shader_test b/tests/hlsl/struct-inheritance.shader_test new file mode 100644 index 00000000..757a1674 --- /dev/null +++ b/tests/hlsl/struct-inheritance.shader_test @@ -0,0 +1,134 @@ +[pixel shader todo(sm<6)] + +struct a +{ + float4 aa; + float4 bb; +}; + +struct b : a +{ + float4 cc; +}; + +struct c : b +{ + float4 bb; // Shadows a.bb +}; + +c data; + +float4 main() : sv_target +{ + return data.aa + data.bb + data.cc; +} + +[test] +uniform 0 float4 1 0 0 0 +uniform 4 float4 0 2 0 0 +uniform 8 float4 0 0 3 0 +uniform 12 float4 0 0 0 4 +todo(sm<6) draw quad +probe (0, 0) rgba (1, 0, 3, 4) + +% Test writing to a field derived from a base class. + +[pixel shader todo(sm<6)] + +struct a +{ + float4 aa; + float4 bb; +}; + +struct b : a +{ + float4 cc; +}; + +struct c : b +{ + float4 bb; // Shadows a.bb +}; + +c data; + +float4 main() : sv_target +{ + c data2 = data; + data2.aa = float4(-1, 0, 0, 0); + data2.bb = float4(0, 0, 0, -4); + return data2.aa + data2.bb + data2.cc; +} + +[test] +uniform 0 float4 1 0 0 0 +uniform 4 float4 0 2 0 0 +uniform 8 float4 0 0 3 0 +uniform 12 float4 0 0 0 4 +todo(sm<6) draw quad +probe (0, 0) rgba (-1, 0, 3, -4) + + +% Multiple concrete base types are not allowed. + +[pixel shader fail] + +struct a +{ + float4 aa; +}; + +struct b +{ + float4 bb; +}; + +struct c : a, b +{ + float4 cc; +}; + +float4 main() : sv_target +{ + return 0; +} + + +% The concrete base type must be a struct. + +[pixel shader fail] + +struct a : float4 +{ + float4 aa; +}; + +float4 main() : sv_target +{ + return 0; +} + +[pixel shader fail] + +struct a : vector +{ + float4 aa; +}; + +float4 main() : sv_target +{ + return 0; +} + +[pixel shader fail] + +struct a : Buffer +{ + float4 aa; +}; + +float4 main() : sv_target +{ + return 0; +}