From 09a9d673322ebf4ca2fcb7d48f13a44e015ea33f Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 9 Dec 2024 04:48:03 -0800 Subject: Allow pointers to existential values. (#5793) * Fix pointer offset logic and add executable tests. * Fix. * Fix test. * Add existential ptr test. * Allow pointers to existential values. * Fix. * Fix. --------- Co-authored-by: Ellie Hermaszewska --- tests/spirv/existential-ptr.slang | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/spirv/existential-ptr.slang (limited to 'tests/spirv/existential-ptr.slang') diff --git a/tests/spirv/existential-ptr.slang b/tests/spirv/existential-ptr.slang new file mode 100644 index 000000000..66f1c64a2 --- /dev/null +++ b/tests/spirv/existential-ptr.slang @@ -0,0 +1,37 @@ +//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -emit-spirv-directly -output-using-type +//DISABLED_TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -wgpu +//DISABLED_TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -d3d12 +//DISABLED_TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -d3d11 +//DISABLED_TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -metal + +interface IFoo +{ + int getVal(); +} + +struct Foo : IFoo +{ + int val; + int getVal() { return val; } +} + +struct Bar : IFoo +{ + float val; + int getVal() { return (int)val + 1; } +} + +//TEST_INPUT: set pFoo = ubuffer(data=[0 0 2 0 2.0f], stride=4); +//TEST_INPUT: type_conformance Foo:IFoo = 1; +//TEST_INPUT: type_conformance Bar:IFoo = 2; +uniform IFoo* pFoo; + +//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0], stride=4); +RWStructuredBuffer outputBuffer; + +[numthreads(1,1,1)] +void computeMain() +{ + // CHECK: 3.0 + outputBuffer[0] = pFoo->getVal(); +} \ No newline at end of file -- cgit v1.2.3