Updated glslang.

This commit is contained in:
Бранимир Караџић 2019-04-20 09:15:56 -07:00
parent 1a0bc13ba1
commit 57496fad1f
20 changed files with 173 additions and 106 deletions

View File

@ -1,7 +1,8 @@
Language: Cpp
IndentWidth: 4
PointerAlignment: Left
BreakBeforeBraces: Custom
BraceWrapping: { AfterFunction: true, AfterControlStatement: true }
BraceWrapping: { AfterFunction: true, AfterControlStatement: false }
IndentCaseLabels: false
ReflowComments: false
ColumnLimit: 120

View File

@ -162,6 +162,7 @@ const char* shaderStageName = nullptr;
const char* variableName = nullptr;
bool HlslEnable16BitTypes = false;
bool HlslDX9compatible = false;
bool DumpBuiltinSymbols = false;
std::vector<std::string> IncludeDirectoryList;
// Source environment
@ -494,6 +495,8 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
Error("--client expects vulkan100 or opengl100");
}
bumpArg();
} else if (lowerword == "dump-builtin-symbols") {
DumpBuiltinSymbols = true;
} else if (lowerword == "entry-point") {
entryPointName = argv[1];
if (argc <= 1)
@ -833,6 +836,8 @@ void SetMessageOptions(EShMessages& messages)
messages = (EShMessages)(messages | EShMsgHlslLegalization);
if (HlslDX9compatible)
messages = (EShMessages)(messages | EShMsgHlslDX9Compatible);
if (DumpBuiltinSymbols)
messages = (EShMessages)(messages | EShMsgBuiltinSymbolTable);
}
//
@ -1520,6 +1525,7 @@ void usage()
" --auto-map-locations | --aml automatically locate input/output lacking\n"
" 'location' (fragile, not cross stage)\n"
" --client {vulkan<ver>|opengl<ver>} see -V and -G\n"
" --dump-builtin-symbols prints builtin symbol table prior each compile\n"
" -dumpfullversion | -dumpversion print bare major.minor.patchlevel\n"
" --flatten-uniform-arrays | --fua flatten uniform texture/sampler arrays to\n"
" scalars\n"

View File

@ -106,9 +106,9 @@ layout(r32i) coherent restrict readonly uniform iimage2D qualim2;
void passrc()
{
passr(qualim1);
passr(qualim2); // ERROR, drops restrict
passr(iimg2D);
passr(qualim1); // ERROR, changing formats
passr(qualim2); // ERROR, drops restrict, ERROR, changing formats
passr(iimg2D); // ERROR, changing formats
}
highp layout(rg8i) uniform readonly uimage2D i1bad; // ERROR, type mismatch

View File

@ -131,9 +131,9 @@ layout(r32i) coherent volatile readonly uniform iimage2D qualim2;
void passrc()
{
passr(qualim1);
passr(qualim2); // ERROR, drops volatile
passr(iimg2D);
passr(qualim1); // ERROR, changing formats
passr(qualim2); // ERROR, drops volatile, ERROR, changing formats
passr(iimg2D); // ERROR, changing formats
}
layout(rg8i) uniform uimage2D i1bad; // ERROR, type mismatch

View File

@ -28,6 +28,10 @@ ERROR: 0:90: 'imageAtomicMax' : no matching overloaded function found
ERROR: 0:94: 'writeonly' : argument cannot drop memory qualifier when passed to formal parameter
ERROR: 0:97: '' : memory qualifiers cannot be used on this type
ERROR: 0:98: '' : memory qualifiers cannot be used on this type
ERROR: 0:109: 'format' : image formats must match
ERROR: 0:110: 'restrict' : argument cannot drop memory qualifier when passed to formal parameter
ERROR: 0:110: 'format' : image formats must match
ERROR: 0:111: 'format' : image formats must match
ERROR: 0:114: 'image load-store format' : not supported with this profile: es
ERROR: 0:114: 'rg8i' : does not apply to unsigned integer images
ERROR: 0:115: 'rgba32i' : does not apply to floating point images
@ -83,7 +87,7 @@ WARNING: 0:238: '#define' : names containing consecutive underscores are reserve
ERROR: 0:244: 'gl_DeviceIndex' : required extension not requested: GL_EXT_device_group
ERROR: 0:245: 'gl_ViewIndex' : undeclared identifier
ERROR: 0:255: 'gl_ViewIndex' : undeclared identifier
ERROR: 82 compilation errors. No code generated.
ERROR: 86 compilation errors. No code generated.
Shader version: 310

