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