mirror of
https://github.com/KhronosGroup/glslang
synced 2024-09-19 12:19:53 +00:00
HLSL: Allow macro expansions to create the 'defined' operator.
This commit is contained in:
parent
3fcb42cfa6
commit
4d5bcd3162
61
Test/baseResults/hlsl.pp.vert.out
Executable file
61
Test/baseResults/hlsl.pp.vert.out
Executable file
@ -0,0 +1,61 @@
|
||||
hlsl.pp.vert
|
||||
Shader version: 500
|
||||
0:? Sequence
|
||||
0:17 Function Definition: @main( ( temp void)
|
||||
0:17 Function Parameters:
|
||||
0:17 Function Definition: main( ( temp void)
|
||||
0:17 Function Parameters:
|
||||
0:? Sequence
|
||||
0:17 Function Call: @main( ( temp void)
|
||||
0:? Linker Objects
|
||||
0:? 'anon@0' (layout( row_major std140) uniform block{ uniform int goodGlobal1, uniform int goodGlobal2})
|
||||
|
||||
|
||||
Linked vertex stage:
|
||||
|
||||
|
||||
Shader version: 500
|
||||
0:? Sequence
|
||||
0:17 Function Definition: @main( ( temp void)
|
||||
0:17 Function Parameters:
|
||||
0:17 Function Definition: main( ( temp void)
|
||||
0:17 Function Parameters:
|
||||
0:? Sequence
|
||||
0:17 Function Call: @main( ( temp void)
|
||||
0:? Linker Objects
|
||||
0:? 'anon@0' (layout( row_major std140) uniform block{ uniform int goodGlobal1, uniform int goodGlobal2})
|
||||
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 80001
|
||||
// Id's are bound by 13
|
||||
|
||||
Capability Shader
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Vertex 4 "main"
|
||||
Source HLSL 500
|
||||
Name 4 "main"
|
||||
Name 6 "@main("
|
||||
Name 10 "$Global"
|
||||
MemberName 10($Global) 0 "goodGlobal1"
|
||||
MemberName 10($Global) 1 "goodGlobal2"
|
||||
Name 12 ""
|
||||
MemberDecorate 10($Global) 0 Offset 0
|
||||
MemberDecorate 10($Global) 1 Offset 4
|
||||
Decorate 10($Global) Block
|
||||
Decorate 12 DescriptorSet 0
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
9: TypeInt 32 1
|
||||
10($Global): TypeStruct 9(int) 9(int)
|
||||
11: TypePointer Uniform 10($Global)
|
||||
12: 11(ptr) Variable Uniform
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
8: 2 FunctionCall 6(@main()
|
||||
Return
|
||||
FunctionEnd
|
||||
6(@main(): 2 Function None 3
|
||||
7: Label
|
||||
Return
|
||||
FunctionEnd
|
17
Test/hlsl.pp.vert
Normal file
17
Test/hlsl.pp.vert
Normal file
@ -0,0 +1,17 @@
|
||||
#define A defined(B)
|
||||
|
||||
#if A
|
||||
int badGlobal1;
|
||||
#else
|
||||
int goodGlobal1;
|
||||
#endif
|
||||
|
||||
#define B
|
||||
|
||||
#if A
|
||||
int goodGlobal2;
|
||||
#else
|
||||
int badGlobal2;
|
||||
#endif
|
||||
|
||||
void main() {}
|
@ -393,7 +393,7 @@ int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, boo
|
||||
TSourceLoc loc = ppToken->loc; // because we sometimes read the newline before reporting the error
|
||||
if (token == PpAtomIdentifier) {
|
||||
if (strcmp("defined", ppToken->name) == 0) {
|
||||
if (isMacroInput()) {
|
||||
if (! parseContext.isReadingHLSL() && isMacroInput()) {
|
||||
if (parseContext.relaxedErrors())
|
||||
parseContext.ppWarn(ppToken->loc, "nonportable when expanded from macros for preprocessor expression",
|
||||
"defined", "");
|
||||
|
@ -200,6 +200,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
{"hlsl.params.default.frag", "main"},
|
||||
{"hlsl.params.default.negative.frag", "main"},
|
||||
{"hlsl.partialInit.frag", "PixelShaderFunction"},
|
||||
{"hlsl.pp.vert", "main"},
|
||||
{"hlsl.pp.line.frag", "main"},
|
||||
{"hlsl.precise.frag", "main"},
|
||||
{"hlsl.promote.atomic.frag", "main"},
|
||||
|
Loading…
Reference in New Issue
Block a user