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