View File

@ -38,7 +38,10 @@ ERROR: 0:115: 'imageAtomicMax' : no matching overloaded function found
ERROR: 0:119: 'writeonly' : argument cannot drop memory qualifier when passed to formal parameter
ERROR: 0:122: '' : memory qualifiers cannot be used on this type
ERROR: 0:123: '' : memory qualifiers cannot be used on this type
ERROR: 0:134: 'format' : image formats must match
ERROR: 0:135: 'volatile' : argument cannot drop memory qualifier when passed to formal parameter
ERROR: 0:135: 'format' : image formats must match
ERROR: 0:136: 'format' : image formats must match
ERROR: 0:139: 'rg8i' : does not apply to unsigned integer images
ERROR: 0:140: 'rgba32i' : does not apply to floating point images
ERROR: 0:141: 'rgba32f' : does not apply to unsigned integer images
@ -52,7 +55,7 @@ ERROR: 0:157: 'assign' : cannot convert from ' const float' to ' temp int'
ERROR: 0:158: 'textureQueryLevels' : no matching overloaded function found
ERROR: 0:158: 'assign' : cannot convert from ' const float' to ' temp int'
WARNING: 0:161: '[]' : assuming binding count of one for compile-time checking of binding numbers for unsized array
ERROR: 51 compilation errors. No code generated.
ERROR: 54 compilation errors. No code generated.
Shader version: 420

View File

@ -30,8 +30,10 @@ ERROR: 0:132: 'shared' : not supported in this stage: vertex
ERROR: 0:134: '' : function does not return a value: funcA
ERROR: 0:136: '' : function does not return a value: funcB
ERROR: 0:153: '' : function does not return a value: func3
ERROR: 0:169: 'format' : image formats must match
ERROR: 0:170: 'coherent' : argument cannot drop memory qualifier when passed to formal parameter
ERROR: 32 compilation errors. No code generated.
ERROR: 0:170: 'format' : image formats must match
ERROR: 34 compilation errors. No code generated.
Shader version: 430

View File

@ -31,8 +31,10 @@ ERROR: 0:132: 'shared' : not supported in this stage: vertex
ERROR: 0:134: '' : function does not return a value: funcA
ERROR: 0:136: '' : function does not return a value: funcB
ERROR: 0:153: '' : function does not return a value: func3
ERROR: 0:169: 'format' : image formats must match
ERROR: 0:170: 'coherent' : argument cannot drop memory qualifier when passed to formal parameter
ERROR: 33 compilation errors. No code generated.
ERROR: 0:170: 'format' : image formats must match
ERROR: 35 compilation errors. No code generated.
Shader version: 430

View File

