Commit f2575989 by Jamie Madill

Use the sh namespace for shader variables.

Since these types originate from the translator, use an appropriate namespace. Also rename some of the gl helper functions to be more specific to their functionality. BUG=angle:466 Change-Id: Idc29987b2053b3c40748dd46b581f3dbd8a6fd61 Reviewed-on: https://chromium-review.googlesource.com/204680Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org>
parent bb94f341
......@@ -12,7 +12,7 @@
#include "common/mathutil.h"
#include "common/utilities.h"
namespace gl
namespace sh
{
BlockLayoutEncoder::BlockLayoutEncoder(std::vector<BlockMemberInfo> *blockInfoOut)
......@@ -103,7 +103,7 @@ void Std140BlockEncoder::exitAggregateType()
void Std140BlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut)
{
// We assume we are only dealing with 4 byte components (no doubles or half-words currently)
ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
ASSERT(gl::VariableComponentSize(gl::VariableComponentType(type)) == BytesPerComponent);
size_t baseAlignment = 0;
int matrixStride = 0;
......@@ -127,7 +127,7 @@ void Std140BlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize,
}
else
{
const int numComponents = gl::UniformComponentCount(type);
const int numComponents = gl::VariableComponentCount(type);
baseAlignment = (numComponents == 3 ? 4u : static_cast<size_t>(numComponents));
}
......@@ -151,7 +151,7 @@ void Std140BlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool
}
else
{
mCurrentOffset += gl::UniformComponentCount(type);
mCurrentOffset += gl::VariableComponentCount(type);
}
}
......@@ -173,7 +173,7 @@ void HLSLBlockEncoder::exitAggregateType()
void HLSLBlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut)
{
// We assume we are only dealing with 4 byte components (no doubles or half-words currently)
ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
ASSERT(gl::VariableComponentSize(gl::VariableComponentType(type)) == BytesPerComponent);
int matrixStride = 0;
int arrayStride = 0;
......@@ -204,7 +204,7 @@ void HLSLBlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, b
}
else if (isPacked())
{
int numComponents = gl::UniformComponentCount(type);
int numComponents = gl::VariableComponentCount(type);
if ((numComponents + (mCurrentOffset % ComponentsPerRegister)) > ComponentsPerRegister)
{
nextRegister();
......@@ -232,7 +232,7 @@ void HLSLBlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool i
}
else if (isPacked())
{
mCurrentOffset += gl::UniformComponentCount(type);
mCurrentOffset += gl::VariableComponentCount(type);
}
else
{
......@@ -245,8 +245,8 @@ void HLSLBlockEncoder::skipRegisters(unsigned int numRegisters)
mCurrentOffset += (numRegisters * ComponentsPerRegister);
}
void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, gl::Uniform *variable, HLSLBlockEncoder *encoder,
const std::vector<gl::BlockMemberInfo> &blockInfo, ShShaderOutput outputType)
void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable, HLSLBlockEncoder *encoder,
const std::vector<BlockMemberInfo> &blockInfo, ShShaderOutput outputType)
{
// because this method computes offsets (element indexes) instead of any total sizes,
// we can ignore the array size of the variable
......@@ -282,7 +282,7 @@ void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, gl::Uniform *va
}
}
void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, gl::Uniform *variable, ShShaderOutput outputType)
void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable, ShShaderOutput outputType)
{
std::vector<BlockMemberInfo> blockInfo;
HLSLBlockEncoder encoder(&blockInfo,
......
......@@ -16,9 +16,8 @@
#include <GLSLANG/ShaderLang.h>
#include <cstddef>
namespace gl
namespace sh
{
struct ShaderVariable;
struct InterfaceBlockField;
struct BlockMemberInfo;
......
......@@ -13,13 +13,14 @@
#include <string>
#include <vector>
#include <algorithm>
#include "GLSLANG/ShaderLang.h"
#include <GLES3/gl3.h>
#include <GLES2/gl2.h>
namespace gl
namespace sh
{
// GLenum alias
typedef unsigned int GLenum;
// Varying interpolation qualifier, see section 4.3.9 of the ESSL 3.00.4 spec
enum InterpolationType
{
......@@ -39,107 +40,115 @@ enum BlockLayoutType
// Base class for all variables defined in shaders, including Varyings, Uniforms, etc
struct ShaderVariable
{
GLenum type;
GLenum precision;
std::string name;
unsigned int arraySize;
ShaderVariable(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn)
: type(typeIn),
precision(precisionIn),
name(nameIn),
arraySize(arraySizeIn)
: type(typeIn),
precision(precisionIn),
name(nameIn),
arraySize(arraySizeIn)
{}
bool isArray() const { return arraySize > 0; }
unsigned int elementCount() const { return std::max(1u, arraySize); }
GLenum type;
GLenum precision;
std::string name;
unsigned int arraySize;
};
// Uniform registers (and element indices) are assigned when outputting shader code
struct Uniform : public ShaderVariable
{
std::vector<Uniform> fields;
// HLSL-specific members
unsigned int registerIndex;
unsigned int elementIndex; // Offset within a register, for struct members
Uniform(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn,
unsigned int registerIndexIn, unsigned int elementIndexIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
registerIndex(registerIndexIn),
elementIndex(elementIndexIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
registerIndex(registerIndexIn),
elementIndex(elementIndexIn)
{}
bool isStruct() const { return !fields.empty(); }
std::vector<Uniform> fields;
// HLSL-specific members
unsigned int registerIndex;
unsigned int elementIndex; // Offset within a register, for struct members
};
struct Attribute : public ShaderVariable
{
int location;
Attribute()
: ShaderVariable(GL_NONE, GL_NONE, "", 0),
location(-1)
: ShaderVariable((GLenum)0, (GLenum)0, "", 0),
location(-1)
{}
Attribute(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, int locationIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
location(locationIn)
{}
int location;
};
struct InterfaceBlockField : public ShaderVariable
{
bool isRowMajorMatrix;
std::vector<InterfaceBlockField> fields;
InterfaceBlockField(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, bool isRowMajorMatrix)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
isRowMajorMatrix(isRowMajorMatrix)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
isRowMajorMatrix(isRowMajorMatrix)
{}
bool isStruct() const { return !fields.empty(); }
bool isRowMajorMatrix;
std::vector<InterfaceBlockField> fields;
};
struct Varying : public ShaderVariable
{
InterpolationType interpolation;
std::vector<Varying> fields;
std::string structName;
Varying(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, InterpolationType interpolationIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
interpolation(interpolationIn)
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
interpolation(interpolationIn)
{}
bool isStruct() const { return !fields.empty(); }
InterpolationType interpolation;
std::vector<Varying> fields;
std::string structName;
};
struct BlockMemberInfo
{
int offset;
int arrayStride;
int matrixStride;
bool isRowMajorMatrix;
BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix)
: offset(offset),
arrayStride(arrayStride),
matrixStride(matrixStride),
isRowMajorMatrix(isRowMajorMatrix)
{}
static BlockMemberInfo getDefaultBlockInfo()
{
return BlockMemberInfo(-1, -1, -1, false);
}
BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix)
: offset(offset),
arrayStride(arrayStride),
matrixStride(matrixStride),
isRowMajorMatrix(isRowMajorMatrix)
{}
int offset;
int arrayStride;
int matrixStride;
bool isRowMajorMatrix;
};
typedef std::vector<BlockMemberInfo> BlockMemberInfoArray;
struct InterfaceBlock
{
InterfaceBlock(const char *name, unsigned int arraySize, unsigned int registerIndex)
: name(name),
arraySize(arraySize),
layout(BLOCKLAYOUT_SHARED),
registerIndex(registerIndex),
isRowMajorLayout(false)
{}
std::string name;
unsigned int arraySize;
size_t dataSize;
......@@ -150,14 +159,6 @@ struct InterfaceBlock
// HLSL-specific members
unsigned int registerIndex;
InterfaceBlock(const char *name, unsigned int arraySize, unsigned int registerIndex)
: name(name),
arraySize(arraySize),
layout(BLOCKLAYOUT_SHARED),
registerIndex(registerIndex),
isRowMajorLayout(false)
{}
};
}
......
......@@ -15,7 +15,7 @@
namespace gl
{
int UniformComponentCount(GLenum type)
int VariableComponentCount(GLenum type)
{
switch (type)
{
......@@ -75,7 +75,7 @@ int UniformComponentCount(GLenum type)
return 0;
}
GLenum UniformComponentType(GLenum type)
GLenum VariableComponentType(GLenum type)
{
switch(type)
{
......@@ -130,7 +130,7 @@ GLenum UniformComponentType(GLenum type)
return GL_NONE;
}
size_t UniformComponentSize(GLenum type)
size_t VariableComponentSize(GLenum type)
{
switch(type)
{
......@@ -144,18 +144,18 @@ size_t UniformComponentSize(GLenum type)
return 0;
}
size_t UniformInternalSize(GLenum type)
size_t VariableInternalSize(GLenum type)
{
// Expanded to 4-element vectors
return UniformComponentSize(UniformComponentType(type)) * VariableRowCount(type) * 4;
return VariableComponentSize(VariableComponentType(type)) * VariableRowCount(type) * 4;
}
size_t UniformExternalSize(GLenum type)
size_t VariableExternalSize(GLenum type)
{
return UniformComponentSize(UniformComponentType(type)) * UniformComponentCount(type);
return VariableComponentSize(VariableComponentType(type)) * VariableComponentCount(type);
}
GLenum UniformBoolVectorType(GLenum type)
GLenum VariableBoolVectorType(GLenum type)
{
switch (type)
{
......@@ -362,7 +362,7 @@ int MatrixComponentCount(GLenum type, bool isRowMajorMatrix)
return isRowMajorMatrix ? VariableColumnCount(type) : VariableRowCount(type);
}
int AttributeRegisterCount(GLenum type)
int VariableRegisterCount(GLenum type)
{
return IsMatrixType(type) ? VariableColumnCount(type) : 1;
}
......
......@@ -20,18 +20,18 @@
namespace gl
{
int UniformComponentCount(GLenum type);
GLenum UniformComponentType(GLenum type);
size_t UniformComponentSize(GLenum type);
size_t UniformInternalSize(GLenum type);
size_t UniformExternalSize(GLenum type);
GLenum UniformBoolVectorType(GLenum type);
int VariableComponentCount(GLenum type);
GLenum VariableComponentType(GLenum type);
size_t VariableComponentSize(GLenum type);
size_t VariableInternalSize(GLenum type);
size_t VariableExternalSize(GLenum type);
GLenum VariableBoolVectorType(GLenum type);
int VariableRowCount(GLenum type);
int VariableColumnCount(GLenum type);
bool IsSampler(GLenum type);
bool IsMatrixType(GLenum type);
GLenum TransposeMatrixType(GLenum type);
int AttributeRegisterCount(GLenum type);
int VariableRegisterCount(GLenum type);
int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix);
int MatrixComponentCount(GLenum type, bool isRowMajorMatrix);
......
......@@ -212,27 +212,27 @@ TInfoSinkBase &OutputHLSL::getBodyStream()
return mBody;
}
const std::vector<gl::Uniform> &OutputHLSL::getUniforms()
const std::vector<sh::Uniform> &OutputHLSL::getUniforms()
{
return mUniformHLSL->getUniforms();
}
const std::vector<gl::InterfaceBlock> &OutputHLSL::getInterfaceBlocks() const
const std::vector<sh::InterfaceBlock> &OutputHLSL::getInterfaceBlocks() const
{
return mUniformHLSL->getInterfaceBlocks();
}
const std::vector<gl::Attribute> &OutputHLSL::getOutputVariables() const
const std::vector<sh::Attribute> &OutputHLSL::getOutputVariables() const
{
return mActiveOutputVariables;
}
const std::vector<gl::Attribute> &OutputHLSL::getAttributes() const
const std::vector<sh::Attribute> &OutputHLSL::getAttributes() const
{
return mActiveAttributes;
}
const std::vector<gl::Varying> &OutputHLSL::getVaryings() const
const std::vector<sh::Varying> &OutputHLSL::getVaryings() const
{
return mActiveVaryings;
}
......@@ -325,7 +325,7 @@ void OutputHLSL::header()
attributes += "static " + TypeString(type) + " " + Decorate(name) + ArrayString(type) + " = " + initializer(type) + ";\n";
gl::Attribute attributeVar(GLVariableType(type), GLVariablePrecision(type), name.c_str(),
sh::Attribute attributeVar(GLVariableType(type), GLVariablePrecision(type), name.c_str(),
(unsigned int)type.getArraySize(), type.getLayoutQualifier().location);
mActiveAttributes.push_back(attributeVar);
}
......@@ -365,7 +365,7 @@ void OutputHLSL::header()
out << "static " + TypeString(variableType) + " out_" + variableName + ArrayString(variableType) +
" = " + initializer(variableType) + ";\n";
gl::Attribute outputVar(GLVariableType(variableType), GLVariablePrecision(variableType), variableName.c_str(),
sh::Attribute outputVar(GLVariableType(variableType), GLVariablePrecision(variableType), variableName.c_str(),
(unsigned int)variableType.getArraySize(), layoutQualifier.location);
mActiveOutputVariables.push_back(outputVar);
}
......@@ -2895,19 +2895,19 @@ const ConstantUnion *OutputHLSL::writeConstantUnion(const TType &type, const Con
return constUnion;
}
void OutputHLSL::declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector<gl::Varying>& fieldsOut)
void OutputHLSL::declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector<Varying> &fieldsOut)
{
const TStructure *structure = type.getStruct();
gl::InterpolationType interpolation = GetInterpolationType(baseTypeQualifier);
InterpolationType interpolation = GetInterpolationType(baseTypeQualifier);
if (!structure)
{
gl::Varying varying(GLVariableType(type), GLVariablePrecision(type), name.c_str(), (unsigned int)type.getArraySize(), interpolation);
sh::Varying varying(GLVariableType(type), GLVariablePrecision(type), name.c_str(), (unsigned int)type.getArraySize(), interpolation);
fieldsOut.push_back(varying);
}
else
{
gl::Varying structVarying(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), interpolation);
sh::Varying structVarying(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), interpolation);
const TFieldList &fields = structure->fields();
structVarying.structName = structure->name().c_str();
......
......@@ -35,11 +35,11 @@ class OutputHLSL : public TIntermTraverser
void output();
TInfoSinkBase &getBodyStream();
const std::vector<gl::Uniform> &getUniforms();
const std::vector<gl::InterfaceBlock> &getInterfaceBlocks() const;
const std::vector<gl::Attribute> &getOutputVariables() const;
const std::vector<gl::Attribute> &getAttributes() const;
const std::vector<gl::Varying> &getVaryings() const;
const std::vector<sh::Uniform> &getUniforms();
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const;
const std::vector<sh::Attribute> &getOutputVariables() const;
const std::vector<sh::Attribute> &getAttributes() const;
const std::vector<sh::Varying> &getVaryings() const;
static TString initializer(const TType &type);
......@@ -153,13 +153,13 @@ class OutputHLSL : public TIntermTraverser
TIntermSymbol *mExcessiveLoopIndex;
void declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector<gl::Varying>& fieldsOut);
void declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector<sh::Varying>& fieldsOut);
TString structInitializerString(int indent, const TStructure &structure, const TString &rhsStructName);
std::vector<gl::Attribute> mActiveOutputVariables;
std::vector<gl::Attribute> mActiveAttributes;
std::vector<gl::Varying> mActiveVaryings;
std::vector<sh::Attribute> mActiveOutputVariables;
std::vector<sh::Attribute> mActiveAttributes;
std::vector<sh::Varying> mActiveVaryings;
std::map<TIntermTyped*, TString> mFlaggedStructMappedNames;
std::map<TIntermTyped*, TString> mFlaggedStructOriginalNames;
......
......@@ -33,7 +33,7 @@ int Std140PaddingHelper::prePadding(const TType &type)
}
const GLenum glType = GLVariableType(type);
const int numComponents = gl::UniformComponentCount(glType);
const int numComponents = gl::VariableComponentCount(glType);
if (numComponents >= 4)
{
......@@ -110,7 +110,7 @@ TString Std140PaddingHelper::postPaddingString(const TType &type, bool useHLSLRo
else
{
const GLenum glType = GLVariableType(type);
numComponents = gl::UniformComponentCount(glType);
numComponents = gl::VariableComponentCount(glType);
}
TString padding;
......
......@@ -15,20 +15,20 @@ public:
TranslatorHLSL(ShShaderType type, ShShaderSpec spec, ShShaderOutput output);
virtual TranslatorHLSL *getAsTranslatorHLSL() { return this; }
const std::vector<gl::Uniform> &getUniforms() { return mActiveUniforms; }
const std::vector<gl::InterfaceBlock> &getInterfaceBlocks() const { return mActiveInterfaceBlocks; }
const std::vector<gl::Attribute> &getOutputVariables() { return mActiveOutputVariables; }
const std::vector<gl::Attribute> &getAttributes() { return mActiveAttributes; }
const std::vector<gl::Varying> &getVaryings() { return mActiveVaryings; }
const std::vector<sh::Uniform> &getUniforms() { return mActiveUniforms; }
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return mActiveInterfaceBlocks; }
const std::vector<sh::Attribute> &getOutputVariables() { return mActiveOutputVariables; }
const std::vector<sh::Attribute> &getAttributes() { return mActiveAttributes; }
const std::vector<sh::Varying> &getVaryings() { return mActiveVaryings; }
protected:
virtual void translate(TIntermNode* root);
std::vector<gl::Uniform> mActiveUniforms;
std::vector<gl::InterfaceBlock> mActiveInterfaceBlocks;
std::vector<gl::Attribute> mActiveOutputVariables;
std::vector<gl::Attribute> mActiveAttributes;
std::vector<gl::Varying> mActiveVaryings;
std::vector<sh::Uniform> mActiveUniforms;
std::vector<sh::InterfaceBlock> mActiveInterfaceBlocks;
std::vector<sh::Attribute> mActiveOutputVariables;
std::vector<sh::Attribute> mActiveAttributes;
std::vector<sh::Varying> mActiveVaryings;
};
#endif // COMPILER_TRANSLATORHLSL_H_
......@@ -19,25 +19,25 @@ namespace sh
{
// Use the same layout for packed and shared
static void SetBlockLayout(gl::InterfaceBlock *interfaceBlock, gl::BlockLayoutType newLayout)
static void SetBlockLayout(InterfaceBlock *interfaceBlock, BlockLayoutType newLayout)
{
interfaceBlock->layout = newLayout;
interfaceBlock->blockInfo.clear();
switch (newLayout)
{
case gl::BLOCKLAYOUT_SHARED:
case gl::BLOCKLAYOUT_PACKED:
case BLOCKLAYOUT_SHARED:
case BLOCKLAYOUT_PACKED:
{
gl::HLSLBlockEncoder hlslEncoder(&interfaceBlock->blockInfo, gl::HLSLBlockEncoder::ENCODE_PACKED);
HLSLBlockEncoder hlslEncoder(&interfaceBlock->blockInfo, HLSLBlockEncoder::ENCODE_PACKED);
hlslEncoder.encodeInterfaceBlockFields(interfaceBlock->fields);
interfaceBlock->dataSize = hlslEncoder.getBlockSize();
}
break;
case gl::BLOCKLAYOUT_STANDARD:
case BLOCKLAYOUT_STANDARD:
{
gl::Std140BlockEncoder stdEncoder(&interfaceBlock->blockInfo);
Std140BlockEncoder stdEncoder(&interfaceBlock->blockInfo);
stdEncoder.encodeInterfaceBlockFields(interfaceBlock->fields);
interfaceBlock->dataSize = stdEncoder.getBlockSize();
}
......@@ -49,14 +49,14 @@ static void SetBlockLayout(gl::InterfaceBlock *interfaceBlock, gl::BlockLayoutTy
}
}
static gl::BlockLayoutType ConvertBlockLayoutType(TLayoutBlockStorage blockStorage)
static BlockLayoutType ConvertBlockLayoutType(TLayoutBlockStorage blockStorage)
{
switch (blockStorage)
{
case EbsPacked: return gl::BLOCKLAYOUT_PACKED;
case EbsShared: return gl::BLOCKLAYOUT_SHARED;
case EbsStd140: return gl::BLOCKLAYOUT_STANDARD;
default: UNREACHABLE(); return gl::BLOCKLAYOUT_SHARED;
case EbsPacked: return BLOCKLAYOUT_PACKED;
case EbsShared: return BLOCKLAYOUT_SHARED;
case EbsStd140: return BLOCKLAYOUT_STANDARD;
default: UNREACHABLE(); return BLOCKLAYOUT_SHARED;
}
}
......@@ -136,27 +136,27 @@ int UniformHLSL::declareUniformAndAssignRegister(const TType &type, const TStrin
{
int registerIndex = (IsSampler(type.getBasicType()) ? mSamplerRegister : mUniformRegister);
const gl::Uniform &uniform = declareUniformToList(type, name, registerIndex, &mActiveUniforms);
const Uniform &uniform = declareUniformToList(type, name, registerIndex, &mActiveUniforms);
if (IsSampler(type.getBasicType()))
{
mSamplerRegister += gl::HLSLVariableRegisterCount(uniform, mOutputType);
mSamplerRegister += HLSLVariableRegisterCount(uniform, mOutputType);
}
else
{
mUniformRegister += gl::HLSLVariableRegisterCount(uniform, mOutputType);
mUniformRegister += HLSLVariableRegisterCount(uniform, mOutputType);
}
return registerIndex;
}
gl::Uniform UniformHLSL::declareUniformToList(const TType &type, const TString &name, int registerIndex, std::vector<gl::Uniform> *output)
Uniform UniformHLSL::declareUniformToList(const TType &type, const TString &name, int registerIndex, std::vector<Uniform> *output)
{
const TStructure *structure = type.getStruct();
if (!structure)
{
gl::Uniform uniform(GLVariableType(type), GLVariablePrecision(type), name.c_str(),
Uniform uniform(GLVariableType(type), GLVariablePrecision(type), name.c_str(),
(unsigned int)type.getArraySize(), (unsigned int)registerIndex, 0);
output->push_back(uniform);
......@@ -164,7 +164,7 @@ gl::Uniform UniformHLSL::declareUniformToList(const TType &type, const TString &
}
else
{
gl::Uniform structUniform(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(),
Uniform structUniform(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(),
(unsigned int)registerIndex, GL_INVALID_INDEX);
const TFieldList &fields = structure->fields();
......@@ -233,7 +233,7 @@ TString UniformHLSL::interfaceBlocksHeader(const ReferencedSymbols &referencedIn
const TFieldList &fieldList = interfaceBlock.fields();
unsigned int arraySize = static_cast<unsigned int>(interfaceBlock.arraySize());
gl::InterfaceBlock activeBlock(interfaceBlock.name().c_str(), arraySize, mInterfaceBlockRegister);
InterfaceBlock activeBlock(interfaceBlock.name().c_str(), arraySize, mInterfaceBlockRegister);
for (unsigned int typeIndex = 0; typeIndex < fieldList.size(); typeIndex++)
{
const TField &field = *fieldList[typeIndex];
......@@ -243,7 +243,7 @@ TString UniformHLSL::interfaceBlocksHeader(const ReferencedSymbols &referencedIn
mInterfaceBlockRegister += std::max(1u, arraySize);
gl::BlockLayoutType blockLayoutType = ConvertBlockLayoutType(interfaceBlock.blockStorage());
BlockLayoutType blockLayoutType = ConvertBlockLayoutType(interfaceBlock.blockStorage());
SetBlockLayout(&activeBlock, blockLayoutType);
if (interfaceBlock.matrixPacking() == EmpRowMajor)
......@@ -356,20 +356,20 @@ TString UniformHLSL::interfaceBlockStructString(const TInterfaceBlock &interface
"};\n\n";
}
void UniformHLSL::declareInterfaceBlockField(const TType &type, const TString &name, std::vector<gl::InterfaceBlockField>& output)
void UniformHLSL::declareInterfaceBlockField(const TType &type, const TString &name, std::vector<InterfaceBlockField>& output)
{
const TStructure *structure = type.getStruct();
if (!structure)
{
const bool isRowMajorMatrix = (type.isMatrix() && type.getLayoutQualifier().matrixPacking == EmpRowMajor);
gl::InterfaceBlockField field(GLVariableType(type), GLVariablePrecision(type), name.c_str(),
InterfaceBlockField field(GLVariableType(type), GLVariablePrecision(type), name.c_str(),
(unsigned int)type.getArraySize(), isRowMajorMatrix);
output.push_back(field);
}
else
{
gl::InterfaceBlockField structField(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), false);
InterfaceBlockField structField(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), false);
const TFieldList &fields = structure->fields();
......
......@@ -30,8 +30,8 @@ class UniformHLSL
// Used for direct index references
static TString interfaceBlockInstanceString(const TInterfaceBlock& interfaceBlock, unsigned int arrayIndex);
const std::vector<gl::Uniform> &getUniforms() const { return mActiveUniforms; }
const std::vector<gl::InterfaceBlock> &getInterfaceBlocks() const { return mActiveInterfaceBlocks; }
const std::vector<Uniform> &getUniforms() const { return mActiveUniforms; }
const std::vector<InterfaceBlock> &getInterfaceBlocks() const { return mActiveInterfaceBlocks; }
private:
TString interfaceBlockString(const TInterfaceBlock &interfaceBlock, unsigned int registerIndex, unsigned int arrayIndex);
......@@ -40,8 +40,8 @@ class UniformHLSL
// Returns the uniform's register index
int declareUniformAndAssignRegister(const TType &type, const TString &name);
void declareInterfaceBlockField(const TType &type, const TString &name, std::vector<gl::InterfaceBlockField>& output);
gl::Uniform declareUniformToList(const TType &type, const TString &name, int registerIndex, std::vector<gl::Uniform> *output);
void declareInterfaceBlockField(const TType &type, const TString &name, std::vector<InterfaceBlockField>& output);
Uniform declareUniformToList(const TType &type, const TString &name, int registerIndex, std::vector<Uniform> *output);
unsigned int mUniformRegister;
unsigned int mInterfaceBlockRegister;
......@@ -49,8 +49,8 @@ class UniformHLSL
StructureHLSL *mStructureHLSL;
ShShaderOutput mOutputType;
std::vector<gl::Uniform> mActiveUniforms;
std::vector<gl::InterfaceBlock> mActiveInterfaceBlocks;
std::vector<Uniform> mActiveUniforms;
std::vector<InterfaceBlock> mActiveInterfaceBlocks;
};
}
......
......@@ -252,13 +252,13 @@ bool IsVarying(TQualifier qualifier)
return IsVaryingIn(qualifier) || IsVaryingOut(qualifier);
}
gl::InterpolationType GetInterpolationType(TQualifier qualifier)
InterpolationType GetInterpolationType(TQualifier qualifier)
{
switch (qualifier)
{
case EvqFlatIn:
case EvqFlatOut:
return gl::INTERPOLATION_FLAT;
return INTERPOLATION_FLAT;
case EvqSmoothIn:
case EvqSmoothOut:
......@@ -266,14 +266,14 @@ gl::InterpolationType GetInterpolationType(TQualifier qualifier)
case EvqFragmentIn:
case EvqVaryingIn:
case EvqVaryingOut:
return gl::INTERPOLATION_SMOOTH;
return INTERPOLATION_SMOOTH;
case EvqCentroidIn:
case EvqCentroidOut:
return gl::INTERPOLATION_CENTROID;
return INTERPOLATION_CENTROID;
default: UNREACHABLE();
return gl::INTERPOLATION_SMOOTH;
return INTERPOLATION_SMOOTH;
}
}
......
......@@ -30,7 +30,7 @@ GLenum GLVariablePrecision(const TType &type);
bool IsVaryingIn(TQualifier qualifier);
bool IsVaryingOut(TQualifier qualifier);
bool IsVarying(TQualifier qualifier);
gl::InterpolationType GetInterpolationType(TQualifier qualifier);
InterpolationType GetInterpolationType(TQualifier qualifier);
TString ArrayString(const TType &type);
}
......
......@@ -69,7 +69,7 @@ std::string HLSLTypeString(GLenum type)
return HLSLMatrixTypeString(type);
}
return HLSLComponentTypeString(gl::UniformComponentType(type), gl::UniformComponentCount(type));
return HLSLComponentTypeString(gl::VariableComponentType(type), gl::VariableComponentCount(type));
}
}
......@@ -301,9 +301,9 @@ std::string DynamicHLSL::generateVaryingHLSL(VertexShader *shader) const
{
switch (varying.interpolation)
{
case INTERPOLATION_SMOOTH: varyingHLSL += " "; break;
case INTERPOLATION_FLAT: varyingHLSL += " nointerpolation "; break;
case INTERPOLATION_CENTROID: varyingHLSL += " centroid "; break;
case sh::INTERPOLATION_SMOOTH: varyingHLSL += " "; break;
case sh::INTERPOLATION_FLAT: varyingHLSL += " nointerpolation "; break;
case sh::INTERPOLATION_CENTROID: varyingHLSL += " centroid "; break;
default: UNREACHABLE();
}
......@@ -320,7 +320,7 @@ std::string DynamicHLSL::generateVaryingHLSL(VertexShader *shader) const
}
else
{
GLenum componentType = UniformComponentType(transposedType);
GLenum componentType = VariableComponentType(transposedType);
int columnCount = VariableColumnCount(transposedType);
typeString = gl_d3d::HLSLComponentTypeString(componentType, columnCount);
}
......@@ -333,7 +333,9 @@ std::string DynamicHLSL::generateVaryingHLSL(VertexShader *shader) const
return varyingHLSL;
}
std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &sourceShader, const VertexFormat inputLayout[], const Attribute shaderAttributes[]) const
std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &sourceShader,
const VertexFormat inputLayout[],
const sh::Attribute shaderAttributes[]) const
{
std::string structHLSL, initHLSL;
......@@ -345,7 +347,7 @@ std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &s
ASSERT(inputIndex < MAX_VERTEX_ATTRIBS);
const VertexFormat &vertexFormat = inputLayout[inputIndex];
const Attribute &shaderAttribute = shaderAttributes[attributeIndex];
const sh::Attribute &shaderAttribute = shaderAttributes[attributeIndex];
if (!shaderAttribute.name.empty())
{
......@@ -358,11 +360,11 @@ std::string DynamicHLSL::generateVertexShaderForInputLayout(const std::string &s
else
{
GLenum componentType = mRenderer->getVertexComponentType(vertexFormat);
structHLSL += " " + gl_d3d::HLSLComponentTypeString(componentType, UniformComponentCount(shaderAttribute.type));
structHLSL += " " + gl_d3d::HLSLComponentTypeString(componentType, VariableComponentCount(shaderAttribute.type));
}
structHLSL += " " + decorateVariable(shaderAttribute.name) + " : TEXCOORD" + Str(semanticIndex) + ";\n";
semanticIndex += AttributeRegisterCount(shaderAttribute.type);
semanticIndex += VariableRegisterCount(shaderAttribute.type);
// HLSL code for initialization
initHLSL += " " + decorateVariable(shaderAttribute.name) + " = ";
......@@ -815,11 +817,11 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
{
defineOutputVariables(fragmentShader, programOutputVars);
const std::vector<Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
for (auto locationIt = programOutputVars->begin(); locationIt != programOutputVars->end(); locationIt++)
{
const VariableLocation &outputLocation = locationIt->second;
const ShaderVariable &outputVariable = shaderOutputVars[outputLocation.index];
const sh::ShaderVariable &outputVariable = shaderOutputVars[outputLocation.index];
const std::string &variableName = "out_" + outputLocation.name;
const std::string &elementString = (outputLocation.element == GL_INVALID_INDEX ? "" : Str(outputLocation.element));
......@@ -955,11 +957,11 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
void DynamicHLSL::defineOutputVariables(FragmentShader *fragmentShader, std::map<int, VariableLocation> *programOutputVars) const
{
const std::vector<Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
for (unsigned int outputVariableIndex = 0; outputVariableIndex < shaderOutputVars.size(); outputVariableIndex++)
{
const Attribute &outputVariable = shaderOutputVars[outputVariableIndex];
const sh::Attribute &outputVariable = shaderOutputVars[outputVariableIndex];
const int baseLocation = outputVariable.location == -1 ? 0 : outputVariable.location;
if (outputVariable.arraySize > 0)
......@@ -1080,7 +1082,7 @@ std::string DynamicHLSL::decorateVariable(const std::string &name)
return name;
}
std::string DynamicHLSL::generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const ShaderVariable &shaderAttrib) const
std::string DynamicHLSL::generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const sh::ShaderVariable &shaderAttrib) const
{
std::string attribString = "input." + decorateVariable(shaderAttrib.name);
......@@ -1090,8 +1092,8 @@ std::string DynamicHLSL::generateAttributeConversionHLSL(const VertexFormat &ver
return "transpose(" + attribString + ")";
}
GLenum shaderComponentType = UniformComponentType(shaderAttrib.type);
int shaderComponentCount = UniformComponentCount(shaderAttrib.type);
GLenum shaderComponentType = VariableComponentType(shaderAttrib.type);
int shaderComponentCount = VariableComponentCount(shaderAttrib.type);
// Perform integer to float conversion (if necessary)
bool requiresTypeConversion = (shaderComponentType == GL_FLOAT && vertexFormat.mType != GL_FLOAT);
......
......@@ -17,6 +17,12 @@ namespace rx
class Renderer;
}
namespace sh
{
struct Attribute;
struct ShaderVariable;
}
namespace gl
{
......@@ -27,9 +33,6 @@ struct VariableLocation;
struct LinkedVarying;
struct VertexAttribute;
struct VertexFormat;
struct ShaderVariable;
struct Varying;
struct Attribute;
struct PackedVarying;
typedef const PackedVarying *VaryingPacking[IMPLEMENTATION_MAX_VARYING_VECTORS][4];
......@@ -49,7 +52,8 @@ class DynamicHLSL
int packVaryings(InfoLog &infoLog, VaryingPacking packing, FragmentShader *fragmentShader,
VertexShader *vertexShader, const std::vector<std::string>& transformFeedbackVaryings);
std::string generateVertexShaderForInputLayout(const std::string &sourceShader, const VertexFormat inputLayout[], const Attribute shaderAttributes[]) const;
std::string generateVertexShaderForInputLayout(const std::string &sourceShader, const VertexFormat inputLayout[],
const sh::Attribute shaderAttributes[]) const;
std::string generatePixelShaderForOutputSignature(const std::string &sourceShader, const std::vector<PixelShaderOuputVariable> &outputVariables,
bool usesFragDepth, const std::vector<GLenum> &outputLayout) const;
bool generateShaderLinkHLSL(InfoLog &infoLog, int registers, const VaryingPacking packing,
......@@ -84,7 +88,7 @@ class DynamicHLSL
// Prepend an underscore
static std::string decorateVariable(const std::string &name);
std::string generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const ShaderVariable &shaderAttrib) const;
std::string generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const sh::ShaderVariable &shaderAttrib) const;
};
// Utility method shared between ProgramBinary and DynamicHLSL
......
......@@ -184,25 +184,25 @@ class ProgramBinary : public RefCountObject
bool linkVaryings(InfoLog &infoLog, FragmentShader *fragmentShader, VertexShader *vertexShader);
bool linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader);
typedef std::vector<BlockMemberInfo>::const_iterator BlockInfoItr;
typedef std::vector<sh::BlockMemberInfo>::const_iterator BlockInfoItr;
template <class ShaderVarType>
bool linkValidateFields(InfoLog &infoLog, const std::string &varName, const ShaderVarType &vertexVar, const ShaderVarType &fragmentVar);
bool linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const ShaderVariable &vertexVariable, const ShaderVariable &fragmentVariable, bool validatePrecision);
bool linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const Uniform &vertexUniform, const Uniform &fragmentUniform);
bool linkValidateVariables(InfoLog &infoLog, const std::string &varyingName, const Varying &vertexVarying, const Varying &fragmentVarying);
bool linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const InterfaceBlockField &vertexUniform, const InterfaceBlockField &fragmentUniform);
bool linkUniforms(InfoLog &infoLog, const std::vector<Uniform> &vertexUniforms, const std::vector<Uniform> &fragmentUniforms);
bool defineUniform(GLenum shader, const Uniform &constant, InfoLog &infoLog);
bool areMatchingInterfaceBlocks(InfoLog &infoLog, const InterfaceBlock &vertexInterfaceBlock, const InterfaceBlock &fragmentInterfaceBlock);
bool linkUniformBlocks(InfoLog &infoLog, const std::vector<InterfaceBlock> &vertexUniformBlocks, const std::vector<InterfaceBlock> &fragmentUniformBlocks);
bool linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const sh::ShaderVariable &vertexVariable, const sh::ShaderVariable &fragmentVariable, bool validatePrecision);
bool linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform);
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 linkUniforms(InfoLog &infoLog, const std::vector<sh::Uniform> &vertexUniforms, const std::vector<sh::Uniform> &fragmentUniforms);
bool defineUniform(GLenum shader, const sh::Uniform &constant, InfoLog &infoLog);
bool areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::InterfaceBlock &vertexInterfaceBlock, const sh::InterfaceBlock &fragmentInterfaceBlock);
bool linkUniformBlocks(InfoLog &infoLog, const std::vector<sh::InterfaceBlock> &vertexUniformBlocks, const std::vector<sh::InterfaceBlock> &fragmentUniformBlocks);
bool gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, const std::vector<LinkedVarying> &linkedVaryings,
const std::vector<std::string> &transformFeedbackVaryingNames,
GLenum transformFeedbackBufferMode,
std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings) const;
void defineUniformBlockMembers(const std::vector<InterfaceBlockField> &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector<unsigned int> *blockUniformIndexes);
bool defineUniformBlock(InfoLog &infoLog, GLenum shader, const InterfaceBlock &interfaceBlock);
void defineUniformBlockMembers(const std::vector<sh::InterfaceBlockField> &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector<unsigned int> *blockUniformIndexes);
bool defineUniformBlock(InfoLog &infoLog, GLenum shader, const sh::InterfaceBlock &interfaceBlock);
bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex);
void defineOutputVariables(FragmentShader *fragmentShader);
void initializeUniformStorage();
......@@ -270,8 +270,8 @@ class ProgramBinary : public RefCountObject
rx::ShaderExecutable *mGeometryExecutable;
Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS];
Attribute mShaderAttributes[MAX_VERTEX_ATTRIBS];
sh::Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS];
sh::Attribute mShaderAttributes[MAX_VERTEX_ATTRIBS];
int mSemanticIndex[MAX_VERTEX_ATTRIBS];
int mAttributesByLayout[MAX_VERTEX_ATTRIBS];
......
......@@ -115,12 +115,12 @@ void Shader::getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer)
getSourceImpl(mHlsl, bufSize, length, buffer);
}
const std::vector<Uniform> &Shader::getUniforms() const
const std::vector<sh::Uniform> &Shader::getUniforms() const
{
return mActiveUniforms;
}
const std::vector<InterfaceBlock> &Shader::getInterfaceBlocks() const
const std::vector<sh::InterfaceBlock> &Shader::getInterfaceBlocks() const
{
return mActiveInterfaceBlocks;
}
......@@ -227,7 +227,7 @@ void Shader::parseVaryings(void *compiler)
{
if (!mHlsl.empty())
{
std::vector<Varying> *activeVaryings;
std::vector<sh::Varying> *activeVaryings;
ShGetInfoPointer(compiler, SH_ACTIVE_VARYINGS_ARRAY, reinterpret_cast<void**>(&activeVaryings));
for (size_t varyingIndex = 0; varyingIndex < activeVaryings->size(); varyingIndex++)
......@@ -363,11 +363,11 @@ void Shader::compileToHLSL(void *compiler)
void *activeUniforms;
ShGetInfoPointer(compiler, SH_ACTIVE_UNIFORMS_ARRAY, &activeUniforms);
mActiveUniforms = *(std::vector<Uniform>*)activeUniforms;
mActiveUniforms = *(std::vector<sh::Uniform>*)activeUniforms;
void *activeInterfaceBlocks;
ShGetInfoPointer(compiler, SH_ACTIVE_INTERFACE_BLOCKS_ARRAY, &activeInterfaceBlocks);
mActiveInterfaceBlocks = *(std::vector<InterfaceBlock>*)activeInterfaceBlocks;
mActiveInterfaceBlocks = *(std::vector<sh::InterfaceBlock>*)activeInterfaceBlocks;
}
else
{
......@@ -517,14 +517,14 @@ int VertexShader::getSemanticIndex(const std::string &attributeName)
int semanticIndex = 0;
for (unsigned int attributeIndex = 0; attributeIndex < mActiveAttributes.size(); attributeIndex++)
{
const ShaderVariable &attribute = mActiveAttributes[attributeIndex];
const sh::ShaderVariable &attribute = mActiveAttributes[attributeIndex];
if (attribute.name == attributeName)
{
return semanticIndex;
}
semanticIndex += AttributeRegisterCount(attribute.type);
semanticIndex += VariableRegisterCount(attribute.type);
}
}
......@@ -538,7 +538,7 @@ void VertexShader::parseAttributes()
{
void *activeAttributes;
ShGetInfoPointer(mVertexCompiler, SH_ACTIVE_ATTRIBUTES_ARRAY, &activeAttributes);
mActiveAttributes = *(std::vector<Attribute>*)activeAttributes;
mActiveAttributes = *(std::vector<sh::Attribute>*)activeAttributes;
}
}
......@@ -569,7 +569,7 @@ void FragmentShader::compile()
{
void *activeOutputVariables;
ShGetInfoPointer(mFragmentCompiler, SH_ACTIVE_OUTPUT_VARIABLES_ARRAY, &activeOutputVariables);
mActiveOutputVariables = *(std::vector<Attribute>*)activeOutputVariables;
mActiveOutputVariables = *(std::vector<sh::Attribute>*)activeOutputVariables;
}
}
......@@ -580,7 +580,7 @@ void FragmentShader::uncompile()
mActiveOutputVariables.clear();
}
const std::vector<Attribute> &FragmentShader::getOutputVariables() const
const std::vector<sh::Attribute> &FragmentShader::getOutputVariables() const
{
return mActiveOutputVariables;
}
......
......@@ -32,12 +32,12 @@ namespace gl
{
class ResourceManager;
struct PackedVarying : public Varying
struct PackedVarying : public sh::Varying
{
unsigned int registerIndex; // Assigned during link
PackedVarying(const Varying &varying)
: Varying(varying),
PackedVarying(const sh::Varying &varying)
: sh::Varying(varying),
registerIndex(GL_INVALID_INDEX)
{}
......@@ -69,8 +69,8 @@ class Shader
void getSource(GLsizei bufSize, GLsizei *length, char *buffer) const;
int getTranslatedSourceLength() const;
void getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer) const;
const std::vector<Uniform> &getUniforms() const;
const std::vector<InterfaceBlock> &getInterfaceBlocks() const;
const std::vector<sh::Uniform> &getUniforms() const;
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const;
std::vector<PackedVarying> &getVaryings();
virtual void compile() = 0;
......@@ -134,8 +134,8 @@ class Shader
std::string mSource;
std::string mHlsl;
std::string mInfoLog;
std::vector<Uniform> mActiveUniforms;
std::vector<InterfaceBlock> mActiveInterfaceBlocks;
std::vector<sh::Uniform> mActiveUniforms;
std::vector<sh::InterfaceBlock> mActiveInterfaceBlocks;
ResourceManager *mResourceManager;
};
......@@ -154,14 +154,14 @@ class VertexShader : public Shader
virtual void uncompile();
int getSemanticIndex(const std::string &attributeName);
const std::vector<Attribute> &activeAttributes() const { return mActiveAttributes; }
const std::vector<sh::Attribute> &activeAttributes() const { return mActiveAttributes; }
private:
DISALLOW_COPY_AND_ASSIGN(VertexShader);
void parseAttributes();
std::vector<Attribute> mActiveAttributes;
std::vector<sh::Attribute> mActiveAttributes;
};
class FragmentShader : public Shader
......@@ -174,12 +174,12 @@ class FragmentShader : public Shader
virtual GLenum getType();
virtual void compile();
virtual void uncompile();
const std::vector<Attribute> &getOutputVariables() const;
const std::vector<sh::Attribute> &getOutputVariables() const;
private:
DISALLOW_COPY_AND_ASSIGN(FragmentShader);
std::vector<Attribute> mActiveOutputVariables;
std::vector<sh::Attribute> mActiveOutputVariables;
};
}
......
......@@ -13,7 +13,7 @@ namespace gl
{
LinkedUniform::LinkedUniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize,
const int blockIndex, const BlockMemberInfo &blockInfo)
const int blockIndex, const sh::BlockMemberInfo &blockInfo)
: type(type),
precision(precision),
name(name),
......@@ -71,7 +71,7 @@ bool LinkedUniform::isInDefaultBlock() const
size_t LinkedUniform::dataSize() const
{
ASSERT(type != GL_STRUCT_ANGLEX);
return UniformInternalSize(type) * elementCount();
return VariableInternalSize(type) * elementCount();
}
bool LinkedUniform::isSampler() const
......
......@@ -23,7 +23,7 @@ namespace gl
// Helper struct representing a single shader uniform
struct LinkedUniform
{
LinkedUniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize, const int blockIndex, const BlockMemberInfo &blockInfo);
LinkedUniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize, const int blockIndex, const sh::BlockMemberInfo &blockInfo);
~LinkedUniform();
......@@ -40,7 +40,7 @@ struct LinkedUniform
const std::string name;
const unsigned int arraySize;
const int blockIndex;
const BlockMemberInfo blockInfo;
const sh::BlockMemberInfo blockInfo;
unsigned char *data;
bool dirty;
......
......@@ -992,7 +992,7 @@ static bool ValidateUniformCommonBase(gl::Context *context, GLenum targetUniform
bool ValidateUniform(gl::Context *context, GLenum uniformType, GLint location, GLsizei count)
{
// Check for ES3 uniform entry points
if (UniformComponentType(uniformType) == GL_UNSIGNED_INT && context->getClientVersion() < 3)
if (VariableComponentType(uniformType) == GL_UNSIGNED_INT && context->getClientVersion() < 3)
{
return gl::error(GL_INVALID_OPERATION, false);
}
......@@ -1003,7 +1003,7 @@ bool ValidateUniform(gl::Context *context, GLenum uniformType, GLint location, G
return false;
}
GLenum targetBoolType = UniformBoolVectorType(uniformType);
GLenum targetBoolType = VariableBoolVectorType(uniformType);
bool samplerUniformCheck = (IsSampler(uniform->type) && uniformType == GL_INT);
if (!samplerUniformCheck && uniformType != uniform->type && targetBoolType != uniform->type)
{
......
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