Commit 41f7bcce by Charlie Lao Committed by Commit Bot

Vulkan: Add missing cache flush

DynamicBuffer are not cache coherent, thus requires flush. Also adds a few assertion to ensure implementation matches expectation. Bug: b/155432713 Change-Id: Iaf28786168a3bb5d746b43e030f882c4b6d005ad Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2174269Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
parent ca50ad42
...@@ -473,8 +473,8 @@ angle::Result BufferVk::directUpdate(ContextVk *contextVk, ...@@ -473,8 +473,8 @@ angle::Result BufferVk::directUpdate(ContextVk *contextVk,
ASSERT(mapPointer); ASSERT(mapPointer);
memcpy(mapPointer, data, size); memcpy(mapPointer, data, size);
mBuffer->unmap(contextVk->getRenderer()); mBuffer->unmap(contextVk->getRenderer());
ASSERT(mBuffer->isCoherent());
mBuffer->onExternalWrite(VK_ACCESS_HOST_WRITE_BIT); mBuffer->onExternalWrite(VK_ACCESS_HOST_WRITE_BIT);
return angle::Result::Continue; return angle::Result::Continue;
...@@ -500,6 +500,8 @@ angle::Result BufferVk::stagedUpdate(ContextVk *contextVk, ...@@ -500,6 +500,8 @@ angle::Result BufferVk::stagedUpdate(ContextVk *contextVk,
ASSERT(mapPointer); ASSERT(mapPointer);
memcpy(mapPointer, data, size); memcpy(mapPointer, data, size);
ASSERT(!mStagingBuffer.isCoherent());
ANGLE_TRY(mStagingBuffer.flush(contextVk));
mStagingBuffer.getCurrentBuffer()->onExternalWrite(VK_ACCESS_HOST_WRITE_BIT); mStagingBuffer.getCurrentBuffer()->onExternalWrite(VK_ACCESS_HOST_WRITE_BIT);
// Enqueue a copy command on the GPU. // Enqueue a copy command on the GPU.
......
...@@ -4122,7 +4122,7 @@ angle::Result ContextVk::updateDefaultAttribute(size_t attribIndex) ...@@ -4122,7 +4122,7 @@ angle::Result ContextVk::updateDefaultAttribute(size_t attribIndex)
const gl::VertexAttribCurrentValueData &defaultValue = const gl::VertexAttribCurrentValueData &defaultValue =
glState.getVertexAttribCurrentValues()[attribIndex]; glState.getVertexAttribCurrentValues()[attribIndex];
memcpy(ptr, &defaultValue.Values, kDefaultValueSize); memcpy(ptr, &defaultValue.Values, kDefaultValueSize);
ASSERT(!defaultBuffer.isCoherent());
ANGLE_TRY(defaultBuffer.flush(this)); ANGLE_TRY(defaultBuffer.flush(this));
mVertexArray->updateDefaultAttrib(this, attribIndex, bufferHandle, mVertexArray->updateDefaultAttrib(this, attribIndex, bufferHandle,
......
...@@ -110,6 +110,11 @@ class DynamicBuffer : angle::NonCopyable ...@@ -110,6 +110,11 @@ class DynamicBuffer : angle::NonCopyable
// For testing only! // For testing only!
void setMinimumSizeForTesting(size_t minSize); void setMinimumSizeForTesting(size_t minSize);
bool isCoherent() const
{
return (mMemoryPropertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) != 0;
}
private: private:
void reset(); void reset();
angle::Result allocateNewBuffer(ContextVk *contextVk); angle::Result allocateNewBuffer(ContextVk *contextVk);
...@@ -569,6 +574,10 @@ class BufferHelper final : public Resource ...@@ -569,6 +574,10 @@ class BufferHelper final : public Resource
{ {
return (mMemoryPropertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0; return (mMemoryPropertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0;
} }
bool isCoherent() const
{
return (mMemoryPropertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) != 0;
}
// Set write access mask when the buffer is modified externally, e.g. by host. There is no // Set write access mask when the buffer is modified externally, e.g. by host. There is no
// graph resource to create a dependency to. // graph resource to create a dependency to.
......
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