summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGangzheng Tong <tonggangzheng@gmail.com>2025-07-25 10:56:50 -0700
committerGitHub <noreply@github.com>2025-07-25 17:56:50 +0000
commitc0726e1d571f7f319a244ee6a6ba1ed2c361e079 (patch)
treead6c5c3872b67a3b147aca285098862925b6f63e /tests
parentc5091f0ae3a8b816af893e84ef289f745acf39dc (diff)
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
Diffstat (limited to 'tests')
-rw-r--r--tests/language-feature/generics/generic-interface-linkage-2.slang48
1 files changed, 48 insertions, 0 deletions
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<float> outputBuffer;
+
+float testBool<let doStuff : bool>()
+{
+ if (doStuff)
+ {
+ return 1.0;
+ }
+ else
+ {
+ return 2.0;
+ }
+}
+
+enum Color {
+ RED,
+ GREEN
+}
+
+float testEnum<let e : Color>()
+{
+ 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<true>();
+ // CHECK: 2.0
+ outputBuffer[1] = testBool<false>();
+
+ // CHECK: 3.0
+ outputBuffer[2] = testEnum<Color::RED>();
+ // CHECK: 4.0
+ outputBuffer[3] = testEnum<Color::GREEN>();
+}