Updated glslang.

This commit is contained in:
Branimir Karadžić 2017-11-19 13:01:01 -08:00
parent ab6972517b
commit 0eb67a9c85
27 changed files with 2064 additions and 132 deletions

View File

@ -17,6 +17,13 @@ branches:
only:
- master
# Travis advances the master-tot tag to current top of the tree after
# each push into the master branch, because it relies on that tag to
# upload build artifacts to the master-tot release. This will cause
# double testing for each push on Appveyor: one for the push, one for
# the tag advance. Disable testing tags.
skip_tags: true
clone_depth: 5
matrix:

View File

@ -38,13 +38,17 @@
#include "InitializeDll.h"
#include "../glslang/Include/InitializeGlobals.h"
#include "../glslang/Public/ShaderLang.h"
#include "../glslang/Include/PoolAlloc.h"
namespace glslang {
OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
// Per-process initialization.
// Needs to be called at least once before parsing, etc. is done.
// Will also do thread initialization for the calling thread; other
// threads will need to do that explicitly.
bool InitProcess()
{
glslang::GetGlobalLock();
@ -85,7 +89,9 @@ bool InitProcess()
return true;
}
// Per-thread scoped initialization.
// Must be called at least once by each new thread sharing the
// symbol tables, etc., needed to parse.
bool InitThread()
{
//
@ -99,17 +105,21 @@ bool InitThread()
if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
return true;
InitializeMemoryPools();
if (! OS_SetTLSValue(ThreadInitializeIndex, (void *)1)) {
assert(0 && "InitThread(): Unable to set init flag.");
return false;
}
glslang::SetThreadPoolAllocator(nullptr);
return true;
}
// Not necessary to call this: InitThread() is reentrant, and the need
// to do per thread tear down has been removed.
//
// This is kept, with memory management removed, to satisfy any exiting
// calls to it that rely on it.
bool DetachThread()
{
bool success = true;
@ -125,14 +135,18 @@ bool DetachThread()
assert(0 && "DetachThread(): Unable to clear init flag.");
success = false;
}
FreeGlobalPools();
}
return success;
}
// Not necessary to call this: InitProcess() is reentrant.
//
// This is kept, with memory management removed, to satisfy any exiting
// calls to it that rely on it.
//
// Users of glslang should call shFinalize() or glslang::FinalizeProcess() for
// process-scoped memory tear down.
bool DetachProcess()
{
bool success = true;
@ -140,12 +154,8 @@ bool DetachProcess()
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
return true;
ShFinalize();
success = DetachThread();
FreePoolIndex();
OS_FreeTLSIndex(ThreadInitializeIndex);
ThreadInitializeIndex = OS_INVALID_TLS_INDEX;

View File

@ -40,8 +40,8 @@ namespace glslang {
bool InitProcess();
bool InitThread();
bool DetachThread();
bool DetachProcess();
bool DetachThread(); // not called from standalone, perhaps other tools rely on parts of it
bool DetachProcess(); // not called from standalone, perhaps other tools rely on parts of it
} // end namespace glslang

View File

@ -49,6 +49,12 @@ There is also a non-shader extension
Building
--------
Instead of building manually, you can also download the binaries for your
platform directly from the [master-tot release][master-tot-release] on GitHub.
Those binaries are automatically uploaded by the buildbots after successful
testing and they always reflect the current top of the tree of the master
branch.
### Dependencies
* [CMake][cmake]: for generating compilation targets.
@ -318,3 +324,4 @@ Basic Internal Operation
[bison]: https://www.gnu.org/software/bison/
[googletest]: https://github.com/google/googletest
[bison-gnu-win32]: http://gnuwin32.sourceforge.net/packages/bison.htm
[master-tot-release]: https://github.com/KhronosGroup/glslang/releases/tag/master-tot

View File

@ -127,6 +127,9 @@ void InfoLogMsg(const char* msg, const char* name, const int num);
bool CompileFailed = false;
bool LinkFailed = false;
// array of unique places to leave the shader names and infologs for the asynchronous compiles
std::vector<std::unique_ptr<glslang::TWorkItem>> WorkItems;
TBuiltInResource Resources;
std::string ConfigFile;
@ -1022,14 +1025,10 @@ void CompileAndLinkShaderFiles(glslang::TWorklist& Worklist)
FreeFileData(const_cast<char*>(it->text[0]));
}
int C_DECL main(int argc, char* argv[])
int singleMain()
{
// array of unique places to leave the shader names and infologs for the asynchronous compiles
std::vector<std::unique_ptr<glslang::TWorkItem>> workItems;
ProcessArguments(workItems, argc, argv);
glslang::TWorklist workList;
std::for_each(workItems.begin(), workItems.end(), [&workList](std::unique_ptr<glslang::TWorkItem>& item) {
std::for_each(WorkItems.begin(), WorkItems.end(), [&workList](std::unique_ptr<glslang::TWorkItem>& item) {
assert(item);
workList.add(item.get());
});
@ -1061,8 +1060,8 @@ int C_DECL main(int argc, char* argv[])
}
if (Options & EOptionStdin) {
workItems.push_back(std::unique_ptr<glslang::TWorkItem>{new glslang::TWorkItem("stdin")});
workList.add(workItems.back().get());
WorkItems.push_back(std::unique_ptr<glslang::TWorkItem>{new glslang::TWorkItem("stdin")});
workList.add(WorkItems.back().get());
}
ProcessConfigFile();
@ -1075,21 +1074,24 @@ int C_DECL main(int argc, char* argv[])
if (Options & EOptionLinkProgram ||
Options & EOptionOutputPreprocessed) {
glslang::InitializeProcess();
glslang::InitializeProcess(); // also test reference counting of users
glslang::InitializeProcess(); // also test reference counting of users
glslang::FinalizeProcess(); // also test reference counting of users
glslang::FinalizeProcess(); // also test reference counting of users
CompileAndLinkShaderFiles(workList);
glslang::FinalizeProcess();
} else {
ShInitialize();
ShInitialize(); // also test reference counting of users
ShFinalize(); // also test reference counting of users
bool printShaderNames = workList.size() > 1;
if (Options & EOptionMultiThreaded)
{
if (Options & EOptionMultiThreaded) {
std::array<std::thread, 16> threads;
for (unsigned int t = 0; t < threads.size(); ++t)
{
for (unsigned int t = 0; t < threads.size(); ++t) {
threads[t] = std::thread(CompileShaders, std::ref(workList));
if (threads[t].get_id() == std::thread::id())
{
if (threads[t].get_id() == std::thread::id()) {
fprintf(stderr, "Failed to create thread\n");
return EFailThreadCreate;
}
@ -1100,11 +1102,11 @@ int C_DECL main(int argc, char* argv[])
CompileShaders(workList);
// Print out all the resulting infologs
for (size_t w = 0; w < workItems.size(); ++w) {
if (workItems[w]) {
if (printShaderNames || workItems[w]->results.size() > 0)
PutsIfNonEmpty(workItems[w]->name.c_str());
PutsIfNonEmpty(workItems[w]->results.c_str());
for (size_t w = 0; w < WorkItems.size(); ++w) {
if (WorkItems[w]) {
if (printShaderNames || WorkItems[w]->results.size() > 0)
PutsIfNonEmpty(WorkItems[w]->name.c_str());
PutsIfNonEmpty(WorkItems[w]->results.c_str());
}
}
@ -1119,6 +1121,25 @@ int C_DECL main(int argc, char* argv[])
return 0;
}
int C_DECL main(int argc, char* argv[])
{
ProcessArguments(WorkItems, argc, argv);
int ret = 0;
// Loop over the entire init/finalize cycle to watch memory changes
const int iterations = 1;
if (iterations > 1)
glslang::OS_DumpMemoryCounters();
for (int i = 0; i < iterations; ++i) {
ret = singleMain();
if (iterations > 1)
glslang::OS_DumpMemoryCounters();
}
return ret;
}
//
// Deduce the language from the filename. Files must end in one of the
// following extensions:
@ -1273,7 +1294,7 @@ void usage()
" -o <file> save binary to <file>, requires a binary option (e.g., -V)\n"
" -q dump reflection query database\n"
" -r synonym for --relaxed-errors\n"
" -s silent mode\n"
" -s silence syntax and semantic error reporting\n"
" -t multi-threaded mode\n"
" -v print version strings\n"
" -w synonym for --suppress-warnings\n"

View File

@ -0,0 +1,37 @@
hlsl.flattenSubset2.frag
WARNING: AST will form illegal SPIR-V; need to transform to legalize
// Module Version 10000
// Generated by (magic number): 80002
// Id's are bound by 44
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 40 43
ExecutionMode 4 OriginUpperLeft
Source HLSL 500
Name 4 "main"
Name 31 "someTex"
Name 40 "vpos"
Name 43 "@entryPointOutput"
Decorate 31(someTex) DescriptorSet 0
Decorate 40(vpos) Location 0
Decorate 43(@entryPointOutput) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
17: TypeImage 6(float) 2D sampled format:Unknown
30: TypePointer UniformConstant 17
31(someTex): 30(ptr) Variable UniformConstant
34: 6(float) Constant 0
35: 7(fvec4) ConstantComposite 34 34 34 34
39: TypePointer Input 7(fvec4)
40(vpos): 39(ptr) Variable Input
42: TypePointer Output 7(fvec4)
43(@entryPointOutput): 42(ptr) Variable Output
4(main): 2 Function None 3
5: Label
Store 43(@entryPointOutput) 35
Return
FunctionEnd

View File

@ -0,0 +1,91 @@
hlsl.partialFlattenLocal.vert
WARNING: AST will form illegal SPIR-V; need to transform to legalize
// Module Version 10000
// Generated by (magic number): 80002
// Id's are bound by 148
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 90 93
Source HLSL 500
Name 4 "main"
Name 17 "tex"
Name 90 "pos"
Name 93 "@entryPointOutput"
Decorate 17(tex) DescriptorSet 0
Decorate 90(pos) Location 0
Decorate 93(@entryPointOutput) BuiltIn Position
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
13: TypeImage 6(float) 2D sampled format:Unknown
16: TypePointer UniformConstant 13
17(tex): 16(ptr) Variable UniformConstant
19: TypeVector 6(float) 3
20: TypeInt 32 0
21: 20(int) Constant 3
22: TypeArray 19(fvec3) 21
23: TypePointer Function 22
25: TypeInt 32 1
26: 25(int) Constant 0
27: 6(float) Constant 0
28: 19(fvec3) ConstantComposite 27 27 27
29: TypePointer Function 19(fvec3)
31: TypeVector 6(float) 2
32: 20(int) Constant 2
33: TypeArray 31(fvec2) 32
34: TypePointer Function 33
36: 6(float) Constant 1065353216
37: 31(fvec2) ConstantComposite 27 36
38: TypePointer Function 31(fvec2)
52: 25(int) Constant 1
53: TypeBool
89: TypePointer Input 7(fvec4)
90(pos): 89(ptr) Variable Input
92: TypePointer Output 7(fvec4)
93(@entryPointOutput): 92(ptr) Variable Output
4(main): 2 Function None 3
5: Label
98: 23(ptr) Variable Function
99: 34(ptr) Variable Function
91: 7(fvec4) Load 90(pos)
110: 29(ptr) AccessChain 98 26
Store 110 28
111: 38(ptr) AccessChain 99 26
Store 111 37
Branch 112
112: Label
147: 25(int) Phi 26 5 131 114
LoopMerge 113 114 None
Branch 115
115: Label
117: 53(bool) SLessThan 147 52
BranchConditional 117 118 113
118: Label
121: 38(ptr) AccessChain 99 147
122: 31(fvec2) Load 121
123: 29(ptr) AccessChain 98 147
124: 19(fvec3) Load 123
125: 31(fvec2) VectorShuffle 124 124 0 1
126: 31(fvec2) FAdd 125 122
127: 29(ptr) AccessChain 98 147
128: 19(fvec3) Load 127
129: 19(fvec3) VectorShuffle 128 126 3 4 2
Store 127 129
Branch 114
114: Label
131: 25(int) IAdd 147 52
Branch 112
113: Label
133: 22 Load 98
146: 19(fvec3) CompositeExtract 133 0
140: 6(float) CompositeExtract 146 0
141: 6(float) CompositeExtract 146 1
142: 6(float) CompositeExtract 146 2
143: 7(fvec4) CompositeConstruct 140 141 142 27
144: 7(fvec4) FAdd 91 143
Store 93(@entryPointOutput) 144
Return
FunctionEnd

View File

@ -0,0 +1,38 @@
hlsl.partialFlattenMixed.vert
WARNING: AST will form illegal SPIR-V; need to transform to legalize
// Module Version 10000
// Generated by (magic number): 80002
// Id's are bound by 31
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 27 30
Source HLSL 500
Name 4 "main"
Name 20 "tex"
Name 27 "pos"
Name 30 "@entryPointOutput"
Decorate 20(tex) DescriptorSet 0
Decorate 27(pos) Location 0
Decorate 30(@entryPointOutput) BuiltIn Position
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
13: TypeImage 6(float) 2D sampled format:Unknown
14: TypeInt 32 0
15: 14(int) Constant 2
16: TypeArray 13 15
19: TypePointer UniformConstant 16
20(tex): 19(ptr) Variable UniformConstant
26: TypePointer Input 7(fvec4)
27(pos): 26(ptr) Variable Input
29: TypePointer Output 7(fvec4)
30(@entryPointOutput): 29(ptr) Variable Output
4(main): 2 Function None 3
5: Label
28: 7(fvec4) Load 27(pos)
Store 30(@entryPointOutput) 28
Return
FunctionEnd

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,212 @@
hlsl.snorm.uav.comp
Shader version: 500
local_size = (16, 16, 1)
0:? Sequence
0:12 Function Definition: @main(vu3; ( temp void)
0:12 Function Parameters:
0:12 'tid' ( in 3-component vector of uint)
0:? Sequence
0:13 Sequence
0:13 move second child to first child ( temp 4-component vector of float)
0:13 'storeTemp' ( temp 4-component vector of float)
0:13 add ( temp 4-component vector of float)
0:13 textureFetch ( temp 4-component vector of float)
0:13 'ResultInS' (layout( binding=1) uniform texture3D)
0:13 'tid' ( in 3-component vector of uint)
0:13 Constant:
0:13 0 (const int)
0:13 uf4: direct index for structure ( uniform 4-component vector of float)
0:13 'anon@0' (layout( row_major std140) uniform block{ uniform 4-component vector of float uf4})
0:13 Constant:
0:13 0 (const uint)
0:13 imageStore ( temp void)
0:13 'ResultOutS' (layout( binding=1 rgba32f) uniform image3D)
0:13 'tid' ( in 3-component vector of uint)
0:13 'storeTemp' ( temp 4-component vector of float)
0:13 'storeTemp' ( temp 4-component vector of float)
0:14 Sequence
0:14 move second child to first child ( temp 4-component vector of float)
0:14 'storeTemp' ( temp 4-component vector of float)
0:14 textureFetch ( temp 4-component vector of float)
0:14 'ResultInU' (layout( binding=0) uniform texture3D)
0:14 'tid' ( in 3-component vector of uint)
0:14 Constant:
0:14 0 (const int)
0:14 imageStore ( temp void)
0:14 'ResultOutU' (layout( binding=0 rgba32f) uniform image3D)
0:14 'tid' ( in 3-component vector of uint)
0:14 'storeTemp' ( temp 4-component vector of float)
0:14 'storeTemp' ( temp 4-component vector of float)
0:12 Function Definition: main( ( temp void)
0:12 Function Parameters:
0:? Sequence
0:12 move second child to first child ( temp 3-component vector of uint)
0:? 'tid' ( temp 3-component vector of uint)
0:? 'tid' ( in 3-component vector of uint GlobalInvocationID)
0:12 Function Call: @main(vu3; ( temp void)
0:? 'tid' ( temp 3-component vector of uint)
0:? Linker Objects
0:? 'anon@0' (layout( row_major std140) uniform block{ uniform 4-component vector of float uf4})
0:? 'ResultInU' (layout( binding=0) uniform texture3D)
0:? 'ResultOutU' (layout( binding=0 rgba32f) uniform image3D)
0:? 'ResultInS' (layout( binding=1) uniform texture3D)
0:? 'ResultOutS' (layout( binding=1 rgba32f) uniform image3D)
0:? 'tid' ( in 3-component vector of uint GlobalInvocationID)
Linked compute stage:
Shader version: 500
local_size = (16, 16, 1)
0:? Sequence
0:12 Function Definition: @main(vu3; ( temp void)
0:12 Function Parameters:
0:12 'tid' ( in 3-component vector of uint)
0:? Sequence
0:13 Sequence
0:13 move second child to first child ( temp 4-component vector of float)
0:13 'storeTemp' ( temp 4-component vector of float)
0:13 add ( temp 4-component vector of float)
0:13 textureFetch ( temp 4-component vector of float)
0:13 'ResultInS' (layout( binding=1) uniform texture3D)
0:13 'tid' ( in 3-component vector of uint)
0:13 Constant:
0:13 0 (const int)
0:13 uf4: direct index for structure ( uniform 4-component vector of float)
0:13 'anon@0' (layout( row_major std140) uniform block{ uniform 4-component vector of float uf4})
0:13 Constant:
0:13 0 (const uint)
0:13 imageStore ( temp void)
0:13 'ResultOutS' (layout( binding=1 rgba32f) uniform image3D)
0:13 'tid' ( in 3-component vector of uint)
0:13 'storeTemp' ( temp 4-component vector of float)
0:13 'storeTemp' ( temp 4-component vector of float)
0:14 Sequence
0:14 move second child to first child ( temp 4-component vector of float)
0:14 'storeTemp' ( temp 4-component vector of float)
0:14 textureFetch ( temp 4-component vector of float)
0:14 'ResultInU' (layout( binding=0) uniform texture3D)
0:14 'tid' ( in 3-component vector of uint)
0:14 Constant:
0:14 0 (const int)
0:14 imageStore ( temp void)
0:14 'ResultOutU' (layout( binding=0 rgba32f) uniform image3D)
0:14 'tid' ( in 3-component vector of uint)
0:14 'storeTemp' ( temp 4-component vector of float)
0:14 'storeTemp' ( temp 4-component vector of float)
0:12 Function Definition: main( ( temp void)
0:12 Function Parameters:
0:? Sequence
0:12 move second child to first child ( temp 3-component vector of uint)
0:? 'tid' ( temp 3-component vector of uint)
0:? 'tid' ( in 3-component vector of uint GlobalInvocationID)
0:12 Function Call: @main(vu3; ( temp void)
0:? 'tid' ( temp 3-component vector of uint)
0:? Linker Objects
0:? 'anon@0' (layout( row_major std140) uniform block{ uniform 4-component vector of float uf4})
0:? 'ResultInU' (layout( binding=0) uniform texture3D)
0:? 'ResultOutU' (layout( binding=0 rgba32f) uniform image3D)
0:? 'ResultInS' (layout( binding=1) uniform texture3D)
0:? 'ResultOutS' (layout( binding=1 rgba32f) uniform image3D)
0:? 'tid' ( in 3-component vector of uint GlobalInvocationID)
// Module Version 10000
// Generated by (magic number): 80002
// Id's are bound by 54
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint GLCompute 4 "main" 49
ExecutionMode 4 LocalSize 16 16 1
Source HLSL 500
Name 4 "main"
Name 11 "@main(vu3;"
Name 10 "tid"
Name 16 "storeTemp"
Name 19 "ResultInS"
Name 25 "$Global"
MemberName 25($Global) 0 "uf4"
Name 27 ""
Name 34 "ResultOutS"
Name 38 "storeTemp"
Name 39 "ResultInU"
Name 43 "ResultOutU"
Name 47 "tid"
Name 49 "tid"
Name 51 "param"
Decorate 19(ResultInS) DescriptorSet 0
Decorate 19(ResultInS) Binding 1
MemberDecorate 25($Global) 0 Offset 0
Decorate 25($Global) Block
Decorate 27 DescriptorSet 0
Decorate 34(ResultOutS) DescriptorSet 0
Decorate 34(ResultOutS) Binding 1
Decorate 39(ResultInU) DescriptorSet 0
Decorate 39(ResultInU) Binding 0
Decorate 43(ResultOutU) DescriptorSet 0
Decorate 43(ResultOutU) Binding 0
Decorate 49(tid) BuiltIn GlobalInvocationId
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
7: TypeVector 6(int) 3
8: TypePointer Function 7(ivec3)
9: TypeFunction 2 8(ptr)
13: TypeFloat 32
14: TypeVector 13(float) 4
15: TypePointer Function 14(fvec4)
17: TypeImage 13(float) 3D sampled format:Unknown
18: TypePointer UniformConstant 17
19(ResultInS): 18(ptr) Variable UniformConstant
22: TypeInt 32 1
23: 22(int) Constant 0
25($Global): TypeStruct 14(fvec4)
26: TypePointer Uniform 25($Global)
27: 26(ptr) Variable Uniform
28: TypePointer Uniform 14(fvec4)
32: TypeImage 13(float) 3D nonsampled format:Rgba32f
33: TypePointer UniformConstant 32
34(ResultOutS): 33(ptr) Variable UniformConstant
39(ResultInU): 18(ptr) Variable UniformConstant
43(ResultOutU): 33(ptr) Variable UniformConstant
48: TypePointer Input 7(ivec3)
49(tid): 48(ptr) Variable Input
4(main): 2 Function None 3
5: Label
47(tid): 8(ptr) Variable Function
51(param): 8(ptr) Variable Function
50: 7(ivec3) Load 49(tid)
Store 47(tid) 50
52: 7(ivec3) Load 47(tid)
Store 51(param) 52
53: 2 FunctionCall 11(@main(vu3;) 51(param)
Return
FunctionEnd
11(@main(vu3;): 2 Function None 9
10(tid): 8(ptr) FunctionParameter
12: Label
16(storeTemp): 15(ptr) Variable Function
38(storeTemp): 15(ptr) Variable Function
20: 17 Load 19(ResultInS)
21: 7(ivec3) Load 10(tid)
24: 14(fvec4) ImageFetch 20 21 Lod 23
29: 28(ptr) AccessChain 27 23
30: 14(fvec4) Load 29
31: 14(fvec4) FAdd 24 30
Store 16(storeTemp) 31
35: 32 Load 34(ResultOutS)
36: 7(ivec3) Load 10(tid)
37: 14(fvec4) Load 16(storeTemp)
ImageWrite 35 36 37
40: 17 Load 39(ResultInU)
41: 7(ivec3) Load 10(tid)
42: 14(fvec4) ImageFetch 40 41 Lod 23
Store 38(storeTemp) 42
44: 32 Load 43(ResultOutU)
45: 7(ivec3) Load 10(tid)
46: 14(fvec4) Load 38(storeTemp)
ImageWrite 44 45 46
Return
FunctionEnd

View File

@ -0,0 +1,153 @@
hlsl.texturebuffer.frag
Shader version: 500
gl_FragCoord origin is upper left
0:? Sequence
0:15 Function Definition: @main(vf4; ( temp 4-component vector of float)
0:15 Function Parameters:
0:15 'pos' ( in 4-component vector of float)
0:? Sequence
0:16 Branch: Return with expression
0:16 add ( temp 4-component vector of float)
0:16 f: direct index for structure (layout( row_major std430) buffer 4-component vector of float)
0:16 'TextureBuffer_var' (layout( binding=0 row_major std430) readonly buffer block{layout( row_major std430) buffer 4-component vector of float f, layout( row_major std430) buffer 4-component vector of int i})
0:16 Constant:
0:16 0 (const int)
0:16 f2: direct index for structure (layout( row_major std430) buffer 4-component vector of float)
0:16 'anon@0' (layout( row_major std430) readonly buffer block{layout( row_major std430) buffer 4-component vector of float f2, layout( row_major std430) buffer 4-component vector of int i2})
0:16 Constant:
0:16 0 (const uint)
0:15 Function Definition: main( ( temp void)
0:15 Function Parameters:
0:? Sequence
0:15 move second child to first child ( temp 4-component vector of float)
0:? 'pos' ( temp 4-component vector of float)
0:? 'pos' ( in 4-component vector of float FragCoord)
0:15 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:15 Function Call: @main(vf4; ( temp 4-component vector of float)
0:? 'pos' ( temp 4-component vector of float)
0:? Linker Objects
0:? 'TextureBuffer_var' (layout( binding=0 row_major std430) readonly buffer block{layout( row_major std430) buffer 4-component vector of float f, layout( row_major std430) buffer 4-component vector of int i})
0:? 'anon@0' (layout( row_major std430) readonly buffer block{layout( row_major std430) buffer 4-component vector of float f2, layout( row_major std430) buffer 4-component vector of int i2})
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:? 'pos' ( in 4-component vector of float FragCoord)
Linked fragment stage:
Shader version: 500
gl_FragCoord origin is upper left
0:? Sequence
0:15 Function Definition: @main(vf4; ( temp 4-component vector of float)
0:15 Function Parameters:
0:15 'pos' ( in 4-component vector of float)
0:? Sequence
0:16 Branch: Return with expression
0:16 add ( temp 4-component vector of float)
0:16 f: direct index for structure (layout( row_major std430) buffer 4-component vector of float)
0:16 'TextureBuffer_var' (layout( binding=0 row_major std430) readonly buffer block{layout( row_major std430) buffer 4-component vector of float f, layout( row_major std430) buffer 4-component vector of int i})
0:16 Constant:
0:16 0 (const int)
0:16 f2: direct index for structure (layout( row_major std430) buffer 4-component vector of float)
0:16 'anon@0' (layout( row_major std430) readonly buffer block{layout( row_major std430) buffer 4-component vector of float f2, layout( row_major std430) buffer 4-component vector of int i2})
0:16 Constant:
0:16 0 (const uint)
0:15 Function Definition: main( ( temp void)
0:15 Function Parameters:
0:? Sequence
0:15 move second child to first child ( temp 4-component vector of float)
0:? 'pos' ( temp 4-component vector of float)
0:? 'pos' ( in 4-component vector of float FragCoord)
0:15 move second child to first child ( temp 4-component vector of float)
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:15 Function Call: @main(vf4; ( temp 4-component vector of float)
0:? 'pos' ( temp 4-component vector of float)
0:? Linker Objects
0:? 'TextureBuffer_var' (layout( binding=0 row_major std430) readonly buffer block{layout( row_major std430) buffer 4-component vector of float f, layout( row_major std430) buffer 4-component vector of int i})
0:? 'anon@0' (layout( row_major std430) readonly buffer block{layout( row_major std430) buffer 4-component vector of float f2, layout( row_major std430) buffer 4-component vector of int i2})
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:? 'pos' ( in 4-component vector of float FragCoord)
// Module Version 10000
// Generated by (magic number): 80002
// Id's are bound by 39
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 32 35
ExecutionMode 4 OriginUpperLeft
Source HLSL 500
Name 4 "main"
Name 11 "@main(vf4;"
Name 10 "pos"
Name 15 "TextureBuffer_var"
MemberName 15(TextureBuffer_var) 0 "f"
MemberName 15(TextureBuffer_var) 1 "i"
Name 17 "TextureBuffer_var"
Name 22 "tbuf2"
MemberName 22(tbuf2) 0 "f2"
MemberName 22(tbuf2) 1 "i2"
Name 24 ""
Name 30 "pos"
Name 32 "pos"
Name 35 "@entryPointOutput"
Name 36 "param"
MemberDecorate 15(TextureBuffer_var) 0 NonWritable
MemberDecorate 15(TextureBuffer_var) 0 Offset 0
MemberDecorate 15(TextureBuffer_var) 1 NonWritable
MemberDecorate 15(TextureBuffer_var) 1 Offset 16
Decorate 15(TextureBuffer_var) BufferBlock
Decorate 17(TextureBuffer_var) DescriptorSet 0
Decorate 17(TextureBuffer_var) Binding 0
MemberDecorate 22(tbuf2) 0 NonWritable
MemberDecorate 22(tbuf2) 0 Offset 0
MemberDecorate 22(tbuf2) 1 NonWritable
MemberDecorate 22(tbuf2) 1 Offset 16
Decorate 22(tbuf2) BufferBlock
Decorate 24 DescriptorSet 0
Decorate 32(pos) BuiltIn FragCoord
Decorate 35(@entryPointOutput) Location 0
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: TypeInt 32 1
14: TypeVector 13(int) 4
15(TextureBuffer_var): TypeStruct 7(fvec4) 14(ivec4)
16: TypePointer Uniform 15(TextureBuffer_var)
17(TextureBuffer_var): 16(ptr) Variable Uniform
18: 13(int) Constant 0
19: TypePointer Uniform 7(fvec4)
22(tbuf2): TypeStruct 7(fvec4) 14(ivec4)
23: TypePointer Uniform 22(tbuf2)
24: 23(ptr) Variable Uniform
31: TypePointer Input 7(fvec4)
32(pos): 31(ptr) Variable Input
34: TypePointer Output 7(fvec4)
35(@entryPointOutput): 34(ptr) Variable Output
4(main): 2 Function None 3
5: Label
30(pos): 8(ptr) Variable Function
36(param): 8(ptr) Variable Function
33: 7(fvec4) Load 32(pos)
Store 30(pos) 33
37: 7(fvec4) Load 30(pos)
Store 36(param) 37
38: 7(fvec4) FunctionCall 11(@main(vf4;) 36(param)
Store 35(@entryPointOutput) 38
Return
FunctionEnd
11(@main(vf4;): 7(fvec4) Function None 9
10(pos): 8(ptr) FunctionParameter
12: Label
20: 19(ptr) AccessChain 17(TextureBuffer_var) 18
21: 7(fvec4) Load 20
25: 19(ptr) AccessChain 24 18
26: 7(fvec4) Load 25
27: 7(fvec4) FAdd 21 26
ReturnValue 27
FunctionEnd

View File

@ -0,0 +1,119 @@
cbuffer UniformBlock0 : register(b0)
{
float4x4 model_view_matrix;
float4x4 proj_matrix;
float4x4 model_view_proj_matrix;
float3x3 normal_matrix;
float3 color;
float3 view_dir;
float3 tess_factor;
};
// =============================================================================
// Hull Shader
// =============================================================================
struct HSInput {
float3 PositionWS : POSITION;
float3 NormalWS : NORMAL;
};
struct HSOutput {
float3 PositionWS : POSITION;
};
struct HSTrianglePatchConstant {
float EdgeTessFactor[3] : SV_TessFactor;
float InsideTessFactor : SV_InsideTessFactor;
float3 NormalWS[3] : NORMAL;
};
HSTrianglePatchConstant HSPatchConstant(InputPatch<HSInput, 3> patch)
{
float3 roundedEdgeTessFactor = tess_factor;
float roundedInsideTessFactor = 3;
float insideTessFactor = 1;
HSTrianglePatchConstant result;
// Edge and inside tessellation factors
result.EdgeTessFactor[0] = roundedEdgeTessFactor.x;
result.EdgeTessFactor[1] = roundedEdgeTessFactor.y;
result.EdgeTessFactor[2] = roundedEdgeTessFactor.z;
result.InsideTessFactor = roundedInsideTessFactor;
// Constant data
result.NormalWS[0] = patch[0].NormalWS;
result.NormalWS[1] = patch[1].NormalWS;
result.NormalWS[2] = patch[2].NormalWS;
return result;
}
[domain("tri")]
[partitioning("fractional_odd")]
[outputtopology("triangle_ccw")]
[outputcontrolpoints(3)]
[patchconstantfunc("HSPatchConstant")]
HSOutput HSMain(
InputPatch<HSInput, 3> patch,
uint id : SV_OutputControlPointID
)
{
HSOutput output;
output.PositionWS = patch[id].PositionWS;
return output;
}
// =============================================================================
// Geometry Shader
// =============================================================================
struct GSVertexInput {
float3 PositionWS : POSITION;
float3 NormalWS : NORMAL;
};
struct GSVertexOutput {
float4 PositionCS : SV_POSITION;
};
[maxvertexcount(6)]
void GSMain(
triangle GSVertexInput input[3],
inout LineStream<GSVertexOutput> output
)
{
float3 P0 = input[0].PositionWS.xyz;
float3 P1 = input[1].PositionWS.xyz;
float3 P2 = input[2].PositionWS.xyz;
GSVertexOutput vertex;
// Totally hacky...
P0.z += 0.001;
P1.z += 0.001;
P2.z += 0.001;
float4 Q0 = mul(proj_matrix, float4(P0, 1.0));
float4 Q1 = mul(proj_matrix, float4(P1, 1.0));
float4 Q2 = mul(proj_matrix, float4(P2, 1.0));
// Edge 0
vertex.PositionCS = Q0;
output.Append(vertex);
vertex.PositionCS = Q1;
output.Append(vertex);
output.RestartStrip();
// Edge 1
vertex.PositionCS = Q1;
output.Append(vertex);
vertex.PositionCS = Q2;
output.Append(vertex);
output.RestartStrip();
// Edge 2
vertex.PositionCS = Q2;
output.Append(vertex);
vertex.PositionCS = Q0;
output.Append(vertex);
output.RestartStrip();
}

View File

@ -0,0 +1,15 @@
unorm float4 uf4;
Texture3D<unorm float4> ResultInU: register(t0);
RWTexture3D<unorm float4> ResultOutU: register(u0);
Texture3D<snorm float4> ResultInS: register(t1);
RWTexture3D<snorm float4> ResultOutS: register(u1);
[numthreads(16, 16, 1)]
void main(uint3 tid: SV_DispatchThreadID)
{
ResultOutS[tid] = ResultInS[tid] + uf4;
ResultOutU[tid] = ResultInU[tid];
}

View File

@ -0,0 +1,17 @@
struct Data {
float4 f;
int4 i;
};
TextureBuffer<Data> TextureBuffer_var : register(t0);
tbuffer tbuf2 {
float4 f2;
int4 i2;
};
float4 main(float4 pos : SV_POSITION) : SV_TARGET
{
return TextureBuffer_var.f + f2;
}

View File

@ -37,10 +37,7 @@
namespace glslang {
void InitializeMemoryPools();
void FreeGlobalPools();
bool InitializePoolIndex();
void FreePoolIndex();
} // end namespace glslang

View File

@ -250,15 +250,8 @@ private:
// different times. But a simple use is to have a global pop
// with everyone using the same global allocator.
//
typedef TPoolAllocator* PoolAllocatorPointer;
extern TPoolAllocator& GetThreadPoolAllocator();
struct TThreadMemoryPools
{
TPoolAllocator* threadPoolAllocator;
};
void SetThreadPoolAllocator(TPoolAllocator& poolAllocator);
void SetThreadPoolAllocator(TPoolAllocator* poolAllocator);
//
// This STL compatible allocator is intended to be used as the allocator

View File

@ -56,11 +56,14 @@ class TUniformMap;
//
class TShHandleBase {
public:
TShHandleBase() { }
virtual ~TShHandleBase() { }
TShHandleBase() { pool = new glslang::TPoolAllocator; }
virtual ~TShHandleBase() { delete pool; }
virtual TCompiler* getAsCompiler() { return 0; }
virtual TLinker* getAsLinker() { return 0; }
virtual TUniformMap* getAsUniformMap() { return 0; }
virtual glslang::TPoolAllocator* getPool() const { return pool; }
private:
glslang::TPoolAllocator* pool;
};
//

View File

@ -40,35 +40,22 @@
namespace glslang {
// Process-wide TLS index
OS_TLSIndex PoolIndex;
void InitializeMemoryPools()
// Return the thread-specific current pool.
TPoolAllocator& GetThreadPoolAllocator()
{
TThreadMemoryPools* pools = static_cast<TThreadMemoryPools*>(OS_GetTLSValue(PoolIndex));
if (pools)
return;
TPoolAllocator *threadPoolAllocator = new TPoolAllocator();
TThreadMemoryPools* threadData = new TThreadMemoryPools();
threadData->threadPoolAllocator = threadPoolAllocator;
OS_SetTLSValue(PoolIndex, threadData);
return *static_cast<TPoolAllocator*>(OS_GetTLSValue(PoolIndex));
}
void FreeGlobalPools()
// Set the thread-specific current pool.
void SetThreadPoolAllocator(TPoolAllocator* poolAllocator)
{
// Release the allocated memory for this thread.
TThreadMemoryPools* globalPools = static_cast<TThreadMemoryPools*>(OS_GetTLSValue(PoolIndex));
if (! globalPools)
return;
GetThreadPoolAllocator().popAll();
delete &GetThreadPoolAllocator();
delete globalPools;
OS_SetTLSValue(PoolIndex, poolAllocator);
}
// Process-wide set up of the TLS pool storage.
bool InitializePoolIndex()
{
// Allocate a TLS index.
@ -78,26 +65,6 @@ bool InitializePoolIndex()
return true;
}
void FreePoolIndex()
{
// Release the TLS index.
OS_FreeTLSIndex(PoolIndex);
}
TPoolAllocator& GetThreadPoolAllocator()
{
TThreadMemoryPools* threadData = static_cast<TThreadMemoryPools*>(OS_GetTLSValue(PoolIndex));
return *threadData->threadPoolAllocator;
}
void SetThreadPoolAllocator(TPoolAllocator& poolAllocator)
{
TThreadMemoryPools* threadData = static_cast<TThreadMemoryPools*>(OS_GetTLSValue(PoolIndex));
threadData->threadPoolAllocator = &poolAllocator;
}
//
// Implement the functionality of the TPoolAllocator class, which
// is documented in PoolAlloc.h.

View File

@ -69,6 +69,10 @@
namespace { // anonymous namespace for file-local functions and symbols
// Total number of successful initializers of glslang: a refcount
// Shared global; access should be protected by a global mutex/critical section.
int NumberOfClients = 0;
using namespace glslang;
// Create a language specific version of parseables.
@ -217,7 +221,7 @@ enum EPrecisionClass {
TSymbolTable* CommonSymbolTable[VersionCount][SpvVersionCount][ProfileCount][SourceCount][EPcCount] = {};
TSymbolTable* SharedSymbolTables[VersionCount][SpvVersionCount][ProfileCount][SourceCount][EShLangCount] = {};
TPoolAllocator* PerProcessGPA = 0;
TPoolAllocator* PerProcessGPA = nullptr;
//
// Parse and add to the given symbol table the content of the given shader string.
@ -361,7 +365,7 @@ bool AddContextSpecificSymbols(const TBuiltInResource* resources, TInfoSink& inf
// pool allocator intact, so:
// - Switch to a new pool for parsing the built-ins
// - Do the parsing, which builds the symbol table, using the new pool
// - Switch to the process-global pool to save a copy the resulting symbol table
// - Switch to the process-global pool to save a copy of the resulting symbol table
// - Free up the new pool used to parse the built-ins
// - Switch back to the original thread's pool
//
@ -388,8 +392,8 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
// Switch to a new pool
TPoolAllocator& previousAllocator = GetThreadPoolAllocator();
TPoolAllocator* builtInPoolAllocator = new TPoolAllocator();
SetThreadPoolAllocator(*builtInPoolAllocator);
TPoolAllocator* builtInPoolAllocator = new TPoolAllocator;
SetThreadPoolAllocator(builtInPoolAllocator);
// Dynamically allocate the local symbol tables so we can control when they are deallocated WRT when the pool is popped.
TSymbolTable* commonTable[EPcCount];
@ -403,7 +407,7 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
InitializeSymbolTables(infoSink, commonTable, stageTables, version, profile, spvVersion, source);
// Switch to the process-global pool
SetThreadPoolAllocator(*PerProcessGPA);
SetThreadPoolAllocator(PerProcessGPA);
// Copy the local symbol tables from the new pool to the global tables using the process-global pool
for (int precClass = 0; precClass < EPcCount; ++precClass) {
@ -430,7 +434,7 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
delete stageTables[stage];
delete builtInPoolAllocator;
SetThreadPoolAllocator(previousAllocator);
SetThreadPoolAllocator(&previousAllocator);
glslang::ReleaseGlobalLock();
}
@ -722,9 +726,6 @@ bool ProcessDeferred(
const std::string sourceEntryPointName = "",
const TEnvironment* environment = nullptr) // optional way of fully setting all versions, overriding the above
{
if (! InitThread())
return false;
// This must be undone (.pop()) by the caller, after it finishes consuming the created tree.
GetThreadPoolAllocator().push();
@ -1196,7 +1197,11 @@ int ShInitialize()
if (! InitProcess())
return 0;
if (! PerProcessGPA)
glslang::GetGlobalLock();
++NumberOfClients;
glslang::ReleaseGlobalLock();
if (PerProcessGPA == nullptr)
PerProcessGPA = new TPoolAllocator();
glslang::TScanContext::fillInKeywordMap();
@ -1262,6 +1267,14 @@ void ShDestruct(ShHandle handle)
//
int __fastcall ShFinalize()
{
glslang::GetGlobalLock();
--NumberOfClients;
assert(NumberOfClients >= 0);
bool finalize = NumberOfClients == 0;
glslang::ReleaseGlobalLock();
if (! finalize)
return 1;
for (int version = 0; version < VersionCount; ++version) {
for (int spvVersion = 0; spvVersion < SpvVersionCount; ++spvVersion) {
for (int p = 0; p < ProfileCount; ++p) {
@ -1288,10 +1301,9 @@ int __fastcall ShFinalize()
}
}
if (PerProcessGPA) {
PerProcessGPA->popAll();
if (PerProcessGPA != nullptr) {
delete PerProcessGPA;
PerProcessGPA = 0;
PerProcessGPA = nullptr;
}
glslang::TScanContext::deleteKeywordMap();
@ -1332,6 +1344,8 @@ int ShCompile(
if (compiler == 0)
return 0;
SetThreadPoolAllocator(compiler->getPool());
compiler->infoSink.info.erase();
compiler->infoSink.debug.erase();
@ -1389,6 +1403,8 @@ int ShLinkExt(
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle);
TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
SetThreadPoolAllocator(linker->getPool());
if (linker == 0)
return 0;
@ -1423,9 +1439,6 @@ void ShSetEncryptionMethod(ShHandle handle)
//
const char* ShGetInfoLog(const ShHandle handle)
{
if (!InitThread())
return 0;
if (handle == 0)
return 0;
@ -1449,9 +1462,6 @@ const char* ShGetInfoLog(const ShHandle handle)
//
const void* ShGetExecutable(const ShHandle handle)
{
if (!InitThread())
return 0;
if (handle == 0)
return 0;
@ -1474,9 +1484,6 @@ const void* ShGetExecutable(const ShHandle handle)
//
int ShSetVirtualAttributeBindings(const ShHandle handle, const ShBindingTable* table)
{
if (!InitThread())
return 0;
if (handle == 0)
return 0;
@ -1496,9 +1503,6 @@ int ShSetVirtualAttributeBindings(const ShHandle handle, const ShBindingTable* t
//
int ShSetFixedAttributeBindings(const ShHandle handle, const ShBindingTable* table)
{
if (!InitThread())
return 0;
if (handle == 0)
return 0;
@ -1517,9 +1521,6 @@ int ShSetFixedAttributeBindings(const ShHandle handle, const ShBindingTable* tab
//
int ShExcludeAttributes(const ShHandle handle, int *attributes, int count)
{
if (!InitThread())
return 0;
if (handle == 0)
return 0;
@ -1541,9 +1542,6 @@ int ShExcludeAttributes(const ShHandle handle, int *attributes, int count)
//
int ShGetUniformLocation(const ShHandle handle, const char* name)
{
if (!InitThread())
return 0;
if (handle == 0)
return -1;
@ -1602,8 +1600,9 @@ public:
};
TShader::TShader(EShLanguage s)
: pool(0), stage(s), lengths(nullptr), stringNames(nullptr), preamble("")
: stage(s), lengths(nullptr), stringNames(nullptr), preamble("")
{
pool = new TPoolAllocator;
infoSink = new TInfoSink;
compiler = new TDeferredCompiler(stage, *infoSink);
intermediate = new TIntermediate(s);
@ -1706,9 +1705,8 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion
{
if (! InitThread())
return false;
SetThreadPoolAllocator(pool);
pool = new TPoolAllocator();
SetThreadPoolAllocator(*pool);
if (! preamble)
preamble = "";
@ -1730,9 +1728,8 @@ bool TShader::preprocess(const TBuiltInResource* builtInResources,
{
if (! InitThread())
return false;
SetThreadPoolAllocator(pool);
pool = new TPoolAllocator();
SetThreadPoolAllocator(*pool);
if (! preamble)
preamble = "";
@ -1752,8 +1749,9 @@ const char* TShader::getInfoDebugLog()
return infoSink->debug.c_str();
}
TProgram::TProgram() : pool(0), reflection(0), ioMapper(nullptr), linked(false)
TProgram::TProgram() : reflection(0), ioMapper(nullptr), linked(false)
{
pool = new TPoolAllocator;
infoSink = new TInfoSink;
for (int s = 0; s < EShLangCount; ++s) {
intermediate[s] = 0;
@ -1788,8 +1786,7 @@ bool TProgram::link(EShMessages messages)
bool error = false;
pool = new TPoolAllocator();
SetThreadPoolAllocator(*pool);
SetThreadPoolAllocator(pool);
for (int s = 0; s < EShLangCount; ++s) {
if (! linkStage((EShLanguage)s, messages))

View File

@ -43,6 +43,9 @@
#include <assert.h>
#include <errno.h>
#include <stdint.h>
#include <cstdio>
#include <sys/time.h>
#include <sys/resource.h>
namespace glslang {
@ -184,8 +187,18 @@ void ReleaseGlobalLock()
pthread_mutex_unlock(&gMutex);
}
// #define DUMP_COUNTERS
void OS_DumpMemoryCounters()
{
#ifdef DUMP_COUNTERS
struct rusage usage;
if (getrusage(RUSAGE_SELF, &usage) == 0)
printf("Working set size: %ld\n", usage.ru_maxrss * 1024);
#else
printf("Recompile with DUMP_COUNTERS defined to see counters.\n");
#endif
}
} // end namespace glslang

View File

@ -68,15 +68,14 @@
#endif
//
// Driver must call this first, once, before doing any other
// compiler/linker operations.
// Call before doing any other compiler/linker operations.
//
// (Call once per process, not once per thread.)
//
SH_IMPORT_EXPORT int ShInitialize();
//
// Driver should call this at process shutdown.
// Call this at process shutdown to clean up memory.
//
SH_IMPORT_EXPORT int __fastcall ShFinalize();
@ -290,7 +289,7 @@ SH_IMPORT_EXPORT int ShGetUniformLocation(const ShHandle uniformMap, const char*
// Deferred-Lowering C++ Interface
// -----------------------------------
//
// Below is a new alternate C++ interface that might potentially replace the above
// Below is a new alternate C++ interface, which deprecates the above
// opaque handle-based interface.
//
// The below is further designed to handle multiple compilation units per stage, where

View File

@ -172,6 +172,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.getdimensions.dx10.vert", "main"},
{"hlsl.getsampleposition.dx10.frag", "main"},
{"hlsl.global-const-init.frag", "main"},
{"hlsl.gs-hs-mix.tesc", "HSMain"},
{"hlsl.domain.1.tese", "main"},
{"hlsl.domain.2.tese", "main"},
{"hlsl.domain.3.tese", "main"},
@ -297,6 +298,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.semicolons.frag", "main"},
{"hlsl.shapeConv.frag", "main"},
{"hlsl.shapeConvRet.frag", "main"},
{"hlsl.snorm.uav.comp", "main"},
{"hlsl.staticMemberFunction.frag", "main"},
{"hlsl.stringtoken.frag", "main"},
{"hlsl.string.frag", "main"},
@ -326,6 +328,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.structStructName.frag", "main"},
{"hlsl.subpass.frag", "main"},
{"hlsl.synthesizeInput.frag", "main"},
{"hlsl.texturebuffer.frag", "main"},
{"hlsl.texture.struct.frag", "main"},
{"hlsl.texture.subvec4.frag", "main"},
{"hlsl.this.frag", "main"},
@ -384,7 +387,10 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.flattenOpaque.frag", "main"},
{"hlsl.flattenOpaqueInit.vert", "main"},
{"hlsl.flattenOpaqueInitMix.vert", "main"},
{"hlsl.flattenSubset.frag", "main"}
{"hlsl.flattenSubset.frag", "main"},
{"hlsl.flattenSubset2.frag", "main"},
{"hlsl.partialFlattenLocal.vert", "main"},
{"hlsl.partialFlattenMixed.vert", "main"}
}),
FileNameAsCustomTestSuffix
);

View File

@ -1378,6 +1378,23 @@ bool HlslGrammar::acceptType(TType& type, TIntermNode*& nodeList)
}
}
bool isUnorm = false;
bool isSnorm = false;
// Accept snorm and unorm. Presently, this is ignored, save for an error check below.
switch (peek()) {
case EHTokUnorm:
isUnorm = true;
advanceToken(); // eat the token
break;
case EHTokSNorm:
isSnorm = true;
advanceToken(); // eat the token
break;
default:
break;
}
switch (peek()) {
case EHTokVector:
return acceptVectorTemplateType(type);
@ -1453,6 +1470,10 @@ bool HlslGrammar::acceptType(TType& type, TIntermNode*& nodeList)
return acceptStructBufferType(type);
break;
case EHTokTextureBuffer:
return acceptTextureBufferType(type);
break;
case EHTokConstantBuffer:
return acceptConstantBufferType(type);
@ -1968,6 +1989,11 @@ bool HlslGrammar::acceptType(TType& type, TIntermNode*& nodeList)
advanceToken();
if ((isUnorm || isSnorm) && !type.isFloatingDomain()) {
parseContext.error(token.loc, "unorm and snorm only valid in floating point domain", "", "");
return false;
}
return true;
}
@ -2127,6 +2153,43 @@ bool HlslGrammar::acceptConstantBufferType(TType& type)
}
}
// texture_buffer
// : TEXTUREBUFFER LEFT_ANGLE type RIGHT_ANGLE
bool HlslGrammar::acceptTextureBufferType(TType& type)
{
if (! acceptTokenClass(EHTokTextureBuffer))
return false;
if (! acceptTokenClass(EHTokLeftAngle)) {
expected("left angle bracket");
return false;
}
TType templateType;
if (! acceptType(templateType)) {
expected("type");
return false;
}
if (! acceptTokenClass(EHTokRightAngle)) {
expected("right angle bracket");
return false;
}
templateType.getQualifier().storage = EvqBuffer;
templateType.getQualifier().readonly = true;
TType blockType(templateType.getWritableStruct(), "", templateType.getQualifier());
blockType.getQualifier().storage = EvqBuffer;
blockType.getQualifier().readonly = true;
type.shallowCopy(blockType);
return true;
}
// struct_buffer
// : APPENDSTRUCTUREDBUFFER
// | BYTEADDRESSBUFFER

View File

@ -89,6 +89,7 @@ namespace glslang {
bool acceptTextureType(TType&);
bool acceptSubpassInputType(TType&);
bool acceptStructBufferType(TType&);
bool acceptTextureBufferType(TType&);
bool acceptConstantBufferType(TType&);
bool acceptStruct(TType&, TIntermNode*& nodeList);
bool acceptStructDeclarationList(TTypeList*&, TIntermNode*& nodeList, TVector<TFunctionDeclarator>&);

View File

@ -8559,6 +8559,11 @@ bool HlslParseContext::handleInputGeometry(const TSourceLoc& loc, const TLayoutG
//
bool HlslParseContext::handleOutputGeometry(const TSourceLoc& loc, const TLayoutGeometry& geometry)
{
// If this is not a geometry shader, ignore. It might be a mixed shader including several stages.
// Since that's an OK situation, return true for success.
if (language != EShLangGeometry)
return true;
switch (geometry) {
case ElgPoints:
case ElgLineStrip:

View File

@ -345,6 +345,7 @@ void HlslScanContext::fillInKeywordMap()
(*KeywordMap)["RWByteAddressBuffer"] = EHTokRWByteAddressBuffer;
(*KeywordMap)["RWStructuredBuffer"] = EHTokRWStructuredBuffer;
(*KeywordMap)["StructuredBuffer"] = EHTokStructuredBuffer;
(*KeywordMap)["TextureBuffer"] = EHTokTextureBuffer;
(*KeywordMap)["class"] = EHTokClass;
(*KeywordMap)["struct"] = EHTokStruct;
@ -829,6 +830,7 @@ EHlslTokenClass HlslScanContext::tokenizeIdentifier()
case EHTokRWByteAddressBuffer:
case EHTokRWStructuredBuffer:
case EHTokStructuredBuffer:
case EHTokTextureBuffer:
case EHTokSubpassInput:
case EHTokSubpassInputMS:
return keyword;

View File

@ -283,6 +283,7 @@ enum EHlslTokenClass {
EHTokRWByteAddressBuffer,
EHTokRWStructuredBuffer,
EHTokStructuredBuffer,
EHTokTextureBuffer,
// variable, user type, ...
EHTokIdentifier,