@ -2,14 +2,14 @@ spv.paramMemory.frag
Validation failed
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 69
// Id's are bound by 64
Capability Shader
Capability StorageImageReadWithoutFormat
Capability StorageImageWriteWithoutFormat
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 27 66
EntryPoint Fragment 4 "main" 27 61
ExecutionMode 4 OriginUpperLeft
Source ESSL 310
Name 4 "main"
@ -22,39 +22,28 @@ Validation failed
Name 22 "data"
Name 27 "in_coords"
Name 35 "read1"
Name 38 "image1"
Name 39 "param"
Name 42 "read2"
Name 45 "image2"
Name 38 "read2"
Name 43 "image3"
Name 46 "param"
Name 49 "image3"
Name 53 "param"
Name 55 "param"
Name 57 "image4"
Name 61 "param"
Name 63 "param"
Name 66 "out_color"
Name 48 "param"
Name 52 "image4"
Name 56 "param"
Name 58 "param"
Name 61 "out_color"
Decorate 14(image) Coherent
Decorate 14(image) NonWritable
Decorate 20(image) Coherent
Decorate 20(image) NonReadable
Decorate 27(in_coords) Flat
Decorate 27(in_coords) Location 0
Decorate 38(image1) DescriptorSet 0
Decorate 38(image1) Binding 0
Decorate 38(image1) Coherent
Decorate 38(image1) NonWritable
Decorate 45(image2) DescriptorSet 0
Decorate 45(image2) Binding 2
Decorate 45(image2) NonWritable
Decorate 49(image3) DescriptorSet 0
Decorate 49(image3) Binding 1
Decorate 49(image3) Coherent
Decorate 49(image3) NonReadable
Decorate 57(image4) DescriptorSet 0
Decorate 57(image4) Binding 3
Decorate 57(image4) NonReadable
Decorate 66(out_color) Location 0
Decorate 43(image3) DescriptorSet 0
Decorate 43(image3) Binding 1
Decorate 43(image3) Coherent
Decorate 43(image3) NonReadable
Decorate 52(image4) DescriptorSet 0
Decorate 52(image4) Binding 3
Decorate 52(image4) NonReadable
Decorate 61(out_color) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -69,51 +58,44 @@ Validation failed
19: TypeFunction 2 8(ptr) 11(ptr) 18(ptr)
26: TypePointer Input 10(ivec2)
27(in_coords): 26(ptr) Variable Input
36: TypeImage 6(float) 2D nonsampled format:Rgba32f
37: TypePointer UniformConstant 36
38(image1): 37(ptr) Variable UniformConstant
43: TypeImage 6(float) 2D nonsampled format:Rgba16f
44: TypePointer UniformConstant 43
45(image2): 44(ptr) Variable UniformConstant
49(image3): 37(ptr) Variable UniformConstant
51: 6(float) Constant 1056964608
57(image4): 44(ptr) Variable UniformConstant
59: 6(float) Constant 1073741824
65: TypePointer Output 12(fvec4)
66(out_color): 65(ptr) Variable Output
67: 6(float) Constant 0
68: 12(fvec4) ConstantComposite 67 67 67 67
36: 6(float) Constant 1053609165
37: 12(fvec4) ConstantComposite 36 36 36 36
39: 6(float) Constant 1056964608
40: 12(fvec4) ConstantComposite 39 39 39 39
41: TypeImage 6(float) 2D nonsampled format:Rgba32f
42: TypePointer UniformConstant 41
43(image3): 42(ptr) Variable UniformConstant
50: TypeImage 6(float) 2D nonsampled format:Rgba16f
51: TypePointer UniformConstant 50
52(image4): 51(ptr) Variable UniformConstant
54: 6(float) Constant 1073741824
60: TypePointer Output 12(fvec4)
61(out_color): 60(ptr) Variable Output
62: 6(float) Constant 0
63: 12(fvec4) ConstantComposite 62 62 62 62
4(main): 2 Function None 3
5: Label
35(read1): 18(ptr) Variable Function
39(param): 11(ptr) Variable Function
42(read2): 18(ptr) Variable Function
38(read2): 18(ptr) Variable Function
46(param): 11(ptr) Variable Function
53(param): 11(ptr) Variable Function
55(param): 18(ptr) Variable Function
61(param): 11(ptr) Variable Function
63(param): 18(ptr) Variable Function
40: 10(ivec2) Load 27(in_coords)
Store 39(param) 40
41: 12(fvec4) FunctionCall 16(image_load(I21;vi2;) 38(image1) 39(param)
Store 35(read1) 41
48(param): 18(ptr) Variable Function
56(param): 11(ptr) Variable Function
58(param): 18(ptr) Variable Function
Store 35(read1) 37
Store 38(read2) 40
44: 12(fvec4) Load 35(read1)
45: 12(fvec4) VectorTimesScalar 44 39
47: 10(ivec2) Load 27(in_coords)
Store 46(param) 47
48: 12(fvec4) FunctionCall 16(image_load(I21;vi2;) 45(image2) 46(param)
Store 42(read2) 48
50: 12(fvec4) Load 35(read1)
52: 12(fvec4) VectorTimesScalar 50 51
54: 10(ivec2) Load 27(in_coords)
Store 53(param) 54
Store 55(param) 52
56: 2 FunctionCall 23(image_store(I21;vi2;vf4;) 49(image3) 53(param) 55(param)
58: 12(fvec4) Load 42(read2)
60: 12(fvec4) VectorTimesScalar 58 59
62: 10(ivec2) Load 27(in_coords)
Store 61(param) 62
Store 63(param) 60
64: 2 FunctionCall 23(image_store(I21;vi2;vf4;) 57(image4) 61(param) 63(param)
Store 66(out_color) 68
Store 48(param) 45
49: 2 FunctionCall 23(image_store(I21;vi2;vf4;) 43(image3) 46(param) 48(param)
53: 12(fvec4) Load 38(read2)
55: 12(fvec4) VectorTimesScalar 53 54
57: 10(ivec2) Load 27(in_coords)
Store 56(param) 57
Store 58(param) 55
59: 2 FunctionCall 23(image_store(I21;vi2;vf4;) 52(image4) 56(param) 58(param)
Store 61(out_color) 63
Return
FunctionEnd
16(image_load(I21;vi2;): 12(fvec4) Function None 13

View File

@ -166,8 +166,8 @@ void main()
v.x = func2(a.x, b.x, c.x, d.x); // precise!
func3(a.x * b.x, c.x * d.x, v.x); // precise!
funcA(img1); // OK, adding "restrict" is allowed
funcB(img2); // illegal, stripping "coherent" is not
funcA(img1); // OK, adding "restrict" is allowed, ERROR, changing formats
funcB(img2); // illegal, stripping "coherent" is not, ERROR, changing formats
{
struct light {

View File

@ -1,7 +1,7 @@
#version 310 es
readonly coherent uniform layout(set = 0, binding = 0, rgba32f) highp image2D image1;
readonly uniform layout(set = 0, binding = 2, rgba16f) highp image2D image2;
// readonly coherent uniform layout(set = 0, binding = 0) highp image2D image1;
// readonly uniform layout(set = 0, binding = 2) highp image2D image2;
writeonly coherent uniform layout(set = 0, binding = 1, rgba32f) highp image2D image3;
writeonly uniform layout(set = 0, binding = 3, rgba16f) highp image2D image4;
@ -20,8 +20,8 @@ void image_store(writeonly coherent highp image2D image, highp ivec2 coords, hig
void main()
{
highp vec4 read1 = image_load(image1, in_coords);
highp vec4 read2 = image_load(image2, in_coords);
highp vec4 read1 = vec4(0.4); // = image_load(image1, in_coords);
highp vec4 read2 = vec4(0.5); // = image_load(image2, in_coords);
image_store(image3, in_coords, read1*0.5);
image_store(image4, in_coords, read2*2.0);

View File

@ -37,9 +37,9 @@
#ifndef _COMMON_INCLUDED_
#define _COMMON_INCLUDED_
#include <sstream>
#if defined(__ANDROID__) || (defined(_MSC_VER) && _MSC_VER < 1700)
#include <sstream>
namespace std {
template<typename T>
std::string to_string(const T& val) {
@ -102,6 +102,7 @@ std::string to_string(const T& val) {
#include <algorithm>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include "PoolAlloc.h"

View File

@ -2018,7 +2018,7 @@ public:
}
// Add struct/block members
if (isStruct()) {
if (isStruct() && structure) {
appendStr("{");
for (size_t i = 0; i < structure->size(); ++i) {
if (! (*structure)[i].type->hiddenMember()) {

View File

@ -1,3 +1,3 @@
// This header is generated by the make-revision script.
#define GLSLANG_PATCH_LEVEL 3188
#define GLSLANG_PATCH_LEVEL 3204

View File

@ -410,7 +410,7 @@ TIntermTyped* TIntermediate::addBuiltInFunctionCall(const TSourceLoc& loc, TOper
//
// This is the safe way to change the operator on an aggregate, as it
// does lots of error checking and fixing. Especially for establishing
// a function call's operation on it's set of parameters. Sequences
// a function call's operation on its set of parameters. Sequences
// of instructions are also aggregates, but they just directly set
// their operator to EOpSequence.
//

View File

@ -1156,6 +1156,15 @@ TIntermTyped* TParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction
error(arguments->getLoc(), message, "readonly", "");
if (argQualifier.writeonly && ! formalQualifier.writeonly)
error(arguments->getLoc(), message, "writeonly", "");
if (!builtIn && argQualifier.restrict && ! formalQualifier.restrict)
error(arguments->getLoc(), message, "restrict", "");
}
if (!builtIn && argQualifier.layoutFormat != formalQualifier.layoutFormat) {
// we have mismatched formats, which should only be allowed if writeonly
// and at least one format is unknown
if (!formalQualifier.writeonly || (formalQualifier.layoutFormat != ElfNone &&
argQualifier.layoutFormat != ElfNone))
error(arguments->getLoc(), "image formats must match", "format", "");
}
if (builtIn && arg->getAsTyped()->getType().containsBasicType(EbtFloat16))

View File

@ -377,6 +377,8 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
infoSink, commonTable, symbolTables);
#endif
return true;
}
@ -474,6 +476,16 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
glslang::ReleaseGlobalLock();
}
// Function to Print all builtins
void DumpBuiltinSymbolTable(TInfoSink& infoSink, const TSymbolTable& symbolTable)
{
infoSink.debug << "BuiltinSymbolTable {\n";
symbolTable.dump(infoSink, true);
infoSink.debug << "}\n";
}
// Return true if the shader was correctly specified for version/profile/stage.
bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNotFirst, int defaultVersion,
EShSource source, int& version, EProfile& profile, const SpvVersion& spvVersion)
@ -905,6 +917,9 @@ bool ProcessDeferred(
return false;
}
if (messages & EShMsgBuiltinSymbolTable)
DumpBuiltinSymbolTable(compiler->infoSink, *symbolTable);
//
// Now we can process the full shader under proper symbols and rules.
//

View File

@ -176,37 +176,77 @@ void TType::buildMangledName(TString& mangledName) const
// Dump functions.
//
void TVariable::dump(TInfoSink& infoSink) const
void TSymbol::dumpExtensions(TInfoSink& infoSink) const
{
infoSink.debug << getName().c_str() << ": " << type.getStorageQualifierString() << " " << type.getBasicTypeString();
if (type.isArray()) {
int numExtensions = getNumExtensions();
if (numExtensions) {
infoSink.debug << " <";
for (int i = 0; i < numExtensions; i++)
infoSink.debug << getExtensions()[i] << ",";
infoSink.debug << ">";
}
}
void TVariable::dump(TInfoSink& infoSink, bool complete) const
{
if (complete) {
infoSink.debug << getName().c_str() << ": " << type.getCompleteString();
dumpExtensions(infoSink);
} else {
infoSink.debug << getName().c_str() << ": " << type.getStorageQualifierString() << " "
<< type.getBasicTypeString();
if (type.isArray())
infoSink.debug << "[0]";
}
infoSink.debug << "\n";
}
void TFunction::dump(TInfoSink& infoSink) const
void TFunction::dump(TInfoSink& infoSink, bool complete) const
{
infoSink.debug << getName().c_str() << ": " << returnType.getBasicTypeString() << " " << getMangledName().c_str() << "\n";
if (complete) {
infoSink.debug << getName().c_str() << ": " << returnType.getCompleteString() << " " << getName().c_str()
<< "(";
int numParams = getParamCount();
for (int i = 0; i < numParams; i++) {
const TParameter &param = parameters[i];
infoSink.debug << param.type->getCompleteString() << " "
<< (param.type->isStruct() ? "of " + param.type->getTypeName() + " " : "")
<< (param.name ? *param.name : "") << (i < numParams - 1 ? "," : "");
}
void TAnonMember::dump(TInfoSink& TInfoSink) const
{
TInfoSink.debug << "anonymous member " << getMemberNumber() << " of " << getAnonContainer().getName().c_str() << "\n";
infoSink.debug << ")";
dumpExtensions(infoSink);
} else {
infoSink.debug << getName().c_str() << ": " << returnType.getBasicTypeString() << " "
<< getMangledName().c_str() << "n";
}
void TSymbolTableLevel::dump(TInfoSink &infoSink) const
infoSink.debug << "\n";
}
void TAnonMember::dump(TInfoSink& TInfoSink, bool complete) const
{
TInfoSink.debug << "anonymous member " << getMemberNumber() << " of " << getAnonContainer().getName().c_str()
<< "\n";
}
void TSymbolTableLevel::dump(TInfoSink& infoSink, bool complete) const
{
tLevel::const_iterator it;
for (it = level.begin(); it != level.end(); ++it)
(*it).second->dump(infoSink);
(*it).second->dump(infoSink, complete);
}
void TSymbolTable::dump(TInfoSink &infoSink) const
void TSymbolTable::dump(TInfoSink& infoSink, bool complete) const
{
for (int level = currentLevel(); level >= 0; --level) {
infoSink.debug << "LEVEL " << level << "\n";
table[level]->dump(infoSink);
table[level]->dump(infoSink, complete);
}
}

View File

@ -116,7 +116,8 @@ public:
}
virtual int getNumExtensions() const { return extensions == nullptr ? 0 : (int)extensions->size(); }
virtual const char** getExtensions() const { return extensions->data(); }
virtual void dump(TInfoSink &infoSink) const = 0;
virtual void dump(TInfoSink& infoSink, bool complete = false) const = 0;
void dumpExtensions(TInfoSink& infoSink) const;
virtual bool isReadOnly() const { return ! writable; }
virtual void makeReadOnly() { writable = false; }
@ -192,7 +193,7 @@ public:
}
virtual const char** getMemberExtensions(int member) const { return (*memberExtensions)[member].data(); }
virtual void dump(TInfoSink &infoSink) const;
virtual void dump(TInfoSink& infoSink, bool complete = false) const;
protected:
explicit TVariable(const TVariable&);
@ -313,7 +314,7 @@ public:
virtual TParameter& operator[](int i) { assert(writable); return parameters[i]; }
virtual const TParameter& operator[](int i) const { return parameters[i]; }
virtual void dump(TInfoSink &infoSink) const override;
virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
protected:
explicit TFunction(const TFunction&);
@ -373,7 +374,7 @@ public:
virtual const char** getExtensions() const override { return anonContainer.getMemberExtensions(memberNumber); }
virtual int getAnonId() const { return anonId; }
virtual void dump(TInfoSink &infoSink) const override;
virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
protected:
explicit TAnonMember(const TAnonMember&);
@ -541,7 +542,7 @@ public:
void relateToOperator(const char* name, TOperator op);
void setFunctionExtensions(const char* name, int num, const char* const extensions[]);
void dump(TInfoSink &infoSink) const;
void dump(TInfoSink& infoSink, bool complete = false) const;
TSymbolTableLevel* clone() const;
void readOnly();
@ -842,7 +843,7 @@ public:
}
int getMaxSymbolId() { return uniqueId; }
void dump(TInfoSink &infoSink) const;
void dump(TInfoSink& infoSink, bool complete = false) const;
void copyTable(const TSymbolTable& copyOf);
void setPreviousDefaultPrecisions(TPrecisionQualifier *p) { table[currentLevel()]->setPreviousDefaultPrecisions(p); }

View File

@ -234,6 +234,7 @@ enum EShMessages {
EShMsgHlslEnable16BitTypes = (1 << 11), // enable use of 16-bit types in SPIR-V for HLSL
EShMsgHlslLegalization = (1 << 12), // enable HLSL Legalization messages
EShMsgHlslDX9Compatible = (1 << 13), // enable HLSL DX9 compatible mode (right now only for samplers)
EShMsgBuiltinSymbolTable = (1 << 14), // print the builtin symbol table
};
//