Updated glslang.

This commit is contained in:
Branimir Karadžić
2018-01-13 16:06:05 -08:00
parent 49a75f2fb1
commit bed461b3c5
21 changed files with 2009 additions and 1791 deletions

View File

@@ -52,8 +52,10 @@ ERROR: 0:209: 'assign' : cannot convert from ' const float' to ' temp 4-compone
ERROR: 0:212: 'sampler2DRect' : Reserved word.
ERROR: 0:244: ':' : wrong operand types: no operation ':' exists that takes a left-hand operand of type ' global void' and a right operand of type ' const int' (or there is no acceptable conversion)
ERROR: 0:245: ':' : wrong operand types: no operation ':' exists that takes a left-hand operand of type ' const int' and a right operand of type ' global void' (or there is no acceptable conversion)
ERROR: 0:248: 'shader half float' : required extension not requested: GL_AMD_gpu_shader_half_float
ERROR: 0:248: 'half floating-point suffix' : not supported with this profile: none
ERROR: 0:248: '' : syntax error, unexpected IDENTIFIER, expecting COMMA or SEMICOLON
ERROR: 54 compilation errors. No code generated.
ERROR: 56 compilation errors. No code generated.
Shader version: 120

View File

@@ -46,7 +46,9 @@ ERROR: 0:166: 'xfb_buffer' : buffer is too large: gl_MaxTransformFeedbackBuffers
ERROR: 0:169: 'xfb_buffer' : buffer is too large: gl_MaxTransformFeedbackBuffers is 4
ERROR: 0:169: 'xfb_stride' : 1/4 stride is too large: gl_MaxTransformFeedbackInterleavedComponents is 64
ERROR: 0:171: 'xfb_buffer' : buffer is too large: gl_MaxTransformFeedbackBuffers is 4
ERROR: 0:178: 'xfb_offset' : overlapping offsets at offset 36 in buffer 3
ERROR: 0:179: 'xfb_buffer' : member cannot contradict block (or what block inherited from global)
ERROR: 0:178: 'xfb_offset' : overlapping offsets at offset 32 in buffer 3
ERROR: 0:185: 'gl_BaseVertexARB' : required extension not requested: GL_ARB_shader_draw_parameters
ERROR: 0:185: 'gl_BaseInstanceARB' : required extension not requested: GL_ARB_shader_draw_parameters
ERROR: 0:185: 'gl_DrawIDARB' : required extension not requested: GL_ARB_shader_draw_parameters
@@ -54,7 +56,7 @@ ERROR: 0:193: 'assign' : l-value required "gl_BaseVertexARB" (can't modify shad
ERROR: 0:194: 'assign' : l-value required "gl_BaseInstanceARB" (can't modify shader input)
ERROR: 0:195: 'assign' : l-value required "gl_DrawIDARB" (can't modify shader input)
ERROR: 0:196: 'glBaseInstanceARB' : undeclared identifier
ERROR: 55 compilation errors. No code generated.
ERROR: 57 compilation errors. No code generated.
Shader version: 440
@@ -154,7 +156,7 @@ ERROR: node is still EOpNull!
0:? 'bbinst9' ( out block{layout( xfb_buffer=4 xfb_offset=1) out bool b, layout( xfb_buffer=4 xfb_offset=12) out structure{ global bool b, global structure{ global int i, global double d, global float f} s, global 2-component vector of float v2} t, layout( xfb_buffer=4 xfb_offset=52) out 3X3 matrix of float m3, layout( xfb_buffer=4 xfb_offset=90) out int i, layout( xfb_buffer=4 xfb_offset=98) out double d, layout( xfb_buffer=4 xfb_offset=108) out structure{ global int a} s})
0:? 'bm' (layout( xfb_buffer=5 xfb_offset=0) smooth out float)
0:? 'bbinst10' ( out block{layout( xfb_buffer=7 xfb_offset=0) out 4X4 matrix of double m1, layout( xfb_buffer=7 xfb_offset=128) out 4X4 matrix of double m2, layout( xfb_buffer=7 xfb_offset=256) out float f})
0:? 'anon@0' ( out block{layout( xfb_buffer=0 xfb_offset=36) gl_Position 4-component vector of float Position gl_Position, layout( xfb_buffer=0 xfb_offset=32) gl_PointSize float PointSize gl_PointSize, })
0:? 'anon@0' ( out block{layout( xfb_buffer=3 xfb_offset=36) gl_Position 4-component vector of float Position gl_Position, layout( xfb_buffer=3 xfb_offset=32) gl_PointSize float PointSize gl_PointSize, })
0:? 'gl_VertexID' ( gl_VertexId int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)
@@ -237,7 +239,7 @@ ERROR: node is still EOpNull!
0:? 'bbinst9' ( out block{layout( xfb_buffer=4 xfb_offset=1) out bool b, layout( xfb_buffer=4 xfb_offset=12) out structure{ global bool b, global structure{ global int i, global double d, global float f} s, global 2-component vector of float v2} t, layout( xfb_buffer=4 xfb_offset=52) out 3X3 matrix of float m3, layout( xfb_buffer=4 xfb_offset=90) out int i, layout( xfb_buffer=4 xfb_offset=98) out double d, layout( xfb_buffer=4 xfb_offset=108) out structure{ global int a} s})
0:? 'bm' (layout( xfb_buffer=5 xfb_offset=0) smooth out float)
0:? 'bbinst10' ( out block{layout( xfb_buffer=7 xfb_offset=0) out 4X4 matrix of double m1, layout( xfb_buffer=7 xfb_offset=128) out 4X4 matrix of double m2, layout( xfb_buffer=7 xfb_offset=256) out float f})
0:? 'anon@0' ( out block{layout( xfb_buffer=0 xfb_offset=36) gl_Position 4-component vector of float Position gl_Position, layout( xfb_buffer=0 xfb_offset=32) gl_PointSize float PointSize gl_PointSize, })
0:? 'anon@0' ( out block{layout( xfb_buffer=3 xfb_offset=36) gl_Position 4-component vector of float Position gl_Position, layout( xfb_buffer=3 xfb_offset=32) gl_PointSize float PointSize gl_PointSize, })
0:? 'gl_VertexID' ( gl_VertexId int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)

File diff suppressed because it is too large Load Diff

View File

@@ -85,12 +85,12 @@ ERROR: node is still EOpNull!
0:17 move second child to first child ( temp int)
0:17 'obig' ( temp int)
0:17 Constant:
0:17 995208915 (const int)
0:17 -1662398820 (const int)
0:18 Sequence
0:18 move second child to first child ( temp int)
0:18 'omax1' ( temp int)
0:18 Constant:
0:18 536870912 (const int)
0:18 0 (const int)
0:20 Sequence
0:20 move second child to first child ( temp uint)
0:20 'uo5' ( temp uint)
@@ -225,7 +225,7 @@ ERROR: node is still EOpNull!
0:50 move second child to first child ( temp int)
0:50 'hbig' ( temp int)
0:50 Constant:
0:50 -1 (const int)
0:50 -15 (const int)
0:52 Sequence
0:52 move second child to first child ( temp float)
0:52 'f1' ( temp float)
@@ -494,12 +494,12 @@ ERROR: node is still EOpNull!
0:17 move second child to first child ( temp int)
0:17 'obig' ( temp int)
0:17 Constant:
0:17 995208915 (const int)
0:17 -1662398820 (const int)
0:18 Sequence
0:18 move second child to first child ( temp int)
0:18 'omax1' ( temp int)
0:18 Constant:
0:18 536870912 (const int)
0:18 0 (const int)
0:20 Sequence
0:20 move second child to first child ( temp uint)
0:20 'uo5' ( temp uint)
@@ -634,7 +634,7 @@ ERROR: node is still EOpNull!
0:50 move second child to first child ( temp int)
0:50 'hbig' ( temp int)
0:50 Constant:
0:50 -1 (const int)
0:50 -15 (const int)
0:52 Sequence
0:52 move second child to first child ( temp float)
0:52 'f1' ( temp float)

View File

@@ -25,6 +25,6 @@ int main(){
== !=
& ^ | && ^^ || ? :
+= -= *= /= %= <<= >>= &= |= ^=
1.2 2E10 5u - 5 lf
1.2 2E10 5u - 5l f
}

View File

@@ -50,7 +50,7 @@ spv.atomicInt64.comp
24: 22(int) Constant 0
28: 17(int) Constant 1
29: TypePointer Uniform 10(int)
31: 10(int) Constant 15 0
31: 10(int) Constant 15 240
84(Struct): TypeStruct 6(int) 10(int)
85: TypePointer Workgroup 84(Struct)
86(s): 85(ptr) Variable Workgroup

View File

@@ -0,0 +1,68 @@
spv.xfb2.vert
// Module Version 10000
// Generated by (magic number): 80003
// Id's are bound by 35
Capability Shader
Capability TransformFeedback
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 10 14
ExecutionMode 4 Xfb
Source GLSL 450
Name 4 "main"
Name 8 "gl_PerVertex"
MemberName 8(gl_PerVertex) 0 "gl_Position"
Name 10 ""
Name 14 "position"
Name 17 "ComponentsBlock"
MemberName 17(ComponentsBlock) 0 "c1"
MemberName 17(ComponentsBlock) 1 "c2"
Name 19 "components"
MemberDecorate 8(gl_PerVertex) 0 Offset 16
MemberDecorate 8(gl_PerVertex) 0 BuiltIn Position
Decorate 8(gl_PerVertex) Block
Decorate 10 XfbBuffer 3
Decorate 10 XfbStride 32
Decorate 14(position) Location 0
MemberDecorate 17(ComponentsBlock) 0 Offset 0
MemberDecorate 17(ComponentsBlock) 1 Offset 16
Decorate 17(ComponentsBlock) Block
Decorate 19(components) DescriptorSet 0
Decorate 19(components) Binding 5
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8(gl_PerVertex): TypeStruct 7(fvec4)
9: TypePointer Output 8(gl_PerVertex)
10: 9(ptr) Variable Output
11: TypeInt 32 1
12: 11(int) Constant 0
13: TypePointer Input 7(fvec4)
14(position): 13(ptr) Variable Input
16: TypeVector 6(float) 2
17(ComponentsBlock): TypeStruct 7(fvec4) 16(fvec2)
18: TypePointer Uniform 17(ComponentsBlock)
19(components): 18(ptr) Variable Uniform
20: TypePointer Uniform 7(fvec4)
24: 11(int) Constant 1
25: TypePointer Uniform 16(fvec2)
28: 6(float) Constant 0
33: TypePointer Output 7(fvec4)
4(main): 2 Function None 3
5: Label
15: 7(fvec4) Load 14(position)
21: 20(ptr) AccessChain 19(components) 12
22: 7(fvec4) Load 21
23: 7(fvec4) FAdd 15 22
26: 25(ptr) AccessChain 19(components) 24
27: 16(fvec2) Load 26
29: 6(float) CompositeExtract 27 0
30: 6(float) CompositeExtract 27 1
31: 7(fvec4) CompositeConstruct 29 30 28 28
32: 7(fvec4) FAdd 23 31
34: 33(ptr) AccessChain 10 12
Store 34 32
Return
FunctionEnd

View File

@@ -0,0 +1,68 @@
spv.xfb3.vert
// Module Version 10000
// Generated by (magic number): 80003
// Id's are bound by 35
Capability Shader
Capability TransformFeedback
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 10 14
ExecutionMode 4 Xfb
Source GLSL 450
Name 4 "main"
Name 8 "gl_PerVertex"
MemberName 8(gl_PerVertex) 0 "gl_Position"
Name 10 ""
Name 14 "position"
Name 17 "ComponentsBlock"
MemberName 17(ComponentsBlock) 0 "c1"
MemberName 17(ComponentsBlock) 1 "c2"
Name 19 "components"
MemberDecorate 8(gl_PerVertex) 0 Offset 16
MemberDecorate 8(gl_PerVertex) 0 BuiltIn Position
Decorate 8(gl_PerVertex) Block
Decorate 10 XfbBuffer 3
Decorate 10 XfbStride 80
Decorate 14(position) Location 0
MemberDecorate 17(ComponentsBlock) 0 Offset 0
MemberDecorate 17(ComponentsBlock) 1 Offset 16
Decorate 17(ComponentsBlock) Block
Decorate 19(components) DescriptorSet 0
Decorate 19(components) Binding 5
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8(gl_PerVertex): TypeStruct 7(fvec4)
9: TypePointer Output 8(gl_PerVertex)
10: 9(ptr) Variable Output
11: TypeInt 32 1
12: 11(int) Constant 0
13: TypePointer Input 7(fvec4)
14(position): 13(ptr) Variable Input
16: TypeVector 6(float) 2
17(ComponentsBlock): TypeStruct 7(fvec4) 16(fvec2)
18: TypePointer Uniform 17(ComponentsBlock)
19(components): 18(ptr) Variable Uniform
20: TypePointer Uniform 7(fvec4)
24: 11(int) Constant 1
25: TypePointer Uniform 16(fvec2)
28: 6(float) Constant 0
33: TypePointer Output 7(fvec4)
4(main): 2 Function None 3
5: Label
15: 7(fvec4) Load 14(position)
21: 20(ptr) AccessChain 19(components) 12
22: 7(fvec4) Load 21
23: 7(fvec4) FAdd 15 22
26: 25(ptr) AccessChain 19(components) 24
27: 16(fvec2) Load 26
29: 6(float) CompositeExtract 27 0
30: 6(float) CompositeExtract 27 1
31: 7(fvec4) CompositeConstruct 29 30 28 28
32: 7(fvec4) FAdd 23 31
34: 33(ptr) AccessChain 10 12
Store 34 32
Return
FunctionEnd

View File

@@ -51,7 +51,7 @@ ERROR: node is still EOpNull!
0:13 move second child to first child ( temp highp int)
0:13 'OE' ( global highp int)
0:13 Constant:
0:13 1073741823 (const int)
0:13 -1 (const int)
0:14 Sequence
0:14 move second child to first child ( temp highp int)
0:14 'HE' ( global highp int)
@@ -92,7 +92,7 @@ ERROR: node is still EOpNull!
0:34 move second child to first child ( temp highp int)
0:34 'superO' ( global highp int)
0:34 Constant:
0:34 1073741823 (const int)
0:34 -1 (const int)
0:35 Sequence
0:35 move second child to first child ( temp highp int)
0:35 'superI' ( global highp int)
@@ -147,7 +147,7 @@ ERROR: node is still EOpNull!
0:13 move second child to first child ( temp highp int)
0:13 'OE' ( global highp int)
0:13 Constant:
0:13 1073741823 (const int)
0:13 -1 (const int)
0:14 Sequence
0:14 move second child to first child ( temp highp int)
0:14 'HE' ( global highp int)
@@ -188,7 +188,7 @@ ERROR: node is still EOpNull!
0:34 move second child to first child ( temp highp int)
0:34 'superO' ( global highp int)
0:34 Constant:
0:34 1073741823 (const int)
0:34 -1 (const int)
0:35 Sequence
0:35 move second child to first child ( temp highp int)
0:35 'superI' ( global highp int)

View File

@@ -13,7 +13,7 @@ groupshared uint4 gs_ua4;
groupshared uint4 gs_ub4;
groupshared uint4 gs_uc4;
float PixelShaderFunctionS(float inF0, float inF1, float inF2, uint inU0, uint inU1)
float PixelShaderFunctionS(float inF0, float inF1, float inF2, uint inU0, int inU1)
{
uint out_u1;
@@ -23,7 +23,7 @@ float PixelShaderFunctionS(float inF0, float inF1, float inF2, uint inU0, uint i
bool r003 = any(inF0);
float r004 = asin(inF0);
int r005 = asint(inF0);
uint r006 = asuint(inF0);
uint r006 = asuint(inU1);
float r007 = asfloat(inU0);
// asdouble(inU0, inU1); // TODO: enable when HLSL parser used for intrinsics
float r009 = atan(inF0);

View File

@@ -22,7 +22,7 @@ shared Struct s;
void main()
{
const int64_t i64c = -24;
const uint64_t u64c = 0xF00000000F;
const uint64_t u64c = 0xF00000000Ful;
// Test shader storage block
int64_t i64 = 0;

18
3rdparty/glslang/Test/spv.xfb2.vert vendored Normal file
View File

@@ -0,0 +1,18 @@
#version 450
layout (location = 0) in vec4 position;
layout (binding = 5) uniform ComponentsBlock
{
vec4 c1;
vec2 c2;
} components;
layout (xfb_buffer = 3, xfb_offset = 16) out gl_PerVertex
{
vec4 gl_Position;
};
void main()
{
gl_Position = position + components.c1 + vec4(components.c2, 0.0, 0.0);
}

18
3rdparty/glslang/Test/spv.xfb3.vert vendored Normal file
View File

@@ -0,0 +1,18 @@
#version 450
layout (location = 0) in vec4 position;
layout (binding = 5) uniform ComponentsBlock
{
vec4 c1;
vec2 c2;
} components;
layout (xfb_buffer = 3, xfb_offset = 16) out gl_PerVertex
{
layout(xfb_stride = 80) vec4 gl_Position;
};
void main()
{
gl_Position = position + components.c1 + vec4(components.c2, 0.0, 0.0);
}

View File

@@ -3486,7 +3486,8 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT
// Fix XFB stuff up, it applies to the order of the redeclaration, not
// the order of the original members.
if (currentBlockQualifier.storage == EvqVaryingOut && globalOutputDefaults.hasXfbBuffer()) {
currentBlockQualifier.layoutXfbBuffer = globalOutputDefaults.layoutXfbBuffer;
if (!currentBlockQualifier.hasXfbBuffer())
currentBlockQualifier.layoutXfbBuffer = globalOutputDefaults.layoutXfbBuffer;
fixBlockXfbOffsets(currentBlockQualifier, newTypeList);
}
@@ -3545,7 +3546,8 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT
error(memberLoc, "cannot add non-XFB layout to redeclared block member", member->type->getFieldName().c_str(), "");
if (newType.getQualifier().patch)
error(memberLoc, "cannot add patch to redeclared block member", member->type->getFieldName().c_str(), "");
if (newType.getQualifier().hasXfbBuffer() && newType.getQualifier().layoutXfbBuffer != currentBlockQualifier.layoutXfbBuffer)
if (newType.getQualifier().hasXfbBuffer() &&
newType.getQualifier().layoutXfbBuffer != currentBlockQualifier.layoutXfbBuffer)
error(memberLoc, "member cannot contradict block (or what block inherited from global)", "xfb_buffer", "");
oldType.getQualifier().centroid = newType.getQualifier().centroid;
oldType.getQualifier().sample = newType.getQualifier().sample;
@@ -3555,11 +3557,20 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT
oldType.getQualifier().flat = newType.getQualifier().flat;
oldType.getQualifier().nopersp = newType.getQualifier().nopersp;
oldType.getQualifier().layoutXfbOffset = newType.getQualifier().layoutXfbOffset;
if (oldType.getQualifier().layoutXfbOffset != TQualifier::layoutXfbBufferEnd)
oldType.getQualifier().layoutXfbBuffer = newType.getQualifier().layoutXfbBuffer;
oldType.getQualifier().layoutXfbStride = newType.getQualifier().layoutXfbStride;
if (oldType.getQualifier().layoutXfbOffset != TQualifier::layoutXfbBufferEnd) {
// if any member as an xfb_offset, then the block's xfb_buffer inherents current xfb_buffer,
// and for xfb processing, the member needs it as well, along with xfb_stride
type.getQualifier().layoutXfbBuffer = currentBlockQualifier.layoutXfbBuffer;
oldType.getQualifier().layoutXfbBuffer = currentBlockQualifier.layoutXfbBuffer;
}
if (oldType.isImplicitlySizedArray() && newType.isExplicitlySizedArray())
oldType.changeOuterArraySize(newType.getOuterArraySize());
// check and process the member's type, which will include managing xfb information
layoutTypeCheck(loc, oldType);
// go to next member
++member;
} else {
@@ -4803,11 +4814,11 @@ void TParseContext::layoutQualifierCheck(const TSourceLoc& loc, const TQualifier
error(loc, "requires uniform or buffer storage qualifier", "binding", "");
}
if (qualifier.hasStream()) {
if (qualifier.storage != EvqVaryingOut)
if (!qualifier.isPipeOutput())
error(loc, "can only be used on an output", "stream", "");
}
if (qualifier.hasXfb()) {
if (qualifier.storage != EvqVaryingOut)
if (!qualifier.isPipeOutput())
error(loc, "can only be used on an output", "xfb layout qualifier", "");
}
if (qualifier.hasUniformLayout()) {

View File

@@ -841,7 +841,8 @@ int TScanContext::tokenizeIdentifier()
case VOLATILE:
if (parseContext.profile == EEsProfile && parseContext.version >= 310)
return keyword;
if (! parseContext.symbolTable.atBuiltInLevel() && (parseContext.profile == EEsProfile || (parseContext.version < 420 && ! parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))))
if (! parseContext.symbolTable.atBuiltInLevel() && (parseContext.profile == EEsProfile ||
(parseContext.version < 420 && ! parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))))
reservedWord();
return keyword;
@@ -985,8 +986,8 @@ int TScanContext::tokenizeIdentifier()
case U64VEC4:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64) &&
parseContext.profile != EEsProfile && parseContext.version >= 450))
(parseContext.profile != EEsProfile && parseContext.version >= 450 &&
parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64)))
return keyword;
return identifierOrType();
@@ -1001,8 +1002,8 @@ int TScanContext::tokenizeIdentifier()
case U16VEC4:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_int16) &&
parseContext.profile != EEsProfile && parseContext.version >= 450))
(parseContext.profile != EEsProfile && parseContext.version >= 450 &&
parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_int16)))
return keyword;
return identifierOrType();
@@ -1024,8 +1025,8 @@ int TScanContext::tokenizeIdentifier()
case F16MAT4X4:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float) &&
parseContext.profile != EEsProfile && parseContext.version >= 450))
(parseContext.profile != EEsProfile && parseContext.version >= 450 &&
parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float)))
return keyword;
return identifierOrType();
#endif
@@ -1115,7 +1116,7 @@ int TScanContext::tokenizeIdentifier()
case SAMPLER3D:
afterType = true;
if (parseContext.profile == EEsProfile && parseContext.version < 300) {
if (! parseContext.extensionTurnedOn(E_GL_OES_texture_3D))
if (!parseContext.extensionTurnedOn(E_GL_OES_texture_3D))
reservedWord();
}
return keyword;
@@ -1403,7 +1404,8 @@ int TScanContext::dMat()
int TScanContext::firstGenerationImage(bool inEs310)
{
if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.profile != EEsProfile && (parseContext.version >= 420 || parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))) ||
(parseContext.profile != EEsProfile && (parseContext.version >= 420 ||
parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))) ||
(inEs310 && parseContext.profile == EEsProfile && parseContext.version >= 310))
return keyword;

View File

@@ -570,7 +570,8 @@ bool TParseVersions::checkExtensionsRequested(const TSourceLoc& loc, int numExte
//
void TParseVersions::requireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[], const char* featureDesc)
{
if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc)) return;
if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc))
return;
// If we get this far, give errors explaining what extensions are needed
if (numExtensions == 1)
@@ -588,7 +589,8 @@ void TParseVersions::requireExtensions(const TSourceLoc& loc, int numExtensions,
//
void TParseVersions::ppRequireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[], const char* featureDesc)
{
if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc)) return;
if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc))
return;
// If we get this far, give errors explaining what extensions are needed
if (numExtensions == 1)
@@ -626,7 +628,8 @@ bool TParseVersions::extensionTurnedOn(const char* const extension)
bool TParseVersions::extensionsTurnedOn(int numExtensions, const char* const extensions[])
{
for (int i = 0; i < numExtensions; ++i) {
if (extensionTurnedOn(extensions[i])) return true;
if (extensionTurnedOn(extensions[i]))
return true;
}
return false;
}

View File

@@ -103,17 +103,6 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
{
bool HasDecimalOrExponent = false;
int isDouble = 0;
bool generateFloat16 = false;
bool acceptFloat16 = parseContext.intermediate.getSource() == EShSourceHlsl;
bool isFloat16 = false;
bool requireHF = false;
#ifdef AMD_EXTENSIONS
if (parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float)) {
acceptFloat16 = true;
generateFloat16 = true;
requireHF = true;
}
#endif
const auto saveName = [&](int ch) {
if (len <= MaxTokenLength)
@@ -182,7 +171,7 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
}
// Suffix:
bool isFloat16 = false;
if (ch == 'l' || ch == 'L') {
parseContext.doubleCheck(ppToken->loc, "double floating-point suffix");
if (! HasDecimalOrExponent)
@@ -196,14 +185,14 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
saveName(ch2);
isDouble = 1;
}
} else if (acceptFloat16 && (ch == 'h' || ch == 'H')) {
} else if (ch == 'h' || ch == 'H') {
#ifdef AMD_EXTENSIONS
if (generateFloat16)
if (parseContext.intermediate.getSource() == EShSourceGlsl)
parseContext.float16Check(ppToken->loc, "half floating-point suffix");
#endif
if (!HasDecimalOrExponent)
parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
if (requireHF) {
if (parseContext.intermediate.getSource() == EShSourceGlsl) {
int ch2 = getChar();
if (ch2 != 'f' && ch2 != 'F') {
ungetChar();
@@ -211,11 +200,11 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
} else {
saveName(ch);
saveName(ch2);
isFloat16 = generateFloat16;
isFloat16 = true;
}
} else {
saveName(ch);
isFloat16 = generateFloat16;
isFloat16 = false;
}
} else if (ch == 'f' || ch == 'F') {
parseContext.profileRequires(ppToken->loc, EEsProfile, 300, nullptr, "floating-point suffix");
@@ -333,19 +322,10 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
int ch = 0;
int ii = 0;
unsigned long long ival = 0;
bool enableInt64 = pp->parseContext.version >= 450 && pp->parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64);
#ifdef AMD_EXTENSIONS
bool enableInt16 = pp->parseContext.version >= 450 && pp->parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_int16);
#endif
bool acceptHalf = pp->parseContext.intermediate.getSource() == EShSourceHlsl;
#ifdef AMD_EXTENSIONS
if (pp->parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float))
acceptHalf = true;
#endif
const auto floatingPointChar = [&](int ch) { return ch == '.' || ch == 'e' || ch == 'E' ||
ch == 'f' || ch == 'F' ||
(acceptHalf && (ch == 'h' || ch == 'H')); };
ch == 'h' || ch == 'H'; };
ppToken->ival = 0;
ppToken->i64val = 0;
@@ -420,7 +400,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
ival = 0;
do {
if (len < MaxTokenLength && (ival <= 0x0fffffffu || (enableInt64 && ival <= 0x0fffffffffffffffull))) {
if (len < MaxTokenLength && ival <= 0x0fffffffffffffffull) {
ppToken->name[len++] = (char)ch;
if (ch >= '0' && ch <= '9') {
ii = ch - '0';
@@ -453,33 +433,31 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
ppToken->name[len++] = (char)ch;
isUnsigned = true;
if (enableInt64) {
int nextCh = getch();
if ((ch == 'u' && nextCh == 'l') || (ch == 'U' && nextCh == 'L')) {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)nextCh;
isInt64 = true;
} else
ungetch();
}
int nextCh = getch();
if (nextCh == 'l' || nextCh == 'L') {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)nextCh;
isInt64 = true;
} else
ungetch();
#ifdef AMD_EXTENSIONS
if (enableInt16) {
int nextCh = getch();
if ((ch == 'u' && nextCh == 's') || (ch == 'U' && nextCh == 'S')) {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)nextCh;
isInt16 = true;
} else
ungetch();
}
nextCh = getch();
if ((nextCh == 's' || nextCh == 'S') &&
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)nextCh;
isInt16 = true;
} else
ungetch();
#endif
} else if (enableInt64 && (ch == 'l' || ch == 'L')) {
} else if (ch == 'l' || ch == 'L') {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)ch;
isInt64 = true;
#ifdef AMD_EXTENSIONS
} else if (enableInt16 && (ch == 's' || ch == 'S')) {
} else if ((ch == 's' || ch == 'S') &&
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)ch;
isInt16 = true;
@@ -488,15 +466,27 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
ungetch();
ppToken->name[len] = '\0';
if (isInt64) {
if (isInt64 && pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
"64-bit hexadecimal literal");
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0, E_GL_ARB_gpu_shader_int64,
"64-bit hexadecimal literal");
ppToken->i64val = ival;
return isUnsigned ? PpAtomConstUint64 : PpAtomConstInt64;
#ifdef AMD_EXTENSIONS
} else if (isInt16) {
if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
"16-bit hexadecimal literal");
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0, E_GL_AMD_gpu_shader_int16,
"16-bit hexadecimal literal");
}
ppToken->ival = (int)ival;
return isUnsigned ? PpAtomConstUint16 : PpAtomConstInt16;
#endif
} else {
if (ival > 0xffffffffu && !AlreadyComplained)
pp->parseContext.ppError(ppToken->loc, "hexadecimal literal too big", "", "");
ppToken->ival = (int)ival;
return isUnsigned ? PpAtomConstUint : PpAtomConstInt;
}
@@ -520,7 +510,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
pp->parseContext.ppError(ppToken->loc, "numeric literal too long", "", "");
AlreadyComplained = 1;
}
if (ival <= 0x1fffffffu || (enableInt64 && ival <= 0x1fffffffffffffffull)) {
if (ival <= 0x1fffffffffffffffull) {
ii = ch - '0';
ival = (ival << 3) | ii;
} else
@@ -553,33 +543,31 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
ppToken->name[len++] = (char)ch;
isUnsigned = true;
if (enableInt64) {
int nextCh = getch();
if ((ch == 'u' && nextCh == 'l') || (ch == 'U' && nextCh == 'L')) {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)nextCh;
isInt64 = true;
} else
ungetch();
}
int nextCh = getch();
if (nextCh == 'l' || nextCh == 'L') {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)nextCh;
isInt64 = true;
} else
ungetch();
#ifdef AMD_EXTENSIONS
if (enableInt16) {
int nextCh = getch();
if ((ch == 'u' && nextCh == 's') || (ch == 'U' && nextCh == 'S')) {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)nextCh;
isInt16 = true;
} else
ungetch();
}
nextCh = getch();
if ((nextCh == 's' || nextCh == 'S') &&
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)nextCh;
isInt16 = true;
} else
ungetch();
#endif
} else if (enableInt64 && (ch == 'l' || ch == 'L')) {
} else if (ch == 'l' || ch == 'L') {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)ch;
isInt64 = true;
#ifdef AMD_EXTENSIONS
} else if (enableInt16 && (ch == 's' || ch == 'S')) {
} else if ((ch == 's' || ch == 'S') &&
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)ch;
isInt16 = true;
@@ -588,14 +576,27 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
ungetch();
ppToken->name[len] = '\0';
if (!isInt64 && ival > 0xffffffffu)
octalOverflow = true;
if (octalOverflow)
pp->parseContext.ppError(ppToken->loc, "octal literal too big", "", "");
if (isInt64) {
if (isInt64 && pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
"64-bit octal literal");
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0, E_GL_ARB_gpu_shader_int64,
"64-bit octal literal");
ppToken->i64val = ival;
return isUnsigned ? PpAtomConstUint64 : PpAtomConstInt64;
#ifdef AMD_EXTENSIONS
} else if (isInt16) {
if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
"16-bit octal literal");
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0, E_GL_AMD_gpu_shader_int16,
"16-bit octal literal");
}
ppToken->ival = (int)ival;
return isUnsigned ? PpAtomConstUint16 : PpAtomConstInt16;
#endif
@@ -633,33 +634,31 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
ppToken->name[len++] = (char)ch;
isUnsigned = true;
if (enableInt64) {
int nextCh = getch();
if ((ch == 'u' && nextCh == 'l') || (ch == 'U' && nextCh == 'L')) {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)nextCh;
isInt64 = true;
} else
ungetch();
}
int nextCh = getch();
if (nextCh == 'l' || nextCh == 'L') {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)nextCh;
isInt64 = true;
} else
ungetch();
#ifdef AMD_EXTENSIONS
if (enableInt16) {
int nextCh = getch();
if ((ch == 'u' && nextCh == 's') || (ch == 'U' && nextCh == 'S')) {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)nextCh;
isInt16 = true;
} else
ungetch();
}
nextCh = getch();
if ((nextCh == 's' || nextCh == 'S') &&
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)nextCh;
isInt16 = true;
} else
ungetch();
#endif
} else if (enableInt64 && (ch == 'l' || ch == 'L')) {
} else if (ch == 'l' || ch == 'L') {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)ch;
isInt64 = true;
#ifdef AMD_EXTENSIONS
} else if (enableInt16 && (ch == 's' || ch == 'S')) {
} else if ((ch == 's' || ch == 'S') &&
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
if (len < MaxTokenLength)
ppToken->name[len++] = (char)ch;
isInt16 = true;
@@ -696,11 +695,21 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
ival = ival * 10 + ch;
}
if (isInt64) {
if (isInt64 && pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
"64-bit literal");
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0, E_GL_ARB_gpu_shader_int64,
"64-bit literal");
ppToken->i64val = ival;
return isUnsigned ? PpAtomConstUint64 : PpAtomConstInt64;
#ifdef AMD_EXTENSIONS
} else if (isInt16) {
if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
"16-bit literal");
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0, E_GL_AMD_gpu_shader_int16,
"16-bit literal");
}
ppToken->ival = (int)ival;
return isUnsigned ? PpAtomConstUint16 : PpAtomConstInt16;
#endif

View File

@@ -331,6 +331,8 @@ INSTANTIATE_TEST_CASE_P(
"spv.precise.tese",
"spv.precise.tesc",
"spv.xfb.vert",
"spv.xfb2.vert",
"spv.xfb3.vert",
})),
FileNameAsCustomTestSuffix
);

View File

@@ -3051,6 +3051,8 @@ bool HlslGrammar::acceptPostfixExpression(TIntermTyped*& node)
}
if (! peekTokenClass(EHTokLeftParen)) {
node = parseContext.handleVariable(idToken.loc, fullName);
if (node == nullptr)
return false;
} else if (acceptFunctionCall(idToken.loc, *fullName, node, nullptr)) {
// function_call (nothing else to do yet)
} else {
@@ -3784,9 +3786,17 @@ bool HlslGrammar::acceptJumpStatement(TIntermNode*& statement)
switch (jump) {
case EHTokContinue:
statement = intermediate.addBranch(EOpContinue, token.loc);
if (parseContext.loopNestingLevel == 0) {
expected("loop");
return false;
}
break;
case EHTokBreak:
statement = intermediate.addBranch(EOpBreak, token.loc);
if (parseContext.loopNestingLevel == 0 && parseContext.switchSequenceStack.size() == 0) {
expected("loop or switch");
return false;
}
break;
case EHTokDiscard:
statement = intermediate.addBranch(EOpKill, token.loc);

View File

@@ -580,8 +580,8 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
{ "asdouble", "V2", "D", "V2,", "UI,", EShLangAll, false },
{ "asfloat", nullptr, "F", "SVM", "BFIU", EShLangAll, false },
{ "asin", nullptr, nullptr, "SVM", "F", EShLangAll, false },
{ "asint", nullptr, "I", "SVM", "FU", EShLangAll, false },
{ "asuint", nullptr, "U", "SVM", "FU", EShLangAll, false },
{ "asint", nullptr, "I", "SVM", "FIU", EShLangAll, false },
{ "asuint", nullptr, "U", "SVM", "FIU", EShLangAll, false },
{ "atan", nullptr, nullptr, "SVM", "F", EShLangAll, false },
{ "atan2", nullptr, nullptr, "SVM,", "F,", EShLangAll, false },
{ "ceil", nullptr, nullptr, "SVM", "F", EShLangAll, false },

View File

@@ -565,10 +565,15 @@ EHlslTokenClass HlslScanContext::tokenizeClass(HlslToken& token)
case EndOfInput: return EHTokNone;
default:
char buf[2];
buf[0] = (char)token;
buf[1] = 0;
parseContext.error(loc, "unexpected token", buf, "");
if (token < PpAtomMaxSingle) {
char buf[2];
buf[0] = (char)token;
buf[1] = 0;
parseContext.error(loc, "unexpected token", buf, "");
} else if (tokenText[0] != 0)
parseContext.error(loc, "unexpected token", tokenText, "");
else
parseContext.error(loc, "unexpected token", "", "");
break;
}
} while (true);