#include "compiler/translator/blocklayout.h"
#include "common/mathutil.h"
#include "common/utilities.h"
#include "compiler/translator/Common.h"
namespace sh
{
bool operator==(const BlockMemberInfo &lhs, const BlockMemberInfo &rhs)
{ … }
namespace
{
class BlockLayoutMapVisitor : public BlockEncoderVisitor
{ … };
template <typename VarT>
void GetInterfaceBlockInfo(const std::vector<VarT> &fields,
const std::string &prefix,
BlockLayoutEncoder *encoder,
bool inRowMajorLayout,
bool onlyActiveVariables,
BlockLayoutMap *blockInfoOut)
{ … }
void TraverseStructVariable(const ShaderVariable &variable,
bool isRowMajorLayout,
ShaderVariableVisitor *visitor)
{ … }
void TraverseStructArrayVariable(const ShaderVariable &variable,
bool inRowMajorLayout,
ShaderVariableVisitor *visitor)
{ … }
void TraverseArrayOfArraysVariable(const ShaderVariable &variable,
unsigned int arrayNestingIndex,
bool isRowMajorMatrix,
ShaderVariableVisitor *visitor)
{ … }
std::string CollapseNameStack(const std::vector<std::string> &nameStack)
{ … }
size_t GetStd430BaseAlignment(GLenum variableType, bool isRowMajor)
{ … }
class BaseAlignmentVisitor : public ShaderVariableVisitor
{ … };
}
BlockLayoutEncoder::BlockLayoutEncoder() : … { … }
BlockMemberInfo BlockLayoutEncoder::encodeType(GLenum type,
const std::vector<unsigned int> &arraySizes,
bool isRowMajorMatrix)
{ … }
BlockMemberInfo BlockLayoutEncoder::encodeArrayOfPreEncodedStructs(
size_t size,
const std::vector<unsigned int> &arraySizes)
{ … }
size_t BlockLayoutEncoder::getCurrentOffset() const
{ … }
size_t BlockLayoutEncoder::getShaderVariableSize(const ShaderVariable &structVar, bool isRowMajor)
{ … }
size_t BlockLayoutEncoder::GetBlockRegister(const BlockMemberInfo &info)
{ … }
size_t BlockLayoutEncoder::GetBlockRegisterElement(const BlockMemberInfo &info)
{ … }
void BlockLayoutEncoder::align(size_t baseAlignment)
{ … }
void StubBlockEncoder::getBlockLayoutInfo(GLenum type,
const std::vector<unsigned int> &arraySizes,
bool isRowMajorMatrix,
int *arrayStrideOut,
int *matrixStrideOut)
{ … }
Std140BlockEncoder::Std140BlockEncoder() { … }
void Std140BlockEncoder::enterAggregateType(const ShaderVariable &structVar)
{ … }
void Std140BlockEncoder::exitAggregateType(const ShaderVariable &structVar)
{ … }
void Std140BlockEncoder::getBlockLayoutInfo(GLenum type,
const std::vector<unsigned int> &arraySizes,
bool isRowMajorMatrix,
int *arrayStrideOut,
int *matrixStrideOut)
{ … }
void Std140BlockEncoder::advanceOffset(GLenum type,
const std::vector<unsigned int> &arraySizes,
bool isRowMajorMatrix,
int arrayStride,
int matrixStride)
{ … }
size_t Std140BlockEncoder::getBaseAlignment(const ShaderVariable &variable) const
{ … }
size_t Std140BlockEncoder::getTypeBaseAlignment(GLenum type, bool isRowMajorMatrix) const
{ … }
Std430BlockEncoder::Std430BlockEncoder() { … }
size_t Std430BlockEncoder::getBaseAlignment(const ShaderVariable &shaderVar) const
{ … }
size_t Std430BlockEncoder::getTypeBaseAlignment(GLenum type, bool isRowMajorMatrix) const
{ … }
void GetInterfaceBlockInfo(const std::vector<ShaderVariable> &fields,
const std::string &prefix,
BlockLayoutEncoder *encoder,
BlockLayoutMap *blockInfoOut)
{ … }
void GetActiveUniformBlockInfo(const std::vector<ShaderVariable> &uniforms,
const std::string &prefix,
BlockLayoutEncoder *encoder,
BlockLayoutMap *blockInfoOut)
{ … }
VariableNameVisitor::VariableNameVisitor(const std::string &namePrefix,
const std::string &mappedNamePrefix)
{ … }
VariableNameVisitor::~VariableNameVisitor() = default;
void VariableNameVisitor::enterStruct(const ShaderVariable &structVar)
{ … }
void VariableNameVisitor::exitStruct(const ShaderVariable &structVar)
{ … }
void VariableNameVisitor::enterStructAccess(const ShaderVariable &structVar, bool isRowMajor)
{ … }
void VariableNameVisitor::exitStructAccess(const ShaderVariable &structVar, bool isRowMajor)
{ … }
void VariableNameVisitor::enterArray(const ShaderVariable &arrayVar)
{ … }
void VariableNameVisitor::exitArray(const ShaderVariable &arrayVar)
{ … }
void VariableNameVisitor::enterArrayElement(const ShaderVariable &arrayVar,
unsigned int arrayElement)
{ … }
void VariableNameVisitor::exitArrayElement(const ShaderVariable &arrayVar,
unsigned int arrayElement)
{ … }
std::string VariableNameVisitor::collapseNameStack() const
{ … }
std::string VariableNameVisitor::collapseMappedNameStack() const
{ … }
void VariableNameVisitor::visitOpaqueObject(const sh::ShaderVariable &variable)
{ … }
void VariableNameVisitor::visitVariable(const ShaderVariable &variable, bool isRowMajor)
{ … }
BlockEncoderVisitor::BlockEncoderVisitor(const std::string &namePrefix,
const std::string &mappedNamePrefix,
BlockLayoutEncoder *encoder)
: … { … }
BlockEncoderVisitor::~BlockEncoderVisitor() = default;
void BlockEncoderVisitor::enterStructAccess(const ShaderVariable &structVar, bool isRowMajor)
{ … }
void BlockEncoderVisitor::exitStructAccess(const ShaderVariable &structVar, bool isRowMajor)
{ … }
void BlockEncoderVisitor::enterArrayElement(const sh::ShaderVariable &arrayVar,
unsigned int arrayElement)
{ … }
void BlockEncoderVisitor::exitArrayElement(const sh::ShaderVariable &arrayVar,
unsigned int arrayElement)
{ … }
void BlockEncoderVisitor::visitNamedVariable(const ShaderVariable &variable,
bool isRowMajor,
const std::string &name,
const std::string &mappedName,
const std::vector<unsigned int> &arraySizes)
{ … }
void TraverseShaderVariable(const ShaderVariable &variable,
bool isRowMajorLayout,
ShaderVariableVisitor *visitor)
{ … }
}