Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Johannes van Waveren 2016-10-21 17:21:46 +09:00
commit 2f4c832d47
484 changed files with 101726 additions and 19867 deletions

View file

@ -46,6 +46,9 @@ enum TBasicType {
EbtVoid,
EbtFloat,
EbtDouble,
#ifdef AMD_EXTENSIONS
EbtFloat16,
#endif
EbtInt,
EbtUint,
EbtInt64,
@ -55,6 +58,10 @@ enum TBasicType {
EbtSampler,
EbtStruct,
EbtBlock,
// HLSL types that live only temporarily.
EbtString,
EbtNumTypes
};
@ -186,6 +193,20 @@ enum TBuiltInVariable {
EbvSamplePosition,
EbvSampleMask,
EbvHelperInvocation,
#ifdef AMD_EXTENSIONS
EbvBaryCoordNoPersp,
EbvBaryCoordNoPerspCentroid,
EbvBaryCoordNoPerspSample,
EbvBaryCoordSmooth,
EbvBaryCoordSmoothCentroid,
EbvBaryCoordSmoothSample,
EbvBaryCoordPullModel,
#endif
// HLSL built-ins that live only temporarily, until they get remapped
// to one of the above.
EbvFragDepthGreater,
EbvFragDepthLesser,
EbvLast
};
@ -286,6 +307,15 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
case EbvSamplePosition: return "SamplePosition";
case EbvSampleMask: return "SampleMaskIn";
case EbvHelperInvocation: return "HelperInvocation";
#ifdef AMD_EXTENSIONS
case EbvBaryCoordNoPersp: return "BaryCoordNoPersp";
case EbvBaryCoordNoPerspCentroid: return "BaryCoordNoPerspCentroid";
case EbvBaryCoordNoPerspSample: return "BaryCoordNoPerspSample";
case EbvBaryCoordSmooth: return "BaryCoordSmooth";
case EbvBaryCoordSmoothCentroid: return "BaryCoordSmoothCentroid";
case EbvBaryCoordSmoothSample: return "BaryCoordSmoothSample";
case EbvBaryCoordPullModel: return "BaryCoordPullModel";
#endif
default: return "unknown built-in variable";
}
}

View file

