diff options
Diffstat (limited to 'src/3rdparty/angle/src/libANGLE/Uniform.cpp')
-rw-r--r-- | src/3rdparty/angle/src/libANGLE/Uniform.cpp | 185 |
1 files changed, 131 insertions, 54 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/Uniform.cpp b/src/3rdparty/angle/src/libANGLE/Uniform.cpp index bfae3c014f..dee8eee915 100644 --- a/src/3rdparty/angle/src/libANGLE/Uniform.cpp +++ b/src/3rdparty/angle/src/libANGLE/Uniform.cpp @@ -13,46 +13,99 @@ namespace gl { +StaticallyUsed::StaticallyUsed() + : vertexStaticUse(false), fragmentStaticUse(false), computeStaticUse(false) +{ +} + +StaticallyUsed::~StaticallyUsed() +{ +} + +StaticallyUsed::StaticallyUsed(const StaticallyUsed &rhs) = default; +StaticallyUsed &StaticallyUsed::operator=(const StaticallyUsed &rhs) = default; + +void StaticallyUsed::setStaticUse(GLenum shaderType, bool used) +{ + switch (shaderType) + { + case GL_VERTEX_SHADER: + vertexStaticUse = used; + break; + + case GL_FRAGMENT_SHADER: + fragmentStaticUse = used; + break; + + case GL_COMPUTE_SHADER: + computeStaticUse = used; + break; + + default: + UNREACHABLE(); + } +} + +void StaticallyUsed::unionReferencesWith(const StaticallyUsed &other) +{ + vertexStaticUse |= other.vertexStaticUse; + fragmentStaticUse |= other.fragmentStaticUse; + computeStaticUse |= other.computeStaticUse; +} + LinkedUniform::LinkedUniform() - : blockIndex(-1), blockInfo(sh::BlockMemberInfo::getDefaultBlockInfo()) + : typeInfo(nullptr), bufferIndex(-1), blockInfo(sh::BlockMemberInfo::getDefaultBlockInfo()) { } LinkedUniform::LinkedUniform(GLenum typeIn, GLenum precisionIn, const std::string &nameIn, - unsigned int arraySizeIn, - const int blockIndexIn, + const std::vector<unsigned int> &arraySizesIn, + const int bindingIn, + const int offsetIn, + const int locationIn, + const int bufferIndexIn, const sh::BlockMemberInfo &blockInfoIn) - : blockIndex(blockIndexIn), blockInfo(blockInfoIn) + : typeInfo(&GetUniformTypeInfo(typeIn)), bufferIndex(bufferIndexIn), blockInfo(blockInfoIn) { type = typeIn; precision = precisionIn; name = nameIn; - arraySize = arraySizeIn; + arraySizes = arraySizesIn; + binding = bindingIn; + offset = offsetIn; + location = locationIn; + ASSERT(!isArrayOfArrays()); + ASSERT(!isArray() || !isStruct()); } LinkedUniform::LinkedUniform(const sh::Uniform &uniform) - : sh::Uniform(uniform), blockIndex(-1), blockInfo(sh::BlockMemberInfo::getDefaultBlockInfo()) + : sh::Uniform(uniform), + typeInfo(&GetUniformTypeInfo(type)), + bufferIndex(-1), + blockInfo(sh::BlockMemberInfo::getDefaultBlockInfo()) { + ASSERT(!isArrayOfArrays()); + ASSERT(!isArray() || !isStruct()); } LinkedUniform::LinkedUniform(const LinkedUniform &uniform) - : sh::Uniform(uniform), blockIndex(uniform.blockIndex), blockInfo(uniform.blockInfo) + : sh::Uniform(uniform), + StaticallyUsed(uniform), + typeInfo(uniform.typeInfo), + bufferIndex(uniform.bufferIndex), + blockInfo(uniform.blockInfo) { - // This function is not intended to be called during runtime. - ASSERT(uniform.mLazyData.empty()); } LinkedUniform &LinkedUniform::operator=(const LinkedUniform &uniform) { - // This function is not intended to be called during runtime. - ASSERT(uniform.mLazyData.empty()); - sh::Uniform::operator=(uniform); - blockIndex = uniform.blockIndex; + StaticallyUsed::operator=(uniform); + typeInfo = uniform.typeInfo; + bufferIndex = uniform.bufferIndex; blockInfo = uniform.blockInfo; - return *this; } @@ -62,80 +115,92 @@ LinkedUniform::~LinkedUniform() bool LinkedUniform::isInDefaultBlock() const { - return blockIndex == -1; + return bufferIndex == -1; } -size_t LinkedUniform::dataSize() const +bool LinkedUniform::isSampler() const { - ASSERT(type != GL_STRUCT_ANGLEX); - if (mLazyData.empty()) - { - mLazyData.resize(VariableExternalSize(type) * elementCount()); - ASSERT(!mLazyData.empty()); - } + return typeInfo->isSampler; +} - return mLazyData.size(); +bool LinkedUniform::isImage() const +{ + return typeInfo->isImageType; } -uint8_t *LinkedUniform::data() +bool LinkedUniform::isAtomicCounter() const { - if (mLazyData.empty()) - { - // dataSize() will init the data store. - size_t size = dataSize(); - memset(mLazyData.data(), 0, size); - } + return IsAtomicCounterType(type); +} - return mLazyData.data(); +bool LinkedUniform::isField() const +{ + return name.find('.') != std::string::npos; } -const uint8_t *LinkedUniform::data() const +size_t LinkedUniform::getElementSize() const { - return const_cast<LinkedUniform *>(this)->data(); + return typeInfo->externalSize; } -bool LinkedUniform::isSampler() const +size_t LinkedUniform::getElementComponents() const { - return IsSamplerType(type); + return typeInfo->componentCount; } -bool LinkedUniform::isField() const +BufferVariable::BufferVariable() + : bufferIndex(-1), blockInfo(sh::BlockMemberInfo::getDefaultBlockInfo()), topLevelArraySize(-1) { - return name.find('.') != std::string::npos; } -size_t LinkedUniform::getElementSize() const +BufferVariable::BufferVariable(GLenum typeIn, + GLenum precisionIn, + const std::string &nameIn, + const std::vector<unsigned int> &arraySizesIn, + const int bufferIndexIn, + const sh::BlockMemberInfo &blockInfoIn) + : bufferIndex(bufferIndexIn), blockInfo(blockInfoIn), topLevelArraySize(-1) +{ + type = typeIn; + precision = precisionIn; + name = nameIn; + arraySizes = arraySizesIn; +} + +BufferVariable::~BufferVariable() { - return VariableExternalSize(type); } -uint8_t *LinkedUniform::getDataPtrToElement(size_t elementIndex) +ShaderVariableBuffer::ShaderVariableBuffer() : binding(0), dataSize(0) { - ASSERT((!isArray() && elementIndex == 0) || (isArray() && elementIndex < arraySize)); - return data() + getElementSize() * elementIndex; } -const uint8_t *LinkedUniform::getDataPtrToElement(size_t elementIndex) const +ShaderVariableBuffer::ShaderVariableBuffer(const ShaderVariableBuffer &other) = default; + +ShaderVariableBuffer::~ShaderVariableBuffer() +{ +} + +int ShaderVariableBuffer::numActiveVariables() const { - return const_cast<LinkedUniform *>(this)->getDataPtrToElement(elementIndex); + return static_cast<int>(memberIndexes.size()); } -UniformBlock::UniformBlock() - : isArray(false), arrayElement(0), dataSize(0), vertexStaticUse(false), fragmentStaticUse(false) +InterfaceBlock::InterfaceBlock() : isArray(false), arrayElement(0) { } -UniformBlock::UniformBlock(const std::string &nameIn, bool isArrayIn, unsigned int arrayElementIn) - : name(nameIn), - isArray(isArrayIn), - arrayElement(arrayElementIn), - dataSize(0), - vertexStaticUse(false), - fragmentStaticUse(false) +InterfaceBlock::InterfaceBlock(const std::string &nameIn, + const std::string &mappedNameIn, + bool isArrayIn, + unsigned int arrayElementIn, + int bindingIn) + : name(nameIn), mappedName(mappedNameIn), isArray(isArrayIn), arrayElement(arrayElementIn) { + binding = bindingIn; } -std::string UniformBlock::nameWithArrayIndex() const +std::string InterfaceBlock::nameWithArrayIndex() const { std::stringstream fullNameStr; fullNameStr << name; @@ -146,4 +211,16 @@ std::string UniformBlock::nameWithArrayIndex() const return fullNameStr.str(); } + +std::string InterfaceBlock::mappedNameWithArrayIndex() const +{ + std::stringstream fullNameStr; + fullNameStr << mappedName; + if (isArray) + { + fullNameStr << "[" << arrayElement << "]"; + } + + return fullNameStr.str(); +} } |