-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a bug on default initialization of interface typed value. (#4249)
* Fix a bug on default initialization of interface typed value. * Fix.
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 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
32 changes: 32 additions & 0 deletions
32
tests/language-feature/interfaces/zero-init-interface.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,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(); | ||
} |