Commit 2e5b500c by Geoff Lang

Revert "Store the applied element array buffer as a binding pointer."

This reverts commit 0018c85e. Change-Id: Ieab61c0a4cd1b24d606263e9bf2bae31ea2e8ac4 Reviewed-on: https://chromium-review.googlesource.com/289486Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 0018c85e
...@@ -54,12 +54,14 @@ void VertexArray::detachBuffer(GLuint bufferName) ...@@ -54,12 +54,14 @@ void VertexArray::detachBuffer(GLuint bufferName)
if (mData.mVertexAttributes[attribute].buffer.id() == bufferName) if (mData.mVertexAttributes[attribute].buffer.id() == bufferName)
{ {
mData.mVertexAttributes[attribute].buffer.set(nullptr); mData.mVertexAttributes[attribute].buffer.set(nullptr);
mVertexArray->setAttribute(attribute, mData.mVertexAttributes[attribute]);
} }
} }
if (mData.mElementArrayBuffer.id() == bufferName) if (mData.mElementArrayBuffer.id() == bufferName)
{ {
mData.mElementArrayBuffer.set(nullptr); mData.mElementArrayBuffer.set(nullptr);
mVertexArray->setElementArrayBuffer(nullptr);
} }
} }
...@@ -73,12 +75,14 @@ void VertexArray::setVertexAttribDivisor(size_t index, GLuint divisor) ...@@ -73,12 +75,14 @@ void VertexArray::setVertexAttribDivisor(size_t index, GLuint divisor)
{ {
ASSERT(index < getMaxAttribs()); ASSERT(index < getMaxAttribs());
mData.mVertexAttributes[index].divisor = divisor; mData.mVertexAttributes[index].divisor = divisor;
mVertexArray->setAttributeDivisor(index, divisor);
} }
void VertexArray::enableAttribute(size_t attributeIndex, bool enabledState) void VertexArray::enableAttribute(size_t attributeIndex, bool enabledState)
{ {
ASSERT(attributeIndex < getMaxAttribs()); ASSERT(attributeIndex < getMaxAttribs());
mData.mVertexAttributes[attributeIndex].enabled = enabledState; mData.mVertexAttributes[attributeIndex].enabled = enabledState;
mVertexArray->enableAttribute(attributeIndex, enabledState);
// Update state cache // Update state cache
if (enabledState) if (enabledState)
...@@ -109,11 +113,14 @@ void VertexArray::setAttributeState(size_t attributeIndex, gl::Buffer *boundBuff ...@@ -109,11 +113,14 @@ void VertexArray::setAttributeState(size_t attributeIndex, gl::Buffer *boundBuff
attrib->pureInteger = pureInteger; attrib->pureInteger = pureInteger;
attrib->stride = stride; attrib->stride = stride;
attrib->pointer = pointer; attrib->pointer = pointer;
mVertexArray->setAttribute(attributeIndex, *attrib);
} }
void VertexArray::setElementArrayBuffer(Buffer *buffer) void VertexArray::setElementArrayBuffer(Buffer *buffer)
{ {
mData.mElementArrayBuffer.set(buffer); mData.mElementArrayBuffer.set(buffer);
mVertexArray->setElementArrayBuffer(buffer);
} }
} }
...@@ -22,6 +22,11 @@ class VertexArrayImpl : angle::NonCopyable ...@@ -22,6 +22,11 @@ class VertexArrayImpl : angle::NonCopyable
VertexArrayImpl(const gl::VertexArray::Data &data) : mData(data) { } VertexArrayImpl(const gl::VertexArray::Data &data) : mData(data) { }
virtual ~VertexArrayImpl() { } virtual ~VertexArrayImpl() { }
virtual void setElementArrayBuffer(const gl::Buffer *buffer) = 0;
virtual void setAttribute(size_t idx, const gl::VertexAttribute &attr) = 0;
virtual void setAttributeDivisor(size_t idx, GLuint divisor) = 0;
virtual void enableAttribute(size_t idx, bool enabledState) = 0;
protected: protected:
const gl::VertexArray::Data &mData; const gl::VertexArray::Data &mData;
}; };
......
...@@ -23,7 +23,12 @@ class VertexArray11 : public VertexArrayImpl ...@@ -23,7 +23,12 @@ class VertexArray11 : public VertexArrayImpl
: VertexArrayImpl(data) : VertexArrayImpl(data)
{ {
} }
virtual ~VertexArray11() {} virtual ~VertexArray11() { }
virtual void setElementArrayBuffer(const gl::Buffer *buffer) { }
virtual void setAttribute(size_t idx, const gl::VertexAttribute &attr) { }
virtual void setAttributeDivisor(size_t idx, GLuint divisor) { }
virtual void enableAttribute(size_t idx, bool enabledState) { }
}; };
} }
......
...@@ -25,6 +25,11 @@ class VertexArray9 : public VertexArrayImpl ...@@ -25,6 +25,11 @@ class VertexArray9 : public VertexArrayImpl
} }
virtual ~VertexArray9() { } virtual ~VertexArray9() { }
virtual void setElementArrayBuffer(const gl::Buffer *buffer) { }
virtual void setAttribute(size_t idx, const gl::VertexAttribute &attr) { }
virtual void setAttributeDivisor(size_t idx, GLuint divisor) { }
virtual void enableAttribute(size_t idx, bool enabledState) { }
}; };
} }
......
...@@ -26,7 +26,7 @@ VertexArrayGL::VertexArrayGL(const gl::VertexArray::Data &data, const FunctionsG ...@@ -26,7 +26,7 @@ VertexArrayGL::VertexArrayGL(const gl::VertexArray::Data &data, const FunctionsG
mFunctions(functions), mFunctions(functions),
mStateManager(stateManager), mStateManager(stateManager),
mVertexArrayID(0), mVertexArrayID(0),
mAppliedElementArrayBuffer(), mAppliedElementArrayBuffer(0),
mStreamingElementArrayBufferSize(0), mStreamingElementArrayBufferSize(0),
mStreamingElementArrayBuffer(0), mStreamingElementArrayBuffer(0),
mStreamingArrayBufferSize(0), mStreamingArrayBufferSize(0),
...@@ -55,13 +55,34 @@ VertexArrayGL::~VertexArrayGL() ...@@ -55,13 +55,34 @@ VertexArrayGL::~VertexArrayGL()
mStreamingArrayBufferSize = 0; mStreamingArrayBufferSize = 0;
mStreamingArrayBuffer = 0; mStreamingArrayBuffer = 0;
mAppliedElementArrayBuffer.set(nullptr);
for (size_t idx = 0; idx < mAppliedAttributes.size(); idx++) for (size_t idx = 0; idx < mAppliedAttributes.size(); idx++)
{ {
mAppliedAttributes[idx].buffer.set(nullptr); mAppliedAttributes[idx].buffer.set(nullptr);
} }
} }
void VertexArrayGL::setElementArrayBuffer(const gl::Buffer *buffer)
{
// If the buffer is being unbound/deleted, reset the currently applied buffer ID
// so that even if a new buffer is generated with the same ID, it will be re-bound.
if (buffer == nullptr && mAppliedElementArrayBuffer != mStreamingElementArrayBuffer)
{
mAppliedElementArrayBuffer = 0;
}
}
void VertexArrayGL::setAttribute(size_t idx, const gl::VertexAttribute &attr)
{
}
void VertexArrayGL::setAttributeDivisor(size_t idx, GLuint divisor)
{
}
void VertexArrayGL::enableAttribute(size_t idx, bool enabledState)
{
}
gl::Error VertexArrayGL::syncDrawArraysState(const std::vector<GLuint> &activeAttribLocations, GLint first, GLsizei count) const gl::Error VertexArrayGL::syncDrawArraysState(const std::vector<GLuint> &activeAttribLocations, GLint first, GLsizei count) const
{ {
return syncDrawState(activeAttribLocations, first, count, GL_NONE, nullptr, nullptr); return syncDrawState(activeAttribLocations, first, count, GL_NONE, nullptr, nullptr);
...@@ -75,7 +96,7 @@ gl::Error VertexArrayGL::syncDrawElementsState(const std::vector<GLuint> &active ...@@ -75,7 +96,7 @@ gl::Error VertexArrayGL::syncDrawElementsState(const std::vector<GLuint> &active
gl::Error VertexArrayGL::syncDrawState(const std::vector<GLuint> &activeAttribLocations, GLint first, GLsizei count, GLenum type, const GLvoid *indices, const GLvoid **outIndices) const gl::Error VertexArrayGL::syncDrawState(const std::vector<GLuint> &activeAttribLocations, GLint first, GLsizei count, GLenum type, const GLvoid *indices, const GLvoid **outIndices) const
{ {
mStateManager->bindVertexArray(mVertexArrayID, getAppliedElementArrayBufferID()); mStateManager->bindVertexArray(mVertexArrayID, mAppliedElementArrayBuffer);
// Check if any attributes need to be streamed, determines if the index range needs to be computed // Check if any attributes need to be streamed, determines if the index range needs to be computed
bool attributesNeedStreaming = doAttributesNeedStreaming(activeAttribLocations); bool attributesNeedStreaming = doAttributesNeedStreaming(activeAttribLocations);
...@@ -229,11 +250,12 @@ gl::Error VertexArrayGL::syncIndexData(GLsizei count, GLenum type, const GLvoid ...@@ -229,11 +250,12 @@ gl::Error VertexArrayGL::syncIndexData(GLsizei count, GLenum type, const GLvoid
// Need to check the range of indices if attributes need to be streamed // Need to check the range of indices if attributes need to be streamed
if (elementArrayBuffer != nullptr) if (elementArrayBuffer != nullptr)
{ {
if (elementArrayBuffer != mAppliedElementArrayBuffer.get()) const BufferGL *bufferGL = GetImplAs<BufferGL>(elementArrayBuffer);
GLuint elementArrayBufferID = bufferGL->getBufferID();
if (elementArrayBufferID != mAppliedElementArrayBuffer)
{ {
const BufferGL *bufferGL = GetImplAs<BufferGL>(elementArrayBuffer); mStateManager->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementArrayBufferID);
mStateManager->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferGL->getBufferID()); mAppliedElementArrayBuffer = elementArrayBufferID;
mAppliedElementArrayBuffer.set(elementArrayBuffer);
} }
// Only compute the index range if the attributes also need to be streamed // Only compute the index range if the attributes also need to be streamed
...@@ -269,7 +291,7 @@ gl::Error VertexArrayGL::syncIndexData(GLsizei count, GLenum type, const GLvoid ...@@ -269,7 +291,7 @@ gl::Error VertexArrayGL::syncIndexData(GLsizei count, GLenum type, const GLvoid
} }
mStateManager->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, mStreamingElementArrayBuffer); mStateManager->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, mStreamingElementArrayBuffer);
mAppliedElementArrayBuffer.set(nullptr); mAppliedElementArrayBuffer = mStreamingElementArrayBuffer;
// Make sure the element array buffer is large enough // Make sure the element array buffer is large enough
const gl::Type &indexTypeInfo = gl::GetTypeInfo(type); const gl::Type &indexTypeInfo = gl::GetTypeInfo(type);
...@@ -392,8 +414,7 @@ GLuint VertexArrayGL::getVertexArrayID() const ...@@ -392,8 +414,7 @@ GLuint VertexArrayGL::getVertexArrayID() const
GLuint VertexArrayGL::getAppliedElementArrayBufferID() const GLuint VertexArrayGL::getAppliedElementArrayBufferID() const
{ {
return mAppliedElementArrayBuffer.get() == nullptr ? mStreamingElementArrayBuffer return mAppliedElementArrayBuffer;
: mAppliedElementArrayBuffer.id();
} }
} }
...@@ -23,6 +23,11 @@ class VertexArrayGL : public VertexArrayImpl ...@@ -23,6 +23,11 @@ class VertexArrayGL : public VertexArrayImpl
VertexArrayGL(const gl::VertexArray::Data &data, const FunctionsGL *functions, StateManagerGL *stateManager); VertexArrayGL(const gl::VertexArray::Data &data, const FunctionsGL *functions, StateManagerGL *stateManager);
~VertexArrayGL() override; ~VertexArrayGL() override;
void setElementArrayBuffer(const gl::Buffer *buffer) override;
void setAttribute(size_t idx, const gl::VertexAttribute &attr) override;
void setAttributeDivisor(size_t idx, GLuint divisor) override;
void enableAttribute(size_t idx, bool enabledState) override;
gl::Error syncDrawArraysState(const std::vector<GLuint> &activeAttribLoations, GLint first, GLsizei count) const; gl::Error syncDrawArraysState(const std::vector<GLuint> &activeAttribLoations, GLint first, GLsizei count) const;
gl::Error syncDrawElementsState(const std::vector<GLuint> &activeAttribLoations, GLsizei count, GLenum type, gl::Error syncDrawElementsState(const std::vector<GLuint> &activeAttribLoations, GLsizei count, GLenum type,
const GLvoid *indices, const GLvoid **outIndices) const; const GLvoid *indices, const GLvoid **outIndices) const;
...@@ -56,7 +61,7 @@ class VertexArrayGL : public VertexArrayImpl ...@@ -56,7 +61,7 @@ class VertexArrayGL : public VertexArrayImpl
GLuint mVertexArrayID; GLuint mVertexArrayID;
mutable BindingPointer<gl::Buffer> mAppliedElementArrayBuffer; mutable GLuint mAppliedElementArrayBuffer;
mutable std::vector<gl::VertexAttribute> mAppliedAttributes; mutable std::vector<gl::VertexAttribute> mAppliedAttributes;
mutable size_t mStreamingElementArrayBufferSize; mutable size_t mStreamingElementArrayBufferSize;
......
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