зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1146034
. Cherry pick "Fix struct uniform packing."
This comes from ANGLE commit 2857f489f32372310014888342c6f9c97fac5995 --HG-- extra : rebase_source : 0a950753cbe67051ad1fa99dfe3d3b8c53f0d062
This commit is contained in:
Родитель
c9f30719f5
Коммит
470a5f318f
|
@ -33,6 +33,18 @@ BlockMemberInfo BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySi
|
|||
return memberInfo;
|
||||
}
|
||||
|
||||
// static
|
||||
size_t BlockLayoutEncoder::getBlockRegister(const BlockMemberInfo &info)
|
||||
{
|
||||
return (info.offset / BytesPerComponent) / ComponentsPerRegister;
|
||||
}
|
||||
|
||||
// static
|
||||
size_t BlockLayoutEncoder::getBlockRegisterElement(const BlockMemberInfo &info)
|
||||
{
|
||||
return (info.offset / BytesPerComponent) % ComponentsPerRegister;
|
||||
}
|
||||
|
||||
void BlockLayoutEncoder::nextRegister()
|
||||
{
|
||||
mCurrentOffset = rx::roundUp<size_t>(mCurrentOffset, ComponentsPerRegister);
|
||||
|
|
|
@ -61,6 +61,9 @@ class BlockLayoutEncoder
|
|||
static const size_t BytesPerComponent = 4u;
|
||||
static const unsigned int ComponentsPerRegister = 4u;
|
||||
|
||||
static size_t getBlockRegister(const BlockMemberInfo &info);
|
||||
static size_t getBlockRegisterElement(const BlockMemberInfo &info);
|
||||
|
||||
protected:
|
||||
size_t mCurrentOffset;
|
||||
|
||||
|
|
|
@ -1394,30 +1394,28 @@ void ProgramD3D::defineUniform(GLenum shader, const sh::ShaderVariable &uniform,
|
|||
|
||||
gl::LinkedUniform *linkedUniform = getUniformByName(fullName);
|
||||
|
||||
// Advance the uniform offset, to track registers allocation for structs
|
||||
sh::BlockMemberInfo blockInfo = encoder->encodeType(uniform.type, uniform.arraySize, false);
|
||||
|
||||
if (!linkedUniform)
|
||||
{
|
||||
linkedUniform = new gl::LinkedUniform(uniform.type, uniform.precision, fullName, uniform.arraySize,
|
||||
-1, sh::BlockMemberInfo::getDefaultBlockInfo());
|
||||
ASSERT(linkedUniform);
|
||||
linkedUniform->registerElement = encoder->getCurrentElement();
|
||||
linkedUniform->registerElement = sh::HLSLBlockEncoder::getBlockRegisterElement(blockInfo);
|
||||
mUniforms.push_back(linkedUniform);
|
||||
}
|
||||
|
||||
ASSERT(linkedUniform->registerElement == encoder->getCurrentElement());
|
||||
|
||||
if (shader == GL_FRAGMENT_SHADER)
|
||||
{
|
||||
linkedUniform->psRegisterIndex = encoder->getCurrentRegister();
|
||||
linkedUniform->psRegisterIndex = sh::HLSLBlockEncoder::getBlockRegister(blockInfo);
|
||||
}
|
||||
else if (shader == GL_VERTEX_SHADER)
|
||||
{
|
||||
linkedUniform->vsRegisterIndex = encoder->getCurrentRegister();
|
||||
linkedUniform->vsRegisterIndex = sh::HLSLBlockEncoder::getBlockRegister(blockInfo);
|
||||
}
|
||||
else UNREACHABLE();
|
||||
|
||||
// Advance the uniform offset, to track registers allocation for structs
|
||||
encoder->encodeType(uniform.type, uniform.arraySize, false);
|
||||
|
||||
// Arrays are treated as aggregate types
|
||||
if (uniform.isArray())
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче