From c0726e1d571f7f319a244ee6a6ba1ed2c361e079 Mon Sep 17 00:00:00 2001 From: Gangzheng Tong Date: Fri, 25 Jul 2025 10:56:50 -0700 Subject: Fix for Generic Function Redefinition Error (#7891) * emit literal values in getTypeNameHint for bool, str etc. * add test for specializing generics with bool literals * fix build error * add specializing with Enum type test --- .../generics/generic-interface-linkage-2.slang | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/language-feature/generics/generic-interface-linkage-2.slang (limited to 'tests') diff --git a/tests/language-feature/generics/generic-interface-linkage-2.slang b/tests/language-feature/generics/generic-interface-linkage-2.slang new file mode 100644 index 000000000..e10cb0348 --- /dev/null +++ b/tests/language-feature/generics/generic-interface-linkage-2.slang @@ -0,0 +1,48 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-slang -compute -compile-arg -obfuscate -shaderobj -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -compute -compile-arg -obfuscate -shaderobj -output-using-type + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +float testBool() +{ + if (doStuff) + { + return 1.0; + } + else + { + return 2.0; + } +} + +enum Color { + RED, + GREEN +} + +float testEnum() +{ + if (e == Color::RED) + { + return 3.0; + } + else + { + return 4.0; + } +} + +[shader("compute")] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + // CHECK: 1.0 + outputBuffer[0] = testBool(); + // CHECK: 2.0 + outputBuffer[1] = testBool(); + + // CHECK: 3.0 + outputBuffer[2] = testEnum(); + // CHECK: 4.0 + outputBuffer[3] = testEnum(); +} -- cgit v1.2.3