Commit 42323e41 by Rex Xu

Merge pull request #1 from KhronosGroup/master

Sync local master branch from the upstream
parents c8b2e36f 31ed4830
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "prefix" FORCE) set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "prefix")
project(glslang) project(glslang)
......
This directory contains a Linux binary for the glslang validator.
Installation: The executable in this directory is self sufficient, and can be
placed where desired; in a test directory, or in a system path, etc.
Usage: Execute glslangValidator with no arguments to get a usage statement.
sudo cp glslangValidator /usr/local/bin
This directory contains a Windows binary for the glslang validator.
Installation: The executable in this directory is self sufficient, and can be
placed where desired; in a test directory, or in a system path, etc.
Usage: Execute glslangValidator with no arguments to get a usage statement.
...@@ -25,8 +25,6 @@ Things left to do: See `Todo.txt` ...@@ -25,8 +25,6 @@ Things left to do: See `Todo.txt`
Execution of Standalone Wrapper Execution of Standalone Wrapper
------------------------------- -------------------------------
There are binaries in the `Install/Windows` and `Install/Linux` directories.
To use the standalone binary form, execute `glslangValidator`, and it will print To use the standalone binary form, execute `glslangValidator`, and it will print
a usage statement. Basic operation is to give it a file containing a shader, a usage statement. Basic operation is to give it a file containing a shader,
and it will print out warnings/errors and optionally an AST. and it will print out warnings/errors and optionally an AST.
...@@ -109,16 +107,24 @@ warning/error and other options for controling compilation. ...@@ -109,16 +107,24 @@ warning/error and other options for controling compilation.
Testing Testing
------- -------
Test results should always be included with a pull request that modifies
functionality. There is a simple process for doing this, described here:
`Test` is an active test directory that contains test input and a `Test` is an active test directory that contains test input and a
subdirectory `baseResults` that contains the expected results of the subdirectory `baseResults` that contains the expected results of the
tests. Both the tests and `baseResults` are under source-code control. tests. Both the tests and `baseResults` are under source-code control.
Executing the script `./runtests` will generate current results in Executing the script `./runtests` will generate current results in
the `localResults` directory and `diff` them against the `baseResults`. the `localResults` directory and `diff` them against the `baseResults`.
When you want to update the tracked test results, they need to be
copied from `localResults` to `baseResults`.
There are some tests borrowed from LunarGLASS. If LunarGLASS is When you want to update the tracked test results, they need to be
missing, those tests just won't run. copied from `localResults` to `baseResults`. This can be done by
the `bump` shell script.
The list of files tested comes from `testlist`, and lists input shaders
in this directory, which must all be public for this to work. However,
you can add your own private list of tests, not tracked here, by using
`localtestlist` to list non-tracked tests. This is automatically read
by `runtests` and included in the `diff` and `bump` process.
Basic Internal Operation Basic Internal Operation
------------------------ ------------------------
......
...@@ -88,6 +88,10 @@ protected: ...@@ -88,6 +88,10 @@ protected:
spv::Id createSpvVariable(const glslang::TIntermSymbol*); spv::Id createSpvVariable(const glslang::TIntermSymbol*);
spv::Id getSampledType(const glslang::TSampler&); spv::Id getSampledType(const glslang::TSampler&);
spv::Id convertGlslangToSpvType(const glslang::TType& type); spv::Id convertGlslangToSpvType(const glslang::TType& type);
spv::Id convertGlslangToSpvType(const glslang::TType& type, bool explicitLayout);
bool requiresExplicitLayout(const glslang::TType& type) const;
int getArrayStride(const glslang::TType& arrayType);
int getMatrixStride(const glslang::TType& matrixType);
void updateMemberOffset(const glslang::TType& structType, const glslang::TType& memberType, int& currentOffset, int& nextOffset); void updateMemberOffset(const glslang::TType& structType, const glslang::TType& memberType, int& currentOffset, int& nextOffset);
bool isShaderEntrypoint(const glslang::TIntermAggregate* node); bool isShaderEntrypoint(const glslang::TIntermAggregate* node);
...@@ -1316,9 +1320,17 @@ spv::Id TGlslangToSpvTraverser::getSampledType(const glslang::TSampler& sampler) ...@@ -1316,9 +1320,17 @@ spv::Id TGlslangToSpvTraverser::getSampledType(const glslang::TSampler& sampler)
} }
} }
// Do full recursive conversion of an arbitrary glslang type to a SPIR-V Id. // Convert from a glslang type to an SPV type, by calling into
// recursive version of this function.
spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& type) spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& type)
{ {
return convertGlslangToSpvType(type, requiresExplicitLayout(type));
}
// Do full recursive conversion of an arbitrary glslang type to a SPIR-V Id.
// explicitLayout can be kept the same throughout the heirarchical recursive walk.
spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& type, bool explicitLayout)
{
spv::Id spvType = 0; spv::Id spvType = 0;
switch (type.getBasicType()) { switch (type.getBasicType()) {
...@@ -1381,7 +1393,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty ...@@ -1381,7 +1393,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
} else { } else {
if (type.getBasicType() == glslang::EbtBlock) if (type.getBasicType() == glslang::EbtBlock)
memberRemapper[glslangStruct][i] = i - memberDelta; memberRemapper[glslangStruct][i] = i - memberDelta;
structFields.push_back(convertGlslangToSpvType(glslangType)); structFields.push_back(convertGlslangToSpvType(glslangType, explicitLayout));
} }
} }
...@@ -1409,7 +1421,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty ...@@ -1409,7 +1421,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
builder.addMemberDecoration(spvType, member, spv::DecorationComponent, glslangType.getQualifier().layoutComponent); builder.addMemberDecoration(spvType, member, spv::DecorationComponent, glslangType.getQualifier().layoutComponent);
if (glslangType.getQualifier().hasXfbOffset()) if (glslangType.getQualifier().hasXfbOffset())
builder.addMemberDecoration(spvType, member, spv::DecorationOffset, glslangType.getQualifier().layoutXfbOffset); builder.addMemberDecoration(spvType, member, spv::DecorationOffset, glslangType.getQualifier().layoutXfbOffset);
else { else if (explicitLayout) {
// figure out what to do with offset, which is accumulating // figure out what to do with offset, which is accumulating
int nextOffset; int nextOffset;
updateMemberOffset(type, glslangType, offset, nextOffset); updateMemberOffset(type, glslangType, offset, nextOffset);
...@@ -1418,6 +1430,10 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty ...@@ -1418,6 +1430,10 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
offset = nextOffset; offset = nextOffset;
} }
if (glslangType.isMatrix() && explicitLayout) {
builder.addMemberDecoration(spvType, member, spv::DecorationMatrixStride, getMatrixStride(glslangType));
}
// built-in variable decorations // built-in variable decorations
spv::BuiltIn builtIn = TranslateBuiltInDecoration(glslangType.getQualifier().builtIn); spv::BuiltIn builtIn = TranslateBuiltInDecoration(glslangType.getQualifier().builtIn);
if (builtIn != spv::BadValue) if (builtIn != spv::BadValue)
...@@ -1459,11 +1475,40 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty ...@@ -1459,11 +1475,40 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
} else } else
arraySize = type.getOuterArraySize(); arraySize = type.getOuterArraySize();
spvType = builder.makeArrayType(spvType, arraySize); spvType = builder.makeArrayType(spvType, arraySize);
if (explicitLayout)
builder.addDecoration(spvType, spv::DecorationArrayStride, getArrayStride(type));
} }
return spvType; return spvType;
} }
bool TGlslangToSpvTraverser::requiresExplicitLayout(const glslang::TType& type) const
{
return type.getBasicType() == glslang::EbtBlock &&
type.getQualifier().layoutPacking != glslang::ElpShared &&
type.getQualifier().layoutPacking != glslang::ElpPacked &&
(type.getQualifier().storage == glslang::EvqUniform ||
type.getQualifier().storage == glslang::EvqBuffer);
}
// Given an array type, returns the integer stride required for that array
int TGlslangToSpvTraverser::getArrayStride(const glslang::TType& arrayType)
{
glslang::TType derefType(arrayType, 0);
int size;
glslangIntermediate->getBaseAlignment(derefType, size, true);
return size;
}
// Given a matrix type, returns the integer stride required for that matrix
// when used as a member of an interface block
int TGlslangToSpvTraverser::getMatrixStride(const glslang::TType& matrixType)
{
int size;
return glslangIntermediate->getBaseAlignment(matrixType, size, true);
}
// Given a member type of a struct, realign the current offset for it, and compute // Given a member type of a struct, realign the current offset for it, and compute
// the next (not yet aligned) offset for the next member, which will get aligned // the next (not yet aligned) offset for the next member, which will get aligned
// on the next call. // on the next call.
...@@ -1666,8 +1711,6 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -1666,8 +1711,6 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
// This is no longer a query.... // This is no longer a query....
if (cracked.fetch)
spv::MissingFunctionality("texel fetch");
if (cracked.gather) if (cracked.gather)
spv::MissingFunctionality("texture gather"); spv::MissingFunctionality("texture gather");
...@@ -1723,7 +1766,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -1723,7 +1766,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
++extraArgs; ++extraArgs;
} }
return builder.createTextureCall(precision, convertGlslangToSpvType(node->getType()), cracked.proj, params); return builder.createTextureCall(precision, convertGlslangToSpvType(node->getType()), cracked.fetch, cracked.proj, params);
} }
spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAggregate* node) spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAggregate* node)
......
...@@ -1137,7 +1137,7 @@ Id Builder::createBuiltinCall(Decoration /*precision*/, Id resultType, Id builti ...@@ -1137,7 +1137,7 @@ Id Builder::createBuiltinCall(Decoration /*precision*/, Id resultType, Id builti
// Accept all parameters needed to create a texture instruction. // Accept all parameters needed to create a texture instruction.
// Create the correct instruction based on the inputs, and make the call. // Create the correct instruction based on the inputs, and make the call.
Id Builder::createTextureCall(Decoration precision, Id resultType, bool proj, const TextureParameters& parameters) Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, bool proj, const TextureParameters& parameters)
{ {
static const int maxTextureArgs = 10; static const int maxTextureArgs = 10;
Id texArgs[maxTextureArgs] = {}; Id texArgs[maxTextureArgs] = {};
...@@ -1196,7 +1196,9 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool proj, co ...@@ -1196,7 +1196,9 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool proj, co
// //
Op opCode; Op opCode;
opCode = OpImageSampleImplicitLod; opCode = OpImageSampleImplicitLod;
if (xplicit) { if (fetch) {
opCode = OpImageFetch;
} else if (xplicit) {
if (parameters.Dref) { if (parameters.Dref) {
if (proj) if (proj)
opCode = OpImageSampleProjDrefExplicitLod; opCode = OpImageSampleProjDrefExplicitLod;
......
...@@ -298,7 +298,7 @@ public: ...@@ -298,7 +298,7 @@ public:
}; };
// Select the correct texture operation based on all inputs, and emit the correct instruction // Select the correct texture operation based on all inputs, and emit the correct instruction
Id createTextureCall(Decoration precision, Id resultType, bool proj, const TextureParameters&); Id createTextureCall(Decoration precision, Id resultType, bool fetch, bool proj, const TextureParameters&);
// Emit the OpTextureQuery* instruction that was passed in. // Emit the OpTextureQuery* instruction that was passed in.
// Figure out the right return value and type, and return it. // Figure out the right return value and type, and return it.
......
ERROR: 0:2: '#define' : "defined" can't be (un)defined: defined
ERROR: 1 compilation errors. No code generated.
...@@ -36,16 +36,23 @@ Linked fragment stage: ...@@ -36,16 +36,23 @@ Linked fragment stage:
Decorate 34(gl_ClipDistance) BuiltIn ClipDistance Decorate 34(gl_ClipDistance) BuiltIn ClipDistance
Decorate 43(k) Smooth Decorate 43(k) Smooth
Decorate 86(samp2Da) NoStaticUse Decorate 86(samp2Da) NoStaticUse
Decorate 89 ArrayStride 64
Decorate 89 ArrayStride 64
MemberDecorate 90(bn) 0 RowMajor MemberDecorate 90(bn) 0 RowMajor
MemberDecorate 90(bn) 0 Offset 0 MemberDecorate 90(bn) 0 Offset 0
MemberDecorate 90(bn) 0 MatrixStride 16
MemberDecorate 90(bn) 1 ColMajor MemberDecorate 90(bn) 1 ColMajor
MemberDecorate 90(bn) 1 Offset 256 MemberDecorate 90(bn) 1 Offset 256
MemberDecorate 90(bn) 1 MatrixStride 16
MemberDecorate 90(bn) 2 RowMajor MemberDecorate 90(bn) 2 RowMajor
MemberDecorate 90(bn) 2 Offset 512 MemberDecorate 90(bn) 2 Offset 512
MemberDecorate 90(bn) 2 MatrixStride 16
MemberDecorate 90(bn) 3 ColMajor MemberDecorate 90(bn) 3 ColMajor
MemberDecorate 90(bn) 3 Offset 576 MemberDecorate 90(bn) 3 Offset 576
MemberDecorate 90(bn) 3 MatrixStride 16
MemberDecorate 90(bn) 4 RowMajor MemberDecorate 90(bn) 4 RowMajor
MemberDecorate 90(bn) 4 Offset 640 MemberDecorate 90(bn) 4 Offset 640
MemberDecorate 90(bn) 4 MatrixStride 16
Decorate 90(bn) Block Decorate 90(bn) Block
Decorate 92 NoStaticUse Decorate 92 NoStaticUse
2: TypeVoid 2: TypeVoid
......
...@@ -46,10 +46,13 @@ Linked vertex stage: ...@@ -46,10 +46,13 @@ Linked vertex stage:
Decorate 12(p) Location 3 Decorate 12(p) Location 3
MemberDecorate 18(Transform) 0 RowMajor MemberDecorate 18(Transform) 0 RowMajor
MemberDecorate 18(Transform) 0 Offset 0 MemberDecorate 18(Transform) 0 Offset 0
MemberDecorate 18(Transform) 0 MatrixStride 16
MemberDecorate 18(Transform) 1 ColMajor MemberDecorate 18(Transform) 1 ColMajor
MemberDecorate 18(Transform) 1 Offset 64 MemberDecorate 18(Transform) 1 Offset 64
MemberDecorate 18(Transform) 1 MatrixStride 16
MemberDecorate 18(Transform) 2 RowMajor MemberDecorate 18(Transform) 2 RowMajor
MemberDecorate 18(Transform) 2 Offset 128 MemberDecorate 18(Transform) 2 Offset 128
MemberDecorate 18(Transform) 2 MatrixStride 16
MemberDecorate 18(Transform) 3 Offset 176 MemberDecorate 18(Transform) 3 Offset 176
Decorate 18(Transform) Block Decorate 18(Transform) Block
MemberDecorate 34(T3) 0 ColMajor MemberDecorate 34(T3) 0 ColMajor
......
#define defined_not_really
#define defined // ERROR: "defined" can't be (un)defined:
...@@ -11,3 +11,4 @@ preprocessor.line.frag ...@@ -11,3 +11,4 @@ preprocessor.line.frag
preprocessor.pragma.vert preprocessor.pragma.vert
preprocessor.simple.vert preprocessor.simple.vert
preprocessor.success_if_parse_would_fail.vert preprocessor.success_if_parse_would_fail.vert
preprocessor.defined.vert
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits. // For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run). // For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "3.0.732" #define GLSLANG_REVISION "3.0.746"
#define GLSLANG_DATE "22-Aug-2015" #define GLSLANG_DATE "09-Sep-2015"
...@@ -2063,6 +2063,8 @@ void TParseContext::reservedPpErrorCheck(const TSourceLoc& loc, const char* iden ...@@ -2063,6 +2063,8 @@ void TParseContext::reservedPpErrorCheck(const TSourceLoc& loc, const char* iden
// however, before that, ES tests required an error. // however, before that, ES tests required an error.
if (strncmp(identifier, "GL_", 3) == 0) if (strncmp(identifier, "GL_", 3) == 0)
ppError(loc, "names beginning with \"GL_\" can't be (un)defined:", op, identifier); ppError(loc, "names beginning with \"GL_\" can't be (un)defined:", op, identifier);
else if (strncmp(identifier, "defined", 8) == 0)
ppError(loc, "\"defined\" can't be (un)defined:", op, identifier);
else if (strstr(identifier, "__") != 0) { else if (strstr(identifier, "__") != 0) {
if (profile == EEsProfile && version >= 300 && if (profile == EEsProfile && version >= 300 &&
(strcmp(identifier, "__LINE__") == 0 || (strcmp(identifier, "__LINE__") == 0 ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment