From b9285f69ba2c7a46eeb308a51689786deaf9ef1b Mon Sep 17 00:00:00 2001 From: Enrico Galli Date: Sun, 12 Jul 2020 16:16:01 +0000 Subject: [PATCH] Rename Buffer::IsMapWritable to Buffer::IsMappableAtCreation Renaming method to better reflect the actual usage. Bug: none Change-Id: I3fcdeffaa06fceae9d5818f79c3b7985fb1885ad Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24701 Reviewed-by: Bryan Bernhart Reviewed-by: Austin Eng Reviewed-by: Corentin Wallez Commit-Queue: Corentin Wallez --- src/dawn_native/Buffer.cpp | 8 ++++---- src/dawn_native/Buffer.h | 2 +- src/dawn_native/d3d12/BufferD3D12.cpp | 2 +- src/dawn_native/d3d12/BufferD3D12.h | 2 +- src/dawn_native/metal/BufferMTL.h | 2 +- src/dawn_native/metal/BufferMTL.mm | 2 +- src/dawn_native/null/DeviceNull.cpp | 2 +- src/dawn_native/null/DeviceNull.h | 2 +- src/dawn_native/opengl/BufferGL.cpp | 2 +- src/dawn_native/opengl/BufferGL.h | 2 +- src/dawn_native/vulkan/BufferVk.cpp | 2 +- src/dawn_native/vulkan/BufferVk.h | 2 +- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/dawn_native/Buffer.cpp b/src/dawn_native/Buffer.cpp index 5f814be5e9..1db64a75cd 100644 --- a/src/dawn_native/Buffer.cpp +++ b/src/dawn_native/Buffer.cpp @@ -54,7 +54,7 @@ namespace dawn_native { } private: - bool IsMapWritable() const override { + bool IsMappableAtCreation() const override { UNREACHABLE(); return false; } @@ -173,7 +173,7 @@ namespace dawn_native { } // Mappable buffers don't use a staging buffer and are just as if mapped through MapAsync. - if (IsMapWritable()) { + if (IsMappableAtCreation()) { DAWN_TRY(MapAtCreationImpl()); return {}; } @@ -348,7 +348,7 @@ namespace dawn_native { if (mStagingBuffer != nullptr) { mStagingBuffer.reset(); } else if (mSize != 0) { - ASSERT(IsMapWritable()); + ASSERT(IsMappableAtCreation()); Unmap(); } } @@ -399,7 +399,7 @@ namespace dawn_native { if (mStagingBuffer != nullptr) { GetDevice()->ConsumedError(CopyFromStagingBuffer()); } else if (mSize != 0) { - ASSERT(IsMapWritable()); + ASSERT(IsMappableAtCreation()); UnmapImpl(); } } diff --git a/src/dawn_native/Buffer.h b/src/dawn_native/Buffer.h index f4a53777bc..457e415864 100644 --- a/src/dawn_native/Buffer.h +++ b/src/dawn_native/Buffer.h @@ -83,7 +83,7 @@ namespace dawn_native { virtual void DestroyImpl() = 0; virtual void* GetMappedPointerImpl() = 0; - virtual bool IsMapWritable() const = 0; + virtual bool IsMappableAtCreation() const = 0; MaybeError CopyFromStagingBuffer(); void* GetMappedRangeInternal(bool writable); void CallMapReadCallback(uint32_t serial, diff --git a/src/dawn_native/d3d12/BufferD3D12.cpp b/src/dawn_native/d3d12/BufferD3D12.cpp index 808b134e14..c38545bedc 100644 --- a/src/dawn_native/d3d12/BufferD3D12.cpp +++ b/src/dawn_native/d3d12/BufferD3D12.cpp @@ -243,7 +243,7 @@ namespace dawn_native { namespace d3d12 { return mResourceAllocation.GetGPUPointer(); } - bool Buffer::IsMapWritable() const { + bool Buffer::IsMappableAtCreation() const { // TODO(enga): Handle CPU-visible memory on UMA return (GetUsage() & (wgpu::BufferUsage::MapRead | wgpu::BufferUsage::MapWrite)) != 0; } diff --git a/src/dawn_native/d3d12/BufferD3D12.h b/src/dawn_native/d3d12/BufferD3D12.h index bb255587d6..33804d79f1 100644 --- a/src/dawn_native/d3d12/BufferD3D12.h +++ b/src/dawn_native/d3d12/BufferD3D12.h @@ -57,7 +57,7 @@ namespace dawn_native { namespace d3d12 { void UnmapImpl() override; void DestroyImpl() override; - bool IsMapWritable() const override; + bool IsMappableAtCreation() const override; virtual MaybeError MapAtCreationImpl() override; void* GetMappedPointerImpl() override; MaybeError MapInternal(bool isWrite, const char* contextInfo); diff --git a/src/dawn_native/metal/BufferMTL.h b/src/dawn_native/metal/BufferMTL.h index 38c403c7f3..f26c7e0c4d 100644 --- a/src/dawn_native/metal/BufferMTL.h +++ b/src/dawn_native/metal/BufferMTL.h @@ -47,7 +47,7 @@ namespace dawn_native { namespace metal { void DestroyImpl() override; void* GetMappedPointerImpl() override; - bool IsMapWritable() const override; + bool IsMappableAtCreation() const override; MaybeError MapAtCreationImpl() override; void InitializeToZero(CommandRecordingContext* commandContext); diff --git a/src/dawn_native/metal/BufferMTL.mm b/src/dawn_native/metal/BufferMTL.mm index 5b10a8dd03..d231e861c6 100644 --- a/src/dawn_native/metal/BufferMTL.mm +++ b/src/dawn_native/metal/BufferMTL.mm @@ -104,7 +104,7 @@ namespace dawn_native { namespace metal { return mMtlBuffer; } - bool Buffer::IsMapWritable() const { + bool Buffer::IsMappableAtCreation() const { // TODO(enga): Handle CPU-visible memory on UMA return (GetUsage() & (wgpu::BufferUsage::MapRead | wgpu::BufferUsage::MapWrite)) != 0; } diff --git a/src/dawn_native/null/DeviceNull.cpp b/src/dawn_native/null/DeviceNull.cpp index 71085cd5b8..ab430c3fb5 100644 --- a/src/dawn_native/null/DeviceNull.cpp +++ b/src/dawn_native/null/DeviceNull.cpp @@ -280,7 +280,7 @@ namespace dawn_native { namespace null { ToBackend(GetDevice())->DecrementMemoryUsage(GetSize()); } - bool Buffer::IsMapWritable() const { + bool Buffer::IsMappableAtCreation() const { // Only return true for mappable buffers so we can test cases that need / don't need a // staging buffer. return (GetUsage() & (wgpu::BufferUsage::MapRead | wgpu::BufferUsage::MapWrite)) != 0; diff --git a/src/dawn_native/null/DeviceNull.h b/src/dawn_native/null/DeviceNull.h index 1c98664426..94d382623e 100644 --- a/src/dawn_native/null/DeviceNull.h +++ b/src/dawn_native/null/DeviceNull.h @@ -204,7 +204,7 @@ namespace dawn_native { namespace null { void UnmapImpl() override; void DestroyImpl() override; - bool IsMapWritable() const override; + bool IsMappableAtCreation() const override; MaybeError MapAtCreationImpl() override; void* GetMappedPointerImpl() override; diff --git a/src/dawn_native/opengl/BufferGL.cpp b/src/dawn_native/opengl/BufferGL.cpp index c0bd7f3405..e7398d6b92 100644 --- a/src/dawn_native/opengl/BufferGL.cpp +++ b/src/dawn_native/opengl/BufferGL.cpp @@ -92,7 +92,7 @@ namespace dawn_native { namespace opengl { SetIsDataInitialized(); } - bool Buffer::IsMapWritable() const { + bool Buffer::IsMappableAtCreation() const { // TODO(enga): All buffers in GL can be mapped. Investigate if mapping them will cause the // driver to migrate it to shared memory. return true; diff --git a/src/dawn_native/opengl/BufferGL.h b/src/dawn_native/opengl/BufferGL.h index 9bc870e381..8dbe764e03 100644 --- a/src/dawn_native/opengl/BufferGL.h +++ b/src/dawn_native/opengl/BufferGL.h @@ -40,7 +40,7 @@ namespace dawn_native { namespace opengl { void UnmapImpl() override; void DestroyImpl() override; - bool IsMapWritable() const override; + bool IsMappableAtCreation() const override; MaybeError MapAtCreationImpl() override; void* GetMappedPointerImpl() override; uint64_t GetAppliedSize() const; diff --git a/src/dawn_native/vulkan/BufferVk.cpp b/src/dawn_native/vulkan/BufferVk.cpp index 417532451d..a3dcf2e46d 100644 --- a/src/dawn_native/vulkan/BufferVk.cpp +++ b/src/dawn_native/vulkan/BufferVk.cpp @@ -234,7 +234,7 @@ namespace dawn_native { namespace vulkan { mLastUsage = usage; } - bool Buffer::IsMapWritable() const { + bool Buffer::IsMappableAtCreation() const { // TODO(enga): Handle CPU-visible memory on UMA return mMemoryAllocation.GetMappedPointer() != nullptr; } diff --git a/src/dawn_native/vulkan/BufferVk.h b/src/dawn_native/vulkan/BufferVk.h index 14be75742d..d0d3ea2035 100644 --- a/src/dawn_native/vulkan/BufferVk.h +++ b/src/dawn_native/vulkan/BufferVk.h @@ -61,7 +61,7 @@ namespace dawn_native { namespace vulkan { void UnmapImpl() override; void DestroyImpl() override; - bool IsMapWritable() const override; + bool IsMappableAtCreation() const override; MaybeError MapAtCreationImpl() override; void* GetMappedPointerImpl() override;