Move Buffer Subject/Observer to front end.
This makes BufferImpl into an Observer Subject. It also refactors
the Vertex Array updates for the D3D11 backend use more of a dirty
bit coding style.
This change makes it so Buffer contents changes trigger front-end
dirty bits from the back-end, which may be undesirable.
Bug: angleproject:2389
Change-Id: Iac8ce1171284a86851c18cd1373ddf24fcefe40b
Reviewed-on: https://chromium-review.googlesource.com/979812
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
index e763e0a..6bb81c5 100644
--- a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
+++ b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
@@ -109,54 +109,65 @@
const auto &attribs = mState.getVertexAttributes();
const auto &bindings = mState.getVertexBindings();
- for (auto dirtyBit : dirtyBits)
+ for (size_t dirtyBit : dirtyBits)
{
- if (dirtyBit == gl::VertexArray::DIRTY_BIT_ELEMENT_ARRAY_BUFFER)
+ switch (dirtyBit)
{
- gl::Buffer *bufferGL = mState.getElementArrayBuffer().get();
- if (bufferGL)
+ case gl::VertexArray::DIRTY_BIT_ELEMENT_ARRAY_BUFFER:
{
- mCurrentElementArrayBufferResource = vk::GetImpl(bufferGL);
+ gl::Buffer *bufferGL = mState.getElementArrayBuffer().get();
+ if (bufferGL)
+ {
+ mCurrentElementArrayBufferResource = vk::GetImpl(bufferGL);
+ }
+ else
+ {
+ mCurrentElementArrayBufferResource = nullptr;
+ }
+ break;
}
- else
+
+ case gl::VertexArray::DIRTY_BIT_ELEMENT_ARRAY_BUFFER_DATA:
+ break;
+
+ default:
{
- mCurrentElementArrayBufferResource = nullptr;
+ size_t attribIndex = gl::VertexArray::GetVertexIndexFromDirtyBit(dirtyBit);
+
+ // Invalidate the input description for pipelines.
+ mDirtyPackedInputs.set(attribIndex);
+
+ const auto &attrib = attribs[attribIndex];
+ const auto &binding = bindings[attrib.bindingIndex];
+
+ if (attrib.enabled)
+ {
+ gl::Buffer *bufferGL = binding.getBuffer().get();
+
+ if (bufferGL)
+ {
+ BufferVk *bufferVk = vk::GetImpl(bufferGL);
+ mCurrentArrayBufferResources[attribIndex] = bufferVk;
+ mCurrentArrayBufferHandles[attribIndex] =
+ bufferVk->getVkBuffer().getHandle();
+ mClientMemoryAttribs.reset(attribIndex);
+ }
+ else
+ {
+ mCurrentArrayBufferResources[attribIndex] = nullptr;
+ mCurrentArrayBufferHandles[attribIndex] = VK_NULL_HANDLE;
+ mClientMemoryAttribs.set(attribIndex);
+ }
+ // TODO(jmadill): Offset handling. Assume zero for now.
+ mCurrentArrayBufferOffsets[attribIndex] = 0;
+ }
+ else
+ {
+ mClientMemoryAttribs.reset(attribIndex);
+ UNIMPLEMENTED();
+ }
+ break;
}
- continue;
- }
-
- size_t attribIndex = gl::VertexArray::GetVertexIndexFromDirtyBit(dirtyBit);
-
- // Invalidate the input description for pipelines.
- mDirtyPackedInputs.set(attribIndex);
-
- const auto &attrib = attribs[attribIndex];
- const auto &binding = bindings[attrib.bindingIndex];
-
- if (attrib.enabled)
- {
- gl::Buffer *bufferGL = binding.getBuffer().get();
-
- if (bufferGL)
- {
- BufferVk *bufferVk = vk::GetImpl(bufferGL);
- mCurrentArrayBufferResources[attribIndex] = bufferVk;
- mCurrentArrayBufferHandles[attribIndex] = bufferVk->getVkBuffer().getHandle();
- mClientMemoryAttribs.reset(attribIndex);
- }
- else
- {
- mCurrentArrayBufferResources[attribIndex] = nullptr;
- mCurrentArrayBufferHandles[attribIndex] = VK_NULL_HANDLE;
- mClientMemoryAttribs.set(attribIndex);
- }
- // TODO(jmadill): Offset handling. Assume zero for now.
- mCurrentArrayBufferOffsets[attribIndex] = 0;
- }
- else
- {
- mClientMemoryAttribs.reset(attribIndex);
- UNIMPLEMENTED();
}
}