diff --git a/src/compiler/translator/ConstantUnion.cpp b/src/compiler/translator/ConstantUnion.cpp index fe22a2d9b..033517150 100644 --- a/src/compiler/translator/ConstantUnion.cpp +++ b/src/compiler/translator/ConstantUnion.cpp @@ -105,6 +105,23 @@ bool TConstantUnion::getBConst() const return bConst; } +bool TConstantUnion::isZero() const +{ + switch (type) + { + case EbtInt: + return getIConst() == 0; + case EbtUInt: + return getUConst() == 0; + case EbtFloat: + return getFConst() == 0.0f; + case EbtBool: + return getBConst() == false; + default: + return false; + } +} + TYuvCscStandardEXT TConstantUnion::getYuvCscStandardEXTConst() const { ASSERT(type == EbtYuvCscStandardEXT); diff --git a/src/compiler/translator/ConstantUnion.h b/src/compiler/translator/ConstantUnion.h index 155fcd44b..4d6591fac 100644 --- a/src/compiler/translator/ConstantUnion.h +++ b/src/compiler/translator/ConstantUnion.h @@ -56,6 +56,7 @@ class TConstantUnion unsigned int getUConst() const; float getFConst() const; bool getBConst() const; + bool isZero() const; TYuvCscStandardEXT getYuvCscStandardEXTConst() const; bool operator==(const int i) const; diff --git a/src/compiler/translator/IntermNode.h b/src/compiler/translator/IntermNode.h index 5667378b1..6787949a6 100644 --- a/src/compiler/translator/IntermNode.h +++ b/src/compiler/translator/IntermNode.h @@ -333,6 +333,10 @@ class TIntermConstantUnion : public TIntermExpression { return mUnionArrayPointer ? mUnionArrayPointer[index].getBConst() : false; } + bool isZero(size_t index) const + { + return mUnionArrayPointer ? mUnionArrayPointer[index].isZero() : false; + } TIntermConstantUnion *getAsConstantUnion() override { return this; } void traverse(TIntermTraverser *it) final; diff --git a/src/compiler/translator/TranslatorVulkan.cpp b/src/compiler/translator/TranslatorVulkan.cpp index ab92a03c1..fdf290344 100644 --- a/src/compiler/translator/TranslatorVulkan.cpp +++ b/src/compiler/translator/TranslatorVulkan.cpp @@ -163,6 +163,8 @@ TIntermConstantUnion *CreateFloatConstant(float value) constexpr ImmutableString kFlippedPointCoordName = ImmutableString("flippedPointCoord"); constexpr ImmutableString kFlippedFragCoordName = ImmutableString("flippedFragCoord"); constexpr ImmutableString kEmulatedDepthRangeParams = ImmutableString("ANGLEDepthRangeParams"); +constexpr ImmutableString kUniformsBlockName = ImmutableString("ANGLEUniformBlock"); +constexpr ImmutableString kUniformsVarName = ImmutableString("ANGLEUniforms"); constexpr const char kViewport[] = "viewport"; constexpr const char kHalfRenderAreaHeight[] = "halfRenderAreaHeight"; @@ -375,7 +377,8 @@ const TVariable *AddDriverUniformsToShader(TIntermBlock *root, TSymbolTable *sym // Define a driver uniform block "ANGLEUniformBlock" with instance name "ANGLEUniforms". return DeclareInterfaceBlock(root, symbolTable, driverFieldList, EvqUniform, - TMemoryQualifier::Create(), "ANGLEUniformBlock", "ANGLEUniforms"); + TMemoryQualifier::Create(), 0, kUniformsBlockName, + kUniformsVarName); } TIntermPreprocessorDirective *GenerateLineRasterIfDef() diff --git a/src/compiler/translator/blocklayout.cpp b/src/compiler/translator/blocklayout.cpp index 7d0609ec8..fefd63f68 100644 --- a/src/compiler/translator/blocklayout.cpp +++ b/src/compiler/translator/blocklayout.cpp @@ -33,7 +33,10 @@ class BlockLayoutMapVisitor : public BlockEncoderVisitor const std::string &mappedName) override { ASSERT(!gl::IsSamplerType(variable.type)); - (*mInfoOut)[name] = variableInfo; + if (!gl::IsOpaqueType(variable.type)) + { + (*mInfoOut)[name] = variableInfo; + } } private: diff --git a/src/compiler/translator/tree_ops/RewriteAtomicCounters.cpp b/src/compiler/translator/tree_ops/RewriteAtomicCounters.cpp index 8e76c4862..c26d84ab1 100644 --- a/src/compiler/translator/tree_ops/RewriteAtomicCounters.cpp +++ b/src/compiler/translator/tree_ops/RewriteAtomicCounters.cpp @@ -18,53 +18,104 @@ namespace sh { namespace { -// DeclareAtomicCountersBuffer adds a storage buffer that's used with atomic counters. -const TVariable *DeclareAtomicCountersBuffer(TIntermBlock *root, TSymbolTable *symbolTable) +constexpr ImmutableString kAtomicCounterTypeName = ImmutableString("ANGLE_atomic_uint"); +constexpr ImmutableString kAtomicCounterBlockName = ImmutableString("ANGLEAtomicCounters"); +constexpr ImmutableString kAtomicCounterVarName = ImmutableString("atomicCounters"); +constexpr ImmutableString kAtomicCounterFieldName = ImmutableString("counters"); + +// DeclareAtomicCountersBuffer adds a storage buffer array that's used with atomic counters. +const TVariable *DeclareAtomicCountersBuffers(TIntermBlock *root, TSymbolTable *symbolTable) { // Define `uint counters[];` as the only field in the interface block. TFieldList *fieldList = new TFieldList; TType *counterType = new TType(EbtUInt); counterType->makeArray(0); - TField *countersField = new TField(counterType, ImmutableString("counters"), TSourceLoc(), - SymbolType::AngleInternal); + TField *countersField = + new TField(counterType, kAtomicCounterFieldName, TSourceLoc(), SymbolType::AngleInternal); fieldList->push_back(countersField); TMemoryQualifier coherentMemory = TMemoryQualifier::Create(); coherentMemory.coherent = true; + // There are a maximum of 8 atomic counter buffers per IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS + // in libANGLE/Constants.h. + constexpr uint32_t kMaxAtomicCounterBuffers = 8; + // Define a storage block "ANGLEAtomicCounters" with instance name "atomicCounters". return DeclareInterfaceBlock(root, symbolTable, fieldList, EvqBuffer, coherentMemory, - "ANGLEAtomicCounters", "atomicCounters"); -} - -TIntermBinary *CreateAtomicCounterRef(const TVariable *atomicCounters, TIntermTyped *offset) -{ - TIntermSymbol *atomicCountersRef = new TIntermSymbol(atomicCounters); - TConstantUnion *firstFieldIndex = new TConstantUnion; - firstFieldIndex->setIConst(0); - TIntermConstantUnion *firstFieldRef = - new TIntermConstantUnion(firstFieldIndex, *StaticType::GetBasic()); - TIntermBinary *firstField = - new TIntermBinary(EOpIndexDirectInterfaceBlock, atomicCountersRef, firstFieldRef); - return new TIntermBinary(EOpIndexDirect, firstField, offset); + kMaxAtomicCounterBuffers, kAtomicCounterBlockName, + kAtomicCounterVarName); } TIntermConstantUnion *CreateUIntConstant(uint32_t value) { - const TType *constantType = StaticType::GetBasic(); + TType *constantType = new TType(*StaticType::GetBasic()); + constantType->setQualifier(EvqConst); + TConstantUnion *constantValue = new TConstantUnion; constantValue->setUConst(value); return new TIntermConstantUnion(constantValue, *constantType); } +TIntermTyped *CreateAtomicCounterConstant(TType *atomicCounterType, + uint32_t binding, + uint32_t offset) +{ + ASSERT(atomicCounterType->getBasicType() == EbtStruct); + + TIntermSequence *arguments = new TIntermSequence(); + arguments->push_back(CreateUIntConstant(binding)); + arguments->push_back(CreateUIntConstant(offset)); + + return TIntermAggregate::CreateConstructor(*atomicCounterType, arguments); +} + +TIntermBinary *CreateAtomicCounterRef(const TVariable *atomicCounters, TIntermTyped *bindingOffset) +{ + // The atomic counters storage buffer declaration looks as such: + // + // layout(...) buffer ANGLEAtomicCounters + // { + // uint counters[]; + // } atomicCounters[N]; + // + // Where N is large enough to accommodate atomic counter buffer bindings used in the shader. + // + // Given an ANGLEAtomicCounter variable (which is a struct of {binding, offset}), we need to + // return: + // + // atomicCounters[binding].counters[offset] + + TIntermSymbol *atomicCountersRef = new TIntermSymbol(atomicCounters); + + TIntermConstantUnion *bindingFieldRef = CreateIndexNode(0); + TIntermConstantUnion *offsetFieldRef = CreateIndexNode(1); + TIntermConstantUnion *countersFieldRef = CreateIndexNode(0); + + // Create references to bindingOffset.binding and bindingOffset.offset. + TIntermBinary *binding = + new TIntermBinary(EOpIndexDirectStruct, bindingOffset, bindingFieldRef); + TIntermBinary *offset = new TIntermBinary(EOpIndexDirectStruct, bindingOffset, offsetFieldRef); + + // Create reference to atomicCounters[bindingOffset.binding] + TIntermBinary *countersBlock = new TIntermBinary(EOpIndexDirect, atomicCountersRef, binding); + + // Create reference to atomicCounters[bindingOffset.binding].counters + TIntermBinary *counters = + new TIntermBinary(EOpIndexDirectInterfaceBlock, countersBlock, countersFieldRef); + + // return atomicCounters[bindingOffset.binding].counters[bindingOffset.offset] + return new TIntermBinary(EOpIndexDirect, counters, offset); +} + // Traverser that: // -// 1. Converts the |atomic_uint| types to |uint|. +// 1. Converts the |atomic_uint| types to |{uint,uint}| for binding and offset. // 2. Substitutes the |uniform atomic_uint| declarations with a global declaration that holds the -// offset. -// 3. Substitutes |atomicVar[n]| with |offset + n|. +// binding and offset. +// 3. Substitutes |atomicVar[n]| with |buffer[binding].counters[offset + n]|. class RewriteAtomicCountersTraverser : public TIntermTraverser { public: @@ -72,8 +123,12 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser : TIntermTraverser(true, true, true, symbolTable), mAtomicCounters(atomicCounters), mCurrentAtomicCounterOffset(0), + mCurrentAtomicCounterBinding(0), mCurrentAtomicCounterDecl(nullptr), - mCurrentAtomicCounterDeclParent(nullptr) + mCurrentAtomicCounterDeclParent(nullptr), + mAtomicCounterType(nullptr), + mAtomicCounterTypeConst(nullptr), + mAtomicCounterTypeDeclaration(nullptr) {} bool visitDeclaration(Visit visit, TIntermDeclaration *node) override @@ -88,13 +143,10 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser { if (isAtomicCounter) { - // We only support one atomic counter buffer, so the binding should necessarily be - // 0. - ASSERT(type.getLayoutQualifier().binding == 0); - mCurrentAtomicCounterDecl = node; mCurrentAtomicCounterDeclParent = getParentNode()->getAsBlock(); mCurrentAtomicCounterOffset = type.getLayoutQualifier().offset; + mCurrentAtomicCounterBinding = type.getLayoutQualifier().binding; } } else if (visit == PostVisit) @@ -102,6 +154,7 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser mCurrentAtomicCounterDecl = nullptr; mCurrentAtomicCounterDeclParent = nullptr; mCurrentAtomicCounterOffset = 0; + mCurrentAtomicCounterBinding = 0; } return true; } @@ -227,10 +280,15 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser // uint counters[]; // } atomicCounters; // - // const uint ac = ; - // const uint acArray = ; + // struct ANGLEAtomicCounter + // { + // uint binding; + // uint offset; + // }; + // const ANGLEAtomicCounter ac = {, }; + // const ANGLEAtomicCounter acArray = {, }; // - // void func(inout uint c) + // void func(inout ANGLEAtomicCounter c) // { // otherFunc(c); // } @@ -238,7 +296,7 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser // void funcArray(inout uint cArray) // { // otherFuncArray(cArray); - // otherFunc(cArray + n); + // otherFunc({cArray.binding, cArray.offset + n}); // } // // void funcGlobal() @@ -246,8 +304,8 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser // func(ac); // func(acArray+n); // funcArray(acArray); - // atomicAdd(atomicCounters.counters[ac]); - // atomicAdd(atomicCounters.counters[ac+n]); + // atomicAdd(atomicCounters[ac.binding]counters[ac.offset]); + // atomicAdd(atomicCounters[ac.binding]counters[ac.offset+n]); // } // // In all cases, the argument transformation is stored in |mAtomicCounterFunctionCallArgs|. @@ -256,15 +314,15 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser // the transformed argument is passed on as is. // - TIntermTyped *offset = nullptr; - if (mAtomicCounterOffsets.count(symbolVariable) != 0) + TIntermTyped *bindingOffset = nullptr; + if (mAtomicCounterBindingOffsets.count(symbolVariable) != 0) { - offset = new TIntermSymbol(mAtomicCounterOffsets[symbolVariable]); + bindingOffset = new TIntermSymbol(mAtomicCounterBindingOffsets[symbolVariable]); } else { ASSERT(mAtomicCounterFunctionParams.count(symbolVariable) != 0); - offset = new TIntermSymbol(mAtomicCounterFunctionParams[symbolVariable]); + bindingOffset = new TIntermSymbol(mAtomicCounterFunctionParams[symbolVariable]); } TIntermNode *argument = symbol; @@ -278,39 +336,103 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser ASSERT(arrayExpression->getOp() == EOpIndexDirect || arrayExpression->getOp() == EOpIndexIndirect); - offset = new TIntermBinary(EOpAdd, offset, arrayExpression->getRight()->deepCopy()); argument = arrayExpression; + + TIntermTyped *subscript = arrayExpression->getRight(); + TIntermConstantUnion *subscriptAsConstant = subscript->getAsConstantUnion(); + const bool subscriptIsZero = subscriptAsConstant && subscriptAsConstant->isZero(0); + + if (!subscriptIsZero) + { + // Copy the atomic counter binding/offset constant and modify it by adding the array + // subscript to its offset field. + TVariable *modified = CreateTempVariable(mSymbolTable, mAtomicCounterType); + TIntermDeclaration *modifiedDecl = + CreateTempInitDeclarationNode(modified, bindingOffset); + + TIntermSymbol *modifiedSymbol = new TIntermSymbol(modified); + TConstantUnion *offsetFieldIndex = new TConstantUnion; + offsetFieldIndex->setIConst(1); + TIntermConstantUnion *offsetFieldRef = + new TIntermConstantUnion(offsetFieldIndex, *StaticType::GetBasic()); + TIntermBinary *offsetField = + new TIntermBinary(EOpIndexDirectStruct, modifiedSymbol, offsetFieldRef); + + TIntermBinary *modifiedOffset = new TIntermBinary( + EOpAddAssign, offsetField, arrayExpression->getRight()->deepCopy()); + + TIntermSequence *modifySequence = new TIntermSequence(); + modifySequence->push_back(modifiedDecl); + modifySequence->push_back(modifiedOffset); + insertStatementsInParentBlock(*modifySequence); + + bindingOffset = modifiedSymbol->deepCopy(); + } } - mAtomicCounterFunctionCallArgs[argument] = offset; + mAtomicCounterFunctionCallArgs[argument] = bindingOffset; } + TIntermDeclaration *getAtomicCounterTypeDeclaration() { return mAtomicCounterTypeDeclaration; } + private: void declareAtomicCounter(const TVariable *symbolVariable) { - // Create a global variable that contains the offset of this atomic counter declaration. - TType *uintType = new TType(*StaticType::GetBasic()); - uintType->setQualifier(EvqConst); - TVariable *offset = - new TVariable(mSymbolTable, symbolVariable->name(), uintType, SymbolType::UserDefined); + // Create a global variable that contains the binding and offset of this atomic counter + // declaration. + if (mAtomicCounterType == nullptr) + { + declareAtomicCounterType(); + } + ASSERT(mAtomicCounterTypeConst); + + TVariable *bindingOffset = new TVariable(mSymbolTable, symbolVariable->name(), + mAtomicCounterTypeConst, SymbolType::UserDefined); ASSERT(mCurrentAtomicCounterOffset % 4 == 0); - TIntermConstantUnion *offsetInitValue = CreateIndexNode(mCurrentAtomicCounterOffset / 4); + TIntermTyped *bindingOffsetInitValue = CreateAtomicCounterConstant( + mAtomicCounterTypeConst, mCurrentAtomicCounterBinding, mCurrentAtomicCounterOffset / 4); - TIntermSymbol *offsetSymbol = new TIntermSymbol(offset); - TIntermBinary *offsetInit = new TIntermBinary(EOpInitialize, offsetSymbol, offsetInitValue); + TIntermSymbol *bindingOffsetSymbol = new TIntermSymbol(bindingOffset); + TIntermBinary *bindingOffsetInit = + new TIntermBinary(EOpInitialize, bindingOffsetSymbol, bindingOffsetInitValue); - TIntermDeclaration *offsetDeclaration = new TIntermDeclaration(); - offsetDeclaration->appendDeclarator(offsetInit); + TIntermDeclaration *bindingOffsetDeclaration = new TIntermDeclaration(); + bindingOffsetDeclaration->appendDeclarator(bindingOffsetInit); - // Replace the atomic_uint declaration with the offset declaration. + // Replace the atomic_uint declaration with the binding/offset declaration. TIntermSequence replacement; - replacement.push_back(offsetDeclaration); + replacement.push_back(bindingOffsetDeclaration); mMultiReplacements.emplace_back(mCurrentAtomicCounterDeclParent, mCurrentAtomicCounterDecl, replacement); - // Remember the offset variable. - mAtomicCounterOffsets[symbolVariable] = offset; + // Remember the binding/offset variable. + mAtomicCounterBindingOffsets[symbolVariable] = bindingOffset; + } + + void declareAtomicCounterType() + { + ASSERT(mAtomicCounterType == nullptr); + + TFieldList *fields = new TFieldList(); + fields->push_back(new TField(new TType(EbtUInt, EbpUndefined, EvqGlobal, 1, 1), + ImmutableString("binding"), TSourceLoc(), + SymbolType::AngleInternal)); + fields->push_back(new TField(new TType(EbtUInt, EbpUndefined, EvqGlobal, 1, 1), + ImmutableString("arrayIndex"), TSourceLoc(), + SymbolType::AngleInternal)); + TStructure *atomicCounterTypeStruct = + new TStructure(mSymbolTable, kAtomicCounterTypeName, fields, SymbolType::AngleInternal); + mAtomicCounterType = new TType(atomicCounterTypeStruct, false); + + mAtomicCounterTypeDeclaration = new TIntermDeclaration; + TVariable *emptyVariable = new TVariable(mSymbolTable, kEmptyImmutableString, + mAtomicCounterType, SymbolType::Empty); + mAtomicCounterTypeDeclaration->appendDeclarator(new TIntermSymbol(emptyVariable)); + + // Keep a const variant around as well. + mAtomicCounterTypeConst = new TType(*mAtomicCounterType); + mAtomicCounterTypeConst->setQualifier(EvqConst); } TVariable *convertFunctionParameter(TIntermNode *parent, const TVariable *param) @@ -319,8 +441,14 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser { return nullptr; } + if (mAtomicCounterType == nullptr) + { + declareAtomicCounterType(); + } - const TType *newType = StaticType::GetBasic(); + const TType *paramType = ¶m->getType(); + TType *newType = + paramType->getQualifier() == EvqConst ? mAtomicCounterTypeConst : mAtomicCounterType; TVariable *replacementVar = new TVariable(mSymbolTable, param->name(), newType, SymbolType::UserDefined); @@ -375,10 +503,10 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser const TIntermNode *param = (*arguments)[0]; ASSERT(mAtomicCounterFunctionCallArgs.count(param) != 0); - TIntermTyped *offset = mAtomicCounterFunctionCallArgs[param]; + TIntermTyped *bindingOffset = mAtomicCounterFunctionCallArgs[param]; TIntermSequence *substituteArguments = new TIntermSequence; - substituteArguments->push_back(CreateAtomicCounterRef(mAtomicCounters, offset)); + substituteArguments->push_back(CreateAtomicCounterRef(mAtomicCounters, bindingOffset)); substituteArguments->push_back(CreateUIntConstant(valueChange)); TIntermTyped *substituteCall = CreateBuiltInFunctionCallNode( @@ -430,11 +558,10 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser queueReplacement(substituteCall, OriginalNode::IS_DROPPED); } - private: const TVariable *mAtomicCounters; - // A map from the atomic_uint variable to the offset declaration. - std::unordered_map mAtomicCounterOffsets; + // A map from the atomic_uint variable to the binding/offset declaration. + std::unordered_map mAtomicCounterBindingOffsets; // A map from functions with atomic_uint parameters to one where that's replaced with uint. std::unordered_map mReplacedFunctions; // A map from atomic_uint function parameters to their replacement uint parameter for the @@ -445,18 +572,31 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser std::unordered_map mAtomicCounterFunctionCallArgs; uint32_t mCurrentAtomicCounterOffset; + uint32_t mCurrentAtomicCounterBinding; TIntermDeclaration *mCurrentAtomicCounterDecl; TIntermAggregateBase *mCurrentAtomicCounterDeclParent; + + TType *mAtomicCounterType; + TType *mAtomicCounterTypeConst; + + // Stored to be put at the top of the shader after the pass. + TIntermDeclaration *mAtomicCounterTypeDeclaration; }; } // anonymous namespace void RewriteAtomicCounters(TIntermBlock *root, TSymbolTable *symbolTable) { - const TVariable *atomicCounters = DeclareAtomicCountersBuffer(root, symbolTable); + const TVariable *atomicCounters = DeclareAtomicCountersBuffers(root, symbolTable); RewriteAtomicCountersTraverser traverser(symbolTable, atomicCounters); root->traverse(&traverser); traverser.updateTree(); + + TIntermDeclaration *atomicCounterTypeDeclaration = traverser.getAtomicCounterTypeDeclaration(); + if (atomicCounterTypeDeclaration) + { + root->getSequence()->insert(root->getSequence()->begin(), atomicCounterTypeDeclaration); + } } } // namespace sh diff --git a/src/compiler/translator/tree_util/IntermNode_util.cpp b/src/compiler/translator/tree_util/IntermNode_util.cpp index 224535bd8..3fa7d57ae 100644 --- a/src/compiler/translator/tree_util/IntermNode_util.cpp +++ b/src/compiler/translator/tree_util/IntermNode_util.cpp @@ -213,22 +213,26 @@ const TVariable *DeclareInterfaceBlock(TIntermBlock *root, TFieldList *fieldList, TQualifier qualifier, const TMemoryQualifier &memoryQualifier, - const char *blockTypeName, - const char *blockVariableName) + uint32_t arraySize, + const ImmutableString &blockTypeName, + const ImmutableString &blockVariableName) { // Define an interface block. TLayoutQualifier layoutQualifier = TLayoutQualifier::Create(); - TInterfaceBlock *interfaceBlock = - new TInterfaceBlock(symbolTable, ImmutableString(blockTypeName), fieldList, layoutQualifier, - SymbolType::AngleInternal); + TInterfaceBlock *interfaceBlock = new TInterfaceBlock( + symbolTable, blockTypeName, fieldList, layoutQualifier, SymbolType::AngleInternal); // Turn the inteface block into a declaration. TType *interfaceBlockType = new TType(interfaceBlock, qualifier, layoutQualifier); interfaceBlockType->setMemoryQualifier(memoryQualifier); + if (arraySize > 0) + { + interfaceBlockType->makeArray(arraySize); + } TIntermDeclaration *interfaceBlockDecl = new TIntermDeclaration; - TVariable *interfaceBlockVar = new TVariable(symbolTable, ImmutableString(blockVariableName), - interfaceBlockType, SymbolType::AngleInternal); + TVariable *interfaceBlockVar = new TVariable(symbolTable, blockVariableName, interfaceBlockType, + SymbolType::AngleInternal); TIntermSymbol *interfaceBlockDeclarator = new TIntermSymbol(interfaceBlockVar); interfaceBlockDecl->appendDeclarator(interfaceBlockDeclarator); diff --git a/src/compiler/translator/tree_util/IntermNode_util.h b/src/compiler/translator/tree_util/IntermNode_util.h index 3a82ec07a..7d1d42156 100644 --- a/src/compiler/translator/tree_util/IntermNode_util.h +++ b/src/compiler/translator/tree_util/IntermNode_util.h @@ -48,8 +48,9 @@ const TVariable *DeclareInterfaceBlock(TIntermBlock *root, TFieldList *fieldList, TQualifier qualifier, const TMemoryQualifier &memoryQualifier, - const char *blockTypeName, - const char *blockVariableName); + uint32_t arraySize, + const ImmutableString &blockTypeName, + const ImmutableString &blockVariableName); // If the input node is nullptr, return nullptr. // If the input node is a block node, return it. diff --git a/src/compiler/translator/tree_util/IntermTraverse.cpp b/src/compiler/translator/tree_util/IntermTraverse.cpp index b58709071..8d989355e 100644 --- a/src/compiler/translator/tree_util/IntermTraverse.cpp +++ b/src/compiler/translator/tree_util/IntermTraverse.cpp @@ -489,23 +489,22 @@ bool TIntermTraverser::CompareInsertion(const NodeInsertMultipleEntry &a, { if (a.parent != b.parent) { - return a.parent > b.parent; + return a.parent < b.parent; } - return a.position > b.position; + return a.position < b.position; } void TIntermTraverser::updateTree() { - // Sort the insertions so that insertion position is decreasing. This way multiple insertions to + // Sort the insertions so that insertion position is increasing and same position insertions are + // not reordered. The insertions are processed in reverse order so that multiple insertions to // the same parent node are handled correctly. - std::sort(mInsertions.begin(), mInsertions.end(), CompareInsertion); + std::stable_sort(mInsertions.begin(), mInsertions.end(), CompareInsertion); for (size_t ii = 0; ii < mInsertions.size(); ++ii) { - // We can't know here what the intended ordering of two insertions to the same position is, - // so it is not supported. - ASSERT(ii == 0 || mInsertions[ii].position != mInsertions[ii - 1].position || - mInsertions[ii].parent != mInsertions[ii - 1].parent); - const NodeInsertMultipleEntry &insertion = mInsertions[ii]; + // If two insertions are to the same position, insert them in the order they were specified. + // The std::stable_sort call above will automatically guarantee this. + const NodeInsertMultipleEntry &insertion = mInsertions[mInsertions.size() - ii - 1]; ASSERT(insertion.parent); if (!insertion.insertionsAfter.empty()) { diff --git a/src/libANGLE/angletypes.h b/src/libANGLE/angletypes.h index 7d1ddd7c5..adf375ca8 100644 --- a/src/libANGLE/angletypes.h +++ b/src/libANGLE/angletypes.h @@ -495,6 +495,7 @@ template using StorageBuffersArray = std::array; template using AtomicCounterBuffersArray = std::array; +using AtomicCounterBufferMask = angle::BitSet; using ImageUnitMask = angle::BitSet; diff --git a/src/libANGLE/renderer/vulkan/GlslangWrapper.cpp b/src/libANGLE/renderer/vulkan/GlslangWrapper.cpp index 7f2ea6578..ae80fd453 100644 --- a/src/libANGLE/renderer/vulkan/GlslangWrapper.cpp +++ b/src/libANGLE/renderer/vulkan/GlslangWrapper.cpp @@ -740,23 +740,27 @@ uint32_t AssignAtomicCounterBufferBindings(const std::vector *shaderSources) { - const std::string resourcesDescriptorSet = "set = " + Str(kShaderResourceDescriptorSetIndex); - - // Currently, we only support a single atomic counter buffer binding. - ASSERT(buffers.size() <= 1); - - uint32_t bindingIndex = bindingStart; - for (const gl::AtomicCounterBuffer &buffer : buffers) + if (buffers.size() == 0) { - const std::string bindingString = - resourcesDescriptorSet + ", binding = " + Str(bindingIndex++); - - constexpr char kAtomicCounterBlockName[] = "ANGLEAtomicCounters"; - AssignResourceBinding(buffer.activeShaders(), kAtomicCounterBlockName, bindingString, - qualifier, kUnusedBlockSubstitution, shaderSources); + return bindingStart; } - return bindingIndex; + constexpr char kAtomicCounterBlockName[] = "ANGLEAtomicCounters"; + const std::string bindingString = + "set = " + Str(kShaderResourceDescriptorSetIndex) + ", binding = " + Str(bindingStart); + + for (const gl::ShaderType shaderType : gl::AllShaderTypes()) + { + IntermediateShaderSource &shaderSource = (*shaderSources)[shaderType]; + if (!shaderSource.empty()) + { + // All atomic counter buffers are placed under one binding shared between all stages. + shaderSource.insertLayoutSpecifier(kAtomicCounterBlockName, bindingString); + shaderSource.insertQualifierSpecifier(kAtomicCounterBlockName, qualifier); + } + } + + return bindingStart + 1; } void AssignBufferBindings(const gl::ProgramState &programState, diff --git a/src/libANGLE/renderer/vulkan/ProgramVk.cpp b/src/libANGLE/renderer/vulkan/ProgramVk.cpp index d04a3f297..8c6598559 100644 --- a/src/libANGLE/renderer/vulkan/ProgramVk.cpp +++ b/src/libANGLE/renderer/vulkan/ProgramVk.cpp @@ -25,6 +25,26 @@ namespace constexpr size_t kUniformBlockDynamicBufferMinSize = 256 * 128; +// Identical to Std140 encoder in all aspects, except it ignores opaque uniform types. +class VulkanDefaultBlockEncoder : public sh::Std140BlockEncoder +{ + public: + void advanceOffset(GLenum type, + const std::vector &arraySizes, + bool isRowMajorMatrix, + int arrayStride, + int matrixStride) override + { + if (gl::IsOpaqueType(type)) + { + return; + } + + sh::Std140BlockEncoder::advanceOffset(type, arraySizes, isRowMajorMatrix, arrayStride, + matrixStride); + } +}; + void InitDefaultUniformBlock(const std::vector &uniforms, sh::BlockLayoutMap *blockLayoutMapOut, size_t *blockSizeOut) @@ -35,7 +55,7 @@ void InitDefaultUniformBlock(const std::vector &uniforms, return; } - sh::Std140BlockEncoder blockEncoder; + VulkanDefaultBlockEncoder blockEncoder; sh::GetUniformBlockInfo(uniforms, "", &blockEncoder, blockLayoutMapOut); size_t blockSize = blockEncoder.getCurrentOffset(); @@ -187,15 +207,20 @@ void AddAtomicCounterBufferDescriptorSetDesc( uint32_t bindingStart, vk::DescriptorSetLayoutDesc *descOut) { - uint32_t bindingIndex = 0; - for (uint32_t bufferIndex = 0; bufferIndex < atomicCounterBuffers.size(); ++bufferIndex) + if (atomicCounterBuffers.empty()) { - VkShaderStageFlags activeStages = - gl_vk::GetShaderStageFlags(atomicCounterBuffers[bufferIndex].activeShaders()); - - descOut->update(bindingStart + bindingIndex, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, - activeStages); + return; } + + VkShaderStageFlags activeStages = 0; + for (const gl::AtomicCounterBuffer &buffer : atomicCounterBuffers) + { + activeStages |= gl_vk::GetShaderStageFlags(buffer.activeShaders()); + } + + // A single storage buffer array is used for all stages for simplicity. + descOut->update(bindingStart, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, + gl::IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS, activeStages); } void WriteBufferDescriptorSetBinding(const gl::OffsetBindingPointer &bufferBinding, @@ -350,7 +375,7 @@ void ProgramVk::reset(ContextVk *contextVk) mDefaultShaderInfo.release(contextVk); mLineRasterShaderInfo.release(contextVk); - mEmptyUniformBlockStorage.release(contextVk); + mEmptyBuffer.release(contextVk); mDescriptorSets.clear(); mEmptyDescriptorSets.fill(VK_NULL_HANDLE); @@ -583,8 +608,8 @@ angle::Result ProgramVk::linkImpl(const gl::Context *glContext, gl::InfoLog &inf } if (storageBlockCount > 0 || atomicCounterBufferCount > 0) { - bufferSetSize.push_back( - {VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, storageBlockCount + atomicCounterBufferCount}); + const uint32_t storageBufferDescCount = storageBlockCount + atomicCounterBufferCount; + bufferSetSize.push_back({VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, storageBufferDescCount}); } VkDescriptorPoolSize textureSetSize = {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, textureCount}; @@ -604,7 +629,22 @@ angle::Result ProgramVk::linkImpl(const gl::Context *glContext, gl::InfoLog &inf mDynamicBufferOffsets.resize(mState.getLinkedShaderStageCount()); - return angle::Result::Continue; + // Initialize an "empty" buffer for use with default uniform blocks where there are no uniforms, + // or atomic counter buffer array indices that are unused. + constexpr VkBufferUsageFlags kEmptyBufferUsage = + VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; + + VkBufferCreateInfo emptyBufferInfo = {}; + emptyBufferInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; + emptyBufferInfo.flags = 0; + emptyBufferInfo.size = 4; + emptyBufferInfo.usage = kEmptyBufferUsage; + emptyBufferInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; + emptyBufferInfo.queueFamilyIndexCount = 0; + emptyBufferInfo.pQueueFamilyIndices = nullptr; + + constexpr VkMemoryPropertyFlags kMemoryType = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + return mEmptyBuffer.init(contextVk, emptyBufferInfo, kMemoryType); } void ProgramVk::updateBindingOffsets() @@ -723,25 +763,6 @@ angle::Result ProgramVk::resizeUniformBlockMemory(ContextVk *contextVk, } } - if (mDefaultUniformBlocksDirty.any() || mState.getTransformFeedbackBufferCount() > 0) - { - // Initialize the "empty" uniform block if necessary. - if (!mDefaultUniformBlocksDirty.all()) - { - VkBufferCreateInfo uniformBufferInfo = {}; - uniformBufferInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; - uniformBufferInfo.flags = 0; - uniformBufferInfo.size = 1; - uniformBufferInfo.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; - uniformBufferInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - uniformBufferInfo.queueFamilyIndexCount = 0; - uniformBufferInfo.pQueueFamilyIndices = nullptr; - - constexpr VkMemoryPropertyFlags kMemoryType = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; - ANGLE_TRY(mEmptyUniformBlockStorage.init(contextVk, uniformBufferInfo, kMemoryType)); - } - } - return angle::Result::Continue; } @@ -1129,7 +1150,8 @@ void ProgramVk::updateDefaultUniformsDescriptorSet(ContextVk *contextVk) } else { - bufferInfo.buffer = mEmptyUniformBlockStorage.getBuffer().getHandle(); + mEmptyBuffer.updateQueueSerial(contextVk->getCurrentQueueSerial()); + bufferInfo.buffer = mEmptyBuffer.getBuffer().getHandle(); } bufferInfo.offset = 0; @@ -1162,6 +1184,11 @@ void ProgramVk::updateBuffersDescriptorSet(ContextVk *contextVk, const std::vector &blocks, VkDescriptorType descriptorType) { + if (blocks.empty()) + { + return; + } + VkDescriptorSet descriptorSet = mDescriptorSets[kShaderResourceDescriptorSetIndex]; ASSERT(descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER || @@ -1237,38 +1264,42 @@ void ProgramVk::updateBuffersDescriptorSet(ContextVk *contextVk, void ProgramVk::updateAtomicCounterBuffersDescriptorSet(ContextVk *contextVk, vk::CommandGraphResource *recorder) { + const gl::State &glState = contextVk->getState(); + const std::vector &atomicCounterBuffers = + mState.getAtomicCounterBuffers(); + + if (atomicCounterBuffers.empty()) + { + return; + } + VkDescriptorSet descriptorSet = mDescriptorSets[kShaderResourceDescriptorSetIndex]; const uint32_t bindingStart = getAtomicCounterBufferBindingsOffset(); gl::AtomicCounterBuffersArray descriptorBufferInfo; gl::AtomicCounterBuffersArray writeDescriptorInfo; - uint32_t writeCount = 0; + gl::AtomicCounterBufferMask writtenBindings; // Write atomic counter buffers. - const gl::State &glState = contextVk->getState(); - const std::vector &atomicCounterBuffers = - mState.getAtomicCounterBuffers(); - for (uint32_t bufferIndex = 0; bufferIndex < atomicCounterBuffers.size(); ++bufferIndex) { const gl::AtomicCounterBuffer &atomicCounterBuffer = atomicCounterBuffers[bufferIndex]; + uint32_t binding = atomicCounterBuffer.binding; const gl::OffsetBindingPointer &bufferBinding = - glState.getIndexedAtomicCounterBuffer(atomicCounterBuffer.binding); + glState.getIndexedAtomicCounterBuffer(binding); if (bufferBinding.get() == nullptr) { continue; } - uint32_t binding = bindingStart + bufferIndex; - - VkDescriptorBufferInfo &bufferInfo = descriptorBufferInfo[writeCount]; - VkWriteDescriptorSet &writeInfo = writeDescriptorInfo[writeCount]; + VkDescriptorBufferInfo &bufferInfo = descriptorBufferInfo[binding]; + VkWriteDescriptorSet &writeInfo = writeDescriptorInfo[binding]; WriteBufferDescriptorSetBinding(bufferBinding, 0, descriptorSet, - VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, binding, 0, &bufferInfo, - &writeInfo); + VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, bindingStart, binding, + &bufferInfo, &writeInfo); BufferVk *bufferVk = vk::GetImpl(bufferBinding.get()); vk::BufferHelper &bufferHelper = bufferVk->getBuffer(); @@ -1276,12 +1307,36 @@ void ProgramVk::updateAtomicCounterBuffersDescriptorSet(ContextVk *contextVk, bufferHelper.onWrite(contextVk, recorder, VK_ACCESS_SHADER_READ_BIT, VK_ACCESS_SHADER_WRITE_BIT); - ++writeCount; + writtenBindings.set(binding); + } + + // Bind the empty buffer to every array slot that's unused. + mEmptyBuffer.updateQueueSerial(contextVk->getCurrentQueueSerial()); + for (size_t binding : ~writtenBindings) + { + VkDescriptorBufferInfo &bufferInfo = descriptorBufferInfo[binding]; + VkWriteDescriptorSet &writeInfo = writeDescriptorInfo[binding]; + + bufferInfo.buffer = mEmptyBuffer.getBuffer().getHandle(); + bufferInfo.offset = 0; + bufferInfo.range = VK_WHOLE_SIZE; + + writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; + writeInfo.pNext = nullptr; + writeInfo.dstSet = descriptorSet; + writeInfo.dstBinding = bindingStart; + writeInfo.dstArrayElement = binding; + writeInfo.descriptorCount = 1; + writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; + writeInfo.pImageInfo = nullptr; + writeInfo.pBufferInfo = &bufferInfo; + writeInfo.pTexelBufferView = nullptr; } VkDevice device = contextVk->getDevice(); - vkUpdateDescriptorSets(device, writeCount, writeDescriptorInfo.data(), 0, nullptr); + vkUpdateDescriptorSets(device, gl::IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS, + writeDescriptorInfo.data(), 0, nullptr); } angle::Result ProgramVk::updateShaderResourcesDescriptorSet(ContextVk *contextVk, diff --git a/src/libANGLE/renderer/vulkan/ProgramVk.h b/src/libANGLE/renderer/vulkan/ProgramVk.h index af82fe627..90ef46f23 100644 --- a/src/libANGLE/renderer/vulkan/ProgramVk.h +++ b/src/libANGLE/renderer/vulkan/ProgramVk.h @@ -266,10 +266,12 @@ class ProgramVk : public ProgramImpl gl::ShaderVector mDynamicBufferOffsets; - // This is a special "empty" placeholder buffer for when a shader has no uniforms. + // This is a special "empty" placeholder buffer for when a shader has no uniforms or doesn't + // use all slots in the atomic counter buffer array. + // // It is necessary because we want to keep a compatible pipeline layout in all cases, // and Vulkan does not tolerate having null handles in a descriptor set. - vk::BufferHelper mEmptyUniformBlockStorage; + vk::BufferHelper mEmptyBuffer; // Descriptor sets for uniform blocks and textures for this program. std::vector mDescriptorSets; diff --git a/src/libANGLE/renderer/vulkan/RendererVk.cpp b/src/libANGLE/renderer/vulkan/RendererVk.cpp index 391fa2cba..99604bb60 100644 --- a/src/libANGLE/renderer/vulkan/RendererVk.cpp +++ b/src/libANGLE/renderer/vulkan/RendererVk.cpp @@ -1115,10 +1115,13 @@ gl::Version RendererVk::getMaxSupportedESVersion() const // Limit to ES3.0 if there are any blockers for 3.1. // ES3.1 requires at least one atomic counter buffer and four storage buffers in compute. - // Atomic counter buffers are emulated with storage buffers, so if Vulkan doesn't support at - // least 5 storage buffers in compute, we cannot support 3.1. + // Atomic counter buffers are emulated with storage buffers. For simplicity, we always support + // either none or IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS atomic counter buffers. So if + // Vulkan doesn't support at least that many storage buffers in compute, we don't support 3.1. + const uint32_t kMinimumStorageBuffersForES31 = + gl::limits::kMinimumComputeStorageBuffers + gl::IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS; if (mPhysicalDeviceProperties.limits.maxPerStageDescriptorStorageBuffers < - gl::limits::kMinimumComputeStorageBuffers + 1) + kMinimumStorageBuffersForES31) { maxVersion = std::min(maxVersion, gl::Version(3, 0)); } diff --git a/src/libANGLE/renderer/vulkan/vk_cache_utils.h b/src/libANGLE/renderer/vulkan/vk_cache_utils.h index 380b60d9d..49fd1b1e8 100644 --- a/src/libANGLE/renderer/vulkan/vk_cache_utils.h +++ b/src/libANGLE/renderer/vulkan/vk_cache_utils.h @@ -894,11 +894,11 @@ class PipelineLayoutCache final : angle::NonCopyable // // The set/binding assignment is done as following: // -// - Set 0 contains uniform blocks created to encompass default uniforms. Bindings 0 and 1 -// correspond to default uniforms in the vertex and fragment shaders respectively. Additionally, -// transform feedback buffers are bound from binding 2 and up. +// - Set 0 contains uniform blocks created to encompass default uniforms. 1 binding is used per +// pipeline stage. Additionally, transform feedback buffers are bound from binding 2 and up. // - Set 1 contains all textures. -// - Set 2 contains all other shader resources. +// - Set 2 contains all other shader resources, such as uniform and storage blocks, atomic counter +// buffers and images. // - Set 3 contains the ANGLE driver uniforms at binding 0. Note that driver uniforms are updated // only under rare circumstances, such as viewport or depth range change. However, there is only // one binding in this set. diff --git a/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp b/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp index aef8a235a..62980325c 100644 --- a/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp +++ b/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp @@ -264,31 +264,39 @@ void RendererVk::ensureCapsInitialized() const maxPerStageStorageBuffers = std::min(maxPerStageStorageBuffers, maxCombinedStorageBuffers); } - // Reserve one storage buffer in the fragment and compute stages for atomic counters. This is - // only possible if the number of per-stage storage buffers is greater than 4, which is the - // required GLES minimum for compute. We use the same value for fragment, to avoid giving one - // of the precious few storage buffers available to an atomic counter buffer. The spec allows - // there to be zero of either of these resources in the fragment stage. + // Reserve up to IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS storage buffers in the fragment and + // compute stages for atomic counters. This is only possible if the number of per-stage storage + // buffers is greater than 4, which is the required GLES minimum for compute. + // + // For each stage, we'll either not support atomic counter buffers, or support exactly + // IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS. This is due to restrictions in the shader + // translator where we can't know how many atomic counter buffers we would really need after + // linking so we can't create a packed buffer array. + // + // For the vertex stage, we could support atomic counters without storage buffers, but that's + // likely not very useful, so we use the same limit (4 + MAX_ATOMIC_COUNTER_BUFFERS) for the + // vertex stage to determine if we would want to add support for atomic counter buffers. + constexpr uint32_t kMinimumStorageBuffersForAtomicCounterBufferSupport = + gl::limits::kMinimumComputeStorageBuffers + gl::IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS; uint32_t maxVertexStageAtomicCounterBuffers = 0; uint32_t maxPerStageAtomicCounterBuffers = 0; uint32_t maxCombinedAtomicCounterBuffers = 0; - if (maxPerStageStorageBuffers > gl::limits::kMinimumComputeStorageBuffers) + if (maxPerStageStorageBuffers >= kMinimumStorageBuffersForAtomicCounterBufferSupport) { - --maxPerStageStorageBuffers; - --maxCombinedStorageBuffers; - maxPerStageAtomicCounterBuffers = 1; - maxCombinedAtomicCounterBuffers = 1; + maxPerStageAtomicCounterBuffers = gl::IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS; + maxCombinedAtomicCounterBuffers = gl::IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS; } - // For the vertex stage, similarly reserve one storage buffer for atomic counters, if there are - // excess storage buffers. - if (maxVertexStageStorageBuffers > gl::limits::kMinimumComputeStorageBuffers) + if (maxVertexStageStorageBuffers >= kMinimumStorageBuffersForAtomicCounterBufferSupport) { - --maxVertexStageStorageBuffers; - maxVertexStageAtomicCounterBuffers = 1; + maxVertexStageAtomicCounterBuffers = gl::IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS; } + maxVertexStageStorageBuffers -= maxVertexStageAtomicCounterBuffers; + maxPerStageStorageBuffers -= maxPerStageAtomicCounterBuffers; + maxCombinedStorageBuffers -= maxCombinedAtomicCounterBuffers; + mNativeCaps.maxShaderStorageBlocks[gl::ShaderType::Vertex] = mPhysicalDeviceFeatures.vertexPipelineStoresAndAtomics ? maxVertexStageStorageBuffers : 0; mNativeCaps.maxShaderStorageBlocks[gl::ShaderType::Fragment] = diff --git a/src/tests/deqp_support/deqp_gles31_test_expectations.txt b/src/tests/deqp_support/deqp_gles31_test_expectations.txt index b58cf86fe..c9383ad3b 100644 --- a/src/tests/deqp_support/deqp_gles31_test_expectations.txt +++ b/src/tests/deqp_support/deqp_gles31_test_expectations.txt @@ -617,6 +617,12 @@ 3520 VULKAN ANDROID : dEQP-GLES31.functional.debug.negative_coverage.get_error.texture.texparameterf = FAIL 3520 VULKAN ANDROID : dEQP-GLES31.functional.debug.negative_coverage.get_error.texture.texparameterfv = FAIL +// Passing on recent drivers: +3726 VULKAN ANDROID : dEQP-GLES31.functional.ssbo.layout.* = FAIL +3726 VULKAN ANDROID : dEQP-GLES31.functional.atomic_counter.* = FAIL +3726 VULKAN ANDROID : dEQP-GLES31.functional.synchronization.inter_call.without_memory_barrier.*atomic_counter* = FAIL +3726 VULKAN ANDROID : dEQP-GLES31.functional.compute.basic.atomic_counter* = FAIL + // General Vulkan failures // Limits: @@ -650,6 +656,10 @@ // SSBO and Image qualifiers: 3602 VULKAN : dEQP-GLES31.functional.synchronization.in_invocation.ssbo_alias_overwrite = FAIL +// Array of array in atomic counters: +3566 VULKAN : dEQP-GLES31.functional.program_interface_query.uniform.atomic_counter_buffer_index.default_block.array.var_array_array = SKIP +3566 VULKAN : dEQP-GLES31.functional.program_interface_query.uniform.location.default_block.array.array.atomic_uint = SKIP + // Struct referenced by: 3596 VULKAN : dEQP-GLES31.functional.program_interface_query.*.referenced_by*struct* = FAIL 3596 VULKAN : dEQP-GLES31.functional.program_interface_query.*random* = FAIL @@ -666,11 +676,6 @@ // Tessellation geometry interaction: 3572 VULKAN : dEQP-GLES31.functional.tessellation_geometry_interaction.* = FAIL -// dEQP bug where atomic counter bindings > max result in failure instead of not-supported: -// https://github.com/KhronosGroup/VK-GL-CTS/issues/156 -3566 VULKAN : dEQP-GLES31.functional.atomic_counter.* = FAIL -3566 VULKAN : dEQP-GLES31.functional.synchronization.inter_call.without_memory_barrier.*atomic_counter* = FAIL - // Storage image: 3563 VULKAN : dEQP-GLES31.functional.state_query.*image* = FAIL 3563 VULKAN : dEQP-GLES31.functional.synchronization.*.image* = FAIL diff --git a/src/tests/deqp_support/deqp_khr_gles31_test_expectations.txt b/src/tests/deqp_support/deqp_khr_gles31_test_expectations.txt index 026131239..c3d89d6d0 100644 --- a/src/tests/deqp_support/deqp_khr_gles31_test_expectations.txt +++ b/src/tests/deqp_support/deqp_khr_gles31_test_expectations.txt @@ -105,11 +105,14 @@ // Blend equations: 3586 VULKAN : KHR-GLES31.core.blend_equation_advanced.* = SKIP +// Atomic Counter buffers: +3566 VULKAN : KHR-GLES31.core.shader_atomic_counters.advanced-usage-multi-stage = FAIL + // Storage image: 3563 VULKAN : KHR-GLES31.core.layout_binding.sampler2D_layout_binding_texture_ComputeShader = FAIL 3563 VULKAN : KHR-GLES31.core.layout_binding.block_layout_binding_block_ComputeShader = FAIL -3563 VULKAN : KHR-GLES31.core.layout_binding.buffer_layout_binding_atomic* = SKIP -3563 VULKAN : KHR-GLES31.core.layout_binding.atomic_uint_layout_binding_atomic* = FAIL +3563 VULKAN : KHR-GLES31.core.layout_binding.buffer_layout_binding_atomicAdd_ComputeShader = FAIL +3563 VULKAN : KHR-GLES31.core.layout_binding.atomic_uint_layout_binding_atomic_ComputeShader = FAIL 3520 VULKAN : KHR-GLES31.core.internalformat.copy_tex_image* = FAIL 3520 VULKAN : KHR-GLES31.core.internalformat.renderbuffer* = FAIL @@ -118,3 +121,7 @@ // Sampler objects: 3208 VULKAN : KHR-GLES31.shaders.layout_location.*sampler* = FAIL + +// Passing on recent drivers: +3726 VULKAN ANDROID : KHR-GLES31.core.shader_atomic_counters.* = FAIL +3726 VULKAN ANDROID : KHR-GLES31.core.shader_atomic_counters.advanced-usage-* = SKIP diff --git a/src/tests/gl_tests/AtomicCounterBufferTest.cpp b/src/tests/gl_tests/AtomicCounterBufferTest.cpp index 955023a95..833ed17d4 100644 --- a/src/tests/gl_tests/AtomicCounterBufferTest.cpp +++ b/src/tests/gl_tests/AtomicCounterBufferTest.cpp @@ -130,16 +130,21 @@ TEST_P(AtomicCounterBufferTest31, AtomicCounterReadCompute) // Crashes in older drivers. http://anglebug.com/3738 ANGLE_SKIP_TEST_IF(IsOpenGL() && IsWindows() && IsAMD()); + // Skipping due to a bug on the Qualcomm Vulkan Android driver. + // http://anglebug.com/3726 + ANGLE_SKIP_TEST_IF(IsAndroid() && IsVulkan()); + // Skipping due to a bug on the Adreno OpenGLES Android driver. // http://anglebug.com/2925 ANGLE_SKIP_TEST_IF(IsAndroid() && IsAdreno() && IsOpenGLES()); constexpr char kComputeShaderSource[] = R"(#version 310 es layout(local_size_x=1, local_size_y=1, local_size_z=1) in; -layout(binding = 0, offset = 8) uniform atomic_uint ac[3]; void atomicCounterInFunction(in atomic_uint counter[3]); +layout(binding = 0, offset = 8) uniform atomic_uint ac[3]; + void atomicCounterInFunction(in atomic_uint counter[3]) { atomicCounter(counter[0]); @@ -161,6 +166,10 @@ TEST_P(AtomicCounterBufferTest31, AtomicCounterRead) // Crashes in older drivers. http://anglebug.com/3738 ANGLE_SKIP_TEST_IF(IsOpenGL() && IsWindows() && IsAMD()); + // Skipping due to a bug on the Qualcomm Vulkan Android driver. + // http://anglebug.com/3726 + ANGLE_SKIP_TEST_IF(IsAndroid() && IsVulkan()); + // Skipping test while we work on enabling atomic counter buffer support in th D3D renderer. // http://anglebug.com/1729 ANGLE_SKIP_TEST_IF(IsD3D11()); @@ -200,6 +209,10 @@ TEST_P(AtomicCounterBufferTest31, AtomicCounterIncrementAndDecrement) // Crashes in older drivers. http://anglebug.com/3738 ANGLE_SKIP_TEST_IF(IsOpenGL() && IsWindows() && IsAMD()); + // Skipping due to a bug on the Qualcomm Vulkan Android driver. + // http://anglebug.com/3726 + ANGLE_SKIP_TEST_IF(IsAndroid() && IsVulkan()); + constexpr char kCS[] = "#version 310 es\n" "layout(local_size_x=1, local_size_y=1, local_size_z=1) in;\n" @@ -244,6 +257,10 @@ TEST_P(AtomicCounterBufferTest31, AtomicCounterMultipleBuffers) // Crashes in older drivers. http://anglebug.com/3738 ANGLE_SKIP_TEST_IF(IsOpenGL() && IsWindows() && IsAMD()); + // Skipping due to a bug on the Qualcomm Vulkan Android driver. + // http://anglebug.com/3726 + ANGLE_SKIP_TEST_IF(IsAndroid() && IsVulkan()); + GLint maxAtomicCounterBuffers = 0; glGetIntegerv(GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS, &maxAtomicCounterBuffers); constexpr unsigned int kBufferCount = 3;