summaryrefslogtreecommitdiff
path: root/tests/bugs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bugs')
-rw-r--r--tests/bugs/gh-1990.slang63
-rw-r--r--tests/bugs/gh-1990.slang.expected.txt2
2 files changed, 65 insertions, 0 deletions
diff --git a/tests/bugs/gh-1990.slang b/tests/bugs/gh-1990.slang
new file mode 100644
index 000000000..758caf1a9
--- /dev/null
+++ b/tests/bugs/gh-1990.slang
@@ -0,0 +1,63 @@
+// Stack overflow bug in type checking when using auto type deduction in a generic method.
+
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile sm_6_0 -use-dxil -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx11 -profile sm_5_0 -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type
+
+[anyValueSize(12)]
+interface IBSDF
+{
+ uint getLobes();
+}
+
+[anyValueSize(16)]
+interface IMaterial
+{
+ associatedtype BSDF : IBSDF;
+ BSDF setupBSDF();
+}
+
+struct StandardBSDF : IBSDF
+{
+ uint getLobes()
+ {
+ return 0;
+ }
+}
+
+struct StandardMaterial : IMaterial
+{
+ typedef StandardBSDF BSDF;
+ StandardBSDF setupBSDF() { StandardBSDF g; return g; }
+};
+
+//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=gOutputBuffer
+RWStructuredBuffer<float> gOutputBuffer;
+
+//TEST_INPUT: type_conformance StandardMaterial:IMaterial = 0
+
+interface IInterface
+{
+ void randomStuff();
+};
+struct Impl : IInterface
+{
+ void randomStuff(){}
+};
+
+void test<R : IInterface>(R r, int id)
+{
+ float result = 0.0;
+ // Use of auto type deduction from a generic method leads to stack overflow during
+ // type checking for `bsdf.getLobes`.
+ let bsdf = createDynamicObject<IMaterial, int>(id, 0).setupBSDF();
+ result = bsdf.getLobes();
+ gOutputBuffer[0] = float(result);
+}
+
+[numthreads(1, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ Impl impl;
+ test(impl, dispatchThreadID.x);
+}
diff --git a/tests/bugs/gh-1990.slang.expected.txt b/tests/bugs/gh-1990.slang.expected.txt
new file mode 100644
index 000000000..4b1f4c0d9
--- /dev/null
+++ b/tests/bugs/gh-1990.slang.expected.txt
@@ -0,0 +1,2 @@
+type: float
+0.000000