Fix Vulkan buffer barriers to use VK_WHOLE_SIZE
Buffers are padded to be at least 4 bytes. Dawn would produce invalid barriers for buffers that were "zero" bytes large. The size for the barrier must be either non-zero or VK_WHOLE_SIZE. Since we always intend to transition the entire buffer, simply use VK_WHOLE_SIZE instead of GetSize() as the size. Fixed: dawn:969 Change-Id: Ifed4e8f9164bafa3c44917074fcf214e72919c56 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57940 Reviewed-by: Jiawei Shao <jiawei.shao@intel.com> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
a145f37e7b
commit
ec380e9589
|
@ -243,7 +243,10 @@ namespace dawn_native { namespace vulkan {
|
|||
barrier->dstQueueFamilyIndex = 0;
|
||||
barrier->buffer = mHandle;
|
||||
barrier->offset = 0;
|
||||
barrier->size = GetSize();
|
||||
// Size must be non-zero or VK_WHOLE_SIZE. Use WHOLE_SIZE
|
||||
// instead of GetSize() because the buffer allocation may
|
||||
// be padded.
|
||||
barrier->size = VK_WHOLE_SIZE;
|
||||
|
||||
mLastUsage = usage;
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ namespace dawn_native { namespace vulkan {
|
|||
private:
|
||||
~Buffer() override;
|
||||
using BufferBase::BufferBase;
|
||||
|
||||
MaybeError Initialize(bool mappedAtCreation);
|
||||
void InitializeToZero(CommandRecordingContext* recordingContext);
|
||||
void ClearBuffer(CommandRecordingContext* recordingContext, uint32_t clearValue);
|
||||
|
|
|
@ -518,6 +518,17 @@ TEST_P(BufferMappingTests, MapWrite_InCallbackRange) {
|
|||
EXPECT_BUFFER_U32_EQ(myData, buffer, 0);
|
||||
}
|
||||
|
||||
// Regression test for crbug.com/dawn/969 where this test
|
||||
// produced invalid barriers.
|
||||
TEST_P(BufferMappingTests, MapWrite_ZeroSizedTwice) {
|
||||
wgpu::Buffer buffer = CreateMapWriteBuffer(0);
|
||||
|
||||
MapAsyncAndWait(buffer, wgpu::MapMode::Write, 0, 0);
|
||||
buffer.Unmap();
|
||||
|
||||
MapAsyncAndWait(buffer, wgpu::MapMode::Write, 0, 0);
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(BufferMappingTests,
|
||||
D3D12Backend(),
|
||||
MetalBackend(),
|
||||
|
|
Loading…
Reference in New Issue