Commit 3f2daa89 by Al Patrick Committed by Shannon Woods

Presort reverse mapping of ProgramBinary::mSemanticIndex.

parent b11713fb
......@@ -1660,6 +1660,8 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
stream.read(&mSemanticIndex[i]);
}
initAttributesByLayout();
for (unsigned int i = 0; i < MAX_TEXTURE_IMAGE_UNITS; ++i)
{
stream.read(&mSamplersPS[i].active);
......@@ -2162,6 +2164,8 @@ bool ProgramBinary::linkAttributes(InfoLog &infoLog, const AttributeBindings &at
}
}
initAttributesByLayout();
return true;
}
......@@ -3212,12 +3216,6 @@ struct AttributeSorter
AttributeSorter(const int (&semanticIndices)[MAX_VERTEX_ATTRIBS])
: originalIndices(semanticIndices)
{
for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
indices[i] = i;
}
std::sort(&indices[0], &indices[MAX_VERTEX_ATTRIBS], *this);
}
bool operator()(int a, int b)
......@@ -3225,27 +3223,32 @@ struct AttributeSorter
return originalIndices[a] == -1 ? false : originalIndices[a] < originalIndices[b];
}
int indices[MAX_VERTEX_ATTRIBS];
const int (&originalIndices)[MAX_VERTEX_ATTRIBS];
};
void ProgramBinary::sortAttributesByLayout(rx::TranslatedAttribute attributes[MAX_VERTEX_ATTRIBS], int sortedSemanticIndices[MAX_VERTEX_ATTRIBS]) const
void ProgramBinary::initAttributesByLayout()
{
AttributeSorter sorter(mSemanticIndex);
for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
mAttributesByLayout[i] = i;
}
std::sort(&mAttributesByLayout[0], &mAttributesByLayout[MAX_VERTEX_ATTRIBS], AttributeSorter(mSemanticIndex));
}
int oldIndices[MAX_VERTEX_ATTRIBS];
void ProgramBinary::sortAttributesByLayout(rx::TranslatedAttribute attributes[MAX_VERTEX_ATTRIBS], int sortedSemanticIndices[MAX_VERTEX_ATTRIBS]) const
{
rx::TranslatedAttribute oldTranslatedAttributes[MAX_VERTEX_ATTRIBS];
for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
oldIndices[i] = mSemanticIndex[i];
oldTranslatedAttributes[i] = attributes[i];
}
for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
int oldIndex = sorter.indices[i];
sortedSemanticIndices[i] = oldIndices[oldIndex];
int oldIndex = mAttributesByLayout[i];
sortedSemanticIndices[i] = mSemanticIndex[oldIndex];
attributes[i] = oldTranslatedAttributes[oldIndex];
}
}
......
......@@ -140,6 +140,7 @@ class ProgramBinary : public RefCountObject
unsigned int getSerial() const;
int getShaderVersion() const;
void initAttributesByLayout();
void sortAttributesByLayout(rx::TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS], int sortedSemanticIndices[MAX_VERTEX_ATTRIBS]) const;
static std::string decorateAttribute(const std::string &name); // Prepend an underscore
......@@ -195,6 +196,7 @@ class ProgramBinary : public RefCountObject
sh::Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS];
int mSemanticIndex[MAX_VERTEX_ATTRIBS];
int mAttributesByLayout[MAX_VERTEX_ATTRIBS];
struct Sampler
{
......
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