Turn on basic support for shader storage buffer objects, but not yet the entire extension.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@27699 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
79cddfcb56
commit
67cf1f6179
14 changed files with 190 additions and 78 deletions
|
|
@ -67,8 +67,8 @@ enum TStorageQualifier {
|
|||
EvqConst, // User-defined constant values, will be semantically constant and constant folded
|
||||
EvqVaryingIn, // pipeline input, read only
|
||||
EvqVaryingOut, // pipeline ouput, read/write
|
||||
EvqUniform, // read only, shader with app
|
||||
EvqBuffer, // read only, shader with app
|
||||
EvqUniform, // read only, shared with app
|
||||
EvqBuffer, // read/write, shared with app
|
||||
EvqShared, // compute shader's read/write 'shared' qualifier
|
||||
|
||||
// parameters
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
bool isUniform() const
|
||||
bool isUniformOrBuffer() const
|
||||
{
|
||||
switch (storage) {
|
||||
case EvqUniform:
|
||||
|
|
@ -802,10 +802,15 @@ public:
|
|||
vectorSize = 0;
|
||||
}
|
||||
|
||||
bool isScalar()
|
||||
bool isScalar() const
|
||||
{
|
||||
return matrixCols == 0 && vectorSize == 1 && arraySizes == 0 && userDef == 0;
|
||||
}
|
||||
|
||||
bool isImage() const
|
||||
{
|
||||
return basicType == EbtSampler && sampler.image;
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::map<TTypeList*, TTypeList*> TStructureMap;
|
||||
|
|
@ -1008,9 +1013,11 @@ public:
|
|||
virtual bool isVector() const { return vectorSize > 1; }
|
||||
virtual bool isMatrix() const { return matrixCols ? true : false; }
|
||||
virtual bool isArray() const { return arraySizes != 0; }
|
||||
virtual bool isImplicitlySizedArray() const { return isArray() && ! getArraySize(); }
|
||||
virtual bool isExplicitlySizedArray() const { return ! isImplicitlySizedArray(); }
|
||||
virtual bool isImplicitlySizedArray() const { return isArray() && ! getArraySize() && qualifier.storage != EvqBuffer; }
|
||||
virtual bool isExplicitlySizedArray() const { return isArray() && getArraySize(); }
|
||||
virtual bool isRuntimeSizedArray() const { return isArray() && ! getArraySize() && qualifier.storage == EvqBuffer; }
|
||||
virtual bool isStruct() const { return structure != 0; }
|
||||
virtual bool isImage() const { return basicType == EbtSampler && getSampler().image; }
|
||||
|
||||
// Recursively checks if the type contains the given basic type
|
||||
virtual bool containsBasicType(TBasicType checkType) const
|
||||
|
|
|
|||
|
|
@ -526,10 +526,10 @@ void TParseContext::checkIndex(TSourceLoc loc, const TType& type, int& index)
|
|||
void TParseContext::handleIndexLimits(TSourceLoc loc, TIntermTyped* base, TIntermTyped* index)
|
||||
{
|
||||
if ((! limits.generalSamplerIndexing && base->getBasicType() == EbtSampler) ||
|
||||
(! limits.generalUniformIndexing && base->getQualifier().isUniform() && language != EShLangVertex) ||
|
||||
(! limits.generalUniformIndexing && base->getQualifier().isUniformOrBuffer() && language != EShLangVertex) ||
|
||||
(! limits.generalAttributeMatrixVectorIndexing && base->getQualifier().isPipeInput() && language == EShLangVertex && (base->getType().isMatrix() || base->getType().isVector())) ||
|
||||
(! limits.generalConstantMatrixVectorIndexing && base->getAsConstantUnion()) ||
|
||||
(! limits.generalVariableIndexing && ! base->getType().getQualifier().isUniform() &&
|
||||
(! limits.generalVariableIndexing && ! base->getType().getQualifier().isUniformOrBuffer() &&
|
||||
! base->getType().getQualifier().isPipeInput() &&
|
||||
! base->getType().getQualifier().isPipeOutput() &&
|
||||
base->getType().getQualifier().storage != EvqConst) ||
|
||||
|
|
@ -1062,7 +1062,10 @@ TIntermTyped* TParseContext::handleLengthMethod(TSourceLoc loc, TFunction* funct
|
|||
else {
|
||||
const TType& type = intermNode->getAsTyped()->getType();
|
||||
if (type.isArray()) {
|
||||
if (type.isImplicitlySizedArray()) {
|
||||
if (type.isRuntimeSizedArray()) {
|
||||
// Create a unary op and let the back end handle it
|
||||
return intermediate.addBuiltInFunctionCall(loc, EOpArrayLength, true, intermNode, TType(EbtInt));
|
||||
} else if (type.isImplicitlySizedArray()) {
|
||||
if (intermNode->getAsSymbolNode() && isIoResizeArray(type)) {
|
||||
// We could be between a layout declaration that gives a built-in io array implicit size and
|
||||
// a user redeclaration of that array, meaning we have to substitute its implicit size here
|
||||
|
|
@ -1565,12 +1568,16 @@ bool TParseContext::lValueErrorCheck(TSourceLoc loc, const char* op, TIntermType
|
|||
case EvqConst: message = "can't modify a const"; break;
|
||||
case EvqConstReadOnly: message = "can't modify a const"; break;
|
||||
case EvqVaryingIn: message = "can't modify shader input"; break;
|
||||
case EvqUniform: message = "can't modify a uniform"; break;
|
||||
case EvqInstanceId: message = "can't modify gl_InstanceID"; break;
|
||||
case EvqVertexId: message = "can't modify gl_VertexID"; break;
|
||||
case EvqFace: message = "can't modify gl_FrontFace"; break;
|
||||
case EvqFragCoord: message = "can't modify gl_FragCoord"; break;
|
||||
case EvqPointCoord: message = "can't modify gl_PointCoord"; break;
|
||||
case EvqUniform: message = "can't modify a uniform"; break;
|
||||
case EvqBuffer:
|
||||
if (node->getQualifier().readonly)
|
||||
message = "can't modify a readonly buffer";
|
||||
break;
|
||||
default:
|
||||
|
||||
//
|
||||
|
|
@ -1911,6 +1918,9 @@ void TParseContext::globalQualifierCheck(TSourceLoc loc, const TQualifier& quali
|
|||
if (! symbolTable.atGlobalLevel())
|
||||
return;
|
||||
|
||||
if (qualifier.isMemory() && ! publicType.isImage() && publicType.qualifier.storage != EvqBuffer)
|
||||
error(loc, "memory qualifiers cannot be used on this type", "", "");
|
||||
|
||||
if (qualifier.storage != EvqVaryingIn && qualifier.storage != EvqVaryingOut)
|
||||
return;
|
||||
|
||||
|
|
@ -3281,8 +3291,8 @@ void TParseContext::layoutObjectCheck(TSourceLoc loc, const TSymbol& symbol)
|
|||
// Check packing and matrix
|
||||
if (qualifier.hasUniformLayout()) {
|
||||
switch (qualifier.storage) {
|
||||
case EvqBuffer:
|
||||
case EvqUniform:
|
||||
case EvqBuffer:
|
||||
if (type.getBasicType() != EbtBlock) {
|
||||
if (qualifier.hasMatrix())
|
||||
error(loc, "cannot specify matrix layout on a variable declaration", "layout", "");
|
||||
|
|
@ -3396,7 +3406,7 @@ void TParseContext::layoutTypeCheck(TSourceLoc loc, const TType& type)
|
|||
|
||||
// Image format
|
||||
if (qualifier.hasFormat()) {
|
||||
if (type.getBasicType() != EbtSampler || ! type.getSampler().image)
|
||||
if (! type.isImage())
|
||||
error(loc, "only apply to images", TQualifier::getLayoutFormatString(qualifier.layoutFormat), "");
|
||||
else {
|
||||
if (type.getSampler().type == EbtFloat && qualifier.layoutFormat > ElfFloatGuard)
|
||||
|
|
@ -3406,10 +3416,8 @@ void TParseContext::layoutTypeCheck(TSourceLoc loc, const TType& type)
|
|||
if (type.getSampler().type == EbtUint && qualifier.layoutFormat < ElfIntGuard)
|
||||
error(loc, "does not apply to unsigned integer images", TQualifier::getLayoutFormatString(qualifier.layoutFormat), "");
|
||||
}
|
||||
} else if (type.getBasicType() == EbtSampler && type.getSampler().image && !qualifier.writeonly)
|
||||
} else if (type.isImage() && ! qualifier.writeonly)
|
||||
error(loc, "image variables not declared 'writeonly' must have a format layout qualifier", "", "");
|
||||
if (qualifier.isMemory() && (type.getBasicType() != EbtSampler || ! type.getSampler().image))
|
||||
error(loc, "memory qualifiers can only be used on image types", "", "");
|
||||
}
|
||||
|
||||
// Do layout error checking that can be done within a qualifier proper, not needing to know
|
||||
|
|
@ -3470,7 +3478,7 @@ void TParseContext::layoutQualifierCheck(TSourceLoc loc, const TQualifier& quali
|
|||
}
|
||||
|
||||
if (qualifier.hasBinding()) {
|
||||
if (qualifier.storage != EvqUniform && qualifier.storage != EvqBuffer)
|
||||
if (! qualifier.isUniformOrBuffer())
|
||||
error(loc, "requires uniform or buffer storage qualifier", "binding", "");
|
||||
}
|
||||
if (qualifier.hasStream()) {
|
||||
|
|
@ -3482,7 +3490,7 @@ void TParseContext::layoutQualifierCheck(TSourceLoc loc, const TQualifier& quali
|
|||
error(loc, "can only be used on an output", "xfb layout qualifier", "");
|
||||
}
|
||||
if (qualifier.hasUniformLayout()) {
|
||||
if (! (qualifier.storage == EvqUniform || qualifier.storage == EvqBuffer)) {
|
||||
if (! qualifier.isUniformOrBuffer()) {
|
||||
if (qualifier.hasMatrix() || qualifier.hasPacking())
|
||||
error(loc, "matrix or packing qualifiers can only be used on a uniform or buffer", "layout", "");
|
||||
if (qualifier.hasOffset() || qualifier.hasAlign())
|
||||
|
|
@ -4122,14 +4130,14 @@ void TParseContext::declareBlock(TSourceLoc loc, TTypeList& typeList, const TStr
|
|||
arraySizeRequiredCheck(loc, arraySizes->getSize());
|
||||
|
||||
switch (currentBlockQualifier.storage) {
|
||||
case EvqBuffer:
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, "buffer block");
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, 0, "buffer block");
|
||||
break;
|
||||
case EvqUniform:
|
||||
profileRequires(loc, EEsProfile, 300, 0, "uniform block");
|
||||
profileRequires(loc, ENoProfile, 140, 0, "uniform block");
|
||||
break;
|
||||
case EvqBuffer:
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, "buffer block");
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, 0, "buffer block");
|
||||
break;
|
||||
case EvqVaryingIn:
|
||||
requireProfile(loc, ~EEsProfile, "input block");
|
||||
profileRequires(loc, ~EEsProfile, 150, GL_ARB_separate_shader_objects, "input block");
|
||||
|
|
@ -4147,16 +4155,19 @@ void TParseContext::declareBlock(TSourceLoc loc, TTypeList& typeList, const TStr
|
|||
|
||||
// fix and check for member storage qualifiers and types that don't belong within a block
|
||||
for (unsigned int member = 0; member < typeList.size(); ++member) {
|
||||
TQualifier& memberQualifier = typeList[member].type->getQualifier();
|
||||
TType& memberType = *typeList[member].type;
|
||||
TQualifier& memberQualifier = memberType.getQualifier();
|
||||
TSourceLoc memberLoc = typeList[member].loc;
|
||||
pipeInOutFix(memberLoc, memberQualifier);
|
||||
if (memberQualifier.storage != EvqTemporary && memberQualifier.storage != EvqGlobal && memberQualifier.storage != currentBlockQualifier.storage)
|
||||
error(memberLoc, "member storage qualifier cannot contradict block storage qualifier", typeList[member].type->getFieldName().c_str(), "");
|
||||
error(memberLoc, "member storage qualifier cannot contradict block storage qualifier", memberType.getFieldName().c_str(), "");
|
||||
memberQualifier.storage = currentBlockQualifier.storage;
|
||||
if (currentBlockQualifier.storage == EvqUniform && (memberQualifier.isInterpolation() || memberQualifier.isAuxiliary()))
|
||||
error(memberLoc, "member of uniform block cannot have an auxiliary or interpolation qualifier", typeList[member].type->getFieldName().c_str(), "");
|
||||
if ((currentBlockQualifier.storage == EvqUniform || currentBlockQualifier.storage == EvqBuffer) && (memberQualifier.isInterpolation() || memberQualifier.isAuxiliary()))
|
||||
error(memberLoc, "member of uniform or buffer block cannot have an auxiliary or interpolation qualifier", memberType.getFieldName().c_str(), "");
|
||||
if (memberType.isRuntimeSizedArray() && member < typeList.size() - 1)
|
||||
error(memberLoc, "only the last member of a buffer block can be run-time sized", memberType.getFieldName().c_str(), "");
|
||||
|
||||
TBasicType basicType = typeList[member].type->getBasicType();
|
||||
TBasicType basicType = memberType.getBasicType();
|
||||
if (basicType == EbtSampler)
|
||||
error(memberLoc, "member of block cannot be a sampler type", typeList[member].type->getFieldName().c_str(), "");
|
||||
}
|
||||
|
|
@ -4179,8 +4190,8 @@ void TParseContext::declareBlock(TSourceLoc loc, TTypeList& typeList, const TStr
|
|||
|
||||
TQualifier defaultQualification;
|
||||
switch (currentBlockQualifier.storage) {
|
||||
case EvqBuffer: defaultQualification = globalBufferDefaults; break;
|
||||
case EvqUniform: defaultQualification = globalUniformDefaults; break;
|
||||
case EvqBuffer: defaultQualification = globalBufferDefaults; break;
|
||||
case EvqVaryingIn: defaultQualification = globalInputDefaults; break;
|
||||
case EvqVaryingOut: defaultQualification = globalOutputDefaults; break;
|
||||
default: defaultQualification.clear(); break;
|
||||
|
|
@ -4401,7 +4412,7 @@ void TParseContext::fixBlockXfbOffsets(TSourceLoc loc, TQualifier& qualifier, TT
|
|||
//
|
||||
void TParseContext::fixBlockUniformOffsets(TSourceLoc loc, TQualifier& qualifier, TTypeList& typeList)
|
||||
{
|
||||
if (qualifier.storage != EvqUniform && qualifier.storage != EvqBuffer)
|
||||
if (! qualifier.isUniformOrBuffer())
|
||||
return;
|
||||
if (qualifier.layoutPacking != ElpStd140 && qualifier.layoutPacking != ElpStd430)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1213,7 +1213,7 @@ storage_qualifier
|
|||
| BUFFER {
|
||||
parseContext.globalCheck($1.loc, "buffer");
|
||||
$$.init($1.loc);
|
||||
$$.qualifier.storage = EvqUniform; // TODO: 4.0 functionality: implement BUFFER
|
||||
$$.qualifier.storage = EvqBuffer;
|
||||
}
|
||||
| SHARED {
|
||||
parseContext.requireProfile($1.loc, ~EEsProfile, "shared");
|
||||
|
|
|
|||
|
|
@ -257,6 +257,8 @@ bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node)
|
|||
case EOpAny: out.debug << "any"; break;
|
||||
case EOpAll: out.debug << "all"; break;
|
||||
|
||||
case EOpArrayLength: out.debug << "array length"; break;
|
||||
|
||||
case EOpEmitStreamVertex: out.debug << "EmitStreamVertex"; break;
|
||||
case EOpEndStreamPrimitive: out.debug << "EndStreamPrimitive"; break;
|
||||
|
||||
|
|
|
|||
|
|
@ -604,13 +604,15 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ
|
|||
set = 0;
|
||||
else if (qualifier.isPipeOutput())
|
||||
set = 1;
|
||||
else if (qualifier.isUniform())
|
||||
else if (qualifier.storage == EvqUniform)
|
||||
set = 2;
|
||||
else if (qualifier.storage == EvqBuffer)
|
||||
set = 3;
|
||||
else
|
||||
return -1;
|
||||
|
||||
int size;
|
||||
if (qualifier.isUniform()) {
|
||||
if (qualifier.isUniformOrBuffer()) {
|
||||
if (type.isArray())
|
||||
size = type.getArraySize();
|
||||
else
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ protected:
|
|||
TGraph callGraph;
|
||||
|
||||
std::set<TString> ioAccessed; // set of names of statically read/written I/O that might need extra checking
|
||||
std::vector<TIoRange> usedIo[3]; // sets of used locations, one for each of in, out, and uniform
|
||||
std::vector<TIoRange> usedIo[4]; // sets of used locations, one for each of in, out, uniform and buffers
|
||||
std::vector<TXfbBuffer> xfbBuffers; // all the data we need to track per xfb buffer
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ public:
|
|||
// We have an array or structure or block dereference, see if it's a uniform
|
||||
// based dereference (if not, skip it).
|
||||
TIntermSymbol* base = findBase(topNode);
|
||||
if (! base || base->getQualifier().storage != EvqUniform)
|
||||
if (! base || ! base->getQualifier().isUniformOrBuffer())
|
||||
return;
|
||||
|
||||
// See if we've already processed this (e.g., in the middle of something
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue