Commit 62ff54eb by Mohan Maiya Committed by Commit Bot

Vulkan: Featurize shadow buffers

Shadow buffers help reduce the latency of glMap* operations at the cost of CPU overhead. It might not be desirable to incur such an overhead for all usecases. Featurize it but enable it by default. Bug: angleproject:4339 Change-Id: I6374618bf99677eef55fd50a139fb86f5ea70791 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2278102Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
parent cf63d872
......@@ -284,6 +284,14 @@ struct FeaturesVk : FeatureSetBase
"Fill new allocations with non-zero values to flush out errors.", &members,
"http://anglebug.com/4384"};
// Allocate a "shadow" buffer for GL buffer objects. For GPU-read only buffers
// glMap* latency can be reduced by maintaining a copy of the buffer which is
// writeable only by the CPU. We then return this shadow buffer on glMap* calls.
Feature shadowBuffers = {
"shadow_buffers", FeatureCategory::VulkanFeatures,
"Allocate a shadow buffer for GL buffer objects to reduce glMap* latency.", &members,
"http://anglebug.com/4339"};
// Persistently map buffer memory until destroy, saves on map/unmap IOCTL overhead
// for buffers that are updated frequently.
Feature persistentlyMappedBuffers = {
......
......@@ -190,6 +190,11 @@ angle::Result BufferVk::initializeShadowBuffer(ContextVk *contextVk,
gl::BufferBinding target,
size_t size)
{
if (!contextVk->getRenderer()->getFeatures().shadowBuffers.enabled)
{
return angle::Result::Continue;
}
// For now, enable shadow buffers only for pixel unpack buffers.
// If usecases present themselves, we can enable them for other buffer types.
if (target == gl::BufferBinding::PixelUnpack)
......
......@@ -1706,6 +1706,8 @@ void RendererVk::initFeatures(DisplayVk *displayVk, const ExtensionNameList &dev
// that can cause OOM and timeouts.
ANGLE_FEATURE_CONDITION(&mFeatures, allocateNonZeroMemory, false);
ANGLE_FEATURE_CONDITION(&mFeatures, shadowBuffers, true);
ANGLE_FEATURE_CONDITION(&mFeatures, persistentlyMappedBuffers, true);
ANGLE_FEATURE_CONDITION(
......
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