@ -68,6 +68,10 @@ inline long long int strtoll (const char* str, char** endptr, int base)
{
return _strtoi64(str, endptr, base);
}
inline unsigned long long int strtoull (const char* str, char** endptr, int base)
{
return _strtoui64(str, endptr, base);
}
inline long long int atoll (const char* str)
{
return strtoll(str, NULL, 10);
@ -93,8 +97,8 @@ inline long long int atoll (const char* str)
#include <list>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <assert.h>
#include <cstdio>
#include <cassert>
#include "PoolAlloc.h"
@ -103,11 +107,11 @@ inline long long int atoll (const char* str)
//
#define POOL_ALLOCATOR_NEW_DELETE(A) \
void* operator new(size_t s) { return (A).allocate(s); } \
void* operator new(size_t, void *_Where) { return (_Where); } \
void* operator new(size_t, void *_Where) { return (_Where); } \
void operator delete(void*) { } \
void operator delete(void *, void *) { } \
void* operator new[](size_t s) { return (A).allocate(s); } \
void* operator new[](size_t, void *_Where) { return (_Where); } \
void* operator new[](size_t, void *_Where) { return (_Where); } \
void operator delete[](void*) { } \
void operator delete[](void *, void *) { }
@ -201,20 +205,25 @@ template <class T> T Max(const T a, const T b) { return a > b ? a : b; }
//
// Create a TString object from an integer.
//
#if defined _MSC_VER || defined MINGW_HAS_SECURE_API
inline const TString String(const int i, const int base = 10)
{
char text[16]; // 32 bit ints are at most 10 digits in base 10
_itoa_s(i, text, sizeof(text), base);
return text;
}
#else
inline const TString String(const int i, const int /*base*/ = 10)
{
char text[16]; // 32 bit ints are at most 10 digits in base 10
#if defined _MSC_VER || defined MINGW_HAS_SECURE_API
_itoa_s(i, text, sizeof(text), base);
#else
// we assume base 10 for all cases
snprintf(text, sizeof(text), "%d", i);
#endif
// we assume base 10 for all cases
snprintf(text, sizeof(text), "%d", i);
return text;
}
#endif
struct TSourceLoc {
void init() { name = nullptr; string = 0; line = 0; column = 0; }
// Returns the name if it exists. Otherwise, returns the string number.

View file

@ -36,7 +36,7 @@
#define _INFOSINK_INCLUDED_
#include "../Include/Common.h"
#include <math.h>
#include <cmath>
namespace glslang {
@ -74,7 +74,6 @@ public:
TInfoSinkBase& operator<<(const char* s) { append(s); return *this; }
TInfoSinkBase& operator<<(int n) { append(String(n)); return *this; }
TInfoSinkBase& operator<<(unsigned int n) { append(String(n)); return *this; }
TInfoSinkBase& operator<<(long unsigned int n) { append(String(n)); return *this; }
TInfoSinkBase& operator<<(float n) { const int size = 40; char buf[size];
snprintf(buf, size, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ? "%f" : "%g", n);
append(buf);

View file

@ -61,13 +61,13 @@
// class as the allocator (second) template argument.
//
#include <stddef.h>
#include <string.h>
#include <cstddef>
#include <cstring>
#include <vector>
namespace glslang {
// If we are using guard blocks, we must track each indivual
// If we are using guard blocks, we must track each individual
// allocation. If we aren't using guard blocks, these
// never get instantiated, so won't have any impact.
//
@ -297,10 +297,10 @@ public:
pointer allocate(size_type n, const void*) {
return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T))); }
void deallocate(void*, size_type) { }
void deallocate(void*, size_type) { }
void deallocate(pointer, size_type) { }
pointer _Charalloc(size_t n) {
pointer _Charalloc(size_t n) {
return reinterpret_cast<pointer>(getAllocator().allocate(n)); }
void construct(pointer p, const T& val) { new ((void *)p) T(val); }

View file

@ -123,8 +123,8 @@ public:
haveReturnableObjectCode(false),
appAttributeBindings(0),
fixedAttributeBindings(0),
excludedAttributes(0),
excludedCount(0),
excludedAttributes(0),
excludedCount(0),
uniformBindings(0) { }
virtual TLinker* getAsLinker() { return this; }
virtual ~TLinker() { }
@ -132,8 +132,8 @@ public:
virtual bool link(THandleList&) { return false; }
virtual void setAppAttributeBindings(const ShBindingTable* t) { appAttributeBindings = t; }
virtual void setFixedAttributeBindings(const ShBindingTable* t) { fixedAttributeBindings = t; }
virtual void getAttributeBindings(ShBindingTable const **t) const = 0;
virtual void setExcludedAttributes(const int* attributes, int count) { excludedAttributes = attributes; excludedCount = count; }
virtual void getAttributeBindings(ShBindingTable const **t) const = 0;
virtual void setExcludedAttributes(const int* attributes, int count) { excludedAttributes = attributes; excludedCount = count; }
virtual ShBindingTable* getUniformBindings() const { return uniformBindings; }
virtual const void* getObjectCode() const { return 0; } // a real compiler would be returning object code here
virtual TInfoSink& getInfoSink() { return infoSink; }
@ -145,8 +145,8 @@ protected:
const ShBindingTable* appAttributeBindings;
const ShBindingTable* fixedAttributeBindings;
const int* excludedAttributes;
int excludedCount;
const int* excludedAttributes;
int excludedCount;
ShBindingTable* uniformBindings; // created by the linker
};

View file

@ -78,12 +78,16 @@ struct TSampler { // misnomer now; includes images, textures without sampler,
bool combined : 1; // true means texture is combined with a sampler, false means texture with no sampler
bool sampler : 1; // true means a pure sampler, other fields should be clear()
bool external : 1; // GL_OES_EGL_image_external
unsigned int vectorSize : 3; // return vector size. TODO: support arbitrary types.
bool isImage() const { return image && dim != EsdSubpass; }
bool isSubpass() const { return dim == EsdSubpass; }
bool isCombined() const { return combined; }
bool isPureSampler() const { return sampler; }
bool isTexture() const { return !sampler && !image; }
bool isShadow() const { return shadow; }
bool isArrayed() const { return arrayed; }
bool isMultiSample() const { return ms; }
void clear()
{
@ -96,6 +100,7 @@ struct TSampler { // misnomer now; includes images, textures without sampler,
combined = false;
sampler = false;
external = false;
vectorSize = 4;
}
// make a combined sampler and texture
@ -161,7 +166,8 @@ struct TSampler { // misnomer now; includes images, textures without sampler,
image == right.image &&
combined == right.combined &&
sampler == right.sampler &&
external == right.external;
external == right.external &&
vectorSize == right.vectorSize;
}
bool operator!=(const TSampler& right) const
@ -182,8 +188,6 @@ struct TSampler { // misnomer now; includes images, textures without sampler,
case EbtFloat: break;
case EbtInt: s.append("i"); break;
case EbtUint: s.append("u"); break;
case EbtInt64: s.append("i64"); break;
case EbtUint64: s.append("u64"); break;
default: break; // some compilers want this
}
if (image) {
@ -403,6 +407,9 @@ public:
smooth = false;
flat = false;
nopersp = false;
#ifdef AMD_EXTENSIONS
explicitInterp = false;
#endif
patch = false;
sample = false;
coherent = false;
@ -436,6 +443,9 @@ public:
bool smooth : 1;
bool flat : 1;
bool nopersp : 1;
#ifdef AMD_EXTENSIONS
bool explicitInterp : 1;
#endif
bool patch : 1;
bool sample : 1;
bool coherent : 1;
@ -451,7 +461,11 @@ public:
}
bool isInterpolation() const
{
#ifdef AMD_EXTENSIONS
return flat || smooth || nopersp || explicitInterp;
#else
return flat || smooth || nopersp;
#endif
}
bool isAuxiliary() const
{
@ -610,8 +624,8 @@ public:
unsigned int layoutSet : 7;
static const unsigned int layoutSetEnd = 0x3F;
unsigned int layoutBinding : 8;
static const unsigned int layoutBindingEnd = 0xFF;
unsigned int layoutBinding : 16;
static const unsigned int layoutBindingEnd = 0xFFFF;
unsigned int layoutIndex : 8;
static const unsigned int layoutIndexEnd = 0xFF;
@ -1062,7 +1076,7 @@ public:
qualifier.clear();
qualifier.storage = q;
qualifier.precision = p;
assert(p >= 0 && p <= EpqHigh);
assert(p >= EpqNone && p <= EpqHigh);
}
// for turning a TPublicType into a TType, using a shallow copy
explicit TType(const TPublicType& p) :
@ -1080,6 +1094,15 @@ public:
typeName = NewPoolTString(p.userDef->getTypeName().c_str());
}
}
// for construction of sampler types
TType(const TSampler& sampler, TStorageQualifier q = EvqUniform, TArraySizes* as = nullptr) :
basicType(EbtSampler), vectorSize(1), matrixCols(0), matrixRows(0), vector1(false),
arraySizes(as), structure(nullptr), fieldName(nullptr), typeName(nullptr),
sampler(sampler)
{
qualifier.clear();
qualifier.storage = q;
}
// to efficiently make a dereferenced type
// without ever duplicating the outer structure that will be thrown away
// and using only shallow copy
@ -1182,7 +1205,7 @@ public:
typeName = NewPoolTString(copyOf.typeName->c_str());
}
TType* clone()
TType* clone() const
{
TType *newType = new TType();
newType->deepCopy(*this);
@ -1255,7 +1278,11 @@ public:
virtual bool isImplicitlySizedArray() const { return isArray() && getOuterArraySize() == UnsizedArraySize && qualifier.storage != EvqBuffer; }
virtual bool isRuntimeSizedArray() const { return isArray() && getOuterArraySize() == UnsizedArraySize && qualifier.storage == EvqBuffer; }
virtual bool isStruct() const { return structure != nullptr; }
#ifdef AMD_EXTENSIONS
virtual bool isFloatingDomain() const { return basicType == EbtFloat || basicType == EbtDouble || basicType == EbtFloat16; }
#else
virtual bool isFloatingDomain() const { return basicType == EbtFloat || basicType == EbtDouble; }
#endif
virtual bool isOpaque() const { return basicType == EbtSampler || basicType == EbtAtomicUint; }
@ -1337,6 +1364,9 @@ public:
case EbtVoid:
case EbtFloat:
case EbtDouble:
#ifdef AMD_EXTENSIONS
case EbtFloat16:
#endif
case EbtInt:
case EbtUint:
case EbtInt64:
@ -1429,6 +1459,9 @@ public:
case EbtVoid: return "void";
case EbtFloat: return "float";
case EbtDouble: return "double";
#ifdef AMD_EXTENSIONS
case EbtFloat16: return "float16_t";
#endif
case EbtInt: return "int";
case EbtUint: return "uint";
case EbtInt64: return "int64_t";
@ -1507,6 +1540,10 @@ public:
p += snprintf(p, end - p, "flat ");
if (qualifier.nopersp)
p += snprintf(p, end - p, "noperspective ");
#ifdef AMD_EXTENSIONS
if (qualifier.explicitInterp)
p += snprintf(p, end - p, "__explicitInterpAMD ");
#endif
if (qualifier.patch)
p += snprintf(p, end - p, "patch ");
if (qualifier.sample)
@ -1707,13 +1744,13 @@ protected:
// functionality is added.
// HLSL does have a 1-component vectors, so this will be true to disambiguate
// from a scalar.
TSampler sampler;
TQualifier qualifier;
TArraySizes* arraySizes; // nullptr unless an array; can be shared across types
TTypeList* structure; // nullptr unless this is a struct; can be shared across types
TString *fieldName; // for structure field names
TString *typeName; // for structure type name
TSampler sampler;
};
} // end namespace glslang

View file

@ -57,6 +57,8 @@
namespace glslang {
class TIntermediate;
//
// Operators used by the high-level (parse tree) representation.
//
@ -124,6 +126,22 @@ enum TOperator {
EOpConvFloatToUint64,
EOpConvDoubleToUint64,
EOpConvInt64ToUint64,
#ifdef AMD_EXTENSIONS
EOpConvBoolToFloat16,
EOpConvIntToFloat16,
EOpConvUintToFloat16,
EOpConvFloatToFloat16,
EOpConvDoubleToFloat16,
EOpConvInt64ToFloat16,
EOpConvUint64ToFloat16,
EOpConvFloat16ToBool,
EOpConvFloat16ToInt,
EOpConvFloat16ToUint,
EOpConvFloat16ToFloat,
EOpConvFloat16ToDouble,
EOpConvFloat16ToInt64,
EOpConvFloat16ToUint64,
#endif
//
// binary operations
@ -241,6 +259,10 @@ enum TOperator {
EOpUnpackInt2x32,
EOpPackUint2x32,
EOpUnpackUint2x32,
#ifdef AMD_EXTENSIONS
EOpPackFloat2x16,
EOpUnpackFloat2x16,
#endif
EOpLength,
EOpDistance,
@ -251,6 +273,12 @@ enum TOperator {
EOpReflect,
EOpRefract,
#ifdef AMD_EXTENSIONS
EOpMin3,
EOpMax3,
EOpMid3,
#endif
EOpDPdx, // Fragment only
EOpDPdy, // Fragment only
EOpFwidth, // Fragment only
@ -265,6 +293,10 @@ enum TOperator {
EOpInterpolateAtSample, // Fragment only
EOpInterpolateAtOffset, // Fragment only
#ifdef AMD_EXTENSIONS
EOpInterpolateAtVertex,
#endif
EOpMatrixTimesMatrix,
EOpOuterProduct,
EOpDeterminant,
@ -296,6 +328,23 @@ enum TOperator {
EOpAllInvocations,
EOpAllInvocationsEqual,
#ifdef AMD_EXTENSIONS
EOpMinInvocations,
EOpMaxInvocations,
EOpAddInvocations,
EOpMinInvocationsNonUniform,
EOpMaxInvocationsNonUniform,
EOpAddInvocationsNonUniform,
EOpSwizzleInvocations,
EOpSwizzleInvocationsMasked,
EOpWriteInvocation,
EOpMbcnt,
EOpCubeFaceIndex,
EOpCubeFaceCoord,
EOpTime,
#endif
EOpAtomicAdd,
EOpAtomicMin,
EOpAtomicMax,
@ -374,6 +423,21 @@ enum TOperator {
EOpConstructDMat4x2,
EOpConstructDMat4x3,
EOpConstructDMat4x4,
#ifdef AMD_EXTENSIONS
EOpConstructFloat16,
EOpConstructF16Vec2,
EOpConstructF16Vec3,
EOpConstructF16Vec4,
EOpConstructF16Mat2x2,
EOpConstructF16Mat2x3,
EOpConstructF16Mat2x4,
EOpConstructF16Mat3x2,
EOpConstructF16Mat3x3,
EOpConstructF16Mat3x4,
EOpConstructF16Mat4x2,
EOpConstructF16Mat4x3,
EOpConstructF16Mat4x4,
#endif
EOpConstructStruct,
EOpConstructTextureSampler,
EOpConstructGuardEnd,
@ -439,6 +503,9 @@ enum TOperator {
EOpTextureQueryLod,
EOpTextureQueryLevels,
EOpTextureQuerySamples,
EOpSamplingGuardBegin,
EOpTexture,
EOpTextureProj,
EOpTextureLod,
@ -481,7 +548,7 @@ enum TOperator {
EOpSparseTextureGradOffsetClamp,
EOpSparseTextureGuardEnd,
EOpSamplingGuardEnd,
EOpTextureGuardEnd,
//
@ -530,6 +597,30 @@ enum TOperator {
EOpLit, // HLSL lighting coefficient vector
EOpTextureBias, // HLSL texture bias: will be lowered to EOpTexture
EOpAsDouble, // slightly different from EOpUint64BitsToDouble
EOpMethodSample, // Texture object methods. These are translated to existing
EOpMethodSampleBias, // AST methods, and exist to represent HLSL semantics until that
EOpMethodSampleCmp, // translation is performed. See HlslParseContext::decomposeSampleMethods().
EOpMethodSampleCmpLevelZero, // ...
EOpMethodSampleGrad, // ...
EOpMethodSampleLevel, // ...
EOpMethodLoad, // ...
EOpMethodGetDimensions, // ...
EOpMethodGetSamplePosition, // ...
EOpMethodGather, // ...
EOpMethodCalculateLevelOfDetail, // ...
EOpMethodCalculateLevelOfDetailUnclamped, // ...
// SM5 texture methods
EOpMethodGatherRed, // These are covered under the above EOpMethodSample comment about
EOpMethodGatherGreen, // translation to existing AST opcodes. They exist temporarily
EOpMethodGatherBlue, // because HLSL arguments are slightly different.
EOpMethodGatherAlpha, // ...
EOpMethodGatherCmp, // ...
EOpMethodGatherCmpRed, // ...
EOpMethodGatherCmpGreen, // ...
EOpMethodGatherCmpBlue, // ...
EOpMethodGatherCmpAlpha, // ...
};
class TIntermTraverser;
@ -761,14 +852,30 @@ public:
virtual TIntermOperator* getAsOperator() { return this; }
virtual const TIntermOperator* getAsOperator() const { return this; }
TOperator getOp() const { return op; }
virtual bool promote() { return true; }
void setOp(TOperator newOp) { op = newOp; }
bool modifiesState() const;
bool isConstructor() const;
bool isTexture() const { return op > EOpTextureGuardBegin && op < EOpTextureGuardEnd; }
bool isImage() const { return op > EOpImageGuardBegin && op < EOpImageGuardEnd; }
bool isTexture() const { return op > EOpTextureGuardBegin && op < EOpTextureGuardEnd; }
bool isSampling() const { return op > EOpSamplingGuardBegin && op < EOpSamplingGuardEnd; }
bool isImage() const { return op > EOpImageGuardBegin && op < EOpImageGuardEnd; }
bool isSparseTexture() const { return op > EOpSparseTextureGuardBegin && op < EOpSparseTextureGuardEnd; }
bool isSparseImage() const { return op == EOpSparseImageLoad; }
void setOperationPrecision(TPrecisionQualifier p) { operationPrecision = p; }
TPrecisionQualifier getOperationPrecision() const { return operationPrecision != EpqNone ?
operationPrecision :
type.getQualifier().precision; }
TString getCompleteString() const
{
TString cs = type.getCompleteString();
if (getOperationPrecision() != type.getQualifier().precision) {
cs += ", operation at ";
cs += GetPrecisionQualifierString(getOperationPrecision());
}
return cs;
}
// Crack the op into the individual dimensions of texturing operation.
void crackTexture(TSampler sampler, TCrackedTextureOp& cracked) const
{
@ -900,9 +1007,15 @@ public:
}
protected:
TIntermOperator(TOperator o) : TIntermTyped(EbtFloat), op(o) {}
TIntermOperator(TOperator o, TType& t) : TIntermTyped(t), op(o) {}
TIntermOperator(TOperator o) : TIntermTyped(EbtFloat), op(o), operationPrecision(EpqNone) {}
TIntermOperator(TOperator o, TType& t) : TIntermTyped(t), op(o), operationPrecision(EpqNone) {}
TOperator op;
// The result precision is in the inherited TType, and is usually meant to be both
// the operation precision and the result precision. However, some more complex things,
// like built-in function calls, distinguish between the two, in which case non-EqpNone
// 'operationPrecision' overrides the result precision as far as operation precision
// is concerned.
TPrecisionQualifier operationPrecision;
};
//
@ -918,7 +1031,6 @@ public:
virtual TIntermTyped* getRight() const { return right; }
virtual TIntermBinary* getAsBinaryNode() { return this; }
virtual const TIntermBinary* getAsBinaryNode() const { return this; }
virtual bool promote();
virtual void updatePrecision();
protected:
TIntermTyped* left;
@ -938,7 +1050,6 @@ public:
virtual const TIntermTyped* getOperand() const { return operand; }
virtual TIntermUnary* getAsUnaryNode() { return this; }
virtual const TIntermUnary* getAsUnaryNode() const { return this; }
virtual bool promote();
virtual void updatePrecision();
protected:
TIntermTyped* operand;

View file

@ -2,5 +2,5 @@
// 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).
#define GLSLANG_REVISION "SPIRV99.947"
#define GLSLANG_DATE "15-Feb-2016"
#define GLSLANG_REVISION "Overload400-PrecQual.1603"
#define GLSLANG_DATE "16-Oct-2016"