mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-15 03:41:34 +00:00
Vulkan: Enable nonzero_clear_resources_on_creation_for_testing on buffer
This patch enables nonzero_clear_resources_on_creation_for_testing toggle on buffer on Vulkan backends as a preparation of supporting buffer lazy-initialization in Dawn. BUG=dawn:414 TEST=dawn_end2end_tests Change-Id: I7619d02ae898e30fd15438d35437802a09e959cc Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22981 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
15cbb6b76a
commit
70d75c8c00
@ -165,6 +165,10 @@ namespace dawn_native { namespace vulkan {
|
|||||||
mMemoryAllocation.GetOffset()),
|
mMemoryAllocation.GetOffset()),
|
||||||
"vkBindBufferMemory"));
|
"vkBindBufferMemory"));
|
||||||
|
|
||||||
|
if (device->IsToggleEnabled(Toggle::NonzeroClearResourcesOnCreationForTesting)) {
|
||||||
|
ClearBuffer(device->GetPendingRecordingContext(), ClearValue::NonZero);
|
||||||
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,4 +287,20 @@ namespace dawn_native { namespace vulkan {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Buffer::ClearBuffer(CommandRecordingContext* recordingContext, ClearValue clearValue) {
|
||||||
|
ASSERT(recordingContext != nullptr);
|
||||||
|
|
||||||
|
// TODO(jiawei.shao@intel.com): support buffer lazy-initialization to 0.
|
||||||
|
ASSERT(clearValue == BufferBase::ClearValue::NonZero);
|
||||||
|
|
||||||
|
constexpr uint32_t kClearBufferValue = 0x01010101;
|
||||||
|
|
||||||
|
TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopyDst);
|
||||||
|
|
||||||
|
Device* device = ToBackend(GetDevice());
|
||||||
|
// TODO(jiawei.shao@intel.com): find out why VK_WHOLE_SIZE doesn't work on old Windows Intel
|
||||||
|
// Vulkan drivers.
|
||||||
|
device->fn.CmdFillBuffer(recordingContext->commandBuffer, mHandle, 0, GetSize(),
|
||||||
|
kClearBufferValue);
|
||||||
|
}
|
||||||
}} // namespace dawn_native::vulkan
|
}} // namespace dawn_native::vulkan
|
||||||
|
@ -49,6 +49,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
~Buffer() override;
|
~Buffer() override;
|
||||||
using BufferBase::BufferBase;
|
using BufferBase::BufferBase;
|
||||||
MaybeError Initialize();
|
MaybeError Initialize();
|
||||||
|
void ClearBuffer(CommandRecordingContext* recordingContext, ClearValue clearValue);
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
MaybeError MapReadAsyncImpl(uint32_t serial) override;
|
MaybeError MapReadAsyncImpl(uint32_t serial) override;
|
||||||
|
@ -51,4 +51,5 @@ TEST_P(NonzeroBufferCreationTests, BufferCreationWithoutCopyDstUsage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DAWN_INSTANTIATE_TEST(NonzeroBufferCreationTests,
|
DAWN_INSTANTIATE_TEST(NonzeroBufferCreationTests,
|
||||||
MetalBackend({"nonzero_clear_resources_on_creation_for_testing"}));
|
MetalBackend({"nonzero_clear_resources_on_creation_for_testing"}),
|
||||||
|
VulkanBackend({"nonzero_clear_resources_on_creation_for_testing"}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user