forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow pointers to existential values. (shader-slang#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 <[email protected]>
- Loading branch information
1 parent
051ae8a
commit 09a9d67
Showing
12 changed files
with
215 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<float> outputBuffer; | ||
|
||
[numthreads(1,1,1)] | ||
void computeMain() | ||
{ | ||
// CHECK: 3.0 | ||
outputBuffer[0] = pFoo->getVal(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -emit-spirv-directly | ||
//DISABLED_TEST: COMPARE_COMPUTE(filecheck-buffer=CHECK): -wgpu | ||
//DISABLED_TEST: COMPARE_COMPUTE(filecheck-buffer=CHECK): -d3d11 | ||
//DISABLED_TEST: COMPARE_COMPUTE(filecheck-buffer=CHECK): -d3d12 | ||
//DISABLED_TEST: COMPARE_COMPUTE(filecheck-buffer=CHECK): -metal | ||
|
||
struct Obj | ||
{ | ||
int val; | ||
|
||
[mutating] | ||
void addOne() { val++; } | ||
|
||
int getValPlusOne() { return val + 1; } | ||
} | ||
|
||
//TEST_INPUT: set pObj = ubuffer(data=[2 0 0 0], stride=4); | ||
uniform Obj* pObj; | ||
|
||
//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0],stride=4); | ||
uniform RWStructuredBuffer<uint> outputBuffer; | ||
|
||
[numthreads(1,1,1)] | ||
void computeMain() | ||
{ | ||
pObj->addOne(); | ||
// CHECK: 4 | ||
outputBuffer[0] = pObj->getValPlusOne(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -emit-spirv-directly | ||
//DISABLED_TEST: COMPARE_COMPUTE(filecheck-buffer=CHECK): -wgpu | ||
//DISABLED_TEST: COMPARE_COMPUTE(filecheck-buffer=CHECK): -d3d11 | ||
//DISABLED_TEST: COMPARE_COMPUTE(filecheck-buffer=CHECK): -d3d12 | ||
//DISABLED_TEST: COMPARE_COMPUTE(filecheck-buffer=CHECK): -metal | ||
|
||
// Test a pointer to a struct with a trailing unsized array. | ||
|
||
struct MeshStorage { | ||
int foo; | ||
uint64_t QuadData[]; | ||
}; | ||
|
||
//TEST_INPUT: set pStorage = ubuffer(data=[1 2 3 4 5 6 7 8],stride=4); | ||
uniform MeshStorage* pStorage; | ||
|
||
//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0],stride=4); | ||
uniform RWStructuredBuffer<uint> outputBuffer; | ||
|
||
[numthreads(1,1,1)] | ||
void computeMain() | ||
{ | ||
// CHECK: 5 | ||
// CHECK: 6 | ||
// CHECK: 1 | ||
outputBuffer[0] = (int)(pStorage.QuadData[1]&0xFFFFFFFF); | ||
outputBuffer[1] = (int)(pStorage.QuadData[1]>>32); | ||
outputBuffer[2] = pStorage.foo; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -emit-spirv-directly | ||
//DISABLED_TEST: COMPARE_COMPUTE(filecheck-buffer=CHECK): -wgpu | ||
//DISABLED_TEST: COMPARE_COMPUTE(filecheck-buffer=CHECK): -d3d11 | ||
//DISABLED_TEST: COMPARE_COMPUTE(filecheck-buffer=CHECK): -d3d12 | ||
//DISABLED_TEST: COMPARE_COMPUTE(filecheck-buffer=CHECK): -metal | ||
|
||
// Test a pointer to a struct that has only one field and is an unsized array. | ||
struct MeshStorage { | ||
uint64_t QuadData[]; | ||
}; | ||
|
||
//TEST_INPUT: set pStorage = ubuffer(data=[1 2 3 4 5 6 7 8],stride=4); | ||
uniform MeshStorage* pStorage; | ||
|
||
//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0],stride=4); | ||
uniform RWStructuredBuffer<uint> outputBuffer; | ||
|
||
[numthreads(1,1,1)] | ||
void computeMain() | ||
{ | ||
// CHECK: 3 | ||
// CHECK: 4 | ||
outputBuffer[0] = (int)(pStorage.QuadData[1]&0xFFFFFFFF); | ||
outputBuffer[1] = (int)(pStorage.QuadData[1]>>32); | ||
} |
Oops, something went wrong.