Commit d55c2d9b by John Kessenich

Merge remote-tracking branch 'GitHub/master'

parents 5ac7a233 7a9db71f
# increase to 3.1 once all major distributions # increase to 3.1 once all major distributions
# include a version of CMake >= 3.1 # include a version of CMake >= 3.1
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 2.8.12)
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Adhere to GNU filesystem layout conventions # Adhere to GNU filesystem layout conventions
......
...@@ -3339,7 +3339,9 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -3339,7 +3339,9 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
operands.push_back(spv::ImageOperandsSampleMask); operands.push_back(spv::ImageOperandsSampleMask);
operands.push_back(*(opIt++)); operands.push_back(*(opIt++));
} }
return builder.createOp(spv::OpImageRead, resultType(), operands); spv::Id result = builder.createOp(spv::OpImageRead, resultType(), operands);
builder.setPrecision(result, precision);
return result;
} }
operands.push_back(*(opIt++)); operands.push_back(*(opIt++));
...@@ -3362,7 +3364,10 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -3362,7 +3364,10 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
} }
if (builder.getImageTypeFormat(builder.getImageType(operands.front())) == spv::ImageFormatUnknown) if (builder.getImageTypeFormat(builder.getImageType(operands.front())) == spv::ImageFormatUnknown)
builder.addCapability(spv::CapabilityStorageImageReadWithoutFormat); builder.addCapability(spv::CapabilityStorageImageReadWithoutFormat);
return builder.createOp(spv::OpImageRead, resultType(), operands);
spv::Id result = builder.createOp(spv::OpImageRead, resultType(), operands);
builder.setPrecision(result, precision);
return result;
#ifdef AMD_EXTENSIONS #ifdef AMD_EXTENSIONS
} else if (node->getOp() == glslang::EOpImageStore || node->getOp() == glslang::EOpImageStoreLod) { } else if (node->getOp() == glslang::EOpImageStore || node->getOp() == glslang::EOpImageStoreLod) {
#else #else
......
...@@ -471,7 +471,10 @@ Id Builder::makeImageType(Id sampledType, Dim dim, bool depth, bool arrayed, boo ...@@ -471,7 +471,10 @@ Id Builder::makeImageType(Id sampledType, Dim dim, bool depth, bool arrayed, boo
if (ms) { if (ms) {
if (sampled == 2) { if (sampled == 2) {
addCapability(CapabilityStorageImageMultisample); // Images used with subpass data are not storage
// images, so don't require the capability for them.
if (dim != Dim::DimSubpassData)
addCapability(CapabilityStorageImageMultisample);
if (arrayed) if (arrayed)
addCapability(CapabilityImageMSArray); addCapability(CapabilityImageMSArray);
} }
......
cppDeepNest.frag
ERROR: 0:66: '#if/#ifdef/#ifndef' : maximum nesting depth exceeded
ERROR: 0:66: '' : missing #endif
ERROR: 0:66: '' : syntax error, unexpected $end
ERROR: 3 compilation errors. No code generated.
Shader version: 100
ERROR: node is still EOpNull!
0:? Linker Objects
Linked fragment stage:
ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point
Shader version: 100
ERROR: node is still EOpNull!
0:? Linker Objects
cppIntMinOverNegativeOne.frag
Shader version: 100
0:? Sequence
0:? Linker Objects
Linked fragment stage:
ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point
Shader version: 100
0:? Sequence
0:? Linker Objects
hlsl.attributeGlobalBuffer.frag
Shader version: 500
gl_FragCoord origin is upper left
0:? Sequence
0:6 Function Definition: @main( ( temp 4-component vector of float)
0:6 Function Parameters:
0:? Sequence
0:7 Branch: Return with expression
0:7 add ( temp 4-component vector of float)
0:7 u1: direct index for structure ( uniform 4-component vector of float)
0:7 'anon@0' (layout( set=2 binding=5 row_major std140) uniform block{ uniform 4-component vector of float u1, uniform 4-component vector of float u2})
0:7 Constant:
0:7 0 (const uint)
0:7 u2: direct index for structure ( uniform 4-component vector of float)
0:7 'anon@0' (layout( set=2 binding=5 row_major std140) uniform block{ uniform 4-component vector of float u1, uniform 4-component vector of float u2})
0:7 Constant:
0:7 1 (const uint)
0:6 Function Definition: main( ( temp void)
0:6 Function Parameters:
0:? Sequence
0:6 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:6 Function Call: @main( ( temp 4-component vector of float)
0:? Linker Objects
0:? 'anon@0' (layout( set=2 binding=5 row_major std140) uniform block{ uniform 4-component vector of float u1, uniform 4-component vector of float u2})
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
Linked fragment stage:
Shader version: 500
gl_FragCoord origin is upper left
0:? Sequence
0:6 Function Definition: @main( ( temp 4-component vector of float)
0:6 Function Parameters:
0:? Sequence
0:7 Branch: Return with expression
0:7 add ( temp 4-component vector of float)
0:7 u1: direct index for structure ( uniform 4-component vector of float)
0:7 'anon@0' (layout( set=2 binding=5 row_major std140) uniform block{ uniform 4-component vector of float u1, uniform 4-component vector of float u2})
0:7 Constant:
0:7 0 (const uint)
0:7 u2: direct index for structure ( uniform 4-component vector of float)
0:7 'anon@0' (layout( set=2 binding=5 row_major std140) uniform block{ uniform 4-component vector of float u1, uniform 4-component vector of float u2})
0:7 Constant:
0:7 1 (const uint)
0:6 Function Definition: main( ( temp void)
0:6 Function Parameters:
0:? Sequence
0:6 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:6 Function Call: @main( ( temp 4-component vector of float)
0:? Linker Objects
0:? 'anon@0' (layout( set=2 binding=5 row_major std140) uniform block{ uniform 4-component vector of float u1, uniform 4-component vector of float u2})
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
// Module Version 10000
// Generated by (magic number): 80002
// Id's are bound by 28
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 26
ExecutionMode 4 OriginUpperLeft
Source HLSL 500
Name 4 "main"
Name 9 "@main("
Name 11 "$Global"
MemberName 11($Global) 0 "u1"
MemberName 11($Global) 1 "u2"
Name 13 ""
Name 26 "@entryPointOutput"
MemberDecorate 11($Global) 0 Offset 0
MemberDecorate 11($Global) 1 Offset 16
Decorate 11($Global) Block
Decorate 13 DescriptorSet 2
Decorate 13 Binding 5
Decorate 26(@entryPointOutput) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypeFunction 7(fvec4)
11($Global): TypeStruct 7(fvec4) 7(fvec4)
12: TypePointer Uniform 11($Global)
13: 12(ptr) Variable Uniform
14: TypeInt 32 1
15: 14(int) Constant 0
16: TypePointer Uniform 7(fvec4)
19: 14(int) Constant 1
25: TypePointer Output 7(fvec4)
26(@entryPointOutput): 25(ptr) Variable Output
4(main): 2 Function None 3
5: Label
27: 7(fvec4) FunctionCall 9(@main()
Store 26(@entryPointOutput) 27
Return
FunctionEnd
9(@main(): 7(fvec4) Function None 8
10: Label
17: 16(ptr) AccessChain 13 15
18: 7(fvec4) Load 17
20: 16(ptr) AccessChain 13 19
21: 7(fvec4) Load 20
22: 7(fvec4) FAdd 18 21
ReturnValue 22
FunctionEnd
This source diff could not be displayed because it is too large. You can view the blob instead.
hlsl.partialFlattenMixed.vert
WARNING: AST will form illegal SPIR-V; need to transform to legalize
Shader version: 500
0:? Sequence
0:10 Function Definition: @main(vf4; ( temp 4-component vector of float)
0:10 Function Parameters:
0:10 'pos' ( in 4-component vector of float)
0:? Sequence
0:13 Sequence
0:13 move second child to first child ( temp texture2D)
0:13 direct index ( temp texture2D)
0:? 'packed.membTex' ( temp 2-element array of texture2D)
0:13 Constant:
0:13 0 (const int)
0:? 'tex[0]' ( uniform texture2D)
0:13 move second child to first child ( temp texture2D)
0:13 direct index ( temp texture2D)
0:? 'packed.membTex' ( temp 2-element array of texture2D)
0:13 Constant:
0:13 1 (const int)
0:? 'tex[1]' ( uniform texture2D)
0:15 Branch: Return with expression
0:15 'pos' ( in 4-component vector of float)
0:10 Function Definition: main( ( temp void)
0:10 Function Parameters:
0:? Sequence
0:10 move second child to first child ( temp 4-component vector of float)
0:? 'pos' ( temp 4-component vector of float)
0:? 'pos' (layout( location=0) in 4-component vector of float)
0:10 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' ( out 4-component vector of float Position)
0:10 Function Call: @main(vf4; ( temp 4-component vector of float)
0:? 'pos' ( temp 4-component vector of float)
0:? Linker Objects
0:? 'tex[0]' ( uniform texture2D)
0:? 'tex[1]' ( uniform texture2D)
0:? '@entryPointOutput' ( out 4-component vector of float Position)
0:? 'pos' (layout( location=0) in 4-component vector of float)
Linked vertex stage:
Shader version: 500
0:? Sequence
0:10 Function Definition: @main(vf4; ( temp 4-component vector of float)
0:10 Function Parameters:
0:10 'pos' ( in 4-component vector of float)
0:? Sequence
0:13 Sequence
0:13 move second child to first child ( temp texture2D)
0:13 direct index ( temp texture2D)
0:? 'packed.membTex' ( temp 2-element array of texture2D)
0:13 Constant:
0:13 0 (const int)
0:? 'tex[0]' ( uniform texture2D)
0:13 move second child to first child ( temp texture2D)
0:13 direct index ( temp texture2D)
0:? 'packed.membTex' ( temp 2-element array of texture2D)
0:13 Constant:
0:13 1 (const int)
0:? 'tex[1]' ( uniform texture2D)
0:15 Branch: Return with expression
0:15 'pos' ( in 4-component vector of float)
0:10 Function Definition: main( ( temp void)
0:10 Function Parameters:
0:? Sequence
0:10 move second child to first child ( temp 4-component vector of float)
0:? 'pos' ( temp 4-component vector of float)
0:? 'pos' (layout( location=0) in 4-component vector of float)
0:10 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' ( out 4-component vector of float Position)
0:10 Function Call: @main(vf4; ( temp 4-component vector of float)
0:? 'pos' ( temp 4-component vector of float)
0:? Linker Objects
0:? 'tex[0]' ( uniform texture2D)
0:? 'tex[1]' ( uniform texture2D)
0:? '@entryPointOutput' ( out 4-component vector of float Position)
0:? 'pos' (layout( location=0) in 4-component vector of float)
// Module Version 10000
// Generated by (magic number): 80002
// Id's are bound by 42
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 35 38
Source HLSL 500
Name 4 "main"
Name 11 "@main(vf4;"
Name 10 "pos"
Name 18 "packed.membTex"
Name 22 "tex[0]"
Name 27 "tex[1]"
Name 33 "pos"
Name 35 "pos"
Name 38 "@entryPointOutput"
Name 39 "param"
Decorate 22(tex[0]) DescriptorSet 0
Decorate 27(tex[1]) DescriptorSet 0
Decorate 35(pos) Location 0
Decorate 38(@entryPointOutput) BuiltIn Position
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4)
9: TypeFunction 7(fvec4) 8(ptr)
13: TypeImage 6(float) 2D sampled format:Unknown
14: TypeInt 32 0
15: 14(int) Constant 2
16: TypeArray 13 15
17: TypePointer Function 16
19: TypeInt 32 1
20: 19(int) Constant 0
21: TypePointer UniformConstant 13
22(tex[0]): 21(ptr) Variable UniformConstant
24: TypePointer Function 13
26: 19(int) Constant 1
27(tex[1]): 21(ptr) Variable UniformConstant
34: TypePointer Input 7(fvec4)
35(pos): 34(ptr) Variable Input
37: TypePointer Output 7(fvec4)
38(@entryPointOutput): 37(ptr) Variable Output
4(main): 2 Function None 3
5: Label
33(pos): 8(ptr) Variable Function
39(param): 8(ptr) Variable Function
36: 7(fvec4) Load 35(pos)
Store 33(pos) 36
40: 7(fvec4) Load 33(pos)
Store 39(param) 40
41: 7(fvec4) FunctionCall 11(@main(vf4;) 39(param)
Store 38(@entryPointOutput) 41
Return
FunctionEnd
11(@main(vf4;): 7(fvec4) Function None 9
10(pos): 8(ptr) FunctionParameter
12: Label
18(packed.membTex): 17(ptr) Variable Function
23: 13 Load 22(tex[0])
25: 24(ptr) AccessChain 18(packed.membTex) 20
Store 25 23
28: 13 Load 27(tex[1])
29: 24(ptr) AccessChain 18(packed.membTex) 26
Store 29 28
30: 7(fvec4) Load 10(pos)
ReturnValue 30
FunctionEnd
...@@ -434,7 +434,6 @@ gl_FragCoord origin is upper left ...@@ -434,7 +434,6 @@ gl_FragCoord origin is upper left
// Id's are bound by 204 // Id's are bound by 204
Capability Shader Capability Shader
Capability StorageImageMultisample
Capability InputAttachment Capability InputAttachment
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
......
invalidSwizzle.vert
ERROR: 0:6: 'xx' : does not apply to this type: global void
ERROR: 0:7: 'xy' : does not apply to this type: global void
ERROR: 2 compilation errors. No code generated.
Shader version: 420
ERROR: node is still EOpNull!
0:5 Function Definition: main( ( global void)
0:5 Function Parameters:
0:6 Sequence
0:6 Function Call: f( ( global void)
0:7 Function Call: f( ( global void)
0:? Linker Objects
0:? 'gl_VertexID' ( gl_VertexId int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)
Linked vertex stage:
ERROR: Linking vertex stage: No function definition (body) found:
f(
Shader version: 420
ERROR: node is still EOpNull!
0:5 Function Definition: main( ( global void)
0:5 Function Parameters:
0:6 Sequence
0:6 Function Call: f( ( global void)
0:7 Function Call: f( ( global void)
0:? Linker Objects
0:? 'gl_VertexID' ( gl_VertexId int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)
spv.precisionNonESSamp.frag
// Module Version 10000
// Generated by (magic number): 80002
// Id's are bound by 47
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 9 17 27 39
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
Name 4 "main"
Name 9 "color"
Name 13 "s"
Name 17 "v2"
Name 23 "t"
Name 27 "v3"
Name 31 "vi1"
Name 34 "i1"
Name 39 "iv2"
Name 42 "vi2"
Name 43 "i2"
Decorate 9(color) RelaxedPrecision
Decorate 9(color) Location 0
Decorate 13(s) RelaxedPrecision
Decorate 13(s) DescriptorSet 0
Decorate 14 RelaxedPrecision
Decorate 17(v2) RelaxedPrecision
Decorate 17(v2) Location 0
Decorate 18 RelaxedPrecision
Decorate 19 RelaxedPrecision
Decorate 23(t) DescriptorSet 0
Decorate 27(v3) RelaxedPrecision
Decorate 27(v3) Location 1
Decorate 28 RelaxedPrecision
Decorate 31(vi1) RelaxedPrecision
Decorate 34(i1) RelaxedPrecision
Decorate 34(i1) DescriptorSet 0
Decorate 35 RelaxedPrecision
Decorate 39(iv2) RelaxedPrecision
Decorate 39(iv2) Flat
Decorate 39(iv2) Location 3
Decorate 40 RelaxedPrecision
Decorate 41 RelaxedPrecision
Decorate 42(vi2) RelaxedPrecision
Decorate 43(i2) DescriptorSet 0
Decorate 45 RelaxedPrecision
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Output 7(fvec4)
9(color): 8(ptr) Variable Output
10: TypeImage 6(float) 2D sampled format:Unknown
11: TypeSampledImage 10
12: TypePointer UniformConstant 11
13(s): 12(ptr) Variable UniformConstant
15: TypeVector 6(float) 2
16: TypePointer Input 15(fvec2)
17(v2): 16(ptr) Variable Input
20: TypeImage 6(float) 3D sampled format:Unknown
21: TypeSampledImage 20
22: TypePointer UniformConstant 21
23(t): 22(ptr) Variable UniformConstant
25: TypeVector 6(float) 3
26: TypePointer Input 25(fvec3)
27(v3): 26(ptr) Variable Input
30: TypePointer Function 7(fvec4)
32: TypeImage 6(float) 2D nonsampled format:Rgba32f
33: TypePointer UniformConstant 32
34(i1): 33(ptr) Variable UniformConstant
36: TypeInt 32 1
37: TypeVector 36(int) 2
38: TypePointer Input 37(ivec2)
39(iv2): 38(ptr) Variable Input
43(i2): 33(ptr) Variable UniformConstant
4(main): 2 Function None 3
5: Label
31(vi1): 30(ptr) Variable Function
42(vi2): 30(ptr) Variable Function
14: 11 Load 13(s)
18: 15(fvec2) Load 17(v2)
19: 7(fvec4) ImageSampleImplicitLod 14 18
Store 9(color) 19
24: 21 Load 23(t)
28: 25(fvec3) Load 27(v3)
29: 7(fvec4) ImageSampleImplicitLod 24 28
Store 9(color) 29
35: 32 Load 34(i1)
40: 37(ivec2) Load 39(iv2)
41: 7(fvec4) ImageRead 35 40
Store 31(vi1) 41
44: 32 Load 43(i2)
45: 37(ivec2) Load 39(iv2)
46: 7(fvec4) ImageRead 44 45
Store 42(vi2) 46
Return
FunctionEnd
...@@ -4,7 +4,6 @@ spv.register.subpass.frag ...@@ -4,7 +4,6 @@ spv.register.subpass.frag
// Id's are bound by 40 // Id's are bound by 40
Capability Shader Capability Shader
Capability StorageImageMultisample
Capability InputAttachment Capability InputAttachment
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
......
...@@ -4,7 +4,6 @@ spv.shaderFragMaskAMD.frag ...@@ -4,7 +4,6 @@ spv.shaderFragMaskAMD.frag
// Id's are bound by 80 // Id's are bound by 80
Capability Shader Capability Shader
Capability StorageImageMultisample
Capability InputAttachment Capability InputAttachment
Capability FragmentMaskAMD Capability FragmentMaskAMD
Extension "SPV_AMD_shader_fragment_mask" Extension "SPV_AMD_shader_fragment_mask"
......
...@@ -4,7 +4,6 @@ spv.subpass.frag ...@@ -4,7 +4,6 @@ spv.subpass.frag
// Id's are bound by 67 // Id's are bound by 67
Capability Shader Capability Shader
Capability StorageImageMultisample
Capability InputAttachment Capability InputAttachment
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
......
#ifdef O
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#if
#endif
#if (-2147483648 / -1) != 0
#error INT_MIN / -1 should yield 0, something went wrong.
#endif
\ No newline at end of file
[[vk::global_cbuffer_binding(5, 2)]]
float4 u1;
float4 u2;
float4 main() : SV_Target0
{
return u1 + u2;
}
\ No newline at end of file
...@@ -31,6 +31,7 @@ float PixelShaderFunctionS(float inF0, float inF1, float inF2, uint inU0, uint i ...@@ -31,6 +31,7 @@ float PixelShaderFunctionS(float inF0, float inF1, float inF2, uint inU0, uint i
float r011 = ceil(inF0); float r011 = ceil(inF0);
float r012 = clamp(inF0, inF1, inF2); float r012 = clamp(inF0, inF1, inF2);
clip(inF0); clip(inF0);
clip(r005);
float r014 = cos(inF0); float r014 = cos(inF0);
float r015 = cosh(inF0); float r015 = cosh(inF0);
int r016 = countbits(7); int r016 = countbits(7);
...@@ -108,6 +109,7 @@ float2 PixelShaderFunction2(float2 inF0, float2 inF1, float2 inF2, uint2 inU0, u ...@@ -108,6 +109,7 @@ float2 PixelShaderFunction2(float2 inF0, float2 inF1, float2 inF2, uint2 inU0, u
float2 r011 = ceil(inF0); float2 r011 = ceil(inF0);
float2 r012 = clamp(inF0, inF1, inF2); float2 r012 = clamp(inF0, inF1, inF2);
clip(inF0); clip(inF0);
clip(inU0);
float2 r013 = cos(inF0); float2 r013 = cos(inF0);
float2 r015 = cosh(inF0); float2 r015 = cosh(inF0);
int2 r016 = countbits(int2(7,3)); int2 r016 = countbits(int2(7,3));
...@@ -190,6 +192,7 @@ float3 PixelShaderFunction3(float3 inF0, float3 inF1, float3 inF2, uint3 inU0, u ...@@ -190,6 +192,7 @@ float3 PixelShaderFunction3(float3 inF0, float3 inF1, float3 inF2, uint3 inU0, u
float3 r011 = ceil(inF0); float3 r011 = ceil(inF0);
float3 r012 = clamp(inF0, inF1, inF2); float3 r012 = clamp(inF0, inF1, inF2);
clip(inF0); clip(inF0);
clip(inU0);
float3 r013 = cos(inF0); float3 r013 = cos(inF0);
float3 r014 = cosh(inF0); float3 r014 = cosh(inF0);
uint3 r015 = countbits(uint3(7,3,5)); uint3 r015 = countbits(uint3(7,3,5));
...@@ -271,6 +274,7 @@ float4 PixelShaderFunction(float4 inF0, float4 inF1, float4 inF2, uint4 inU0, ui ...@@ -271,6 +274,7 @@ float4 PixelShaderFunction(float4 inF0, float4 inF1, float4 inF2, uint4 inU0, ui
float4 r011 = ceil(inF0); float4 r011 = ceil(inF0);
float4 r012 = clamp(inF0, inF1, inF2); float4 r012 = clamp(inF0, inF1, inF2);
clip(inF0); clip(inF0);
clip(inU0);
float4 r013 = cos(inF0); float4 r013 = cos(inF0);
float4 r014 = cosh(inF0); float4 r014 = cosh(inF0);
uint4 r015 = countbits(uint4(7,3,5,2)); uint4 r015 = countbits(uint4(7,3,5,2));
......
Texture2D tex;
struct Packed {
Texture2D tex;
float3 pos[3];
float2 uv[2];
float x;
int n;
};
float4 main(float4 pos : POSITION) : SV_POSITION
{
Packed packed;
packed.tex = tex;
packed.pos[0] = float3(0, 0, 0);
packed.uv[0] = float2(0, 1);
packed.x = 1.0;
packed.n = 3;
for (int i = 0; i < 1; ++i) {
packed.pos[i].xy += packed.uv[i];
}
Packed packed2 = packed;
return pos + float4(packed2.pos[0], 0);
}
\ No newline at end of file
Texture2D tex[2];
struct Packed {
int a;
Texture2D membTex[2];
int b;
};
float4 main(float4 pos : POSITION) : SV_POSITION
{
Packed packed;
packed.membTex = tex;
return pos;
}
\ No newline at end of file
#version 420
void f();
void main() {
f().xx; // Scalar swizzle does not apply to void
f().xy; // Vector swizzle does not apply either
}
\ No newline at end of file
#version 450
precision lowp sampler2D;
precision lowp int;
precision lowp float;
uniform lowp sampler2D s;
uniform highp sampler3D t;
layout(rgba32f) uniform lowp image2D i1;
layout(rgba32f) uniform highp image2D i2;
layout(location = 0) in lowp vec2 v2;
layout(location = 1) in lowp vec3 v3;
layout(location = 3) flat in lowp ivec2 iv2;
layout(location = 0) out lowp vec4 color;
void main()
{
color = texture(s, v2);
color = texture(t, v3);
lowp vec4 vi1 = imageLoad(i1, iv2);
lowp vec4 vi2 = imageLoad(i2, iv2);
}
...@@ -944,6 +944,7 @@ class TIntermBranch; ...@@ -944,6 +944,7 @@ class TIntermBranch;
class TIntermTyped; class TIntermTyped;
class TIntermMethod; class TIntermMethod;
class TIntermSymbol; class TIntermSymbol;
class TIntermLoop;
} // end namespace glslang } // end namespace glslang
...@@ -971,6 +972,7 @@ public: ...@@ -971,6 +972,7 @@ public:
virtual glslang::TIntermMethod* getAsMethodNode() { return 0; } virtual glslang::TIntermMethod* getAsMethodNode() { return 0; }
virtual glslang::TIntermSymbol* getAsSymbolNode() { return 0; } virtual glslang::TIntermSymbol* getAsSymbolNode() { return 0; }
virtual glslang::TIntermBranch* getAsBranchNode() { return 0; } virtual glslang::TIntermBranch* getAsBranchNode() { return 0; }
virtual glslang::TIntermLoop* getAsLoopNode() { return 0; }
virtual const glslang::TIntermTyped* getAsTyped() const { return 0; } virtual const glslang::TIntermTyped* getAsTyped() const { return 0; }
virtual const glslang::TIntermOperator* getAsOperator() const { return 0; } virtual const glslang::TIntermOperator* getAsOperator() const { return 0; }
...@@ -983,6 +985,7 @@ public: ...@@ -983,6 +985,7 @@ public:
virtual const glslang::TIntermMethod* getAsMethodNode() const { return 0; } virtual const glslang::TIntermMethod* getAsMethodNode() const { return 0; }
virtual const glslang::TIntermSymbol* getAsSymbolNode() const { return 0; } virtual const glslang::TIntermSymbol* getAsSymbolNode() const { return 0; }
virtual const glslang::TIntermBranch* getAsBranchNode() const { return 0; } virtual const glslang::TIntermBranch* getAsBranchNode() const { return 0; }
virtual const glslang::TIntermLoop* getAsLoopNode() const { return 0; }
virtual ~TIntermNode() { } virtual ~TIntermNode() { }
protected: protected:
...@@ -1064,6 +1067,8 @@ public: ...@@ -1064,6 +1067,8 @@ public:
control(ELoopControlNone) control(ELoopControlNone)
{ } { }
virtual TIntermLoop* getAsLoopNode() { return this; }
virtual const TIntermLoop* getAsLoopNode() const { return this; }
virtual void traverse(TIntermTraverser*); virtual void traverse(TIntermTraverser*);
TIntermNode* getBody() const { return body; } TIntermNode* getBody() const { return body; }
TIntermTyped* getTest() const { return test; } TIntermTyped* getTest() const { return test; }
...@@ -1133,7 +1138,6 @@ public: ...@@ -1133,7 +1138,6 @@ public:
constSubtree(nullptr) constSubtree(nullptr)
{ name = n; } { name = n; }
virtual int getId() const { return id; } virtual int getId() const { return id; }
virtual void setId(int newId) { id = newId; }
virtual const TString& getName() const { return name; } virtual const TString& getName() const { return name; }
virtual void traverse(TIntermTraverser*); virtual void traverse(TIntermTraverser*);
virtual TIntermSymbol* getAsSymbolNode() { return this; } virtual TIntermSymbol* getAsSymbolNode() { return this; }
...@@ -1147,6 +1151,10 @@ public: ...@@ -1147,6 +1151,10 @@ public:
int getFlattenSubset() const { return flattenSubset; } // -1 means full object int getFlattenSubset() const { return flattenSubset; } // -1 means full object
#endif #endif
// This is meant for cases where a node has already been constructed, and
// later on, it becomes necessary to switch to a different symbol.
virtual void switchId(int newId) { id = newId; }
protected: protected:
int id; // the unique id of the symbol this node represents int id; // the unique id of the symbol this node represents
#ifdef ENABLE_HLSL #ifdef ENABLE_HLSL
......
...@@ -569,6 +569,10 @@ void TParseContextBase::growGlobalUniformBlock(const TSourceLoc& loc, TType& mem ...@@ -569,6 +569,10 @@ void TParseContextBase::growGlobalUniformBlock(const TSourceLoc& loc, TType& mem
firstNewMember = 0; firstNewMember = 0;
} }
// Update with binding and set
globalUniformBlock->getWritableType().getQualifier().layoutBinding = globalUniformBinding;
globalUniformBlock->getWritableType().getQualifier().layoutSet = globalUniformSet;
// Add the requested member as a member to the global block. // Add the requested member as a member to the global block.
TType* type = new TType; TType* type = new TType;
type->shallowCopy(memberType); type->shallowCopy(memberType);
......
...@@ -127,11 +127,6 @@ void TParseContext::setPrecisionDefaults() ...@@ -127,11 +127,6 @@ void TParseContext::setPrecisionDefaults()
sampler.set(EbtFloat, Esd2D); sampler.set(EbtFloat, Esd2D);
sampler.external = true; sampler.external = true;
defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow; defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
} else {
// Non-ES profile
// All default to highp.
for (int type = 0; type < maxSamplerIndex; ++type)
defaultSamplerPrecision[type] = EpqHigh;
} }
// If we are parsing built-in computational variables/functions, it is meaningful to record // If we are parsing built-in computational variables/functions, it is meaningful to record
...@@ -147,6 +142,13 @@ void TParseContext::setPrecisionDefaults() ...@@ -147,6 +142,13 @@ void TParseContext::setPrecisionDefaults()
defaultPrecision[EbtUint] = EpqHigh; defaultPrecision[EbtUint] = EpqHigh;
defaultPrecision[EbtFloat] = EpqHigh; defaultPrecision[EbtFloat] = EpqHigh;
} }
if (profile != EEsProfile) {
// Non-ES profile
// All sampler precisions default to highp.
for (int type = 0; type < maxSamplerIndex; ++type)
defaultSamplerPrecision[type] = EpqHigh;
}
} }
defaultPrecision[EbtSampler] = EpqLow; defaultPrecision[EbtSampler] = EpqLow;
...@@ -664,7 +666,7 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm ...@@ -664,7 +666,7 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
// leaving swizzles and struct/block dereferences. // leaving swizzles and struct/block dereferences.
TIntermTyped* result = base; TIntermTyped* result = base;
if (base->isVector() || base->isScalar()) { if (base->getBasicType() != EbtVoid && (base->isVector() || base->isScalar())) {
if (base->isScalar()) { if (base->isScalar()) {
const char* dotFeature = "scalar swizzle"; const char* dotFeature = "scalar swizzle";
requireProfile(loc, ~EEsProfile, dotFeature); requireProfile(loc, ~EEsProfile, dotFeature);
......
...@@ -84,7 +84,9 @@ public: ...@@ -84,7 +84,9 @@ public:
contextPragma(true, false), contextPragma(true, false),
parsingBuiltins(parsingBuiltins), scanContext(nullptr), ppContext(nullptr), parsingBuiltins(parsingBuiltins), scanContext(nullptr), ppContext(nullptr),
limits(resources.limits), limits(resources.limits),
globalUniformBlock(nullptr) globalUniformBlock(nullptr),
globalUniformBinding(TQualifier::layoutBindingEnd),
globalUniformSet(TQualifier::layoutSetEnd)
{ {
if (entryPoint != nullptr) if (entryPoint != nullptr)
sourceEntryPointName = *entryPoint; sourceEntryPointName = *entryPoint;
...@@ -208,8 +210,10 @@ protected: ...@@ -208,8 +210,10 @@ protected:
TSwizzleSelectors<TVectorSelector>&); TSwizzleSelectors<TVectorSelector>&);
// Manage the global uniform block (default uniforms in GLSL, $Global in HLSL) // Manage the global uniform block (default uniforms in GLSL, $Global in HLSL)
TVariable* globalUniformBlock; // the actual block, inserted into the symbol table TVariable* globalUniformBlock; // the actual block, inserted into the symbol table
int firstNewMember; // the index of the first member not yet inserted into the symbol table unsigned int globalUniformBinding; // the block's binding number
unsigned int globalUniformSet; // the block's set number
int firstNewMember; // the index of the first member not yet inserted into the symbol table
// override this to set the language-specific name // override this to set the language-specific name
virtual const char* getGlobalUniformBlockName() const { return ""; } virtual const char* getGlobalUniformBlockName() const { return ""; }
virtual void setUniformBlockDefaults(TType&) const { } virtual void setUniformBlockDefaults(TType&) const { }
......
...@@ -84,6 +84,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -84,6 +84,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <cctype> #include <cctype>
#include <climits>
#include "PpContext.h" #include "PpContext.h"
#include "PpTokens.h" #include "PpTokens.h"
...@@ -241,15 +242,20 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken) ...@@ -241,15 +242,20 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken)
int nextAtom = atomStrings.getAtom(ppToken->name); int nextAtom = atomStrings.getAtom(ppToken->name);
if (nextAtom == PpAtomIf || nextAtom == PpAtomIfdef || nextAtom == PpAtomIfndef) { if (nextAtom == PpAtomIf || nextAtom == PpAtomIfdef || nextAtom == PpAtomIfndef) {
depth++; depth++;
ifdepth++; if (ifdepth >= maxIfNesting || elsetracker >= maxIfNesting) {
elsetracker++; parseContext.ppError(ppToken->loc, "maximum nesting depth exceeded", "#if/#ifdef/#ifndef", "");
return EndOfInput;
} else {
ifdepth++;
elsetracker++;
}
} else if (nextAtom == PpAtomEndif) { } else if (nextAtom == PpAtomEndif) {
token = extraTokenCheck(nextAtom, ppToken, scanToken(ppToken)); token = extraTokenCheck(nextAtom, ppToken, scanToken(ppToken));
elseSeen[elsetracker] = false; elseSeen[elsetracker] = false;
--elsetracker; --elsetracker;
if (depth == 0) { if (depth == 0) {
// found the #endif we are looking for // found the #endif we are looking for
if (ifdepth) if (ifdepth > 0)
--ifdepth; --ifdepth;
break; break;
} }
...@@ -266,7 +272,7 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken) ...@@ -266,7 +272,7 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken)
parseContext.ppError(ppToken->loc, "#elif after #else", "#elif", ""); parseContext.ppError(ppToken->loc, "#elif after #else", "#elif", "");
/* we decrement ifdepth here, because CPPif will increment /* we decrement ifdepth here, because CPPif will increment
* it and we really want to leave it alone */ * it and we really want to leave it alone */
if (ifdepth) { if (ifdepth > 0) {
--ifdepth; --ifdepth;
elseSeen[elsetracker] = false; elseSeen[elsetracker] = false;
--elsetracker; --elsetracker;
...@@ -345,7 +351,7 @@ namespace { ...@@ -345,7 +351,7 @@ namespace {
int op_add(int a, int b) { return a + b; } int op_add(int a, int b) { return a + b; }
int op_sub(int a, int b) { return a - b; } int op_sub(int a, int b) { return a - b; }
int op_mul(int a, int b) { return a * b; } int op_mul(int a, int b) { return a * b; }
int op_div(int a, int b) { return a / b; } int op_div(int a, int b) { return a == INT_MIN && b == -1 ? 0 : a / b; }
int op_mod(int a, int b) { return a % b; } int op_mod(int a, int b) { return a % b; }
int op_pos(int a) { return a; } int op_pos(int a) { return a; }
int op_neg(int a) { return -a; } int op_neg(int a) { return -a; }
...@@ -536,11 +542,12 @@ int TPpContext::evalToToken(int token, bool shortCircuit, int& res, bool& err, T ...@@ -536,11 +542,12 @@ int TPpContext::evalToToken(int token, bool shortCircuit, int& res, bool& err, T
int TPpContext::CPPif(TPpToken* ppToken) int TPpContext::CPPif(TPpToken* ppToken)
{ {
int token = scanToken(ppToken); int token = scanToken(ppToken);
elsetracker++; if (ifdepth >= maxIfNesting || elsetracker >= maxIfNesting) {
ifdepth++;
if (ifdepth > maxIfNesting) {
parseContext.ppError(ppToken->loc, "maximum nesting depth exceeded", "#if", ""); parseContext.ppError(ppToken->loc, "maximum nesting depth exceeded", "#if", "");
return 0; return EndOfInput;
} else {
elsetracker++;
ifdepth++;
} }
int res = 0; int res = 0;
bool err = false; bool err = false;
...@@ -556,11 +563,14 @@ int TPpContext::CPPif(TPpToken* ppToken) ...@@ -556,11 +563,14 @@ int TPpContext::CPPif(TPpToken* ppToken)
int TPpContext::CPPifdef(int defined, TPpToken* ppToken) int TPpContext::CPPifdef(int defined, TPpToken* ppToken)
{ {
int token = scanToken(ppToken); int token = scanToken(ppToken);
if (++ifdepth > maxIfNesting) { if (ifdepth > maxIfNesting || elsetracker > maxIfNesting) {
parseContext.ppError(ppToken->loc, "maximum nesting depth exceeded", "#ifdef", ""); parseContext.ppError(ppToken->loc, "maximum nesting depth exceeded", "#ifdef", "");
return 0; return EndOfInput;
} else {
elsetracker++;
ifdepth++;
} }
elsetracker++;
if (token != PpAtomIdentifier) { if (token != PpAtomIdentifier) {
if (defined) if (defined)
parseContext.ppError(ppToken->loc, "must be followed by macro name", "#ifdef", ""); parseContext.ppError(ppToken->loc, "must be followed by macro name", "#ifdef", "");
...@@ -882,16 +892,16 @@ int TPpContext::readCPPline(TPpToken* ppToken) ...@@ -882,16 +892,16 @@ int TPpContext::readCPPline(TPpToken* ppToken)
token = CPPdefine(ppToken); token = CPPdefine(ppToken);
break; break;
case PpAtomElse: case PpAtomElse:
if (elsetracker[elseSeen]) if (elseSeen[elsetracker])
parseContext.ppError(ppToken->loc, "#else after #else", "#else", ""); parseContext.ppError(ppToken->loc, "#else after #else", "#else", "");
elsetracker[elseSeen] = true; elseSeen[elsetracker] = true;
if (! ifdepth) if (ifdepth == 0)
parseContext.ppError(ppToken->loc, "mismatched statements", "#else", ""); parseContext.ppError(ppToken->loc, "mismatched statements", "#else", "");
token = extraTokenCheck(PpAtomElse, ppToken, scanToken(ppToken)); token = extraTokenCheck(PpAtomElse, ppToken, scanToken(ppToken));
token = CPPelse(0, ppToken); token = CPPelse(0, ppToken);
break; break;
case PpAtomElif: case PpAtomElif:
if (! ifdepth) if (ifdepth == 0)
parseContext.ppError(ppToken->loc, "mismatched statements", "#elif", ""); parseContext.ppError(ppToken->loc, "mismatched statements", "#elif", "");
if (elseSeen[elsetracker]) if (elseSeen[elsetracker])
parseContext.ppError(ppToken->loc, "#elif after #else", "#elif", ""); parseContext.ppError(ppToken->loc, "#elif after #else", "#elif", "");
...@@ -902,7 +912,7 @@ int TPpContext::readCPPline(TPpToken* ppToken) ...@@ -902,7 +912,7 @@ int TPpContext::readCPPline(TPpToken* ppToken)
token = CPPelse(0, ppToken); token = CPPelse(0, ppToken);
break; break;
case PpAtomEndif: case PpAtomEndif:
if (! ifdepth) if (ifdepth == 0)
parseContext.ppError(ppToken->loc, "mismatched statements", "#endif", ""); parseContext.ppError(ppToken->loc, "mismatched statements", "#endif", "");
else { else {
elseSeen[elsetracker] = false; elseSeen[elsetracker] = false;
......
...@@ -309,7 +309,7 @@ protected: ...@@ -309,7 +309,7 @@ protected:
bool endOfReplacementList() { return inputStack.empty() || inputStack.back()->endOfReplacementList(); } bool endOfReplacementList() { return inputStack.empty() || inputStack.back()->endOfReplacementList(); }
bool isMacroInput() { return inputStack.size() > 0 && inputStack.back()->isMacroInput(); } bool isMacroInput() { return inputStack.size() > 0 && inputStack.back()->isMacroInput(); }
static const int maxIfNesting = 64; static const int maxIfNesting = 65;
int ifdepth; // current #if-#else-#endif nesting in the cpp.c file (pre-processor) int ifdepth; // current #if-#else-#endif nesting in the cpp.c file (pre-processor)
bool elseSeen[maxIfNesting]; // Keep a track of whether an else has been seen at a particular depth bool elseSeen[maxIfNesting]; // Keep a track of whether an else has been seen at a particular depth
......
...@@ -493,8 +493,8 @@ public: ...@@ -493,8 +493,8 @@ public:
const char* getInfoLog(); const char* getInfoLog();
const char* getInfoDebugLog(); const char* getInfoDebugLog();
EShLanguage getStage() const { return stage; } EShLanguage getStage() const { return stage; }
TIntermediate* getIntermediate() const { return intermediate; }
protected: protected:
TPoolAllocator* pool; TPoolAllocator* pool;
......
...@@ -78,10 +78,12 @@ INSTANTIATE_TEST_CASE_P( ...@@ -78,10 +78,12 @@ INSTANTIATE_TEST_CASE_P(
"matrixError.vert", "matrixError.vert",
"cppSimple.vert", "cppSimple.vert",
"cppIndent.vert", "cppIndent.vert",
"cppIntMinOverNegativeOne.frag",
"cppNest.vert", "cppNest.vert",
"cppBad.vert", "cppBad.vert",
"cppBad2.vert", "cppBad2.vert",
"cppComplexExpr.vert", "cppComplexExpr.vert",
"cppDeepNest.frag",
"badChars.frag", "badChars.frag",
"pointCoord.frag", "pointCoord.frag",
"array.frag", "array.frag",
...@@ -187,6 +189,7 @@ INSTANTIATE_TEST_CASE_P( ...@@ -187,6 +189,7 @@ INSTANTIATE_TEST_CASE_P(
"structDeref.frag", "structDeref.frag",
"structure.frag", "structure.frag",
"swizzle.frag", "swizzle.frag",
"invalidSwizzle.vert",
"syntaxError.frag", "syntaxError.frag",
"test.frag", "test.frag",
"texture.frag", "texture.frag",
......
...@@ -100,6 +100,7 @@ INSTANTIATE_TEST_CASE_P( ...@@ -100,6 +100,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.attribute.frag", "PixelShaderFunction"}, {"hlsl.attribute.frag", "PixelShaderFunction"},
{"hlsl.attribute.expression.comp", "main"}, {"hlsl.attribute.expression.comp", "main"},
{"hlsl.attributeC11.frag", "main"}, {"hlsl.attributeC11.frag", "main"},
{"hlsl.attributeGlobalBuffer.frag", "main"},
{"hlsl.basic.comp", "main"}, {"hlsl.basic.comp", "main"},
{"hlsl.basic.geom", "main"}, {"hlsl.basic.geom", "main"},
{"hlsl.boolConv.vert", "main"}, {"hlsl.boolConv.vert", "main"},
...@@ -247,6 +248,7 @@ INSTANTIATE_TEST_CASE_P( ...@@ -247,6 +248,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.params.default.frag", "main"}, {"hlsl.params.default.frag", "main"},
{"hlsl.params.default.negative.frag", "main"}, {"hlsl.params.default.negative.frag", "main"},
{"hlsl.partialInit.frag", "PixelShaderFunction"}, {"hlsl.partialInit.frag", "PixelShaderFunction"},
{"hlsl.partialFlattenLocal.vert", "main"},
{"hlsl.pp.vert", "main"}, {"hlsl.pp.vert", "main"},
{"hlsl.pp.line.frag", "main"}, {"hlsl.pp.line.frag", "main"},
{"hlsl.precise.frag", "main"}, {"hlsl.precise.frag", "main"},
...@@ -378,6 +380,7 @@ INSTANTIATE_TEST_CASE_P( ...@@ -378,6 +380,7 @@ INSTANTIATE_TEST_CASE_P(
ToSpirv, HlslCompileAndFlattenTest, ToSpirv, HlslCompileAndFlattenTest,
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{ ::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
{"hlsl.array.flatten.frag", "main"}, {"hlsl.array.flatten.frag", "main"},
{"hlsl.partialFlattenMixed.vert", "main"},
}), }),
FileNameAsCustomTestSuffix FileNameAsCustomTestSuffix
); );
......
...@@ -277,6 +277,7 @@ INSTANTIATE_TEST_CASE_P( ...@@ -277,6 +277,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.Operations.frag", "spv.Operations.frag",
"spv.paramMemory.frag", "spv.paramMemory.frag",
"spv.precision.frag", "spv.precision.frag",
"spv.precisionNonESSamp.frag",
"spv.prepost.frag", "spv.prepost.frag",
"spv.qualifiers.vert", "spv.qualifiers.vert",
"spv.sampleMaskOverrideCoverage.frag", "spv.sampleMaskOverrideCoverage.frag",
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "hlslAttributes.h" #include "hlslAttributes.h"
#include <cstdlib> #include <cstdlib>
#include <cctype> #include <cctype>
#include <algorithm>
namespace glslang { namespace glslang {
// Map the given string to an attribute enum from TAttributeType, // Map the given string to an attribute enum from TAttributeType,
...@@ -57,6 +58,8 @@ namespace glslang { ...@@ -57,6 +58,8 @@ namespace glslang {
return EatLocation; return EatLocation;
else if (lowername == "binding") else if (lowername == "binding")
return EatBinding; return EatBinding;
else if (lowername == "global_cbuffer_binding")
return EatGlobalBinding;
} else if (lowernameSpace.size() > 0) } else if (lowernameSpace.size() > 0)
return EatNone; return EatNone;
...@@ -131,4 +134,51 @@ namespace glslang { ...@@ -131,4 +134,51 @@ namespace glslang {
return attributes.find(attr) != attributes.end(); return attributes.find(attr) != attributes.end();
} }
// extract integers out of attribute arguments stored in attribute aggregate
bool TAttributeMap::getInt(TAttributeType attr, int& value, int argNum) const
{
const TConstUnion* intConst = getConstUnion(attr, EbtInt, argNum);
if (intConst == nullptr)
return false;
value = intConst->getIConst();
return true;
};
// extract strings out of attribute arguments stored in attribute aggregate.
// convert to lower case if converToLower is true (for case-insensitive compare convenience)
bool TAttributeMap::getString(TAttributeType attr, TString& value, int argNum, bool convertToLower) const
{
const TConstUnion* stringConst = getConstUnion(attr, EbtString, argNum);
if (stringConst == nullptr)
return false;
value = *stringConst->getSConst();
// Convenience.
if (convertToLower)
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
return true;
};
// Helper to get attribute const union. Returns nullptr on failure.
const TConstUnion* TAttributeMap::getConstUnion(TAttributeType attr, TBasicType basicType, int argNum) const
{
const TIntermAggregate* attrAgg = (*this)[attr];
if (attrAgg == nullptr)
return nullptr;
if (argNum >= int(attrAgg->getSequence().size()))
return nullptr;
const TConstUnion* constVal = &attrAgg->getSequence()[argNum]->getAsConstantUnion()->getConstArray()[0];
if (constVal == nullptr || constVal->getType() != basicType)
return nullptr;
return constVal;
}
} // end namespace glslang } // end namespace glslang
...@@ -64,6 +64,7 @@ namespace glslang { ...@@ -64,6 +64,7 @@ namespace glslang {
EatUnroll, EatUnroll,
EatLoop, EatLoop,
EatBinding, EatBinding,
EatGlobalBinding,
EatLocation, EatLocation,
EatInputAttachment EatInputAttachment
}; };
...@@ -93,7 +94,16 @@ namespace glslang { ...@@ -93,7 +94,16 @@ namespace glslang {
// True if entry exists in map (even if value is nullptr) // True if entry exists in map (even if value is nullptr)
bool contains(TAttributeType) const; bool contains(TAttributeType) const;
// Obtain attribute as integer
bool getInt(TAttributeType attr, int& value, int argNum = 0) const;
// Obtain attribute as string, with optional to-lower transform
bool getString(TAttributeType attr, TString& value, int argNum = 0, bool convertToLower = true) const;
protected: protected:
// Helper to get attribute const union
const TConstUnion* getConstUnion(TAttributeType attr, TBasicType, int argNum) const;
// Find an attribute enum given its name. // Find an attribute enum given its name.
static TAttributeType attributeFromName(const TString& nameSpace, const TString& name); static TAttributeType attributeFromName(const TString& nameSpace, const TString& name);
......
...@@ -187,7 +187,8 @@ public: ...@@ -187,7 +187,8 @@ public:
void pushSwitchSequence(TIntermSequence* sequence) { switchSequenceStack.push_back(sequence); } void pushSwitchSequence(TIntermSequence* sequence) { switchSequenceStack.push_back(sequence); }
void popSwitchSequence() { switchSequenceStack.pop_back(); } void popSwitchSequence() { switchSequenceStack.pop_back(); }
virtual void growGlobalUniformBlock(const TSourceLoc&, TType&, const TString& memberName, TTypeList* typeList = nullptr) override; virtual void growGlobalUniformBlock(const TSourceLoc&, TType&, const TString& memberName,
TTypeList* typeList = nullptr) override;
// Apply L-value conversions. E.g, turning a write to a RWTexture into an ImageStore. // Apply L-value conversions. E.g, turning a write to a RWTexture into an ImageStore.
TIntermTyped* handleLvalue(const TSourceLoc&, const char* op, TIntermTyped*& node); TIntermTyped* handleLvalue(const TSourceLoc&, const char* op, TIntermTyped*& node);
...@@ -244,15 +245,14 @@ protected: ...@@ -244,15 +245,14 @@ protected:
// Array and struct flattening // Array and struct flattening
TIntermTyped* flattenAccess(TIntermTyped* base, int member); TIntermTyped* flattenAccess(TIntermTyped* base, int member);
TIntermTyped* flattenAccess(int uniqueId, int member, const TType&, int subset = -1); TIntermTyped* flattenAccess(int uniqueId, int member, TStorageQualifier outerStorage, const TType&, int subset = -1);
int findSubtreeOffset(const TIntermNode&) const; int findSubtreeOffset(const TIntermNode&) const;
int findSubtreeOffset(const TType&, int subset, const TVector<int>& offsets) const; int findSubtreeOffset(const TType&, int subset, const TVector<int>& offsets) const;
bool shouldFlatten(const TType&) const; bool shouldFlatten(const TType&, TStorageQualifier, bool topLevel) const;
bool wasFlattened(const TIntermTyped* node) const; bool wasFlattened(const TIntermTyped* node) const;
bool wasFlattened(int id) const { return flattenMap.find(id) != flattenMap.end(); } bool wasFlattened(int id) const { return flattenMap.find(id) != flattenMap.end(); }
int addFlattenedMember(const TVariable&, const TType&, TFlattenData&, const TString& name, bool linkage, int addFlattenedMember(const TVariable&, const TType&, TFlattenData&, const TString& name, bool linkage,
const TQualifier& outerQualifier, const TArraySizes* builtInArraySizes); const TQualifier& outerQualifier, const TArraySizes* builtInArraySizes);
bool isFinalFlattening(const TType& type) const { return !(type.isStruct() || type.isArray()); }
// Structure splitting (splits interstage built-in types into its own struct) // Structure splitting (splits interstage built-in types into its own struct)
void split(const TVariable&); void split(const TVariable&);
......
...@@ -569,8 +569,8 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c ...@@ -569,8 +569,8 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
unsigned int stage; // stage mask unsigned int stage; // stage mask
bool method; // true if it's a method. bool method; // true if it's a method.
} hlslIntrinsics[] = { } hlslIntrinsics[] = {
// name retOrd retType argOrder argType stage mask // name retOrd retType argOrder argType stage mask method
// ----------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
{ "abort", nullptr, nullptr, "-", "-", EShLangAll, false }, { "abort", nullptr, nullptr, "-", "-", EShLangAll, false },
{ "abs", nullptr, nullptr, "SVM", "DFUI", EShLangAll, false }, { "abs", nullptr, nullptr, "SVM", "DFUI", EShLangAll, false },
{ "acos", nullptr, nullptr, "SVM", "F", EShLangAll, false }, { "acos", nullptr, nullptr, "SVM", "F", EShLangAll, false },
...@@ -589,7 +589,7 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c ...@@ -589,7 +589,7 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
{ "ceil", nullptr, nullptr, "SVM", "F", EShLangAll, false }, { "ceil", nullptr, nullptr, "SVM", "F", EShLangAll, false },
{ "CheckAccessFullyMapped", "S", "B" , "S", "U", EShLangPSCS, false }, { "CheckAccessFullyMapped", "S", "B" , "S", "U", EShLangPSCS, false },
{ "clamp", nullptr, nullptr, "SVM,,", "FUI,,", EShLangAll, false }, { "clamp", nullptr, nullptr, "SVM,,", "FUI,,", EShLangAll, false },
{ "clip", "-", "-", "SVM", "F", EShLangPS, false }, { "clip", "-", "-", "SVM", "FUI", EShLangPS, false },
{ "cos", nullptr, nullptr, "SVM", "F", EShLangAll, false }, { "cos", nullptr, nullptr, "SVM", "F", EShLangAll, false },
{ "cosh", nullptr, nullptr, "SVM", "F", EShLangAll, false }, { "cosh", nullptr, nullptr, "SVM", "F", EShLangAll, false },
{ "countbits", nullptr, nullptr, "SV", "UI", EShLangAll, false }, { "countbits", nullptr, nullptr, "SV", "UI", EShLangAll, false },
......
...@@ -5,14 +5,14 @@ ...@@ -5,14 +5,14 @@
"site" : "github", "site" : "github",
"subrepo" : "KhronosGroup/SPIRV-Tools", "subrepo" : "KhronosGroup/SPIRV-Tools",
"subdir" : "External/spirv-tools", "subdir" : "External/spirv-tools",
"commit" : "99cd25c4139e0dc914ab8a5a3b75e6fed0ad1329" "commit" : "1a9061a2be884eed0e518ac19866246a5c9babc0"
}, },
{ {
"name" : "spirv-tools/external/spirv-headers", "name" : "spirv-tools/external/spirv-headers",
"site" : "github", "site" : "github",
"subrepo" : "KhronosGroup/SPIRV-Headers", "subrepo" : "KhronosGroup/SPIRV-Headers",
"subdir" : "External/spirv-tools/external/spirv-headers", "subdir" : "External/spirv-tools/external/spirv-headers",
"commit" : "2bb92e6fe2c6aa410152fc6c63443f452acb1a65" "commit" : "061097878467b8e040fbf153a837d844ef9f9f96"
} }
] ]
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment