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.
Hoist resource variables using a global initializer function correctly
Fixes: shader-slang#4874 Hoist resource variables using a global initializer function in such a way that the initializer function is passed into every entry-point opposed to emitting a local-variable asignment in global scope.
- Loading branch information
Showing
5 changed files
with
94 additions
and
10 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
48 changes: 48 additions & 0 deletions
48
tests/compute/type-legalize-global-with-init-function.slang
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,48 @@ | ||
// type-legalize-global-with-init.slang | ||
// | ||
// Confirm that type legalization can handle a global constant | ||
// with a resource type or a type that recursively contains | ||
// resources. | ||
// | ||
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -shaderobj | ||
// | ||
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer | ||
RWStructuredBuffer<uint> outputBuffer; | ||
|
||
//TEST_INPUT:ubuffer(data=[1 2 3 4 5 6 7 8], stride=4):name=inputBuffer | ||
RWStructuredBuffer<uint> inputBuffer; | ||
|
||
static const RWStructuredBuffer<uint> gBuffer = inputBuffer; | ||
|
||
struct Stuff | ||
{ | ||
__init(RWStructuredBuffer<uint> inA, RWStructuredBuffer<uint> inB) | ||
{ | ||
a = inA; | ||
b = inB; | ||
} | ||
RWStructuredBuffer<uint> a; | ||
RWStructuredBuffer<uint> b; | ||
} | ||
|
||
static const Stuff gStuff = Stuff( inputBuffer, inputBuffer ); | ||
|
||
uint test(uint x) | ||
{ | ||
return gBuffer[x] | ||
+ gStuff.a[x + 1] * 16 | ||
+ gStuff.b[x + 2] * 256; | ||
} | ||
|
||
[numthreads(4, 1, 1)] | ||
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) | ||
{ | ||
let tid = dispatchThreadID.x; | ||
let inVal = tid; | ||
let outVal = test(inVal); | ||
outputBuffer[tid] = outVal; | ||
} | ||
//BUF: 321 | ||
//BUF: 432 | ||
//BUF: 543 | ||
//BUF: 654 |
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
4 changes: 0 additions & 4 deletions
4
tests/compute/type-legalize-global-with-init.slang.expected.txt
This file was deleted.
Oops, something went wrong.