Commit 5b21ed5f by Jamie Madill

Revert "Implement dirty bits acceleration for VertexArrayGL."

Seems to cause an exception in Release, in end2end_tests. BUG=angleproject:1040 This reverts commit 6d51c70c. Change-Id: I6548bc68dce07d2d85e40afdb604157e689c1d6c Reviewed-on: https://chromium-review.googlesource.com/293821Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 6d51c70c
......@@ -1481,7 +1481,7 @@ void Context::detachSampler(GLuint sampler)
void Context::setVertexAttribDivisor(GLuint index, GLuint divisor)
{
mState.setVertexAttribDivisor(index, divisor);
mState.getVertexArray()->setVertexAttribDivisor(index, divisor);
}
void Context::samplerParameteri(GLuint sampler, GLenum pname, GLint param)
......
......@@ -846,8 +846,6 @@ bool State::removeDrawFramebufferBinding(GLuint framebuffer)
void State::setVertexArrayBinding(VertexArray *vertexArray)
{
mVertexArray = vertexArray;
mDirtyBits.set(DIRTY_BIT_VERTEX_ARRAY_BINDING);
mDirtyBits.set(DIRTY_BIT_VERTEX_ARRAY_OBJECT);
}
GLuint State::getVertexArrayId() const
......@@ -867,8 +865,6 @@ bool State::removeVertexArrayBinding(GLuint vertexArray)
if (mVertexArray->id() == vertexArray)
{
mVertexArray = NULL;
mDirtyBits.set(DIRTY_BIT_VERTEX_ARRAY_BINDING);
mDirtyBits.set(DIRTY_BIT_VERTEX_ARRAY_OBJECT);
return true;
}
......@@ -1055,7 +1051,6 @@ Buffer *State::getTargetBuffer(GLenum target) const
void State::setEnableVertexAttribArray(unsigned int attribNum, bool enabled)
{
getVertexArray()->enableAttribute(attribNum, enabled);
mDirtyBits.set(DIRTY_BIT_VERTEX_ARRAY_OBJECT);
}
void State::setVertexAttribf(GLuint index, const GLfloat values[4])
......@@ -1079,23 +1074,10 @@ void State::setVertexAttribi(GLuint index, const GLint values[4])
mDirtyBits.set(DIRTY_BIT_CURRENT_VALUE_0 + index);
}
void State::setVertexAttribState(unsigned int attribNum,
Buffer *boundBuffer,
GLint size,
GLenum type,
bool normalized,
bool pureInteger,
GLsizei stride,
const void *pointer)
void State::setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type, bool normalized,
bool pureInteger, GLsizei stride, const void *pointer)
{
getVertexArray()->setAttributeState(attribNum, boundBuffer, size, type, normalized, pureInteger, stride, pointer);
mDirtyBits.set(DIRTY_BIT_VERTEX_ARRAY_OBJECT);
}
void State::setVertexAttribDivisor(GLuint index, GLuint divisor)
{
getVertexArray()->setVertexAttribDivisor(index, divisor);
mDirtyBits.set(DIRTY_BIT_VERTEX_ARRAY_OBJECT);
}
const VertexAttribCurrentValueData &State::getVertexAttribCurrentValue(unsigned int attribNum) const
......
......@@ -226,7 +226,6 @@ class State : angle::NonCopyable
void setVertexAttribi(GLuint index, const GLint values[4]);
void setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type,
bool normalized, bool pureInteger, GLsizei stride, const void *pointer);
void setVertexAttribDivisor(GLuint index, GLuint divisor);
const VertexAttribCurrentValueData &getVertexAttribCurrentValue(unsigned int attribNum) const;
const void *getVertexAttribPointer(unsigned int attribNum) const;
......
......@@ -73,14 +73,12 @@ void VertexArray::setVertexAttribDivisor(size_t index, GLuint divisor)
{
ASSERT(index < getMaxAttribs());
mData.mVertexAttributes[index].divisor = divisor;
mDirtyBits.set(DIRTY_BIT_ATTRIB_0_DIVISOR + index);
}
void VertexArray::enableAttribute(size_t attributeIndex, bool enabledState)
{
ASSERT(attributeIndex < getMaxAttribs());
mData.mVertexAttributes[attributeIndex].enabled = enabledState;
mDirtyBits.set(DIRTY_BIT_ATTRIB_0_ENABLED + attributeIndex);
// Update state cache
if (enabledState)
......@@ -111,22 +109,11 @@ void VertexArray::setAttributeState(size_t attributeIndex, gl::Buffer *boundBuff
attrib->pureInteger = pureInteger;
attrib->stride = stride;
attrib->pointer = pointer;
mDirtyBits.set(DIRTY_BIT_ATTRIB_0_POINTER + attributeIndex);
}
void VertexArray::setElementArrayBuffer(Buffer *buffer)
{
mData.mElementArrayBuffer.set(buffer);
mDirtyBits.set(DIRTY_BIT_ELEMENT_ARRAY_BUFFER);
}
void VertexArray::syncImplState()
{
if (mDirtyBits.any())
{
mVertexArray->syncState(mDirtyBits);
mDirtyBits.reset();
}
}
}
......@@ -15,7 +15,6 @@
#include "libANGLE/RefCountObject.h"
#include "libANGLE/Constants.h"
#include "libANGLE/State.h"
#include "libANGLE/VertexAttribute.h"
#include <vector>
......@@ -30,9 +29,6 @@ namespace gl
{
class Buffer;
// Used in other places.
typedef std::bitset<MAX_VERTEX_ATTRIBS> AttributesMask;
class VertexArray
{
public:
......@@ -70,10 +66,6 @@ class VertexArray
size_t getMaxAttribs() const { return mVertexAttributes.size(); }
size_t getMaxEnabledAttribute() const { return mMaxEnabledAttribute; }
const std::vector<VertexAttribute> &getVertexAttributes() const { return mVertexAttributes; }
const VertexAttribute &getVertexAttribute(size_t index) const
{
return mVertexAttributes[index];
}
private:
friend class VertexArray;
......@@ -82,37 +74,12 @@ class VertexArray
size_t mMaxEnabledAttribute;
};
enum DirtyBitType
{
DIRTY_BIT_ELEMENT_ARRAY_BUFFER,
// Reserve bits for enabled flags
DIRTY_BIT_ATTRIB_0_ENABLED,
DIRTY_BIT_ATTRIB_MAX_ENABLED = DIRTY_BIT_ATTRIB_0_ENABLED + gl::MAX_VERTEX_ATTRIBS,
// Reserve bits for attrib pointers
DIRTY_BIT_ATTRIB_0_POINTER = DIRTY_BIT_ATTRIB_MAX_ENABLED,
DIRTY_BIT_ATTRIB_MAX_POINTER = DIRTY_BIT_ATTRIB_0_POINTER + gl::MAX_VERTEX_ATTRIBS,
// Reserve bits for divisors
DIRTY_BIT_ATTRIB_0_DIVISOR = DIRTY_BIT_ATTRIB_MAX_POINTER,
DIRTY_BIT_ATTRIB_MAX_DIVISOR = DIRTY_BIT_ATTRIB_0_DIVISOR + gl::MAX_VERTEX_ATTRIBS,
DIRTY_BIT_UNKNOWN = DIRTY_BIT_ATTRIB_MAX_DIVISOR,
DIRTY_BIT_MAX = DIRTY_BIT_UNKNOWN,
};
typedef std::bitset<DIRTY_BIT_MAX> DirtyBits;
void syncImplState();
private:
GLuint mId;
rx::VertexArrayImpl *mVertexArray;
Data mData;
DirtyBits mDirtyBits;
};
}
......
......@@ -21,7 +21,7 @@ class VertexArrayImpl : angle::NonCopyable
public:
VertexArrayImpl(const gl::VertexArray::Data &data) : mData(data) { }
virtual ~VertexArrayImpl() { }
virtual void syncState(const gl::VertexArray::DirtyBits &dirtyBits) {}
protected:
const gl::VertexArray::Data &mData;
};
......
......@@ -207,7 +207,7 @@ LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog,
// TODO: determine attribute precision
setShaderAttribute(static_cast<size_t>(i), attributeType, GL_NONE, attributeName, attributeSize, location);
mActiveAttributesMask.set(location);
mActiveAttributeLocations.push_back(location);
}
return LinkResult(true, gl::Error(GL_NO_ERROR));
......@@ -445,7 +445,7 @@ void ProgramGL::reset()
mSamplerUniformMap.clear();
mSamplerBindings.clear();
mActiveAttributesMask.reset();
mActiveAttributeLocations.clear();
}
GLuint ProgramGL::getProgramID() const
......@@ -458,9 +458,9 @@ const std::vector<SamplerBindingGL> &ProgramGL::getAppliedSamplerUniforms() cons
return mSamplerBindings;
}
const gl::AttributesMask &ProgramGL::getActiveAttributesMask() const
const std::vector<GLuint> &ProgramGL::getActiveAttributeLocations() const
{
return mActiveAttributesMask;
return mActiveAttributeLocations;
}
}
......@@ -95,7 +95,7 @@ class ProgramGL : public ProgramImpl
GLuint getProgramID() const;
const std::vector<SamplerBindingGL> &getAppliedSamplerUniforms() const;
const gl::AttributesMask &getActiveAttributesMask() const;
const std::vector<GLuint> &getActiveAttributeLocations() const;
private:
const FunctionsGL *mFunctions;
......@@ -113,7 +113,7 @@ class ProgramGL : public ProgramImpl
std::vector<SamplerBindingGL> mSamplerBindings;
// Array of attribute locations used by this program
gl::AttributesMask mActiveAttributesMask;
std::vector<GLuint> mActiveAttributeLocations;
GLuint mProgramID;
};
......
......@@ -383,8 +383,7 @@ gl::Error StateManagerGL::setDrawArraysState(const gl::Data &data, GLint first,
const gl::VertexArray *vao = state.getVertexArray();
const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(vao);
gl::Error error =
vaoGL->syncDrawArraysState(programGL->getActiveAttributesMask(), first, count);
gl::Error error = vaoGL->syncDrawArraysState(programGL->getActiveAttributeLocations(), first, count);
if (error.isError())
{
return error;
......@@ -406,8 +405,7 @@ gl::Error StateManagerGL::setDrawElementsState(const gl::Data &data, GLsizei cou
const gl::VertexArray *vao = state.getVertexArray();
const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(vao);
gl::Error error = vaoGL->syncDrawElementsState(programGL->getActiveAttributesMask(), count,
type, indices, outIndices);
gl::Error error = vaoGL->syncDrawElementsState(programGL->getActiveAttributeLocations(), count, type, indices, outIndices);
if (error.isError())
{
return error;
......@@ -1081,7 +1079,7 @@ void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBit
// TODO(jmadill): implement this
break;
case gl::State::DIRTY_BIT_VERTEX_ARRAY_OBJECT:
state.getVertexArray()->syncImplState();
// TODO(jmadill): implement this
break;
case gl::State::DIRTY_BIT_PROGRAM_BINDING:
// TODO(jmadill): implement this
......
......@@ -23,46 +23,33 @@ class VertexArrayGL : public VertexArrayImpl
VertexArrayGL(const gl::VertexArray::Data &data, const FunctionsGL *functions, StateManagerGL *stateManager);
~VertexArrayGL() override;
gl::Error syncDrawArraysState(const gl::AttributesMask &activeAttributesMask,
GLint first,
GLsizei count) const;
gl::Error syncDrawElementsState(const gl::AttributesMask &activeAttributesMask,
GLsizei count,
GLenum type,
const GLvoid *indices,
const GLvoid **outIndices) 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,
const GLvoid *indices, const GLvoid **outIndices) const;
GLuint getVertexArrayID() const;
GLuint getAppliedElementArrayBufferID() const;
void syncState(const gl::VertexArray::DirtyBits &dirtyBits) override;
private:
gl::Error syncDrawState(const gl::AttributesMask &activeAttributesMask,
GLint first,
GLsizei count,
GLenum type,
const GLvoid *indices,
const GLvoid **outIndices) const;
gl::Error syncDrawState(const std::vector<GLuint> &activeAttribLoations, GLint first, GLsizei count,
GLenum type, const GLvoid *indices, const GLvoid **outIndices) const;
// Check if any vertex attributes need to be streamed
bool doAttributesNeedStreaming(const std::vector<GLuint> &activeAttribLoations) const;
// Apply attribute state, returns the amount of space needed to stream all attributes that need streaming
// and the data size of the largest attribute
gl::Error syncAttributeState(const std::vector<GLuint> &activeAttribLoations, bool attributesNeedStreaming,
const gl::RangeUI &indexRange, size_t *outStreamingDataSize,
size_t *outMaxAttributeDataSize) const;
// Apply index data, only sets outIndexRange if attributesNeedStreaming is true
gl::Error syncIndexData(GLsizei count, GLenum type, const GLvoid *indices, bool attributesNeedStreaming,
gl::RangeUI *outIndexRange, const GLvoid **outIndices) const;
// Returns the amount of space needed to stream all attributes that need streaming
// and the data size of the largest attribute
void computeStreamingAttributeSizes(const gl::AttributesMask &activeAttributesMask,
const gl::RangeUI &indexRange,
size_t *outStreamingDataSize,
size_t *outMaxAttributeDataSize) const;
// Stream attributes that have client data
gl::Error streamAttributes(const gl::AttributesMask &activeAttributesMask,
const gl::RangeUI &indexRange) const;
void updateNeedsStreaming(size_t attribIndex);
void updateAttribEnabled(size_t attribIndex);
void updateAttribPointer(size_t attribIndex);
gl::Error streamAttributes(const std::vector<GLuint> &activeAttribLoations, size_t streamingDataSize,
size_t maxAttributeDataSize, const gl::RangeUI &indexRange) const;
const FunctionsGL *mFunctions;
StateManagerGL *mStateManager;
......@@ -77,8 +64,6 @@ class VertexArrayGL : public VertexArrayImpl
mutable size_t mStreamingArrayBufferSize;
mutable GLuint mStreamingArrayBuffer;
gl::AttributesMask mAttributesNeedStreaming;
};
}
......
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