Commit 3f572680 by Jamie Madill Committed by Commit Bot

Rename gl::VertexArray::Data to gl::VertexArrayState.

BUG=angleproject:1363 Change-Id: I5acf670bd88988941676cc9bc75606d55cca224e Reviewed-on: https://chromium-review.googlesource.com/340744Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 15243d9b
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
namespace gl namespace gl
{ {
VertexArray::Data::Data(size_t maxAttribs) VertexArrayState::VertexArrayState(size_t maxAttribs)
: mLabel(), mVertexAttributes(maxAttribs), mMaxEnabledAttribute(0) : mLabel(), mVertexAttributes(maxAttribs), mMaxEnabledAttribute(0)
{ {
} }
VertexArray::Data::~Data() VertexArrayState::~VertexArrayState()
{ {
for (size_t i = 0; i < getMaxAttribs(); i++) for (size_t i = 0; i < getMaxAttribs(); i++)
{ {
...@@ -29,7 +29,7 @@ VertexArray::Data::~Data() ...@@ -29,7 +29,7 @@ VertexArray::Data::~Data()
} }
VertexArray::VertexArray(rx::ImplFactory *factory, GLuint id, size_t maxAttribs) VertexArray::VertexArray(rx::ImplFactory *factory, GLuint id, size_t maxAttribs)
: mId(id), mData(maxAttribs), mVertexArray(factory->createVertexArray(mData)) : mId(id), mState(maxAttribs), mVertexArray(factory->createVertexArray(mState))
{ {
} }
...@@ -45,60 +45,60 @@ GLuint VertexArray::id() const ...@@ -45,60 +45,60 @@ GLuint VertexArray::id() const
void VertexArray::setLabel(const std::string &label) void VertexArray::setLabel(const std::string &label)
{ {
mData.mLabel = label; mState.mLabel = label;
} }
const std::string &VertexArray::getLabel() const const std::string &VertexArray::getLabel() const
{ {
return mData.mLabel; return mState.mLabel;
} }
void VertexArray::detachBuffer(GLuint bufferName) void VertexArray::detachBuffer(GLuint bufferName)
{ {
for (size_t attribute = 0; attribute < getMaxAttribs(); attribute++) for (size_t attribute = 0; attribute < getMaxAttribs(); attribute++)
{ {
if (mData.mVertexAttributes[attribute].buffer.id() == bufferName) if (mState.mVertexAttributes[attribute].buffer.id() == bufferName)
{ {
mData.mVertexAttributes[attribute].buffer.set(nullptr); mState.mVertexAttributes[attribute].buffer.set(nullptr);
} }
} }
if (mData.mElementArrayBuffer.id() == bufferName) if (mState.mElementArrayBuffer.id() == bufferName)
{ {
mData.mElementArrayBuffer.set(nullptr); mState.mElementArrayBuffer.set(nullptr);
} }
} }
const VertexAttribute &VertexArray::getVertexAttribute(size_t attributeIndex) const const VertexAttribute &VertexArray::getVertexAttribute(size_t attributeIndex) const
{ {
ASSERT(attributeIndex < getMaxAttribs()); ASSERT(attributeIndex < getMaxAttribs());
return mData.mVertexAttributes[attributeIndex]; return mState.mVertexAttributes[attributeIndex];
} }
void VertexArray::setVertexAttribDivisor(size_t index, GLuint divisor) void VertexArray::setVertexAttribDivisor(size_t index, GLuint divisor)
{ {
ASSERT(index < getMaxAttribs()); ASSERT(index < getMaxAttribs());
mData.mVertexAttributes[index].divisor = divisor; mState.mVertexAttributes[index].divisor = divisor;
mDirtyBits.set(DIRTY_BIT_ATTRIB_0_DIVISOR + index); mDirtyBits.set(DIRTY_BIT_ATTRIB_0_DIVISOR + index);
} }
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; mState.mVertexAttributes[attributeIndex].enabled = enabledState;
mDirtyBits.set(DIRTY_BIT_ATTRIB_0_ENABLED + attributeIndex); mDirtyBits.set(DIRTY_BIT_ATTRIB_0_ENABLED + attributeIndex);
// Update state cache // Update state cache
if (enabledState) if (enabledState)
{ {
mData.mMaxEnabledAttribute = std::max(attributeIndex + 1, mData.mMaxEnabledAttribute); mState.mMaxEnabledAttribute = std::max(attributeIndex + 1, mState.mMaxEnabledAttribute);
} }
else if (mData.mMaxEnabledAttribute == attributeIndex + 1) else if (mState.mMaxEnabledAttribute == attributeIndex + 1)
{ {
while (mData.mMaxEnabledAttribute > 0 && while (mState.mMaxEnabledAttribute > 0 &&
!mData.mVertexAttributes[mData.mMaxEnabledAttribute - 1].enabled) !mState.mVertexAttributes[mState.mMaxEnabledAttribute - 1].enabled)
{ {
--mData.mMaxEnabledAttribute; --mState.mMaxEnabledAttribute;
} }
} }
} }
...@@ -108,7 +108,7 @@ void VertexArray::setAttributeState(size_t attributeIndex, gl::Buffer *boundBuff ...@@ -108,7 +108,7 @@ void VertexArray::setAttributeState(size_t attributeIndex, gl::Buffer *boundBuff
{ {
ASSERT(attributeIndex < getMaxAttribs()); ASSERT(attributeIndex < getMaxAttribs());
VertexAttribute *attrib = &mData.mVertexAttributes[attributeIndex]; VertexAttribute *attrib = &mState.mVertexAttributes[attributeIndex];
attrib->buffer.set(boundBuffer); attrib->buffer.set(boundBuffer);
attrib->size = size; attrib->size = size;
...@@ -122,7 +122,7 @@ void VertexArray::setAttributeState(size_t attributeIndex, gl::Buffer *boundBuff ...@@ -122,7 +122,7 @@ void VertexArray::setAttributeState(size_t attributeIndex, gl::Buffer *boundBuff
void VertexArray::setElementArrayBuffer(Buffer *buffer) void VertexArray::setElementArrayBuffer(Buffer *buffer)
{ {
mData.mElementArrayBuffer.set(buffer); mState.mElementArrayBuffer.set(buffer);
mDirtyBits.set(DIRTY_BIT_ELEMENT_ARRAY_BUFFER); mDirtyBits.set(DIRTY_BIT_ELEMENT_ARRAY_BUFFER);
} }
......
...@@ -31,6 +31,31 @@ namespace gl ...@@ -31,6 +31,31 @@ namespace gl
{ {
class Buffer; class Buffer;
class VertexArrayState final : public angle::NonCopyable
{
public:
explicit VertexArrayState(size_t maxAttribs);
~VertexArrayState();
const std::string &getLabel() const { return mLabel; }
const BindingPointer<Buffer> &getElementArrayBuffer() const { return mElementArrayBuffer; }
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;
std::string mLabel;
std::vector<VertexAttribute> mVertexAttributes;
BindingPointer<Buffer> mElementArrayBuffer;
size_t mMaxEnabledAttribute;
};
class VertexArray final : public LabeledObject class VertexArray final : public LabeledObject
{ {
public: public:
...@@ -52,39 +77,20 @@ class VertexArray final : public LabeledObject ...@@ -52,39 +77,20 @@ class VertexArray final : public LabeledObject
void setElementArrayBuffer(Buffer *buffer); void setElementArrayBuffer(Buffer *buffer);
const BindingPointer<Buffer> &getElementArrayBuffer() const { return mData.getElementArrayBuffer(); } const BindingPointer<Buffer> &getElementArrayBuffer() const
size_t getMaxAttribs() const { return mData.getVertexAttributes().size(); }
const std::vector<VertexAttribute> &getVertexAttributes() const { return mData.getVertexAttributes(); }
rx::VertexArrayImpl *getImplementation() { return mVertexArray; }
const rx::VertexArrayImpl *getImplementation() const { return mVertexArray; }
size_t getMaxEnabledAttribute() const { return mData.getMaxEnabledAttribute(); }
class Data final : public angle::NonCopyable
{ {
public: return mState.getElementArrayBuffer();
explicit Data(size_t maxAttribs); }
~Data(); size_t getMaxAttribs() const { return mState.getVertexAttributes().size(); }
const std::vector<VertexAttribute> &getVertexAttributes() const
const std::string &getLabel() const { return mLabel; }
const BindingPointer<Buffer> &getElementArrayBuffer() const { return mElementArrayBuffer; }
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]; return mState.getVertexAttributes();
} }
private: rx::VertexArrayImpl *getImplementation() { return mVertexArray; }
friend class VertexArray; const rx::VertexArrayImpl *getImplementation() const { return mVertexArray; }
std::string mLabel;
std::vector<VertexAttribute> mVertexAttributes; size_t getMaxEnabledAttribute() const { return mState.getMaxEnabledAttribute(); }
BindingPointer<Buffer> mElementArrayBuffer;
size_t mMaxEnabledAttribute;
};
enum DirtyBitType enum DirtyBitType
{ {
...@@ -114,7 +120,7 @@ class VertexArray final : public LabeledObject ...@@ -114,7 +120,7 @@ class VertexArray final : public LabeledObject
private: private:
GLuint mId; GLuint mId;
Data mData; VertexArrayState mState;
DirtyBits mDirtyBits; DirtyBits mDirtyBits;
rx::VertexArrayImpl *mVertexArray; rx::VertexArrayImpl *mVertexArray;
......
...@@ -55,7 +55,7 @@ class ImplFactory : angle::NonCopyable ...@@ -55,7 +55,7 @@ class ImplFactory : angle::NonCopyable
virtual BufferImpl *createBuffer() = 0; virtual BufferImpl *createBuffer() = 0;
// Vertex Array creation // Vertex Array creation
virtual VertexArrayImpl *createVertexArray(const gl::VertexArray::Data &data) = 0; virtual VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) = 0;
// Query and Fence creation // Query and Fence creation
virtual QueryImpl *createQuery(GLenum type) = 0; virtual QueryImpl *createQuery(GLenum type) = 0;
......
...@@ -19,11 +19,11 @@ namespace rx ...@@ -19,11 +19,11 @@ namespace rx
class VertexArrayImpl : angle::NonCopyable class VertexArrayImpl : angle::NonCopyable
{ {
public: public:
VertexArrayImpl(const gl::VertexArray::Data &data) : mData(data) { } VertexArrayImpl(const gl::VertexArrayState &data) : mData(data) {}
virtual ~VertexArrayImpl() { } virtual ~VertexArrayImpl() { }
virtual void syncState(const gl::VertexArray::DirtyBits &dirtyBits) {} virtual void syncState(const gl::VertexArray::DirtyBits &dirtyBits) {}
protected: protected:
const gl::VertexArray::Data &mData; const gl::VertexArrayState &mData;
}; };
} }
......
...@@ -3577,7 +3577,7 @@ BufferImpl *Renderer11::createBuffer() ...@@ -3577,7 +3577,7 @@ BufferImpl *Renderer11::createBuffer()
return buffer; return buffer;
} }
VertexArrayImpl *Renderer11::createVertexArray(const gl::VertexArray::Data &data) VertexArrayImpl *Renderer11::createVertexArray(const gl::VertexArrayState &data)
{ {
return new VertexArray11(data); return new VertexArray11(data);
} }
......
...@@ -239,7 +239,7 @@ class Renderer11 : public RendererD3D ...@@ -239,7 +239,7 @@ class Renderer11 : public RendererD3D
virtual IndexBuffer *createIndexBuffer(); virtual IndexBuffer *createIndexBuffer();
// Vertex Array creation // Vertex Array creation
VertexArrayImpl *createVertexArray(const gl::VertexArray::Data &data) override; VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override;
// Query and Fence creation // Query and Fence creation
virtual QueryImpl *createQuery(GLenum type); virtual QueryImpl *createQuery(GLenum type);
......
...@@ -37,7 +37,7 @@ size_t GetAttribIndex(unsigned long dirtyBit) ...@@ -37,7 +37,7 @@ size_t GetAttribIndex(unsigned long dirtyBit)
} }
} // anonymous namespace } // anonymous namespace
VertexArray11::VertexArray11(const gl::VertexArray::Data &data) VertexArray11::VertexArray11(const gl::VertexArrayState &data)
: VertexArrayImpl(data), : VertexArrayImpl(data),
mAttributeStorageTypes(data.getVertexAttributes().size(), VertexStorageType::CURRENT_VALUE), mAttributeStorageTypes(data.getVertexAttributes().size(), VertexStorageType::CURRENT_VALUE),
mTranslatedAttribs(data.getVertexAttributes().size()), mTranslatedAttribs(data.getVertexAttributes().size()),
......
...@@ -19,7 +19,7 @@ class Renderer11; ...@@ -19,7 +19,7 @@ class Renderer11;
class VertexArray11 : public VertexArrayImpl class VertexArray11 : public VertexArrayImpl
{ {
public: public:
VertexArray11(const gl::VertexArray::Data &data); VertexArray11(const gl::VertexArrayState &data);
~VertexArray11() override; ~VertexArray11() override;
void syncState(const gl::VertexArray::DirtyBits &dirtyBits) override; void syncState(const gl::VertexArray::DirtyBits &dirtyBits) override;
......
...@@ -759,7 +759,7 @@ BufferImpl *Renderer9::createBuffer() ...@@ -759,7 +759,7 @@ BufferImpl *Renderer9::createBuffer()
return new Buffer9(this); return new Buffer9(this);
} }
VertexArrayImpl *Renderer9::createVertexArray(const gl::VertexArray::Data &data) VertexArrayImpl *Renderer9::createVertexArray(const gl::VertexArrayState &data)
{ {
return new VertexArray9(data); return new VertexArray9(data);
} }
......
...@@ -235,7 +235,7 @@ class Renderer9 : public RendererD3D ...@@ -235,7 +235,7 @@ class Renderer9 : public RendererD3D
virtual IndexBuffer *createIndexBuffer(); virtual IndexBuffer *createIndexBuffer();
// Vertex Array creation // Vertex Array creation
VertexArrayImpl *createVertexArray(const gl::VertexArray::Data &data) override; VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override;
// Query and Fence creation // Query and Fence creation
virtual QueryImpl *createQuery(GLenum type); virtual QueryImpl *createQuery(GLenum type);
......
...@@ -19,10 +19,7 @@ class Renderer9; ...@@ -19,10 +19,7 @@ class Renderer9;
class VertexArray9 : public VertexArrayImpl class VertexArray9 : public VertexArrayImpl
{ {
public: public:
VertexArray9(const gl::VertexArray::Data &data) VertexArray9(const gl::VertexArrayState &data) : VertexArrayImpl(data) {}
: VertexArrayImpl(data)
{
}
virtual ~VertexArray9() { } virtual ~VertexArray9() { }
}; };
......
...@@ -297,7 +297,7 @@ BufferImpl *RendererGL::createBuffer() ...@@ -297,7 +297,7 @@ BufferImpl *RendererGL::createBuffer()
return new BufferGL(mFunctions, mStateManager); return new BufferGL(mFunctions, mStateManager);
} }
VertexArrayImpl *RendererGL::createVertexArray(const gl::VertexArray::Data &data) VertexArrayImpl *RendererGL::createVertexArray(const gl::VertexArrayState &data)
{ {
return new VertexArrayGL(data, mFunctions, mStateManager); return new VertexArrayGL(data, mFunctions, mStateManager);
} }
......
...@@ -78,7 +78,7 @@ class RendererGL : public Renderer ...@@ -78,7 +78,7 @@ class RendererGL : public Renderer
BufferImpl *createBuffer() override; BufferImpl *createBuffer() override;
// Vertex Array creation // Vertex Array creation
VertexArrayImpl *createVertexArray(const gl::VertexArray::Data &data) override; VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override;
// Query and Fence creation // Query and Fence creation
QueryImpl *createQuery(GLenum type) override; QueryImpl *createQuery(GLenum type) override;
......
...@@ -32,10 +32,10 @@ bool AttributeNeedsStreaming(const VertexAttribute &attribute) ...@@ -32,10 +32,10 @@ bool AttributeNeedsStreaming(const VertexAttribute &attribute)
} // anonymous namespace } // anonymous namespace
VertexArrayGL::VertexArrayGL(const VertexArray::Data &data, VertexArrayGL::VertexArrayGL(const VertexArrayState &state,
const FunctionsGL *functions, const FunctionsGL *functions,
StateManagerGL *stateManager) StateManagerGL *stateManager)
: VertexArrayImpl(data), : VertexArrayImpl(state),
mFunctions(functions), mFunctions(functions),
mStateManager(stateManager), mStateManager(stateManager),
mVertexArrayID(0), mVertexArrayID(0),
......
...@@ -20,7 +20,9 @@ class StateManagerGL; ...@@ -20,7 +20,9 @@ class StateManagerGL;
class VertexArrayGL : public VertexArrayImpl class VertexArrayGL : public VertexArrayImpl
{ {
public: public:
VertexArrayGL(const gl::VertexArray::Data &data, const FunctionsGL *functions, StateManagerGL *stateManager); VertexArrayGL(const gl::VertexArrayState &data,
const FunctionsGL *functions,
StateManagerGL *stateManager);
~VertexArrayGL() override; ~VertexArrayGL() override;
gl::Error syncDrawArraysState(const gl::AttributesMask &activeAttributesMask, gl::Error syncDrawArraysState(const gl::AttributesMask &activeAttributesMask,
......
...@@ -41,7 +41,10 @@ class NullFactory : public ImplFactory ...@@ -41,7 +41,10 @@ class NullFactory : public ImplFactory
BufferImpl *createBuffer() override { return nullptr; } BufferImpl *createBuffer() override { return nullptr; }
// Vertex Array creation // Vertex Array creation
VertexArrayImpl *createVertexArray(const gl::VertexArray::Data &data) override { return nullptr; } VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override
{
return nullptr;
}
// Query and Fence creation // Query and Fence creation
QueryImpl *createQuery(GLenum type) override { return nullptr; } QueryImpl *createQuery(GLenum type) override { return nullptr; }
...@@ -66,7 +69,7 @@ class MockFactory : public ImplFactory ...@@ -66,7 +69,7 @@ class MockFactory : public ImplFactory
MOCK_METHOD1(createTexture, TextureImpl *(GLenum target)); MOCK_METHOD1(createTexture, TextureImpl *(GLenum target));
MOCK_METHOD0(createRenderbuffer, RenderbufferImpl *()); MOCK_METHOD0(createRenderbuffer, RenderbufferImpl *());
MOCK_METHOD0(createBuffer, BufferImpl *()); MOCK_METHOD0(createBuffer, BufferImpl *());
MOCK_METHOD1(createVertexArray, VertexArrayImpl *(const gl::VertexArray::Data &)); MOCK_METHOD1(createVertexArray, VertexArrayImpl *(const gl::VertexArrayState &));
MOCK_METHOD1(createQuery, QueryImpl *(GLenum type)); MOCK_METHOD1(createQuery, QueryImpl *(GLenum type));
MOCK_METHOD0(createFenceNV, FenceNVImpl *()); MOCK_METHOD0(createFenceNV, FenceNVImpl *());
MOCK_METHOD0(createFenceSync, FenceSyncImpl *()); MOCK_METHOD0(createFenceSync, FenceSyncImpl *());
......
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