Commit 42bcf32e by Jamie Madill

Refactor ShaderVariables to store fields in the base.

Instead of only storing structure information in Varyings, Uniforms and Interface Block Fields, store it in the base class. Also only store base variable information for struct fields, instead of fully typed information. This works because stuff like interpolation type, invariance, and other properties are for the entire variable, not individual fields. Also add new fields for interface block instance name, varying invariance and structure name for all struct types. BUG=angle:466 Change-Id: If03fc071e6becb7aad6dea5093989bba7daee69e Reviewed-on: https://chromium-review.googlesource.com/213501Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarNicolas Capens <capn@chromium.org>
parent 6982260b
...@@ -39,6 +39,7 @@ typedef unsigned int GLenum; ...@@ -39,6 +39,7 @@ typedef unsigned int GLenum;
} }
// Must be included after GLenum proxy typedef // Must be included after GLenum proxy typedef
// Note: make sure to increment ANGLE_SH_VERSION when changing ShaderVars.h
#include "ShaderVars.h" #include "ShaderVars.h"
#ifdef __cplusplus #ifdef __cplusplus
...@@ -47,7 +48,7 @@ extern "C" { ...@@ -47,7 +48,7 @@ extern "C" {
// Version number for shader translation API. // Version number for shader translation API.
// It is incremented every time the API changes. // It is incremented every time the API changes.
#define ANGLE_SH_VERSION 129 #define ANGLE_SH_VERSION 130
typedef enum { typedef enum {
SH_GLES2_SPEC = 0x8B40, SH_GLES2_SPEC = 0x8B40,
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <algorithm> #include <algorithm>
// Assume ShaderLang.h is included before ShaderVars.h, for sh::GLenum // Assume ShaderLang.h is included before ShaderVars.h, for sh::GLenum
// Note: make sure to increment ANGLE_SH_VERSION when changing ShaderVars.h
namespace sh namespace sh
{ {
...@@ -49,6 +50,7 @@ struct COMPILER_EXPORT ShaderVariable ...@@ -49,6 +50,7 @@ struct COMPILER_EXPORT ShaderVariable
bool isArray() const { return arraySize > 0; } bool isArray() const { return arraySize > 0; }
unsigned int elementCount() const { return std::max(1u, arraySize); } unsigned int elementCount() const { return std::max(1u, arraySize); }
bool isStruct() const { return !fields.empty(); }
GLenum type; GLenum type;
GLenum precision; GLenum precision;
...@@ -56,6 +58,8 @@ struct COMPILER_EXPORT ShaderVariable ...@@ -56,6 +58,8 @@ struct COMPILER_EXPORT ShaderVariable
std::string mappedName; std::string mappedName;
unsigned int arraySize; unsigned int arraySize;
bool staticUse; bool staticUse;
std::vector<ShaderVariable> fields;
std::string structName;
}; };
struct COMPILER_EXPORT Uniform : public ShaderVariable struct COMPILER_EXPORT Uniform : public ShaderVariable
...@@ -64,10 +68,6 @@ struct COMPILER_EXPORT Uniform : public ShaderVariable ...@@ -64,10 +68,6 @@ struct COMPILER_EXPORT Uniform : public ShaderVariable
~Uniform(); ~Uniform();
Uniform(const Uniform &other); Uniform(const Uniform &other);
Uniform &operator=(const Uniform &other); Uniform &operator=(const Uniform &other);
bool isStruct() const { return !fields.empty(); }
std::vector<Uniform> fields;
}; };
struct COMPILER_EXPORT Attribute : public ShaderVariable struct COMPILER_EXPORT Attribute : public ShaderVariable
...@@ -87,10 +87,7 @@ struct COMPILER_EXPORT InterfaceBlockField : public ShaderVariable ...@@ -87,10 +87,7 @@ struct COMPILER_EXPORT InterfaceBlockField : public ShaderVariable
InterfaceBlockField(const InterfaceBlockField &other); InterfaceBlockField(const InterfaceBlockField &other);
InterfaceBlockField &operator=(const InterfaceBlockField &other); InterfaceBlockField &operator=(const InterfaceBlockField &other);
bool isStruct() const { return !fields.empty(); }
bool isRowMajorMatrix; bool isRowMajorMatrix;
std::vector<InterfaceBlockField> fields;
}; };
struct COMPILER_EXPORT Varying : public ShaderVariable struct COMPILER_EXPORT Varying : public ShaderVariable
...@@ -100,11 +97,8 @@ struct COMPILER_EXPORT Varying : public ShaderVariable ...@@ -100,11 +97,8 @@ struct COMPILER_EXPORT Varying : public ShaderVariable
Varying(const Varying &other); Varying(const Varying &other);
Varying &operator=(const Varying &other); Varying &operator=(const Varying &other);
bool isStruct() const { return !fields.empty(); }
InterpolationType interpolation; InterpolationType interpolation;
std::vector<Varying> fields; bool isInvariant;
std::string structName;
}; };
struct COMPILER_EXPORT InterfaceBlock struct COMPILER_EXPORT InterfaceBlock
...@@ -116,6 +110,7 @@ struct COMPILER_EXPORT InterfaceBlock ...@@ -116,6 +110,7 @@ struct COMPILER_EXPORT InterfaceBlock
std::string name; std::string name;
std::string mappedName; std::string mappedName;
std::string instanceName;
unsigned int arraySize; unsigned int arraySize;
BlockLayoutType layout; BlockLayoutType layout;
bool isRowMajorLayout; bool isRowMajorLayout;
......
...@@ -15,15 +15,17 @@ namespace sh ...@@ -15,15 +15,17 @@ namespace sh
{ {
BlockLayoutEncoder::BlockLayoutEncoder() BlockLayoutEncoder::BlockLayoutEncoder()
: mCurrentOffset(0) : mCurrentOffset(0),
mInRowMajorField(false)
{ {
} }
void BlockLayoutEncoder::encodeInterfaceBlockFields(const std::vector<InterfaceBlockField> &fields) template <typename VarT>
void BlockLayoutEncoder::encodeVariables(const std::vector<VarT> &fields)
{ {
for (unsigned int fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++) for (unsigned int fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++)
{ {
const InterfaceBlockField &variable = fields[fieldIndex]; const VarT &variable = fields[fieldIndex];
if (variable.fields.size() > 0) if (variable.fields.size() > 0)
{ {
...@@ -32,28 +34,38 @@ void BlockLayoutEncoder::encodeInterfaceBlockFields(const std::vector<InterfaceB ...@@ -32,28 +34,38 @@ void BlockLayoutEncoder::encodeInterfaceBlockFields(const std::vector<InterfaceB
for (unsigned int elementIndex = 0; elementIndex < elementCount; elementIndex++) for (unsigned int elementIndex = 0; elementIndex < elementCount; elementIndex++)
{ {
enterAggregateType(); enterAggregateType();
encodeInterfaceBlockFields(variable.fields); encodeVariables(variable.fields);
exitAggregateType(); exitAggregateType();
} }
} }
else else
{ {
encodeInterfaceBlockField(variable); encodeVariable(variable);
} }
} }
} }
BlockMemberInfo BlockLayoutEncoder::encodeInterfaceBlockField(const InterfaceBlockField &field) // Only defined for interface block fields, and shader variable base
template void BlockLayoutEncoder::encodeVariables(const std::vector<ShaderVariable> &);
template void BlockLayoutEncoder::encodeVariables(const std::vector<InterfaceBlockField> &);
BlockMemberInfo BlockLayoutEncoder::encodeVariable(const InterfaceBlockField &field)
{
mInRowMajorField = field.isRowMajorMatrix;
return encodeVariable(static_cast<ShaderVariable>(field));
}
BlockMemberInfo BlockLayoutEncoder::encodeVariable(const sh::ShaderVariable &field)
{ {
int arrayStride; int arrayStride;
int matrixStride; int matrixStride;
ASSERT(field.fields.empty()); ASSERT(field.fields.empty());
getBlockLayoutInfo(field.type, field.arraySize, field.isRowMajorMatrix, &arrayStride, &matrixStride); getBlockLayoutInfo(field.type, field.arraySize, mInRowMajorField, &arrayStride, &matrixStride);
const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, field.isRowMajorMatrix); const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, mInRowMajorField);
advanceOffset(field.type, field.arraySize, field.isRowMajorMatrix, arrayStride, matrixStride); advanceOffset(field.type, field.arraySize, mInRowMajorField, arrayStride, matrixStride);
return memberInfo; return memberInfo;
} }
......
...@@ -49,8 +49,12 @@ class BlockLayoutEncoder ...@@ -49,8 +49,12 @@ class BlockLayoutEncoder
public: public:
BlockLayoutEncoder(); BlockLayoutEncoder();
void encodeInterfaceBlockFields(const std::vector<InterfaceBlockField> &fields); template <typename VarT>
BlockMemberInfo encodeInterfaceBlockField(const InterfaceBlockField &field); void encodeVariables(const std::vector<VarT> &fields);
BlockMemberInfo encodeVariable(const sh::ShaderVariable &field);
BlockMemberInfo encodeVariable(const InterfaceBlockField &field);
void encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix); void encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix);
size_t getBlockSize() const { return mCurrentOffset * BytesPerComponent; } size_t getBlockSize() const { return mCurrentOffset * BytesPerComponent; }
...@@ -65,6 +69,7 @@ class BlockLayoutEncoder ...@@ -65,6 +69,7 @@ class BlockLayoutEncoder
protected: protected:
size_t mCurrentOffset; size_t mCurrentOffset;
bool mInRowMajorField;
void nextRegister(); void nextRegister();
......
...@@ -71,9 +71,9 @@ class TCompiler : public TShHandleBase ...@@ -71,9 +71,9 @@ class TCompiler : public TShHandleBase
const std::vector<sh::Attribute> &getAttributes() const { return attributes; } const std::vector<sh::Attribute> &getAttributes() const { return attributes; }
const std::vector<sh::Attribute> &getOutputVariables() const { return outputVariables; } const std::vector<sh::Attribute> &getOutputVariables() const { return outputVariables; }
const std::vector<sh::Uniform> &getUniforms() const { return uniforms; } const std::vector<sh::Uniform> &getUniforms() const { return uniforms; }
const std::vector<sh::Uniform> &getExpandedUniforms() const { return expandedUniforms; } const std::vector<sh::ShaderVariable> &getExpandedUniforms() const { return expandedUniforms; }
const std::vector<sh::Varying> &getVaryings() const { return varyings; } const std::vector<sh::Varying> &getVaryings() const { return varyings; }
const std::vector<sh::Varying> &getExpandedVaryings() const { return expandedVaryings; } const std::vector<sh::ShaderVariable> &getExpandedVaryings() const { return expandedVaryings; }
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return interfaceBlocks; } const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return interfaceBlocks; }
ShHashFunction64 getHashFunction() const { return hashFunction; } ShHashFunction64 getHashFunction() const { return hashFunction; }
...@@ -138,9 +138,9 @@ class TCompiler : public TShHandleBase ...@@ -138,9 +138,9 @@ class TCompiler : public TShHandleBase
std::vector<sh::Attribute> attributes; std::vector<sh::Attribute> attributes;
std::vector<sh::Attribute> outputVariables; std::vector<sh::Attribute> outputVariables;
std::vector<sh::Uniform> uniforms; std::vector<sh::Uniform> uniforms;
std::vector<sh::Uniform> expandedUniforms; std::vector<sh::ShaderVariable> expandedUniforms;
std::vector<sh::Varying> varyings; std::vector<sh::Varying> varyings;
std::vector<sh::Varying> expandedVaryings; std::vector<sh::ShaderVariable> expandedVaryings;
std::vector<sh::InterfaceBlock> interfaceBlocks; std::vector<sh::InterfaceBlock> interfaceBlocks;
private: private:
......
...@@ -2922,29 +2922,12 @@ const ConstantUnion *OutputHLSL::writeConstantUnion(const TType &type, const Con ...@@ -2922,29 +2922,12 @@ const ConstantUnion *OutputHLSL::writeConstantUnion(const TType &type, const Con
return constUnion; return constUnion;
} }
class DeclareVaryingTraverser : public GetVariableTraverser<Varying>
{
public:
DeclareVaryingTraverser(std::vector<Varying> *output,
InterpolationType interpolation)
: GetVariableTraverser(output),
mInterpolation(interpolation)
{}
private:
void visitVariable(Varying *varying)
{
varying->interpolation = mInterpolation;
}
InterpolationType mInterpolation;
};
void OutputHLSL::declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, void OutputHLSL::declareVaryingToList(const TType &type, TQualifier baseTypeQualifier,
const TString &name, std::vector<Varying> &fieldsOut) const TString &name, std::vector<Varying> &fieldsOut)
{ {
DeclareVaryingTraverser traverser(&fieldsOut, GetInterpolationType(baseTypeQualifier)); GetVariableTraverser traverser;
traverser.traverse(type, name); traverser.traverse(type, name, &fieldsOut);
fieldsOut.back().interpolation = GetInterpolationType(baseTypeQualifier);
} }
} }
...@@ -35,7 +35,9 @@ ShaderVariable::ShaderVariable(const ShaderVariable &other) ...@@ -35,7 +35,9 @@ ShaderVariable::ShaderVariable(const ShaderVariable &other)
name(other.name), name(other.name),
mappedName(other.mappedName), mappedName(other.mappedName),
arraySize(other.arraySize), arraySize(other.arraySize),
staticUse(other.staticUse) staticUse(other.staticUse),
fields(other.fields),
structName(other.structName)
{} {}
ShaderVariable &ShaderVariable::operator=(const ShaderVariable &other) ShaderVariable &ShaderVariable::operator=(const ShaderVariable &other)
...@@ -46,6 +48,8 @@ ShaderVariable &ShaderVariable::operator=(const ShaderVariable &other) ...@@ -46,6 +48,8 @@ ShaderVariable &ShaderVariable::operator=(const ShaderVariable &other)
mappedName = other.mappedName; mappedName = other.mappedName;
arraySize = other.arraySize; arraySize = other.arraySize;
staticUse = other.staticUse; staticUse = other.staticUse;
fields = other.fields;
structName = other.structName;
return *this; return *this;
} }
...@@ -56,14 +60,12 @@ Uniform::~Uniform() ...@@ -56,14 +60,12 @@ Uniform::~Uniform()
{} {}
Uniform::Uniform(const Uniform &other) Uniform::Uniform(const Uniform &other)
: ShaderVariable(other), : ShaderVariable(other)
fields(other.fields)
{} {}
Uniform &Uniform::operator=(const Uniform &other) Uniform &Uniform::operator=(const Uniform &other)
{ {
ShaderVariable::operator=(other); ShaderVariable::operator=(other);
fields = other.fields;
return *this; return *this;
} }
...@@ -95,20 +97,19 @@ InterfaceBlockField::~InterfaceBlockField() ...@@ -95,20 +97,19 @@ InterfaceBlockField::~InterfaceBlockField()
InterfaceBlockField::InterfaceBlockField(const InterfaceBlockField &other) InterfaceBlockField::InterfaceBlockField(const InterfaceBlockField &other)
: ShaderVariable(other), : ShaderVariable(other),
isRowMajorMatrix(other.isRowMajorMatrix), isRowMajorMatrix(other.isRowMajorMatrix)
fields(other.fields)
{} {}
InterfaceBlockField &InterfaceBlockField::operator=(const InterfaceBlockField &other) InterfaceBlockField &InterfaceBlockField::operator=(const InterfaceBlockField &other)
{ {
ShaderVariable::operator=(other); ShaderVariable::operator=(other);
isRowMajorMatrix = other.isRowMajorMatrix; isRowMajorMatrix = other.isRowMajorMatrix;
fields = other.fields;
return *this; return *this;
} }
Varying::Varying() Varying::Varying()
: interpolation(INTERPOLATION_SMOOTH) : interpolation(INTERPOLATION_SMOOTH),
isInvariant(false)
{} {}
Varying::~Varying() Varying::~Varying()
...@@ -117,16 +118,14 @@ Varying::~Varying() ...@@ -117,16 +118,14 @@ Varying::~Varying()
Varying::Varying(const Varying &other) Varying::Varying(const Varying &other)
: ShaderVariable(other), : ShaderVariable(other),
interpolation(other.interpolation), interpolation(other.interpolation),
fields(other.fields), isInvariant(other.isInvariant)
structName(other.structName)
{} {}
Varying &Varying::operator=(const Varying &other) Varying &Varying::operator=(const Varying &other)
{ {
ShaderVariable::operator=(other); ShaderVariable::operator=(other);
interpolation = other.interpolation; interpolation = other.interpolation;
fields = other.fields; isInvariant = other.isInvariant;
structName = other.structName;
return *this; return *this;
} }
...@@ -143,6 +142,7 @@ InterfaceBlock::~InterfaceBlock() ...@@ -143,6 +142,7 @@ InterfaceBlock::~InterfaceBlock()
InterfaceBlock::InterfaceBlock(const InterfaceBlock &other) InterfaceBlock::InterfaceBlock(const InterfaceBlock &other)
: name(other.name), : name(other.name),
mappedName(other.mappedName), mappedName(other.mappedName),
instanceName(other.instanceName),
arraySize(other.arraySize), arraySize(other.arraySize),
layout(other.layout), layout(other.layout),
isRowMajorLayout(other.isRowMajorLayout), isRowMajorLayout(other.isRowMajorLayout),
...@@ -154,6 +154,7 @@ InterfaceBlock &InterfaceBlock::operator=(const InterfaceBlock &other) ...@@ -154,6 +154,7 @@ InterfaceBlock &InterfaceBlock::operator=(const InterfaceBlock &other)
{ {
name = other.name; name = other.name;
mappedName = other.mappedName; mappedName = other.mappedName;
instanceName = other.instanceName;
arraySize = other.arraySize; arraySize = other.arraySize;
layout = other.layout; layout = other.layout;
isRowMajorLayout = other.isRowMajorLayout; isRowMajorLayout = other.isRowMajorLayout;
......
...@@ -30,18 +30,6 @@ static const char *UniformRegisterPrefix(const TType &type) ...@@ -30,18 +30,6 @@ static const char *UniformRegisterPrefix(const TType &type)
} }
} }
static TString InterfaceBlockFieldName(const TInterfaceBlock &interfaceBlock, const TField &field)
{
if (interfaceBlock.hasInstanceName())
{
return interfaceBlock.name() + "." + field.name();
}
else
{
return field.name();
}
}
static TString InterfaceBlockFieldTypeString(const TField &field, TLayoutBlockStorage blockStorage) static TString InterfaceBlockFieldTypeString(const TField &field, TLayoutBlockStorage blockStorage)
{ {
const TType &fieldType = *field.type(); const TType &fieldType = *field.type();
...@@ -94,8 +82,8 @@ unsigned int UniformHLSL::declareUniformAndAssignRegister(const TType &type, con ...@@ -94,8 +82,8 @@ unsigned int UniformHLSL::declareUniformAndAssignRegister(const TType &type, con
{ {
unsigned int registerIndex = (IsSampler(type.getBasicType()) ? mSamplerRegister : mUniformRegister); unsigned int registerIndex = (IsSampler(type.getBasicType()) ? mSamplerRegister : mUniformRegister);
GetVariableTraverser<Uniform> traverser(&mActiveUniforms); GetVariableTraverser traverser;
traverser.traverse(type, name); traverser.traverse(type, name, &mActiveUniforms);
const sh::Uniform &activeUniform = mActiveUniforms.back(); const sh::Uniform &activeUniform = mActiveUniforms.back();
mUniformRegisterMap[activeUniform.name] = registerIndex; mUniformRegisterMap[activeUniform.name] = registerIndex;
...@@ -162,7 +150,6 @@ TString UniformHLSL::interfaceBlocksHeader(const ReferencedSymbols &referencedIn ...@@ -162,7 +150,6 @@ TString UniformHLSL::interfaceBlocksHeader(const ReferencedSymbols &referencedIn
{ {
const TType &nodeType = interfaceBlockIt->second->getType(); const TType &nodeType = interfaceBlockIt->second->getType();
const TInterfaceBlock &interfaceBlock = *nodeType.getInterfaceBlock(); const TInterfaceBlock &interfaceBlock = *nodeType.getInterfaceBlock();
const TFieldList &fieldList = interfaceBlock.fields();
unsigned int arraySize = static_cast<unsigned int>(interfaceBlock.arraySize()); unsigned int arraySize = static_cast<unsigned int>(interfaceBlock.arraySize());
unsigned int activeRegister = mInterfaceBlockRegister; unsigned int activeRegister = mInterfaceBlockRegister;
...@@ -171,15 +158,7 @@ TString UniformHLSL::interfaceBlocksHeader(const ReferencedSymbols &referencedIn ...@@ -171,15 +158,7 @@ TString UniformHLSL::interfaceBlocksHeader(const ReferencedSymbols &referencedIn
activeBlock.name = interfaceBlock.name().c_str(); activeBlock.name = interfaceBlock.name().c_str();
activeBlock.arraySize = arraySize; activeBlock.arraySize = arraySize;
for (unsigned int typeIndex = 0; typeIndex < fieldList.size(); typeIndex++) GetInterfaceBlockFields(interfaceBlock, &activeBlock.fields);
{
const TField &field = *fieldList[typeIndex];
const TString &fullFieldName = InterfaceBlockFieldName(interfaceBlock, field);
bool isRowMajor = (field.type()->getLayoutQualifier().matrixPacking == EmpRowMajor);
GetInterfaceBlockFieldTraverser traverser(&activeBlock.fields, isRowMajor);
traverser.traverse(*field.type(), fullFieldName);
}
mInterfaceBlockRegisterMap[activeBlock.name] = activeRegister; mInterfaceBlockRegisterMap[activeBlock.name] = activeRegister;
mInterfaceBlockRegister += std::max(1u, arraySize); mInterfaceBlockRegister += std::max(1u, arraySize);
......
...@@ -9,20 +9,17 @@ ...@@ -9,20 +9,17 @@
#include "compiler/translator/util.h" #include "compiler/translator/util.h"
#include "common/utilities.h" #include "common/utilities.h"
template <typename VarT> static void ExpandUserDefinedVariable(const sh::ShaderVariable &variable,
static void ExpandUserDefinedVariable(const VarT &variable,
const std::string &name, const std::string &name,
const std::string &mappedName, const std::string &mappedName,
bool markStaticUse, bool markStaticUse,
std::vector<VarT> *expanded); std::vector<sh::ShaderVariable> *expanded);
// Returns info for an attribute, uniform, or varying. static void ExpandVariable(const sh::ShaderVariable &variable,
template <typename VarT>
static void ExpandVariable(const VarT &variable,
const std::string &name, const std::string &name,
const std::string &mappedName, const std::string &mappedName,
bool markStaticUse, bool markStaticUse,
std::vector<VarT> *expanded) std::vector<sh::ShaderVariable> *expanded)
{ {
if (variable.isStruct()) if (variable.isStruct())
{ {
...@@ -42,7 +39,7 @@ static void ExpandVariable(const VarT &variable, ...@@ -42,7 +39,7 @@ static void ExpandVariable(const VarT &variable,
} }
else else
{ {
VarT expandedVar = variable; sh::ShaderVariable expandedVar = variable;
expandedVar.name = name; expandedVar.name = name;
expandedVar.mappedName = mappedName; expandedVar.mappedName = mappedName;
...@@ -63,20 +60,19 @@ static void ExpandVariable(const VarT &variable, ...@@ -63,20 +60,19 @@ static void ExpandVariable(const VarT &variable,
} }
} }
template <class VarT> static void ExpandUserDefinedVariable(const sh::ShaderVariable &variable,
static void ExpandUserDefinedVariable(const VarT &variable,
const std::string &name, const std::string &name,
const std::string &mappedName, const std::string &mappedName,
bool markStaticUse, bool markStaticUse,
std::vector<VarT> *expanded) std::vector<sh::ShaderVariable> *expanded)
{ {
ASSERT(variable.isStruct()); ASSERT(variable.isStruct());
const std::vector<VarT> &fields = variable.fields; const std::vector<sh::ShaderVariable> &fields = variable.fields;
for (size_t fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++) for (size_t fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++)
{ {
const VarT &field = fields[fieldIndex]; const sh::ShaderVariable &field = fields[fieldIndex];
ExpandVariable(field, ExpandVariable(field,
name + "." + field.name, name + "." + field.name,
mappedName + "." + field.mappedName, mappedName + "." + field.mappedName,
...@@ -216,17 +212,17 @@ void CollectVariables::visitSymbol(TIntermSymbol *symbol) ...@@ -216,17 +212,17 @@ void CollectVariables::visitSymbol(TIntermSymbol *symbol)
} }
} }
template <typename VarT> class NameHashingTraverser : public sh::GetVariableTraverser
class NameHashingTraverser : public sh::GetVariableTraverser<VarT>
{ {
public: public:
NameHashingTraverser(std::vector<VarT> *output, ShHashFunction64 hashFunction) NameHashingTraverser(ShHashFunction64 hashFunction)
: sh::GetVariableTraverser<VarT>(output), : mHashFunction(hashFunction)
mHashFunction(hashFunction)
{} {}
private: private:
void visitVariable(VarT *variable) DISALLOW_COPY_AND_ASSIGN(NameHashingTraverser);
virtual void visitVariable(sh::ShaderVariable *variable)
{ {
TString stringName = TString(variable->name.c_str()); TString stringName = TString(variable->name.c_str());
variable->mappedName = TIntermTraverser::hash(stringName, mHashFunction).c_str(); variable->mappedName = TIntermTraverser::hash(stringName, mHashFunction).c_str();
...@@ -262,26 +258,16 @@ void CollectVariables::visitVariable(const TIntermSymbol *variable, ...@@ -262,26 +258,16 @@ void CollectVariables::visitVariable(const TIntermSymbol *variable,
{ {
sh::InterfaceBlock interfaceBlock; sh::InterfaceBlock interfaceBlock;
const TInterfaceBlock *blockType = variable->getType().getInterfaceBlock(); const TInterfaceBlock *blockType = variable->getType().getInterfaceBlock();
ASSERT(blockType);
bool isRowMajor = (blockType->matrixPacking() == EmpRowMajor);
interfaceBlock.name = blockType->name().c_str(); interfaceBlock.name = blockType->name().c_str();
interfaceBlock.mappedName = TIntermTraverser::hash(variable->getSymbol(), mHashFunction).c_str(); interfaceBlock.mappedName = TIntermTraverser::hash(variable->getSymbol(), mHashFunction).c_str();
interfaceBlock.instanceName = (blockType->hasInstanceName() ? blockType->instanceName().c_str() : "");
interfaceBlock.arraySize = variable->getArraySize(); interfaceBlock.arraySize = variable->getArraySize();
interfaceBlock.isRowMajorLayout = isRowMajor; interfaceBlock.isRowMajorLayout = (blockType->matrixPacking() == EmpRowMajor);
interfaceBlock.layout = sh::GetBlockLayoutType(blockType->blockStorage()); interfaceBlock.layout = sh::GetBlockLayoutType(blockType->blockStorage());
ASSERT(blockType); sh::GetInterfaceBlockFields(*blockType, &interfaceBlock.fields);
const TFieldList &blockFields = blockType->fields();
for (size_t fieldIndex = 0; fieldIndex < blockFields.size(); fieldIndex++)
{
const TField *field = blockFields[fieldIndex];
ASSERT(field);
sh::GetInterfaceBlockFieldTraverser traverser(&interfaceBlock.fields, isRowMajor);
traverser.traverse(*field->type(), field->name());
}
infoList->push_back(interfaceBlock); infoList->push_back(interfaceBlock);
} }
...@@ -290,8 +276,8 @@ template <typename VarT> ...@@ -290,8 +276,8 @@ template <typename VarT>
void CollectVariables::visitVariable(const TIntermSymbol *variable, void CollectVariables::visitVariable(const TIntermSymbol *variable,
std::vector<VarT> *infoList) const std::vector<VarT> *infoList) const
{ {
NameHashingTraverser<VarT> traverser(infoList, mHashFunction); NameHashingTraverser traverser(mHashFunction);
traverser.traverse(variable->getType(), variable->getSymbol()); traverser.traverse(variable->getType(), variable->getSymbol(), infoList);
} }
template <typename VarT> template <typename VarT>
...@@ -361,14 +347,15 @@ bool CollectVariables::visitAggregate(Visit, TIntermAggregate *node) ...@@ -361,14 +347,15 @@ bool CollectVariables::visitAggregate(Visit, TIntermAggregate *node)
} }
template <typename VarT> template <typename VarT>
void ExpandVariables(const std::vector<VarT> &compact, std::vector<VarT> *expanded) void ExpandVariables(const std::vector<VarT> &compact,
std::vector<sh::ShaderVariable> *expanded)
{ {
for (size_t variableIndex = 0; variableIndex < compact.size(); variableIndex++) for (size_t variableIndex = 0; variableIndex < compact.size(); variableIndex++)
{ {
const VarT &variable = compact[variableIndex]; const sh::ShaderVariable &variable = compact[variableIndex];
ExpandVariable(variable, variable.name, variable.mappedName, variable.staticUse, expanded); ExpandVariable(variable, variable.name, variable.mappedName, variable.staticUse, expanded);
} }
} }
template void ExpandVariables(const std::vector<sh::Uniform> &, std::vector<sh::Uniform> *); template void ExpandVariables(const std::vector<sh::Uniform> &, std::vector<sh::ShaderVariable> *);
template void ExpandVariables(const std::vector<sh::Varying> &, std::vector<sh::Varying> *); template void ExpandVariables(const std::vector<sh::Varying> &, std::vector<sh::ShaderVariable> *);
...@@ -48,8 +48,8 @@ class CollectVariables : public TIntermTraverser ...@@ -48,8 +48,8 @@ class CollectVariables : public TIntermTraverser
}; };
// Expand struct variables to flattened lists of split variables // Expand struct variables to flattened lists of split variables
// Implemented for sh::Varying and sh::Uniform.
template <typename VarT> template <typename VarT>
void ExpandVariables(const std::vector<VarT> &compact, std::vector<VarT> *expanded); void ExpandVariables(const std::vector<VarT> &compact,
std::vector<sh::ShaderVariable> *expanded);
#endif // COMPILER_VARIABLE_INFO_H_ #endif // COMPILER_VARIABLE_INFO_H_
...@@ -282,7 +282,7 @@ InterpolationType GetInterpolationType(TQualifier qualifier) ...@@ -282,7 +282,7 @@ InterpolationType GetInterpolationType(TQualifier qualifier)
} }
template <typename VarT> template <typename VarT>
void GetVariableTraverser<VarT>::traverse(const TType &type, const TString &name) void GetVariableTraverser::traverse(const TType &type, const TString &name, std::vector<VarT> *output)
{ {
const TStructure *structure = type.getStruct(); const TStructure *structure = type.getStruct();
...@@ -297,60 +297,66 @@ void GetVariableTraverser<VarT>::traverse(const TType &type, const TString &name ...@@ -297,60 +297,66 @@ void GetVariableTraverser<VarT>::traverse(const TType &type, const TString &name
} }
else else
{ {
// Note: this enum value is not exposed outside ANGLE
variable.type = GL_STRUCT_ANGLEX; variable.type = GL_STRUCT_ANGLEX;
variable.structName = structure->name().c_str();
mOutputStack.push(&variable.fields);
const TFieldList &fields = structure->fields(); const TFieldList &fields = structure->fields();
for (size_t fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++) for (size_t fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++)
{ {
TField *field = fields[fieldIndex]; TField *field = fields[fieldIndex];
traverse(*field->type(), field->name()); traverse(*field->type(), field->name(), &variable.fields);
} }
mOutputStack.pop();
} }
visitVariable(&variable); visitVariable(&variable);
ASSERT(!mOutputStack.empty());
mOutputStack.top()->push_back(variable);
}
template <typename VarT>
GetVariableTraverser<VarT>::GetVariableTraverser(std::vector<VarT> *output)
{
ASSERT(output); ASSERT(output);
mOutputStack.push(output); output->push_back(variable);
} }
template class GetVariableTraverser<Uniform>; template void GetVariableTraverser::traverse(const TType &, const TString &, std::vector<Uniform> *);
template class GetVariableTraverser<Varying>; template void GetVariableTraverser::traverse(const TType &, const TString &, std::vector<Varying> *);
template class GetVariableTraverser<InterfaceBlockField>; template void GetVariableTraverser::traverse(const TType &, const TString &, std::vector<InterfaceBlockField> *);
GetInterfaceBlockFieldTraverser::GetInterfaceBlockFieldTraverser(std::vector<InterfaceBlockField> *output, bool isRowMajorMatrix) BlockLayoutType GetBlockLayoutType(TLayoutBlockStorage blockStorage)
: GetVariableTraverser(output),
mIsRowMajorMatrix(isRowMajorMatrix)
{ {
switch (blockStorage)
{
case EbsPacked: return BLOCKLAYOUT_PACKED;
case EbsShared: return BLOCKLAYOUT_SHARED;
case EbsStd140: return BLOCKLAYOUT_STANDARD;
default: UNREACHABLE(); return BLOCKLAYOUT_SHARED;
}
} }
void GetInterfaceBlockFieldTraverser::visitVariable(InterfaceBlockField *newField) static TString InterfaceBlockFieldName(const TInterfaceBlock &interfaceBlock, const TField &field)
{ {
if (gl::IsMatrixType(newField->type)) if (interfaceBlock.hasInstanceName())
{
return interfaceBlock.name() + "." + field.name();
}
else
{ {
newField->isRowMajorMatrix = mIsRowMajorMatrix; return field.name();
} }
} }
BlockLayoutType GetBlockLayoutType(TLayoutBlockStorage blockStorage) void GetInterfaceBlockFields(const TInterfaceBlock &interfaceBlock, std::vector<InterfaceBlockField> *fieldsOut)
{ {
switch (blockStorage) const TFieldList &fieldList = interfaceBlock.fields();
for (size_t fieldIndex = 0; fieldIndex < fieldList.size(); ++fieldIndex)
{ {
case EbsPacked: return BLOCKLAYOUT_PACKED; const TField &field = *fieldList[fieldIndex];
case EbsShared: return BLOCKLAYOUT_SHARED; const TString &fullFieldName = InterfaceBlockFieldName(interfaceBlock, field);
case EbsStd140: return BLOCKLAYOUT_STANDARD; const TType &fieldType = *field.type();
default: UNREACHABLE(); return BLOCKLAYOUT_SHARED;
GetVariableTraverser traverser;
traverser.traverse(fieldType, fullFieldName, fieldsOut);
fieldsOut->back().isRowMajorMatrix = (fieldType.getLayoutQualifier().matrixPacking == EmpRowMajor);
} }
} }
......
...@@ -36,31 +36,23 @@ InterpolationType GetInterpolationType(TQualifier qualifier); ...@@ -36,31 +36,23 @@ InterpolationType GetInterpolationType(TQualifier qualifier);
BlockLayoutType GetBlockLayoutType(TLayoutBlockStorage blockStorage); BlockLayoutType GetBlockLayoutType(TLayoutBlockStorage blockStorage);
TString ArrayString(const TType &type); TString ArrayString(const TType &type);
template <typename VarT>
class GetVariableTraverser class GetVariableTraverser
{ {
public: public:
GetVariableTraverser(std::vector<VarT> *output); GetVariableTraverser() {}
void traverse(const TType &type, const TString &name);
template <typename VarT>
void traverse(const TType &type, const TString &name, std::vector<VarT> *output);
protected: protected:
// May be overloaded // May be overloaded
virtual void visitVariable(VarT *newVar) {} virtual void visitVariable(ShaderVariable *newVar) {}
private: private:
std::stack<std::vector<VarT> *> mOutputStack; DISALLOW_COPY_AND_ASSIGN(GetVariableTraverser);
}; };
struct GetInterfaceBlockFieldTraverser : public GetVariableTraverser<InterfaceBlockField> void GetInterfaceBlockFields(const TInterfaceBlock &interfaceBlock, std::vector<InterfaceBlockField> *fieldsOut);
{
public:
GetInterfaceBlockFieldTraverser(std::vector<InterfaceBlockField> *output, bool isRowMajorMatrix);
private:
virtual void visitVariable(InterfaceBlockField *newField);
bool mIsRowMajorMatrix;
};
} }
......
...@@ -1077,7 +1077,7 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, FragmentShader *fragmentShade ...@@ -1077,7 +1077,7 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, FragmentShader *fragmentShade
PackedVarying *output = &vertexVaryings[vertVaryingIndex]; PackedVarying *output = &vertexVaryings[vertVaryingIndex];
if (output->name == input->name) if (output->name == input->name)
{ {
if (!linkValidateVariables(infoLog, output->name, *input, *output)) if (!linkValidateVaryings(infoLog, output->name, *input, *output))
{ {
return false; return false;
} }
...@@ -1818,32 +1818,29 @@ bool ProgramBinary::linkValidateVariablesBase(InfoLog &infoLog, const std::strin ...@@ -1818,32 +1818,29 @@ bool ProgramBinary::linkValidateVariablesBase(InfoLog &infoLog, const std::strin
return false; return false;
} }
return true; if (vertexVariable.fields.size() != fragmentVariable.fields.size())
}
template <class ShaderVarType>
bool ProgramBinary::linkValidateFields(InfoLog &infoLog, const std::string &varName, const ShaderVarType &vertexVar, const ShaderVarType &fragmentVar)
{
if (vertexVar.fields.size() != fragmentVar.fields.size())
{ {
infoLog.append("Structure lengths for %s differ between vertex and fragment shaders", varName.c_str()); infoLog.append("Structure lengths for %s differ between vertex and fragment shaders", variableName.c_str());
return false; return false;
} }
const unsigned int numMembers = vertexVar.fields.size(); const unsigned int numMembers = vertexVariable.fields.size();
for (unsigned int memberIndex = 0; memberIndex < numMembers; memberIndex++) for (unsigned int memberIndex = 0; memberIndex < numMembers; memberIndex++)
{ {
const ShaderVarType &vertexMember = vertexVar.fields[memberIndex]; const sh::ShaderVariable &vertexMember = vertexVariable.fields[memberIndex];
const ShaderVarType &fragmentMember = fragmentVar.fields[memberIndex]; const sh::ShaderVariable &fragmentMember = fragmentVariable.fields[memberIndex];
if (vertexMember.name != fragmentMember.name) if (vertexMember.name != fragmentMember.name)
{ {
infoLog.append("Name mismatch for field '%d' of %s: (in vertex: '%s', in fragment: '%s')", infoLog.append("Name mismatch for field '%d' of %s: (in vertex: '%s', in fragment: '%s')",
memberIndex, varName.c_str(), vertexMember.name.c_str(), fragmentMember.name.c_str()); memberIndex, variableName.c_str(),
vertexMember.name.c_str(), fragmentMember.name.c_str());
return false; return false;
} }
const std::string memberName = varName.substr(0, varName.length()-1) + "." + vertexVar.name + "'"; const std::string memberName = variableName.substr(0, variableName.length() - 1) + "." +
if (!linkValidateVariables(infoLog, memberName, vertexMember, fragmentMember)) vertexMember.name + "'";
if (!linkValidateVariablesBase(infoLog, vertexMember.name, vertexMember, fragmentMember, validatePrecision))
{ {
return false; return false;
} }
...@@ -1852,22 +1849,17 @@ bool ProgramBinary::linkValidateFields(InfoLog &infoLog, const std::string &varN ...@@ -1852,22 +1849,17 @@ bool ProgramBinary::linkValidateFields(InfoLog &infoLog, const std::string &varN
return true; return true;
} }
bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform) bool ProgramBinary::linkValidateUniforms(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform)
{ {
if (!linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform, true)) if (!linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform, true))
{ {
return false; return false;
} }
if (!linkValidateFields<sh::Uniform>(infoLog, uniformName, vertexUniform, fragmentUniform))
{
return false;
}
return true; return true;
} }
bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &varyingName, const sh::Varying &vertexVarying, const sh::Varying &fragmentVarying) bool ProgramBinary::linkValidateVaryings(InfoLog &infoLog, const std::string &varyingName, const sh::Varying &vertexVarying, const sh::Varying &fragmentVarying)
{ {
if (!linkValidateVariablesBase(infoLog, varyingName, vertexVarying, fragmentVarying, false)) if (!linkValidateVariablesBase(infoLog, varyingName, vertexVarying, fragmentVarying, false))
{ {
...@@ -1880,15 +1872,10 @@ bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &v ...@@ -1880,15 +1872,10 @@ bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &v
return false; return false;
} }
if (!linkValidateFields<sh::Varying>(infoLog, varyingName, vertexVarying, fragmentVarying))
{
return false;
}
return true; return true;
} }
bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform) bool ProgramBinary::linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform)
{ {
if (!linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform, true)) if (!linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform, true))
{ {
...@@ -1901,11 +1888,6 @@ bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &u ...@@ -1901,11 +1888,6 @@ bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &u
return false; return false;
} }
if (!linkValidateFields<sh::InterfaceBlockField>(infoLog, uniformName, vertexUniform, fragmentUniform))
{
return false;
}
return true; return true;
} }
...@@ -1932,7 +1914,7 @@ bool ProgramBinary::linkUniforms(InfoLog &infoLog, const VertexShader &vertexSha ...@@ -1932,7 +1914,7 @@ bool ProgramBinary::linkUniforms(InfoLog &infoLog, const VertexShader &vertexSha
{ {
const sh::Uniform &vertexUniform = *entry->second; const sh::Uniform &vertexUniform = *entry->second;
const std::string &uniformName = "uniform '" + vertexUniform.name + "'"; const std::string &uniformName = "uniform '" + vertexUniform.name + "'";
if (!linkValidateVariables(infoLog, uniformName, vertexUniform, fragmentUniform)) if (!linkValidateUniforms(infoLog, uniformName, vertexUniform, fragmentUniform))
{ {
return false; return false;
} }
...@@ -1970,7 +1952,7 @@ void ProgramBinary::defineUniformBase(GLenum shader, const sh::Uniform &uniform, ...@@ -1970,7 +1952,7 @@ void ProgramBinary::defineUniformBase(GLenum shader, const sh::Uniform &uniform,
defineUniform(shader, uniform, uniform.name, &encoder); defineUniform(shader, uniform, uniform.name, &encoder);
} }
void ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &uniform, void ProgramBinary::defineUniform(GLenum shader, const sh::ShaderVariable &uniform,
const std::string &fullName, sh::HLSLBlockEncoder *encoder) const std::string &fullName, sh::HLSLBlockEncoder *encoder)
{ {
if (uniform.isStruct()) if (uniform.isStruct())
...@@ -1983,7 +1965,7 @@ void ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &uniform, ...@@ -1983,7 +1965,7 @@ void ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &uniform,
for (size_t fieldIndex = 0; fieldIndex < uniform.fields.size(); fieldIndex++) for (size_t fieldIndex = 0; fieldIndex < uniform.fields.size(); fieldIndex++)
{ {
const sh::Uniform &field = uniform.fields[fieldIndex]; const sh::ShaderVariable &field = uniform.fields[fieldIndex];
const std::string &fieldFullName = (fullName + elementString + "." + field.name); const std::string &fieldFullName = (fullName + elementString + "." + field.name);
defineUniform(shader, field, fieldFullName, encoder); defineUniform(shader, field, fieldFullName, encoder);
...@@ -2169,8 +2151,8 @@ bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::Inter ...@@ -2169,8 +2151,8 @@ bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::Inter
return false; return false;
} }
std::string uniformName = "interface block '" + vertexInterfaceBlock.name + "' member '" + vertexMember.name + "'"; std::string memberName = "interface block '" + vertexInterfaceBlock.name + "' member '" + vertexMember.name + "'";
if (!linkValidateVariables(infoLog, uniformName, vertexMember, fragmentMember)) if (!linkValidateInterfaceBlockFields(infoLog, memberName, vertexMember, fragmentMember))
{ {
return false; return false;
} }
...@@ -2286,12 +2268,13 @@ bool ProgramBinary::gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, cons ...@@ -2286,12 +2268,13 @@ bool ProgramBinary::gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, cons
return true; return true;
} }
void ProgramBinary::defineUniformBlockMembers(const std::vector<sh::InterfaceBlockField> &fields, const std::string &prefix, int blockIndex, template <typename VarT>
void ProgramBinary::defineUniformBlockMembers(const std::vector<VarT> &fields, const std::string &prefix, int blockIndex,
sh::BlockLayoutEncoder *encoder, std::vector<unsigned int> *blockUniformIndexes) sh::BlockLayoutEncoder *encoder, std::vector<unsigned int> *blockUniformIndexes)
{ {
for (unsigned int uniformIndex = 0; uniformIndex < fields.size(); uniformIndex++) for (unsigned int uniformIndex = 0; uniformIndex < fields.size(); uniformIndex++)
{ {
const sh::InterfaceBlockField &field = fields[uniformIndex]; const VarT &field = fields[uniformIndex];
const std::string &fieldName = (prefix.empty() ? field.name : prefix + "." + field.name); const std::string &fieldName = (prefix.empty() ? field.name : prefix + "." + field.name);
if (field.isStruct()) if (field.isStruct())
...@@ -2308,7 +2291,7 @@ void ProgramBinary::defineUniformBlockMembers(const std::vector<sh::InterfaceBlo ...@@ -2308,7 +2291,7 @@ void ProgramBinary::defineUniformBlockMembers(const std::vector<sh::InterfaceBlo
} }
else else
{ {
sh::BlockMemberInfo memberInfo = encoder->encodeInterfaceBlockField(field); sh::BlockMemberInfo memberInfo = encoder->encodeVariable(field);
LinkedUniform *newUniform = new LinkedUniform(field.type, field.precision, fieldName, field.arraySize, LinkedUniform *newUniform = new LinkedUniform(field.type, field.precision, fieldName, field.arraySize,
blockIndex, memberInfo); blockIndex, memberInfo);
......
...@@ -197,16 +197,18 @@ class ProgramBinary : public RefCountObject ...@@ -197,16 +197,18 @@ class ProgramBinary : public RefCountObject
bool linkVaryings(InfoLog &infoLog, FragmentShader *fragmentShader, VertexShader *vertexShader); bool linkVaryings(InfoLog &infoLog, FragmentShader *fragmentShader, VertexShader *vertexShader);
bool linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader); bool linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader);
template <class ShaderVarType> bool linkValidateVariablesBase(InfoLog &infoLog,
bool linkValidateFields(InfoLog &infoLog, const std::string &varName, const ShaderVarType &vertexVar, const ShaderVarType &fragmentVar); const std::string &variableName,
bool linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const sh::ShaderVariable &vertexVariable, const sh::ShaderVariable &fragmentVariable, bool validatePrecision); const sh::ShaderVariable &vertexVariable,
const sh::ShaderVariable &fragmentVariable,
bool linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform); bool validatePrecision);
bool linkValidateVariables(InfoLog &infoLog, const std::string &varyingName, const sh::Varying &vertexVarying, const sh::Varying &fragmentVarying);
bool linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform); bool linkValidateUniforms(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform);
bool linkValidateVaryings(InfoLog &infoLog, const std::string &varyingName, const sh::Varying &vertexVarying, const sh::Varying &fragmentVarying);
bool linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform);
bool linkUniforms(InfoLog &infoLog, const VertexShader &vertexShader, const FragmentShader &fragmentShader); bool linkUniforms(InfoLog &infoLog, const VertexShader &vertexShader, const FragmentShader &fragmentShader);
void defineUniformBase(GLenum shader, const sh::Uniform &uniform, unsigned int uniformRegister); void defineUniformBase(GLenum shader, const sh::Uniform &uniform, unsigned int uniformRegister);
void defineUniform(GLenum shader, const sh::Uniform &uniform, const std::string &fullName, sh::HLSLBlockEncoder *encoder); void defineUniform(GLenum shader, const sh::ShaderVariable &uniform, const std::string &fullName, sh::HLSLBlockEncoder *encoder);
bool indexSamplerUniform(const LinkedUniform &uniform, InfoLog &infoLog); bool indexSamplerUniform(const LinkedUniform &uniform, InfoLog &infoLog);
bool indexUniforms(InfoLog &infoLog); bool indexUniforms(InfoLog &infoLog);
static bool assignSamplers(unsigned int startSamplerIndex, GLenum samplerType, unsigned int samplerCount, static bool assignSamplers(unsigned int startSamplerIndex, GLenum samplerType, unsigned int samplerCount,
...@@ -217,7 +219,8 @@ class ProgramBinary : public RefCountObject ...@@ -217,7 +219,8 @@ class ProgramBinary : public RefCountObject
const std::vector<std::string> &transformFeedbackVaryingNames, const std::vector<std::string> &transformFeedbackVaryingNames,
GLenum transformFeedbackBufferMode, GLenum transformFeedbackBufferMode,
std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings) const; std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings) const;
void defineUniformBlockMembers(const std::vector<sh::InterfaceBlockField> &fields, const std::string &prefix, int blockIndex, template <typename VarT>
void defineUniformBlockMembers(const std::vector<VarT> &fields, const std::string &prefix, int blockIndex,
sh::BlockLayoutEncoder *encoder, std::vector<unsigned int> *blockUniformIndexes); sh::BlockLayoutEncoder *encoder, std::vector<unsigned int> *blockUniformIndexes);
bool defineUniformBlock(InfoLog &infoLog, const Shader &shader, const sh::InterfaceBlock &interfaceBlock); bool defineUniformBlock(InfoLog &infoLog, const Shader &shader, const sh::InterfaceBlock &interfaceBlock);
bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex); bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment