Updated glslang.

This commit is contained in:
Branimir Karadžić 2018-10-01 20:01:14 -07:00
parent 50a64a7fdf
commit 474f6e1472
20 changed files with 1654 additions and 1133 deletions

165
3rdparty/glslang/BUILD.gn vendored Normal file
View File

@ -0,0 +1,165 @@
# Copyright (C) 2018 Google, Inc.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
#
# Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
import("//build_overrides/glslang.gni")
spirv_tools_dir = glslang_spirv_tools_dir
config("glslang_public") {
include_dirs = [ "." ]
}
source_set("glslang_sources") {
sources = [
"OGLCompilersDLL/InitializeDll.cpp",
"OGLCompilersDLL/InitializeDll.h",
"SPIRV/GLSL.ext.EXT.h",
"SPIRV/GLSL.ext.KHR.h",
"SPIRV/GLSL.std.450.h",
"SPIRV/GlslangToSpv.cpp",
"SPIRV/GlslangToSpv.h",
"SPIRV/InReadableOrder.cpp",
"SPIRV/Logger.cpp",
"SPIRV/Logger.h",
"SPIRV/SPVRemapper.cpp",
"SPIRV/SPVRemapper.h",
"SPIRV/SpvBuilder.cpp",
"SPIRV/SpvBuilder.h",
"SPIRV/SpvPostProcess.cpp",
"SPIRV/SpvPostProcess.h",
"SPIRV/bitutils.h",
"SPIRV/disassemble.cpp",
"SPIRV/disassemble.h",
"SPIRV/doc.cpp",
"SPIRV/doc.h",
"SPIRV/hex_float.h",
"SPIRV/spirv.hpp",
"SPIRV/spvIR.h",
"glslang/GenericCodeGen/CodeGen.cpp",
"glslang/GenericCodeGen/Link.cpp",
"glslang/Include/BaseTypes.h",
"glslang/Include/Common.h",
"glslang/Include/ConstantUnion.h",
"glslang/Include/InfoSink.h",
"glslang/Include/InitializeGlobals.h",
"glslang/Include/PoolAlloc.h",
"glslang/Include/ResourceLimits.h",
"glslang/Include/ShHandle.h",
"glslang/Include/Types.h",
"glslang/Include/arrays.h",
"glslang/Include/intermediate.h",
"glslang/Include/revision.h",
"glslang/MachineIndependent/Constant.cpp",
"glslang/MachineIndependent/InfoSink.cpp",
"glslang/MachineIndependent/Initialize.cpp",
"glslang/MachineIndependent/Initialize.h",
"glslang/MachineIndependent/IntermTraverse.cpp",
"glslang/MachineIndependent/Intermediate.cpp",
"glslang/MachineIndependent/LiveTraverser.h",
"glslang/MachineIndependent/ParseContextBase.cpp",
"glslang/MachineIndependent/ParseHelper.cpp",
"glslang/MachineIndependent/ParseHelper.h",
"glslang/MachineIndependent/PoolAlloc.cpp",
"glslang/MachineIndependent/RemoveTree.cpp",
"glslang/MachineIndependent/RemoveTree.h",
"glslang/MachineIndependent/Scan.cpp",
"glslang/MachineIndependent/Scan.h",
"glslang/MachineIndependent/ScanContext.h",
"glslang/MachineIndependent/ShaderLang.cpp",
"glslang/MachineIndependent/SymbolTable.cpp",
"glslang/MachineIndependent/SymbolTable.h",
"glslang/MachineIndependent/Versions.cpp",
"glslang/MachineIndependent/Versions.h",
"glslang/MachineIndependent/attribute.cpp",
"glslang/MachineIndependent/attribute.h",
"glslang/MachineIndependent/gl_types.h",
"glslang/MachineIndependent/glslang.y",
"glslang/MachineIndependent/glslang_tab.cpp",
"glslang/MachineIndependent/glslang_tab.cpp.h",
"glslang/MachineIndependent/intermOut.cpp",
"glslang/MachineIndependent/iomapper.cpp",
"glslang/MachineIndependent/iomapper.h",
"glslang/MachineIndependent/limits.cpp",
"glslang/MachineIndependent/linkValidate.cpp",
"glslang/MachineIndependent/localintermediate.h",
"glslang/MachineIndependent/parseConst.cpp",
"glslang/MachineIndependent/parseVersions.h",
"glslang/MachineIndependent/preprocessor/Pp.cpp",
"glslang/MachineIndependent/preprocessor/PpAtom.cpp",
"glslang/MachineIndependent/preprocessor/PpContext.cpp",
"glslang/MachineIndependent/preprocessor/PpContext.h",
"glslang/MachineIndependent/preprocessor/PpScanner.cpp",
"glslang/MachineIndependent/preprocessor/PpTokens.cpp",
"glslang/MachineIndependent/preprocessor/PpTokens.h",
"glslang/MachineIndependent/propagateNoContraction.cpp",
"glslang/MachineIndependent/propagateNoContraction.h",
"glslang/MachineIndependent/reflection.cpp",
"glslang/MachineIndependent/reflection.h",
"glslang/OSDependent/osinclude.h",
"glslang/Public/ShaderLang.h",
]
defines = []
if (is_win) {
sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
} else {
sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
}
if (is_clang) {
cflags_cc = [
"-Wno-implicit-fallthrough",
"-Wno-ignored-qualifiers",
"-Wno-unused-variable",
]
}
deps = [
"${spirv_tools_dir}:spvtools_opt",
]
}
static_library("glslang_static") {
public_configs = [ ":glslang_public" ]
deps = [
":glslang_sources",
]
complete_static_lib = true
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}

