Commit fc0c8d18 by Mohan Maiya Committed by Commit Bot

Vulkan: Honor mapRangeImpl and unmapImpl abstraction

All BufferVk methods need to honor the abstraction provided by mapRangeImpl and unmapImpl. Do not map BufferVk::mBuffer directly, this is needed for when we support device local buffers that cannot be CPU mapped. Bug: angleproject:5909 Change-Id: I520e5cc0994560a3784b8978e349550211dc2cde Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2862559Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
parent cffd5d87
...@@ -400,18 +400,15 @@ angle::Result BufferVk::copySubData(const gl::Context *context, ...@@ -400,18 +400,15 @@ angle::Result BufferVk::copySubData(const gl::Context *context,
// all recorded and in-flight commands involving the source buffer. // all recorded and in-flight commands involving the source buffer.
if (mShadowBuffer.valid()) if (mShadowBuffer.valid())
{ {
ANGLE_TRY(sourceBuffer.waitForIdle( // Map the source buffer.
contextVk, void *mapPtr;
"GPU stall due to copy from buffer in use by the GPU to a pixel unpack buffer")); ANGLE_TRY(sourceVk->mapRangeImpl(contextVk, sourceOffset, size, 0, &mapPtr));
// Update the shadow buffer // Update the shadow buffer with data from source buffer
uint8_t *srcPtr; updateShadowBuffer(static_cast<uint8_t *>(mapPtr), size, destOffset);
ANGLE_TRY(sourceBuffer.mapWithOffset(contextVk, &srcPtr, sourceOffset));
updateShadowBuffer(srcPtr, size, destOffset);
// Unmap the source buffer // Unmap the source buffer
sourceBuffer.unmap(contextVk->getRenderer()); ANGLE_TRY(sourceVk->unmapImpl(contextVk));
} }
// Check for self-dependency. // Check for self-dependency.
...@@ -560,20 +557,10 @@ angle::Result BufferVk::getSubData(const gl::Context *context, ...@@ -560,20 +557,10 @@ angle::Result BufferVk::getSubData(const gl::Context *context,
{ {
ASSERT(mBuffer && mBuffer->valid()); ASSERT(mBuffer && mBuffer->valid());
ContextVk *contextVk = vk::GetImpl(context); ContextVk *contextVk = vk::GetImpl(context);
// Note: This function is used for ANGLE's capture/replay tool, so no performance warnings void *mapPtr;
// is generated. ANGLE_TRY(mapRangeImpl(contextVk, offset, size, 0, &mapPtr));
ANGLE_TRY(mBuffer->waitForIdle(contextVk, nullptr)); memcpy(outData, mapPtr, size);
if (mBuffer->isMapped()) ANGLE_TRY(unmapImpl(contextVk));
{
memcpy(outData, mBuffer->getMappedMemory() + offset, size);
}
else
{
uint8_t *mappedPtr = nullptr;
ANGLE_TRY(mBuffer->mapWithOffset(contextVk, &mappedPtr, offset));
memcpy(outData, mappedPtr, size);
mBuffer->unmap(contextVk->getRenderer());
}
} }
else else
{ {
...@@ -603,28 +590,11 @@ angle::Result BufferVk::getIndexRange(const gl::Context *context, ...@@ -603,28 +590,11 @@ angle::Result BufferVk::getIndexRange(const gl::Context *context,
ANGLE_TRACE_EVENT0("gpu.angle", "BufferVk::getIndexRange"); ANGLE_TRACE_EVENT0("gpu.angle", "BufferVk::getIndexRange");
uint8_t *mapPointer; void *mapPtr;
ANGLE_TRY(mapRangeImpl(contextVk, offset, getSize(), 0, &mapPtr));
if (!mShadowBuffer.valid()) *outRange = gl::ComputeIndexRange(type, mapPtr, count, primitiveRestartEnabled);
{ ANGLE_TRY(unmapImpl(contextVk));
ANGLE_PERF_WARNING(contextVk->getDebug(), GL_DEBUG_SEVERITY_HIGH,
"GPU stall due to index range validation");
// Needed before reading buffer or we could get stale data.
ANGLE_TRY(mBuffer->finishRunningCommands(contextVk));
ASSERT(mBuffer && mBuffer->valid());
ANGLE_TRY(mBuffer->mapWithOffset(contextVk, &mapPointer, offset));
}
else
{
mapPointer = getShadowBuffer(offset);
}
*outRange = gl::ComputeIndexRange(type, mapPointer, count, primitiveRestartEnabled);
mBuffer->unmap(renderer);
return angle::Result::Continue; return angle::Result::Continue;
} }
......
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