Revert "Move shader attributes into Program shared data."
Once again a signed/unsigned mismatch warning in 32-bit.
src\libangle\renderer\gl\programgl.cpp(190) : warning C4018: '<' : signed/unsigned mismatch
BUG=angleproject:1123
This reverts commit 2d7731838722a53102e5086dba445e37f6e98d7e.
Change-Id: Icd26906ead1eaa06b4bd3ff7fc2b10bef4f46022
Reviewed-on: https://chromium-review.googlesource.com/295241
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/ProgramImpl.cpp b/src/libANGLE/renderer/ProgramImpl.cpp
index 03d3c7c..b0fd8f9 100644
--- a/src/libANGLE/renderer/ProgramImpl.cpp
+++ b/src/libANGLE/renderer/ProgramImpl.cpp
@@ -135,4 +135,26 @@
SafeDeleteContainer(mUniformBlocks);
}
+void ProgramImpl::setShaderAttribute(size_t index, const sh::Attribute &attrib)
+{
+ if (mShaderAttributes.size() <= index)
+ {
+ mShaderAttributes.resize(index + 1);
+ }
+ mShaderAttributes[index] = attrib;
+}
+
+void ProgramImpl::setShaderAttribute(size_t index, GLenum type, GLenum precision, const std::string &name, GLint size, int location)
+{
+ if (mShaderAttributes.size() <= index)
+ {
+ mShaderAttributes.resize(index + 1);
+ }
+ mShaderAttributes[index].type = type;
+ mShaderAttributes[index].precision = precision;
+ mShaderAttributes[index].name = name;
+ mShaderAttributes[index].arraySize = size;
+ mShaderAttributes[index].location = location;
+}
+
}
diff --git a/src/libANGLE/renderer/ProgramImpl.h b/src/libANGLE/renderer/ProgramImpl.h
index d2f7041..e1bb357 100644
--- a/src/libANGLE/renderer/ProgramImpl.h
+++ b/src/libANGLE/renderer/ProgramImpl.h
@@ -85,6 +85,7 @@
const std::vector<gl::LinkedUniform*> &getUniforms() const { return mUniforms; }
const std::map<GLuint, gl::VariableLocation> &getUniformIndices() const { return mUniformIndex; }
const std::vector<gl::UniformBlock*> &getUniformBlocks() const { return mUniformBlocks; }
+ const std::vector<sh::Attribute> getShaderAttributes() { return mShaderAttributes; }
const SemanticIndexArray &getSemanticIndexes() const { return mSemanticIndex; }
std::vector<gl::LinkedUniform*> &getUniforms() { return mUniforms; }
@@ -100,6 +101,9 @@
GLuint getUniformIndex(const std::string &name) const;
GLuint getUniformBlockIndex(const std::string &name) const;
+ void setShaderAttribute(size_t index, const sh::Attribute &attrib);
+ void setShaderAttribute(size_t index, GLenum type, GLenum precision, const std::string &name, GLint size, int location);
+
virtual void reset();
protected:
@@ -113,6 +117,9 @@
std::vector<gl::UniformBlock*> mUniformBlocks;
SemanticIndexArray mSemanticIndex;
+
+ private:
+ std::vector<sh::Attribute> mShaderAttributes;
};
}
diff --git a/src/libANGLE/renderer/d3d/ProgramD3D.cpp b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
index e4f7d54..c41dc78 100644
--- a/src/libANGLE/renderer/d3d/ProgramD3D.cpp
+++ b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
@@ -1003,8 +1003,7 @@
}
// Generate new dynamic layout with attribute conversions
- std::string finalVertexHLSL = mDynamicHLSL->generateVertexShaderForInputLayout(
- mVertexHLSL, inputLayout, mData.getAttributes());
+ std::string finalVertexHLSL = mDynamicHLSL->generateVertexShaderForInputLayout(mVertexHLSL, inputLayout, getShaderAttributes());
// Generate new vertex executable
ShaderExecutableD3D *vertexExecutable = NULL;
diff --git a/src/libANGLE/renderer/d3d/ProgramD3D.h b/src/libANGLE/renderer/d3d/ProgramD3D.h
index 7207d8c..17f7c3d 100644
--- a/src/libANGLE/renderer/d3d/ProgramD3D.h
+++ b/src/libANGLE/renderer/d3d/ProgramD3D.h
@@ -124,7 +124,6 @@
void sortAttributesByLayout(const std::vector<TranslatedAttribute> &unsortedAttributes,
int sortedSemanticIndicesOut[gl::MAX_VERTEX_ATTRIBS],
const rx::TranslatedAttribute *sortedAttributesOut[gl::MAX_VERTEX_ATTRIBS]) const;
- const SemanticIndexArray &getAttributesByLayout() const { return mAttributesByLayout; }
void updateCachedInputLayout(const gl::Program *program, const gl::State &state);
const gl::InputLayout &getCachedInputLayout() const { return mCachedInputLayout; }
@@ -246,7 +245,7 @@
int mShaderVersion;
- SemanticIndexArray mAttributesByLayout;
+ int mAttributesByLayout[gl::MAX_VERTEX_ATTRIBS];
unsigned int mSerial;
diff --git a/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.cpp b/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.cpp
index bae230c..67c59a3 100644
--- a/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.cpp
@@ -46,20 +46,20 @@
return inputLayout;
}
-GLenum GetGLSLAttributeType(const std::vector<sh::Attribute> &shaderAttributes, int index)
+GLenum GetNextGLSLAttributeType(const std::vector<sh::Attribute> &linkedAttributes, int index)
{
// Count matrices differently
- for (const sh::Attribute &attrib : shaderAttributes)
+ int subIndex = 0;
+ for (const sh::Attribute &attrib : linkedAttributes)
{
- if (attrib.location == -1)
+ if (attrib.type == GL_NONE)
{
continue;
}
GLenum transposedType = gl::TransposeMatrixType(attrib.type);
- int rows = gl::VariableRowCount(transposedType);
-
- if (index >= attrib.location && index < attrib.location + rows)
+ subIndex += gl::VariableRowCount(transposedType);
+ if (subIndex > index)
{
return transposedType;
}
@@ -185,8 +185,6 @@
bool instancedPointSpritesActive = programUsesInstancedPointSprites && (mode == GL_POINTS);
bool indexedPointSpriteEmulationActive = instancedPointSpritesActive && (sourceInfo != nullptr);
- const auto &semanticToLocation = programD3D->getAttributesByLayout();
-
if (!mDevice || !mDeviceContext)
{
return gl::Error(GL_OUT_OF_MEMORY, "Internal input layout cache is not initialized.");
@@ -202,7 +200,7 @@
unsigned int firstInstancedElement = gl::MAX_VERTEX_ATTRIBS;
unsigned int nextAvailableInputSlot = 0;
- const std::vector<sh::Attribute> &shaderAttributes = program->getAttributes();
+ const std::vector<sh::Attribute> &linkedAttributes = program->getLinkedAttributes();
for (unsigned int i = 0; i < unsortedAttributes.size(); i++)
{
@@ -234,8 +232,7 @@
// Record the type of the associated vertex shader vector in our key
// This will prevent mismatched vertex shaders from using the same input layout
- GLenum glslElementType = GetGLSLAttributeType(
- shaderAttributes, semanticToLocation[sortedSemanticIndices[i]]);
+ GLenum glslElementType = GetNextGLSLAttributeType(linkedAttributes, inputElementCount);
layout.addAttributeData(glslElementType,
sortedSemanticIndices[i],
diff --git a/src/libANGLE/renderer/gl/ProgramGL.cpp b/src/libANGLE/renderer/gl/ProgramGL.cpp
index 1a070b6..56fed09 100644
--- a/src/libANGLE/renderer/gl/ProgramGL.cpp
+++ b/src/libANGLE/renderer/gl/ProgramGL.cpp
@@ -169,33 +169,34 @@
}
}
- for (const sh::Attribute &attribute : mData.getAttributes())
+ // Query the attribute information
+ GLint activeAttributeMaxLength = 0;
+ mFunctions->getProgramiv(mProgramID, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &activeAttributeMaxLength);
+
+ std::vector<GLchar> attributeNameBuffer(activeAttributeMaxLength);
+
+ GLint attributeCount = 0;
+ mFunctions->getProgramiv(mProgramID, GL_ACTIVE_ATTRIBUTES, &attributeCount);
+ for (GLint i = 0; i < attributeCount; i++)
{
- if (!attribute.staticUse)
- continue;
+ GLsizei attributeNameLength = 0;
+ GLint attributeSize = 0;
+ GLenum attributeType = GL_NONE;
+ mFunctions->getActiveAttrib(mProgramID, i, static_cast<GLsizei>(attributeNameBuffer.size()),
+ &attributeNameLength, &attributeSize, &attributeType,
+ &attributeNameBuffer[0]);
- GLint realLocation = mFunctions->getAttribLocation(mProgramID, attribute.name.c_str());
+ std::string attributeName(&attributeNameBuffer[0], attributeNameLength);
- // Some drivers optimize attributes more aggressively.
- if (realLocation == -1)
+ GLint location = mFunctions->getAttribLocation(mProgramID, attributeName.c_str());
+
+ // TODO: determine attribute precision
+ setShaderAttribute(static_cast<size_t>(i), attributeType, GL_NONE, attributeName, attributeSize, location);
+
+ int attributeRegisterCount = gl::VariableRegisterCount(attributeType);
+ for (int offset = 0; offset < attributeRegisterCount; offset++)
{
- continue;
- }
-
- // TODO(jmadill): Fix this
- ASSERT(attribute.location == realLocation);
-
- int registerCount = gl::VariableRegisterCount(attribute.type);
-
- if (mAttributeRealLocations.size() < attribute.location + registerCount + 1)
- {
- mAttributeRealLocations.resize(attribute.location + registerCount + 1, -1);
- }
-
- for (int offset = 0; offset < registerCount; ++offset)
- {
- mActiveAttributesMask.set(attribute.location + offset);
- mAttributeRealLocations[attribute.location + offset] = realLocation + offset;
+ mActiveAttributesMask.set(location + offset);
}
}
@@ -377,7 +378,6 @@
mSamplerUniformMap.clear();
mSamplerBindings.clear();
mActiveAttributesMask.reset();
- mAttributeRealLocations.clear();
}
GLuint ProgramGL::getProgramID() const
diff --git a/src/libANGLE/renderer/gl/ProgramGL.h b/src/libANGLE/renderer/gl/ProgramGL.h
index c900c09..ec4eaa6 100644
--- a/src/libANGLE/renderer/gl/ProgramGL.h
+++ b/src/libANGLE/renderer/gl/ProgramGL.h
@@ -101,9 +101,6 @@
// An array of the samplers that are used by the program
std::vector<SamplerBindingGL> mSamplerBindings;
- // Map from GL-layer attribute location to native location.
- std::vector<GLint> mAttributeRealLocations;
-
// Array of attribute locations used by this program
gl::AttributesMask mActiveAttributesMask;