View File

@ -631,7 +631,7 @@ Id Builder::getContainedTypeId(Id typeId) const
// Returns true if 'typeId' is or contains a scalar type declared with 'typeOp'
// of width 'width'. The 'width' is only consumed for int and float types.
// Returns false otherwise.
bool Builder::containsType(Id typeId, spv::Op typeOp, int width) const
bool Builder::containsType(Id typeId, spv::Op typeOp, unsigned int width) const
{
const Instruction& instr = *module.getInstruction(typeId);

View File

@ -131,10 +131,8 @@ public:
Id makeSamplerType();
Id makeSampledImageType(Id imageType);
#ifdef NV_EXTENSIONS
// accelerationStructureNV type
Id makeAccelerationStructureNVType();
#endif
// For querying about types.
Id getTypeId(Id resultId) const { return module.getTypeId(resultId); }
@ -172,7 +170,7 @@ public:
bool isImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeImage; }
bool isSamplerType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampler; }
bool isSampledImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampledImage; }
bool containsType(Id typeId, Op typeOp, int width) const;
bool containsType(Id typeId, Op typeOp, unsigned int width) const;
bool isConstantOpCode(Op opcode) const;
bool isSpecConstantOpCode(Op opcode) const;
@ -371,10 +369,8 @@ public:
Id component;
Id texelOut;
Id lodClamp;
#ifdef NV_EXTENSIONS
Id granularity;
Id coarse;
#endif
bool nonprivate;
bool volatil;
};

View File

@ -125,7 +125,6 @@ const TBuiltInResource DefaultTBuiltInResource = {
/* .MaxCullDistances = */ 8,
/* .MaxCombinedClipAndCullDistances = */ 8,
/* .MaxSamples = */ 4,
#ifdef NV_EXTENSIONS
/* .maxMeshOutputVerticesNV = */ 256,
/* .maxMeshOutputPrimitivesNV = */ 512,
/* .maxMeshWorkGroupSizeX_NV = */ 32,
@ -135,7 +134,6 @@ const TBuiltInResource DefaultTBuiltInResource = {
/* .maxTaskWorkGroupSizeY_NV = */ 1,
/* .maxTaskWorkGroupSizeZ_NV = */ 1,
/* .maxMeshViewCountNV = */ 4,
#endif
/* .limits = */ {
/* .nonInductiveForLoops = */ 1,

View File

@ -0,0 +1,205 @@
spv.meshShaderUserDefined.mesh
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 140
Capability MeshShadingNV
Extension "SPV_NV_mesh_shader"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint MeshNV 4 "main" 12 19 37 103
ExecutionMode 4 LocalSize 32 1 1
ExecutionMode 4 OutputVertices 81
ExecutionMode 4 OutputPrimitivesNV 32
ExecutionMode 4 OutputTrianglesNV
Source ESSL 320
SourceExtension "GL_NV_mesh_shader"
Name 4 "main"
Name 8 "iid"
Name 12 "gl_LocalInvocationID"
Name 18 "gid"
Name 19 "gl_WorkGroupID"
Name 33 "myblock"
MemberName 33(myblock) 0 "f"
MemberName 33(myblock) 1 "fArr"
MemberName 33(myblock) 2 "pos"
MemberName 33(myblock) 3 "posArr"
MemberName 33(myblock) 4 "m"
MemberName 33(myblock) 5 "mArr"
Name 37 "blk"
Name 99 "myblock2"
MemberName 99(myblock2) 0 "f"
MemberName 99(myblock2) 1 "pos"
MemberName 99(myblock2) 2 "m"
Name 103 "blk2"
Decorate 12(gl_LocalInvocationID) BuiltIn LocalInvocationId
Decorate 19(gl_WorkGroupID) BuiltIn WorkgroupId
MemberDecorate 33(myblock) 0 PerPrimitiveNV
MemberDecorate 33(myblock) 1 PerPrimitiveNV
MemberDecorate 33(myblock) 2 PerPrimitiveNV
MemberDecorate 33(myblock) 3 PerPrimitiveNV
MemberDecorate 33(myblock) 4 PerPrimitiveNV
MemberDecorate 33(myblock) 5 PerPrimitiveNV
Decorate 33(myblock) Block
Decorate 37(blk) Location 0
Decorate 99(myblock2) Block
Decorate 103(blk2) Location 20
Decorate 139 BuiltIn WorkgroupSize
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypePointer Function 6(int)
9: TypeInt 32 0
10: TypeVector 9(int) 3
11: TypePointer Input 10(ivec3)
12(gl_LocalInvocationID): 11(ptr) Variable Input
13: 9(int) Constant 0
14: TypePointer Input 9(int)
19(gl_WorkGroupID): 11(ptr) Variable Input
23: TypeFloat 32
24: 9(int) Constant 4
25: TypeArray 23(float) 24
26: TypeVector 23(float) 3
27: TypeVector 23(float) 4
28: TypeArray 27(fvec4) 24
29: TypeMatrix 27(fvec4) 4
30: TypeMatrix 26(fvec3) 3
31: 9(int) Constant 2
32: TypeArray 30 31
33(myblock): TypeStruct 23(float) 25 26(fvec3) 28 29 32
34: 9(int) Constant 32
35: TypeArray 33(myblock) 34
36: TypePointer Output 35
37(blk): 36(ptr) Variable Output
39: 6(int) Constant 0
40: 23(float) Constant 1093664768
41: TypePointer Output 23(float)
44: 6(int) Constant 1
52: 6(int) Constant 2
54: 23(float) Constant 1096810496
55: 23(float) Constant 1097859072
56: 23(float) Constant 1095761920
57: 26(fvec3) ConstantComposite 54 55 56
58: TypePointer Output 26(fvec3)
64: 6(int) Constant 3
69: TypePointer Output 27(fvec4)
74: 6(int) Constant 4
76: 23(float) Constant 1098907648
77: 27(fvec4) ConstantComposite 56 54 55 76
82: 6(int) Constant 5
85: 9(int) Constant 3
88: 9(int) Constant 1
93: 23(float) Constant 1099431936
94: 23(float) Constant 1099956224
95: 23(float) Constant 1100480512
96: 26(fvec3) ConstantComposite 93 94 95
98: 9(int) Constant 264
99(myblock2): TypeStruct 23(float) 27(fvec4) 29
100: 9(int) Constant 81
101: TypeArray 99(myblock2) 100
102: TypePointer Output 101
103(blk2): 102(ptr) Variable Output
109: 23(float) Constant 1101004800
113: 23(float) Constant 1101529088
114: 23(float) Constant 1102053376
115: 23(float) Constant 1102577664
116: 23(float) Constant 1103101952
117: 27(fvec4) ConstantComposite 113 114 115 116
129: 23(float) Constant 1105723392
139: 10(ivec3) ConstantComposite 34 88 88
4(main): 2 Function None 3
5: Label
8(iid): 7(ptr) Variable Function
18(gid): 7(ptr) Variable Function
15: 14(ptr) AccessChain 12(gl_LocalInvocationID) 13
16: 9(int) Load 15
17: 6(int) Bitcast 16
Store 8(iid) 17
20: 14(ptr) AccessChain 19(gl_WorkGroupID) 13
21: 9(int) Load 20
22: 6(int) Bitcast 21
Store 18(gid) 22
38: 6(int) Load 8(iid)
42: 41(ptr) AccessChain 37(blk) 38 39
Store 42 40
43: 6(int) Load 8(iid)
45: 6(int) IAdd 43 44
46: 6(int) Load 18(gid)
47: 6(int) Load 8(iid)
48: 41(ptr) AccessChain 37(blk) 47 39
49: 23(float) Load 48
50: 41(ptr) AccessChain 37(blk) 45 44 46
Store 50 49
51: 6(int) Load 8(iid)
53: 6(int) SDiv 51 52
59: 58(ptr) AccessChain 37(blk) 53 52
60: 26(fvec3) Load 59
61: 26(fvec3) VectorShuffle 60 57 5 3 4
Store 59 61
62: 6(int) Load 8(iid)
63: 6(int) IMul 62 52
65: 6(int) Load 8(iid)
66: 6(int) SDiv 65 52
67: 58(ptr) AccessChain 37(blk) 66 52
68: 26(fvec3) Load 67
70: 69(ptr) AccessChain 37(blk) 63 64 44
71: 27(fvec4) Load 70
72: 27(fvec4) VectorShuffle 71 68 0 4 5 6
Store 70 72
73: 6(int) Load 8(iid)
75: 6(int) SDiv 73 74
78: 69(ptr) AccessChain 37(blk) 75 74 52
79: 27(fvec4) Load 78
80: 27(fvec4) VectorShuffle 79 77 7 6 5 4
Store 78 80
81: 6(int) Load 8(iid)
83: 6(int) Load 8(iid)
84: 6(int) SDiv 83 74
86: 41(ptr) AccessChain 37(blk) 84 74 52 85
87: 23(float) Load 86
89: 41(ptr) AccessChain 37(blk) 81 82 39 44 88
Store 89 87
90: 6(int) Load 8(iid)
91: 6(int) IMul 90 74
92: 6(int) Load 18(gid)
97: 58(ptr) AccessChain 37(blk) 91 82 44 92
Store 97 96
MemoryBarrier 88 98
ControlBarrier 31 31 98
104: 6(int) Load 8(iid)
105: 6(int) Load 8(iid)
106: 6(int) ISub 105 44
107: 41(ptr) AccessChain 103(blk2) 106 39
108: 23(float) Load 107
110: 23(float) FAdd 108 109
111: 41(ptr) AccessChain 103(blk2) 104 39
Store 111 110
112: 6(int) Load 8(iid)
118: 69(ptr) AccessChain 103(blk2) 112 44
Store 118 117
119: 6(int) Load 8(iid)
120: 6(int) IAdd 119 44
121: 6(int) Load 18(gid)
122: 6(int) Load 8(iid)
123: 69(ptr) AccessChain 103(blk2) 122 44
124: 27(fvec4) Load 123
125: 69(ptr) AccessChain 103(blk2) 120 52 121
Store 125 124
126: 6(int) Load 8(iid)
127: 6(int) IAdd 126 44
128: 6(int) Load 18(gid)
130: 41(ptr) AccessChain 103(blk2) 127 52 128 31
Store 130 129
131: 6(int) Load 8(iid)
132: 6(int) IAdd 131 52
133: 6(int) Load 8(iid)
134: 6(int) IAdd 133 44
135: 6(int) Load 18(gid)
136: 69(ptr) AccessChain 103(blk2) 134 52 135
137: 27(fvec4) Load 136
138: 69(ptr) AccessChain 103(blk2) 132 52 64
Store 138 137
MemoryBarrier 88 98
ControlBarrier 31 31 98
Return
FunctionEnd

View File

@ -0,0 +1,59 @@
#version 320 es
#define MAX_VER 81
#define MAX_PRIM 32
#define BARRIER() \
memoryBarrierShared(); \
barrier();
#extension GL_NV_mesh_shader : enable
layout(local_size_x = 32) in;
layout(max_vertices=MAX_VER) out;
layout(max_primitives=MAX_PRIM) out;
layout(triangles) out;
// test use of user defined interface out blocks:
// per-primitive block
perprimitiveNV layout(location=0) out myblock {
float f;
float fArr[4];
vec3 pos;
vec4 posArr[4];
mat4 m;
mat3 mArr[2];
} blk[];
// per-vertex block
layout(location=20) out myblock2 {
float f;
vec4 pos;
mat4 m;
} blk2[];
void main()
{
int iid = int(gl_LocalInvocationID.x);
int gid = int(gl_WorkGroupID.x);
blk[iid].f = 11.0;
blk[iid+1].fArr[gid] = blk[iid].f;
blk[iid/2].pos.yzx = vec3(14.0, 15.0, 13.0);
blk[iid*2].posArr[1].yzw = blk[iid/2].pos;
blk[iid/4].m[2].wzyx = vec4(13.0, 14.0, 15.0, 16.0);
blk[iid].mArr[0][1][1] = blk[iid/4].m[2].w;
blk[iid*4].mArr[1][gid] = vec3(17.0, 18.0, 19.0);
BARRIER();
blk2[iid].f = blk2[iid-1].f + 20.0;
blk2[iid].pos = vec4(21.0, 22.0, 23.0, 24.0);
blk2[iid+1].m[gid] = blk2[iid].pos;
blk2[iid+1].m[gid][2] = 29.0;
blk2[iid+2].m[3] = blk2[iid+1].m[gid];
BARRIER();
}

View File

@ -0,0 +1,37 @@
# Copyright (C) 2018 Google, Inc.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
#
# Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# These are variables that are overridable by projects that include glslang.
# The path to glslang dependencies.
glslang_spirv_tools_dir = "//Externals/spirv-tools"

View File

@ -133,7 +133,6 @@ struct TBuiltInResource {
int maxCullDistances;
int maxCombinedClipAndCullDistances;
int maxSamples;
#ifdef NV_EXTENSIONS
int maxMeshOutputVerticesNV;
int maxMeshOutputPrimitivesNV;
int maxMeshWorkGroupSizeX_NV;
@ -143,7 +142,6 @@ struct TBuiltInResource {
int maxTaskWorkGroupSizeY_NV;
int maxTaskWorkGroupSizeZ_NV;
int maxMeshViewCountNV;
#endif
TLimits limits;
};

View File

@ -4878,7 +4878,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"void barrier();"
);
#ifdef NV_EXTENSIONS
if ((profile != EEsProfile && version >= 450) || esBarrier) {
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
stageBuiltins[EShLangMeshNV].append(
"void barrier();"
);
@ -4903,7 +4903,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
);
}
#ifdef NV_EXTENSIONS
if (profile != EEsProfile && version >= 450) {
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
stageBuiltins[EShLangMeshNV].append(
"void memoryBarrierShared();"
"void groupMemoryBarrier();"
@ -5094,7 +5094,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
}
// Builtins for GL_NV_mesh_shader
if (profile != EEsProfile && version >= 450) {
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
stageBuiltins[EShLangMeshNV].append(
"void writePackedPrimitiveIndices4x8NV(uint, uint);"
"\n");
@ -5287,7 +5287,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
//
//============================================================================
if (profile != EEsProfile && version >= 450) {
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
// per-vertex attributes
stageBuiltins[EShLangMeshNV].append(
"out gl_MeshPerVertexNV {"
@ -5328,17 +5328,8 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"in highp uvec3 gl_GlobalInvocationID;"
"in highp uint gl_LocalInvocationIndex;"
"in highp int gl_DeviceIndex;" // GL_EXT_device_group
"in int gl_DrawIDARB;" // GL_ARB_shader_draw_parameters
"\n");
if (version >= 460) {
stageBuiltins[EShLangMeshNV].append(
"in int gl_DrawID;"
);
}
stageBuiltins[EShLangTaskNV].append(
"out uint gl_TaskCountNV;"
@ -5350,15 +5341,28 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"in highp uvec3 gl_GlobalInvocationID;"
"in highp uint gl_LocalInvocationIndex;"
"\n");
}
if (profile != EEsProfile && version >= 450) {
stageBuiltins[EShLangMeshNV].append(
"in highp int gl_DeviceIndex;" // GL_EXT_device_group
"in int gl_DrawIDARB;" // GL_ARB_shader_draw_parameters
"\n");
stageBuiltins[EShLangTaskNV].append(
"in highp int gl_DeviceIndex;" // GL_EXT_device_group
"in int gl_DrawIDARB;" // GL_ARB_shader_draw_parameters
"\n");
if (version >= 460) {
stageBuiltins[EShLangMeshNV].append(
"in int gl_DrawID;"
"\n");
stageBuiltins[EShLangTaskNV].append(
"in int gl_DrawID;"
);
"\n");
}
}
#endif
@ -7658,7 +7662,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
#ifdef NV_EXTENSIONS
// SPV_NV_mesh_shader
if (profile != EEsProfile && version >= 450) {
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
snprintf(builtInConstant, maxSize, "const int gl_MaxMeshOutputVerticesNV = %d;", resources.maxMeshOutputVerticesNV);
s.append(builtInConstant);
@ -8633,7 +8637,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
}
break;
case EShLangMeshNV:
if (profile != EEsProfile && version >= 450) {
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
// Per-vertex builtins
BuiltInVariable("gl_MeshVerticesNV", "gl_Position", EbvPosition, symbolTable);
BuiltInVariable("gl_MeshVerticesNV", "gl_PointSize", EbvPointSize, symbolTable);
@ -8681,7 +8685,9 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setFunctionExtensions("barrier", 1, &E_GL_NV_mesh_shader);
symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_NV_mesh_shader);
symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader);
}
if (profile != EEsProfile && version >= 450) {
// GL_EXT_device_group
symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
@ -8743,7 +8749,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
break;
case EShLangTaskNV:
if (profile != EEsProfile && version >= 450) {
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
symbolTable.setVariableExtensions("gl_TaskCountNV", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_WorkGroupSize", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_WorkGroupID", 1, &E_GL_NV_mesh_shader);
@ -8763,7 +8769,9 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setFunctionExtensions("barrier", 1, &E_GL_NV_mesh_shader);
symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_NV_mesh_shader);
symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader);
}
if (profile != EEsProfile && version >= 450) {
// GL_EXT_device_group
symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
@ -9379,12 +9387,12 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
}
break;
case EShLangMeshNV:
if (profile != EEsProfile && version >= 450) {
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
symbolTable.relateToOperator("writePackedPrimitiveIndices4x8NV", EOpWritePackedPrimitiveIndices4x8NV);
}
// fall through
case EShLangTaskNV:
if (profile != EEsProfile && version >= 450) {
if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
symbolTable.relateToOperator("memoryBarrierShared", EOpMemoryBarrierShared);
symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier);
}

View File

@ -1576,27 +1576,29 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
return false;
}
case EbtFloat16:
switch (from) {
#ifdef AMD_EXTENSIONS
switch (from) {
case EbtInt16:
case EbtUint16:
return extensionRequested(E_GL_AMD_gpu_shader_int16);
case EbtFloat16:
return extensionRequested(E_GL_AMD_gpu_shader_half_float);
#endif
default:
return false;
}
break;
}
#endif
return false;
case EbtUint16:
switch (from) {
#ifdef AMD_EXTENSIONS
switch (from) {
case EbtInt16:
case EbtUint16:
return extensionRequested(E_GL_AMD_gpu_shader_int16);
#endif
default:
return false;
}
break;
}
#endif
return false;
default:
return false;
}

View File

@ -612,7 +612,7 @@ int TParseContext::getIoArrayImplicitSize(bool isPerPrimitive) const
return 3; //Number of vertices for Fragment shader is always three.
else if (language == EShLangMeshNV) {
if (isPerPrimitive) {
return intermediate.getPrimitives() != TQualifier::layoutNotSet ? intermediate.getPrimitives() : 0;
return intermediate.getPrimitives() != TQualifier::layoutNotSet ? intermediate.getPrimitives() : 0;
} else {
return intermediate.getVertices() != TQualifier::layoutNotSet ? intermediate.getVertices() : 0;
}
@ -1560,6 +1560,8 @@ void TParseContext::memorySemanticsCheck(const TSourceLoc& loc, const TFunction&
storageClassSemantics = (*argp)[1]->getAsConstantUnion()->getConstArray()[0].getIConst();
semantics = (*argp)[2]->getAsConstantUnion()->getConstArray()[0].getIConst();
break;
default:
break;
}
if ((semantics & gl_SemanticsAcquire) &&
@ -3600,6 +3602,14 @@ void TParseContext::arraySizesCheck(const TSourceLoc& loc, const TQualifier& qua
extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader))
return;
break;
#ifdef NV_EXTENSIONS
case EShLangMeshNV:
if (qualifier.storage == EvqVaryingOut)
if ((profile == EEsProfile && version >= 320) ||
extensionTurnedOn(E_GL_NV_mesh_shader))
return;
break;
#endif
default:
break;
}
@ -4460,6 +4470,12 @@ void TParseContext::finish()
if (profile != EEsProfile && version < 430)
requireExtensions(getCurrentLoc(), 1, &E_GL_ARB_compute_shader, "compute shaders");
break;
#ifdef NV_EXTENSIONS
case EShLangTaskNV:
case EShLangMeshNV:
requireExtensions(getCurrentLoc(), 1, &E_GL_NV_mesh_shader, "mesh shaders");
break;
#endif
default:
break;
}
@ -4963,12 +4979,14 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
#ifdef NV_EXTENSIONS
case EShLangMeshNV:
if (id == "max_vertices") {
requireExtensions(loc, 1, &E_GL_NV_mesh_shader, "max_vertices");
publicType.shaderQualifiers.vertices = value;
if (value > resources.maxMeshOutputVerticesNV)
error(loc, "too large, must be less than gl_MaxMeshOutputVerticesNV", "max_vertices", "");
return;
}
if (id == "max_primitives") {
requireExtensions(loc, 1, &E_GL_NV_mesh_shader, "max_primitives");
publicType.shaderQualifiers.primitives = value;
if (value > resources.maxMeshOutputPrimitivesNV)
error(loc, "too large, must be less than gl_MaxMeshOutputPrimitivesNV", "max_primitives", "");
@ -4983,7 +5001,7 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
if (id.compare(0, 11, "local_size_") == 0) {
#ifdef NV_EXTENSIONS
if (language == EShLangMeshNV || language == EShLangTaskNV) {
profileRequires(loc, ~EEsProfile, 450, E_GL_NV_mesh_shader, "gl_WorkGroupSize");
requireExtensions(loc, 1, &E_GL_NV_mesh_shader, "gl_WorkGroupSize");
}
else
#endif

View File

@ -348,9 +348,7 @@ public:
void boolCheck(const TSourceLoc&, const TPublicType&);
void samplerCheck(const TSourceLoc&, const TType&, const TString& identifier, TIntermTyped* initializer);
void atomicUintCheck(const TSourceLoc&, const TType&, const TString& identifier);
#ifdef NV_EXTENSIONS
void accStructNVCheck(const TSourceLoc & loc, const TType & type, const TString & identifier);
#endif
void transparentOpaqueCheck(const TSourceLoc&, const TType&, const TString& identifier);
void memberQualifierCheck(glslang::TPublicType&);
void globalQualifierFixCheck(const TSourceLoc&, TQualifier&);
@ -426,9 +424,8 @@ public:
// Determine loop control from attributes
void handleLoopAttributes(const TAttributes& attributes, TIntermNode*);
#ifdef NV_EXTENSIONS
void resizeMeshViewDimension(const TSourceLoc&, TType&);
#endif
protected:
void nonInitConstCheck(const TSourceLoc&, TString& identifier, TType& type);
void inheritGlobalDefaults(TQualifier& dst) const;

View File

@ -1591,8 +1591,9 @@ int TScanContext::tokenizeIdentifier()
case PERPRIMITIVENV:
case PERVIEWNV:
case PERTASKNV:
if (parseContext.profile != EEsProfile &&
(parseContext.version >= 450 || parseContext.extensionTurnedOn(E_GL_NV_mesh_shader)))
if ((parseContext.profile != EEsProfile && parseContext.version >= 450) ||
(parseContext.profile == EEsProfile && parseContext.version >= 320) ||
parseContext.extensionTurnedOn(E_GL_NV_mesh_shader))
return keyword;
return identifierOrType();
#endif

View File

@ -361,13 +361,16 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangMissNV, source,
infoSink, commonTable, symbolTables);
}
// check for mesh
if (profile != EEsProfile && version >= 450)
if ((profile != EEsProfile && version >= 450) ||
(profile == EEsProfile && version >= 320))
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangMeshNV, source,
infoSink, commonTable, symbolTables);
// check for task
if (profile != EEsProfile && version >= 450)
if ((profile != EEsProfile && version >= 450) ||
(profile == EEsProfile && version >= 320))
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangTaskNV, source,
infoSink, commonTable, symbolTables);
#endif
@ -600,6 +603,7 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
case EShLangIntersectNV:
case EShLangAnyHitNV:
case EShLangClosestHitNV:
case EShLangMissNV:
case EShLangCallableNV:
if (profile == EEsProfile || version < 460) {
correct = false;
@ -609,11 +613,11 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
break;
case EShLangMeshNV:
case EShLangTaskNV:
if ((profile == EEsProfile) ||
if ((profile == EEsProfile && version < 320) ||
(profile != EEsProfile && version < 450)) {
correct = false;
infoSink.info.message(EPrefixError, "#version: mesh/task shaders require non-es profile with version 450 or above");
version = 450;
infoSink.info.message(EPrefixError, "#version: mesh/task shaders require es profile with version 320 or above, or non-es profile with version 450 or above");
version = profile == EEsProfile ? 320 : 450;
}
#endif
default:

View File

@ -742,6 +742,9 @@ void TParseVersions::updateExtensionBehavior(int line, const char* extension, co
return;
}
// check if extension is used with correct shader stage
checkExtensionStage(getCurrentLoc(), extension);
// update the requested extension
updateExtensionBehavior(extension, behavior);
@ -834,6 +837,17 @@ void TParseVersions::updateExtensionBehavior(const char* extension, TExtensionBe
}
}
// Check if extension is used with correct shader stage.
void TParseVersions::checkExtensionStage(const TSourceLoc& loc, const char * const extension)
{
#ifdef NV_EXTENSIONS
// GL_NV_mesh_shader extension is only allowed in task/mesh shaders
if (strcmp(extension, "GL_NV_mesh_shader") == 0)
requireStage(loc, (EShLanguageMask)(EShLangTaskNVMask | EShLangMeshNVMask),
"#extension GL_NV_mesh_shader");
#endif
}
// Call for any operation needing full GLSL integer data-type support.
void TParseVersions::fullIntegerCheck(const TSourceLoc& loc, const char* op)
{

View File

@ -1158,7 +1158,9 @@ interpolation_qualifier
| PERPRIMITIVENV {
#ifdef NV_EXTENSIONS
parseContext.globalCheck($1.loc, "perprimitiveNV");
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangFragmentMask | EShLangMeshNVMask), "perprimitiveNV");
parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "perprimitiveNV");
parseContext.profileRequires($1.loc, EEsProfile, 320, E_GL_NV_mesh_shader, "perprimitiveNV");
$$.init($1.loc);
$$.qualifier.perPrimitiveNV = true;
#endif
@ -1166,7 +1168,9 @@ interpolation_qualifier
| PERVIEWNV {
#ifdef NV_EXTENSIONS
parseContext.globalCheck($1.loc, "perviewNV");
parseContext.requireStage($1.loc, EShLangMeshNV, "perviewNV");
parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "perviewNV");
parseContext.profileRequires($1.loc, EEsProfile, 320, E_GL_NV_mesh_shader, "perviewNV");
$$.init($1.loc);
$$.qualifier.perViewNV = true;
#endif
@ -1174,7 +1178,9 @@ interpolation_qualifier
| PERTASKNV {
#ifdef NV_EXTENSIONS
parseContext.globalCheck($1.loc, "taskNV");
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangTaskNVMask | EShLangMeshNVMask), "taskNV");
parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "taskNV");
parseContext.profileRequires($1.loc, EEsProfile, 320, E_GL_NV_mesh_shader, "taskNV");
$$.init($1.loc);
$$.qualifier.perTaskNV = true;
#endif

File diff suppressed because it is too large Load Diff

View File

@ -103,6 +103,7 @@ public:
virtual void requireSpv(const TSourceLoc&, const char* op);
virtual bool checkExtensionsRequested(const TSourceLoc&, int numExtensions, const char* const extensions[], const char* featureDesc);
virtual void updateExtensionBehavior(const char* const extension, TExtensionBehavior);
virtual void checkExtensionStage(const TSourceLoc&, const char* const extension);
virtual void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) = 0;

4
3rdparty/glslang/glslang/Public/ShaderLang.h vendored Executable file → Normal file
View File

@ -94,7 +94,6 @@ typedef enum {
EShLangGeometry,
EShLangFragment,
EShLangCompute,
#ifdef NV_EXTENSIONS
EShLangRayGenNV,
EShLangIntersectNV,
EShLangAnyHitNV,
@ -103,7 +102,6 @@ typedef enum {
EShLangCallableNV,
EShLangTaskNV,
EShLangMeshNV,
#endif
EShLangCount,
} EShLanguage; // would be better as stage, but this is ancient now
@ -114,7 +112,6 @@ typedef enum {
EShLangGeometryMask = (1 << EShLangGeometry),
EShLangFragmentMask = (1 << EShLangFragment),
EShLangComputeMask = (1 << EShLangCompute),
#ifdef NV_EXTENSIONS
EShLangRayGenNVMask = (1 << EShLangRayGenNV),
EShLangIntersectNVMask = (1 << EShLangIntersectNV),
EShLangAnyHitNVMask = (1 << EShLangAnyHitNV),
@ -123,7 +120,6 @@ typedef enum {
EShLangCallableNVMask = (1 << EShLangCallableNV),
EShLangTaskNVMask = (1 << EShLangTaskNV),
EShLangMeshNVMask = (1 << EShLangMeshNV),
#endif
} EShLanguageMask;
namespace glslang {

View File

@ -137,16 +137,26 @@ namespace bgfx { namespace spirv
8, // MaxCullDistances
8, // MaxCombinedClipAndCullDistances
4, // MaxSamples
{ // limits
1, // nonInductiveForLoops
1, // whileLoops
1, // doWhileLoops
1, // generalUniformIndexing
1, // generalAttributeMatrixVectorIndexing
1, // generalVaryingIndexing
1, // generalSamplerIndexing
1, // generalVariableIndexing
1, // generalConstantMatrixVectorIndexing
0, // maxMeshOutputVerticesNV;
0, // maxMeshOutputPrimitivesNV;
0, // maxMeshWorkGroupSizeX_NV;
0, // maxMeshWorkGroupSizeY_NV;
0, // maxMeshWorkGroupSizeZ_NV;
0, // maxTaskWorkGroupSizeX_NV;
0, // maxTaskWorkGroupSizeY_NV;
0, // maxTaskWorkGroupSizeZ_NV;
0, // maxMeshViewCountNV
{ // limits
true, // nonInductiveForLoops
true, // whileLoops
true, // doWhileLoops
true, // generalUniformIndexing
true, // generalAttributeMatrixVectorIndexing
true, // generalVaryingIndexing
true, // generalSamplerIndexing
true, // generalVariableIndexing
true, // generalConstantMatrixVectorIndexing
},
};