Commit e04a5b7b by Jamie Madill

Remove sh::InterfaceBlock member info.

We can compute the interface block member info entirely on the API side. This will allow us to get rid of some un-necessary code in the compiler. BUG=angle:466 Change-Id: I664ffc82de5f2723156e51f4e9ffc07e4de162aa Reviewed-on: https://chromium-review.googlesource.com/207781Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarNicolas Capens <capn@chromium.org>
parent 28f70c3a
...@@ -15,9 +15,8 @@ ...@@ -15,9 +15,8 @@
namespace sh namespace sh
{ {
BlockLayoutEncoder::BlockLayoutEncoder(std::vector<BlockMemberInfo> *blockInfoOut) BlockLayoutEncoder::BlockLayoutEncoder()
: mCurrentOffset(0), : mCurrentOffset(0)
mBlockInfoOut(blockInfoOut)
{ {
} }
...@@ -45,7 +44,7 @@ void BlockLayoutEncoder::encodeInterfaceBlockFields(const std::vector<InterfaceB ...@@ -45,7 +44,7 @@ void BlockLayoutEncoder::encodeInterfaceBlockFields(const std::vector<InterfaceB
} }
} }
void BlockLayoutEncoder::encodeInterfaceBlockField(const InterfaceBlockField &field) BlockMemberInfo BlockLayoutEncoder::encodeInterfaceBlockField(const InterfaceBlockField &field)
{ {
int arrayStride; int arrayStride;
int matrixStride; int matrixStride;
...@@ -55,12 +54,9 @@ void BlockLayoutEncoder::encodeInterfaceBlockField(const InterfaceBlockField &fi ...@@ -55,12 +54,9 @@ void BlockLayoutEncoder::encodeInterfaceBlockField(const InterfaceBlockField &fi
const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, field.isRowMajorMatrix); const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, field.isRowMajorMatrix);
if (mBlockInfoOut)
{
mBlockInfoOut->push_back(memberInfo);
}
advanceOffset(field.type, field.arraySize, field.isRowMajorMatrix, arrayStride, matrixStride); advanceOffset(field.type, field.arraySize, field.isRowMajorMatrix, arrayStride, matrixStride);
return memberInfo;
} }
void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix) void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix)
...@@ -72,11 +68,6 @@ void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool is ...@@ -72,11 +68,6 @@ void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool is
const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, isRowMajorMatrix); const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, isRowMajorMatrix);
if (mBlockInfoOut)
{
mBlockInfoOut->push_back(memberInfo);
}
advanceOffset(type, arraySize, isRowMajorMatrix, arrayStride, matrixStride); advanceOffset(type, arraySize, isRowMajorMatrix, arrayStride, matrixStride);
} }
...@@ -85,8 +76,7 @@ void BlockLayoutEncoder::nextRegister() ...@@ -85,8 +76,7 @@ void BlockLayoutEncoder::nextRegister()
mCurrentOffset = rx::roundUp<size_t>(mCurrentOffset, ComponentsPerRegister); mCurrentOffset = rx::roundUp<size_t>(mCurrentOffset, ComponentsPerRegister);
} }
Std140BlockEncoder::Std140BlockEncoder(std::vector<BlockMemberInfo> *blockInfoOut) Std140BlockEncoder::Std140BlockEncoder()
: BlockLayoutEncoder(blockInfoOut)
{ {
} }
...@@ -155,15 +145,8 @@ void Std140BlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool ...@@ -155,15 +145,8 @@ void Std140BlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool
} }
} }
HLSLBlockEncoder::HLSLBlockEncoder(std::vector<BlockMemberInfo> *blockInfoOut, HLSLBlockEncoderStrategy strategy) HLSLBlockEncoder::HLSLBlockEncoder(HLSLBlockEncoderStrategy strategy)
: BlockLayoutEncoder(blockInfoOut), : mEncoderStrategy(strategy)
mEncoderStrategy(strategy)
{
}
HLSLBlockEncoder::HLSLBlockEncoder(ShShaderOutput outputType)
: BlockLayoutEncoder(NULL),
mEncoderStrategy(GetStrategyFor(outputType))
{ {
} }
...@@ -261,33 +244,6 @@ HLSLBlockEncoder::HLSLBlockEncoderStrategy HLSLBlockEncoder::GetStrategyFor(ShSh ...@@ -261,33 +244,6 @@ HLSLBlockEncoder::HLSLBlockEncoderStrategy HLSLBlockEncoder::GetStrategyFor(ShSh
} }
} }
size_t HLSLInterfaceBlockDataSize(const sh::InterfaceBlock &interfaceBlock)
{
switch (interfaceBlock.layout)
{
case BLOCKLAYOUT_SHARED:
case BLOCKLAYOUT_PACKED:
{
HLSLBlockEncoder hlslEncoder(NULL, HLSLBlockEncoder::ENCODE_PACKED);
hlslEncoder.encodeInterfaceBlockFields(interfaceBlock.fields);
return hlslEncoder.getBlockSize();
}
break;
case BLOCKLAYOUT_STANDARD:
{
Std140BlockEncoder stdEncoder(NULL);
stdEncoder.encodeInterfaceBlockFields(interfaceBlock.fields);
return stdEncoder.getBlockSize();
}
break;
default:
UNREACHABLE();
return 0;
}
}
template <class ShaderVarType> template <class ShaderVarType>
void HLSLVariableRegisterCount(const ShaderVarType &variable, HLSLBlockEncoder *encoder) void HLSLVariableRegisterCount(const ShaderVarType &variable, HLSLBlockEncoder *encoder)
{ {
...@@ -314,7 +270,7 @@ void HLSLVariableRegisterCount(const ShaderVarType &variable, HLSLBlockEncoder * ...@@ -314,7 +270,7 @@ void HLSLVariableRegisterCount(const ShaderVarType &variable, HLSLBlockEncoder *
unsigned int HLSLVariableRegisterCount(const Varying &variable) unsigned int HLSLVariableRegisterCount(const Varying &variable)
{ {
HLSLBlockEncoder encoder(NULL, HLSLBlockEncoder::ENCODE_PACKED); HLSLBlockEncoder encoder(HLSLBlockEncoder::ENCODE_PACKED);
HLSLVariableRegisterCount(variable, &encoder); HLSLVariableRegisterCount(variable, &encoder);
const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister); const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister);
...@@ -323,7 +279,7 @@ unsigned int HLSLVariableRegisterCount(const Varying &variable) ...@@ -323,7 +279,7 @@ unsigned int HLSLVariableRegisterCount(const Varying &variable)
unsigned int HLSLVariableRegisterCount(const Uniform &variable, ShShaderOutput outputType) unsigned int HLSLVariableRegisterCount(const Uniform &variable, ShShaderOutput outputType)
{ {
HLSLBlockEncoder encoder(outputType); HLSLBlockEncoder encoder(HLSLBlockEncoder::GetStrategyFor(outputType));
HLSLVariableRegisterCount(variable, &encoder); HLSLVariableRegisterCount(variable, &encoder);
const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister); const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister);
......
...@@ -19,23 +19,46 @@ namespace sh ...@@ -19,23 +19,46 @@ namespace sh
{ {
struct ShaderVariable; struct ShaderVariable;
struct InterfaceBlockField; struct InterfaceBlockField;
struct BlockMemberInfo;
struct Uniform; struct Uniform;
struct Varying; struct Varying;
struct InterfaceBlock; struct InterfaceBlock;
struct BlockMemberInfo
{
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);
}
int offset;
int arrayStride;
int matrixStride;
bool isRowMajorMatrix;
};
class BlockLayoutEncoder class BlockLayoutEncoder
{ {
public: public:
BlockLayoutEncoder(std::vector<BlockMemberInfo> *blockInfoOut); BlockLayoutEncoder();
void encodeInterfaceBlockFields(const std::vector<InterfaceBlockField> &fields); void encodeInterfaceBlockFields(const std::vector<InterfaceBlockField> &fields);
void encodeInterfaceBlockField(const InterfaceBlockField &field); BlockMemberInfo encodeInterfaceBlockField(const InterfaceBlockField &field);
void encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix); void encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix);
size_t getBlockSize() const { return mCurrentOffset * BytesPerComponent; } size_t getBlockSize() const { return mCurrentOffset * BytesPerComponent; }
size_t getCurrentRegister() const { return mCurrentOffset / ComponentsPerRegister; } size_t getCurrentRegister() const { return mCurrentOffset / ComponentsPerRegister; }
size_t getCurrentElement() const { return mCurrentOffset % ComponentsPerRegister; } size_t getCurrentElement() const { return mCurrentOffset % ComponentsPerRegister; }
virtual void enterAggregateType() = 0;
virtual void exitAggregateType() = 0;
static const size_t BytesPerComponent = 4u; static const size_t BytesPerComponent = 4u;
static const unsigned int ComponentsPerRegister = 4u; static const unsigned int ComponentsPerRegister = 4u;
...@@ -44,13 +67,8 @@ class BlockLayoutEncoder ...@@ -44,13 +67,8 @@ class BlockLayoutEncoder
void nextRegister(); void nextRegister();
virtual void enterAggregateType() = 0;
virtual void exitAggregateType() = 0;
virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut) = 0; virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut) = 0;
virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride) = 0; virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride) = 0;
private:
std::vector<BlockMemberInfo> *mBlockInfoOut;
}; };
// Block layout according to the std140 block layout // Block layout according to the std140 block layout
...@@ -59,11 +77,12 @@ class BlockLayoutEncoder ...@@ -59,11 +77,12 @@ class BlockLayoutEncoder
class Std140BlockEncoder : public BlockLayoutEncoder class Std140BlockEncoder : public BlockLayoutEncoder
{ {
public: public:
Std140BlockEncoder(std::vector<BlockMemberInfo> *blockInfoOut); Std140BlockEncoder();
protected:
virtual void enterAggregateType(); virtual void enterAggregateType();
virtual void exitAggregateType(); virtual void exitAggregateType();
protected:
virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut); virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut);
virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride); virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride);
}; };
...@@ -82,9 +101,7 @@ class HLSLBlockEncoder : public BlockLayoutEncoder ...@@ -82,9 +101,7 @@ class HLSLBlockEncoder : public BlockLayoutEncoder
ENCODE_LOOSE ENCODE_LOOSE
}; };
HLSLBlockEncoder(std::vector<BlockMemberInfo> *blockInfoOut, HLSLBlockEncoder(HLSLBlockEncoderStrategy strategy);
HLSLBlockEncoderStrategy strategy);
HLSLBlockEncoder(ShShaderOutput outputType);
virtual void enterAggregateType(); virtual void enterAggregateType();
virtual void exitAggregateType(); virtual void exitAggregateType();
...@@ -101,9 +118,6 @@ class HLSLBlockEncoder : public BlockLayoutEncoder ...@@ -101,9 +118,6 @@ class HLSLBlockEncoder : public BlockLayoutEncoder
HLSLBlockEncoderStrategy mEncoderStrategy; HLSLBlockEncoderStrategy mEncoderStrategy;
}; };
// This method returns the data size of an interface block in HLSL, according to its layout.
size_t HLSLInterfaceBlockDataSize(const sh::InterfaceBlock &interfaceBlock);
// This method returns the number of used registers for a ShaderVariable. It is dependent on the HLSLBlockEncoder // This method returns the number of used registers for a ShaderVariable. It is dependent on the HLSLBlockEncoder
// class to count the number of used registers in a struct (which are individually packed according to the same rules). // class to count the number of used registers in a struct (which are individually packed according to the same rules).
unsigned int HLSLVariableRegisterCount(const Varying &variable); unsigned int HLSLVariableRegisterCount(const Varying &variable);
......
...@@ -126,28 +126,6 @@ struct Varying : public ShaderVariable ...@@ -126,28 +126,6 @@ struct Varying : public ShaderVariable
std::string structName; std::string structName;
}; };
struct BlockMemberInfo
{
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);
}
int offset;
int arrayStride;
int matrixStride;
bool isRowMajorMatrix;
};
typedef std::vector<BlockMemberInfo> BlockMemberInfoArray;
struct InterfaceBlock struct InterfaceBlock
{ {
InterfaceBlock() InterfaceBlock()
...@@ -172,7 +150,6 @@ struct InterfaceBlock ...@@ -172,7 +150,6 @@ struct InterfaceBlock
bool isRowMajorLayout; bool isRowMajorLayout;
bool staticUse; bool staticUse;
std::vector<InterfaceBlockField> fields; std::vector<InterfaceBlockField> fields;
std::vector<BlockMemberInfo> blockInfo;
}; };
} }
......
...@@ -18,35 +18,6 @@ ...@@ -18,35 +18,6 @@
namespace sh namespace sh
{ {
// Use the same layout for packed and shared
static void SetBlockLayout(InterfaceBlock *interfaceBlock, BlockLayoutType newLayout)
{
interfaceBlock->layout = newLayout;
interfaceBlock->blockInfo.clear();
switch (newLayout)
{
case BLOCKLAYOUT_SHARED:
case BLOCKLAYOUT_PACKED:
{
HLSLBlockEncoder hlslEncoder(&interfaceBlock->blockInfo, HLSLBlockEncoder::ENCODE_PACKED);
hlslEncoder.encodeInterfaceBlockFields(interfaceBlock->fields);
}
break;
case BLOCKLAYOUT_STANDARD:
{
Std140BlockEncoder stdEncoder(&interfaceBlock->blockInfo);
stdEncoder.encodeInterfaceBlockFields(interfaceBlock->fields);
}
break;
default:
UNREACHABLE();
break;
}
}
static const char *UniformRegisterPrefix(const TType &type) static const char *UniformRegisterPrefix(const TType &type)
{ {
if (IsSampler(type.getBasicType())) if (IsSampler(type.getBasicType()))
...@@ -205,8 +176,7 @@ TString UniformHLSL::interfaceBlocksHeader(const ReferencedSymbols &referencedIn ...@@ -205,8 +176,7 @@ TString UniformHLSL::interfaceBlocksHeader(const ReferencedSymbols &referencedIn
mInterfaceBlockRegisterMap[activeBlock.name] = activeRegister; mInterfaceBlockRegisterMap[activeBlock.name] = activeRegister;
mInterfaceBlockRegister += std::max(1u, arraySize); mInterfaceBlockRegister += std::max(1u, arraySize);
BlockLayoutType blockLayoutType = GetBlockLayoutType(interfaceBlock.blockStorage()); activeBlock.layout = GetBlockLayoutType(interfaceBlock.blockStorage());
SetBlockLayout(&activeBlock, blockLayoutType);
if (interfaceBlock.matrixPacking() == EmpRowMajor) if (interfaceBlock.matrixPacking() == EmpRowMajor)
{ {
......
...@@ -1656,9 +1656,11 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin ...@@ -1656,9 +1656,11 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
// special case for gl_DepthRange, the only built-in uniform (also a struct) // special case for gl_DepthRange, the only built-in uniform (also a struct)
if (vertexShader->usesDepthRange() || fragmentShader->usesDepthRange()) if (vertexShader->usesDepthRange() || fragmentShader->usesDepthRange())
{ {
mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.near", 0, -1, sh::BlockMemberInfo::getDefaultBlockInfo())); const sh::BlockMemberInfo &defaultInfo = sh::BlockMemberInfo::getDefaultBlockInfo();
mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.far", 0, -1, sh::BlockMemberInfo::getDefaultBlockInfo()));
mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.diff", 0, -1, sh::BlockMemberInfo::getDefaultBlockInfo())); mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.near", 0, -1, defaultInfo));
mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.far", 0, -1, defaultInfo));
mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.diff", 0, -1, defaultInfo));
} }
if (!linkUniformBlocks(infoLog, *vertexShader, *fragmentShader)) if (!linkUniformBlocks(infoLog, *vertexShader, *fragmentShader))
...@@ -1955,7 +1957,7 @@ bool ProgramBinary::linkUniforms(InfoLog &infoLog, const VertexShader &vertexSha ...@@ -1955,7 +1957,7 @@ bool ProgramBinary::linkUniforms(InfoLog &infoLog, const VertexShader &vertexSha
void ProgramBinary::defineUniformBase(GLenum shader, const sh::Uniform &uniform, unsigned int uniformRegister) void ProgramBinary::defineUniformBase(GLenum shader, const sh::Uniform &uniform, unsigned int uniformRegister)
{ {
ShShaderOutput outputType = Shader::getCompilerOutputType(shader); ShShaderOutput outputType = Shader::getCompilerOutputType(shader);
sh::HLSLBlockEncoder encoder(outputType); sh::HLSLBlockEncoder encoder(sh::HLSLBlockEncoder::GetStrategyFor(outputType));
encoder.skipRegisters(uniformRegister); encoder.skipRegisters(uniformRegister);
defineUniform(shader, uniform, uniform.name, &encoder); defineUniform(shader, uniform, uniform.name, &encoder);
...@@ -2278,37 +2280,36 @@ bool ProgramBinary::gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, cons ...@@ -2278,37 +2280,36 @@ bool ProgramBinary::gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, cons
return true; return true;
} }
void ProgramBinary::defineUniformBlockMembers(const std::vector<sh::InterfaceBlockField> &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector<unsigned int> *blockUniformIndexes) void ProgramBinary::defineUniformBlockMembers(const std::vector<sh::InterfaceBlockField> &fields, const std::string &prefix, int blockIndex,
sh::BlockLayoutEncoder *encoder, std::vector<unsigned int> *blockUniformIndexes)
{ {
for (unsigned int uniformIndex = 0; uniformIndex < fields.size(); uniformIndex++) for (unsigned int uniformIndex = 0; uniformIndex < fields.size(); uniformIndex++)
{ {
const sh::InterfaceBlockField &field = fields[uniformIndex]; const sh::InterfaceBlockField &field = fields[uniformIndex];
const std::string &fieldName = (prefix.empty() ? field.name : prefix + "." + field.name); const std::string &fieldName = (prefix.empty() ? field.name : prefix + "." + field.name);
if (!field.fields.empty()) if (field.isStruct())
{ {
if (field.arraySize > 0) for (unsigned int arrayElement = 0; arrayElement < field.elementCount(); arrayElement++)
{
for (unsigned int arrayElement = 0; arrayElement < field.arraySize; arrayElement++)
{
const std::string uniformElementName = fieldName + ArrayString(arrayElement);
defineUniformBlockMembers(field.fields, uniformElementName, blockIndex, blockInfoItr, blockUniformIndexes);
}
}
else
{ {
defineUniformBlockMembers(field.fields, fieldName, blockIndex, blockInfoItr, blockUniformIndexes); encoder->enterAggregateType();
const std::string uniformElementName = fieldName + (field.isArray() ? ArrayString(arrayElement) : "");
defineUniformBlockMembers(field.fields, uniformElementName, blockIndex, encoder, blockUniformIndexes);
encoder->exitAggregateType();
} }
} }
else else
{ {
sh::BlockMemberInfo memberInfo = encoder->encodeInterfaceBlockField(field);
LinkedUniform *newUniform = new LinkedUniform(field.type, field.precision, fieldName, field.arraySize, LinkedUniform *newUniform = new LinkedUniform(field.type, field.precision, fieldName, field.arraySize,
blockIndex, **blockInfoItr); blockIndex, memberInfo);
// add to uniform list, but not index, since uniform block uniforms have no location // add to uniform list, but not index, since uniform block uniforms have no location
blockUniformIndexes->push_back(mUniforms.size()); blockUniformIndexes->push_back(mUniforms.size());
mUniforms.push_back(newUniform); mUniforms.push_back(newUniform);
(*blockInfoItr)++;
} }
} }
} }
...@@ -2322,10 +2323,21 @@ bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, const Shader &shader, c ...@@ -2322,10 +2323,21 @@ bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, const Shader &shader, c
const unsigned int blockIndex = mUniformBlocks.size(); const unsigned int blockIndex = mUniformBlocks.size();
// define member uniforms // define member uniforms
BlockInfoItr blockInfoItr = interfaceBlock.blockInfo.cbegin(); sh::BlockLayoutEncoder *encoder = NULL;
defineUniformBlockMembers(interfaceBlock.fields, "", blockIndex, &blockInfoItr, &blockUniformIndexes);
if (interfaceBlock.layout == sh::BLOCKLAYOUT_STANDARD)
{
encoder = new sh::Std140BlockEncoder;
}
else
{
encoder = new sh::HLSLBlockEncoder(sh::HLSLBlockEncoder::ENCODE_PACKED);
}
ASSERT(encoder);
defineUniformBlockMembers(interfaceBlock.fields, "", blockIndex, encoder, &blockUniformIndexes);
size_t dataSize = sh::HLSLInterfaceBlockDataSize(interfaceBlock); size_t dataSize = encoder->getBlockSize();
// create all the uniform blocks // create all the uniform blocks
if (interfaceBlock.arraySize > 0) if (interfaceBlock.arraySize > 0)
......
...@@ -197,8 +197,6 @@ class ProgramBinary : public RefCountObject ...@@ -197,8 +197,6 @@ 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<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 sh::ShaderVariable &vertexVariable, const sh::ShaderVariable &fragmentVariable, bool validatePrecision); bool linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const sh::ShaderVariable &vertexVariable, const sh::ShaderVariable &fragmentVariable, bool validatePrecision);
...@@ -219,7 +217,8 @@ class ProgramBinary : public RefCountObject ...@@ -219,7 +217,8 @@ class ProgramBinary : public RefCountObject
const std::vector<std::string> &transformFeedbackVaryingNames, const std::vector<std::string> &transformFeedbackVaryingNames,
GLenum transformFeedbackBufferMode, GLenum transformFeedbackBufferMode,
std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings) const; std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings) const;
void defineUniformBlockMembers(const std::vector<sh::InterfaceBlockField> &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector<unsigned int> *blockUniformIndexes); void defineUniformBlockMembers(const std::vector<sh::InterfaceBlockField> &fields, const std::string &prefix, int blockIndex,
sh::BlockLayoutEncoder *encoder, std::vector<unsigned int> *blockUniformIndexes);
bool defineUniformBlock(InfoLog &infoLog, const Shader &shader, const sh::InterfaceBlock &interfaceBlock); bool defineUniformBlock(InfoLog &infoLog, const Shader &shader, const sh::InterfaceBlock &interfaceBlock);
bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex); bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex);
void defineOutputVariables(FragmentShader *fragmentShader); void defineOutputVariables(FragmentShader *fragmentShader);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "common/debug.h" #include "common/debug.h"
#include "angletypes.h" #include "angletypes.h"
#include "common/shadervars.h" #include "common/shadervars.h"
#include "common/blocklayout.h"
namespace gl namespace gl
{ {
......
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