summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/interfaces
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-05-31 22:08:27 -0700
committerGitHub <noreply@github.com>2024-05-31 22:08:27 -0700
commita5cdb574b391e8adce1ce71e1e7ab3a20ce15818 (patch)
treef853363b68186888d7478da0e89cb38ee1daab2e /tests/language-feature/interfaces
parentfebbeb140bea65180ff4be9b164207c582235d4d (diff)
Fix a bug on default initialization of interface typed value. (#4249)
* Fix a bug on default initialization of interface typed value. * Fix.
Diffstat (limited to 'tests/language-feature/interfaces')
-rw-r--r--tests/language-feature/interfaces/zero-init-interface.slang32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/language-feature/interfaces/zero-init-interface.slang b/tests/language-feature/interfaces/zero-init-interface.slang
new file mode 100644
index 000000000..ee38f4d83
--- /dev/null
+++ b/tests/language-feature/interfaces/zero-init-interface.slang
@@ -0,0 +1,32 @@
+// Test that we can zero-init a struct with interface typed member.
+
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER): -shaderobj
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+interface IFoo
+{
+ int method();
+}
+
+//TEST_INPUT: type_conformance Impl1:IFoo = 0
+struct Impl1 : IFoo
+{
+ int data;
+ int method() { return data + 1; }
+}
+
+struct MyType
+{
+ IFoo foo;
+}
+
+
+[numthreads(1, 1, 1)]
+void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
+{
+ MyType t = {};
+ // BUFFER: 1
+ outputBuffer[0] = t.foo.method();
+}