forked from microsoft/DirectXShaderCompiler
-
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.
Process enums in class (microsoft#5330)
The SPIR-V emitter does not process enum that are declared in class. This leads to errors in some places it will be used. The fix is to process the enum in the same place that static variables for an enum are processed. They are essentially treated like a static variable. Fixes microsoft#5325
- Loading branch information
Showing
3 changed files
with
31 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// RUN: %dxc -T ps_6_2 -E PSMain | ||
|
||
// The value for the enum is stored in a variable, which will be optimized | ||
// away when optimizations are enabled. | ||
// CHECK: [[enum_var:%\w+]] = OpVariable %_ptr_Private_int Private %int_1 | ||
struct TestStruct { | ||
enum EnumInTestStruct { | ||
A = 1, | ||
}; | ||
}; | ||
|
||
// CHECK: %testFunc = OpFunction %int | ||
// CHECK-NEXT: OpLabel | ||
// CHECK-NEXT: [[ld:%\w+]] = OpLoad %int [[enum_var]] | ||
// CHECK-NEXT: OpReturnValue [[ld]] | ||
TestStruct::EnumInTestStruct testFunc() { | ||
return TestStruct::A; | ||
} | ||
|
||
uint PSMain() : SV_TARGET | ||
{ | ||
TestStruct::EnumInTestStruct i = testFunc(); | ||
return i; | ||
} |
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