diff --git a/src/dawn/native/Buffer.cpp b/src/dawn/native/Buffer.cpp index 22fcffb05f..b2efa6208d 100644 --- a/src/dawn/native/Buffer.cpp +++ b/src/dawn/native/Buffer.cpp @@ -101,6 +101,9 @@ class ErrorBuffer final : public BufferBase { std::unique_ptr mFakeMappedData; }; +// GetMappedRange on a zero-sized buffer returns a pointer to this value. +static uint32_t sZeroSizedMappingData = 0xCAFED00D; + } // anonymous namespace MaybeError ValidateBufferDescriptor(DeviceBase* device, const BufferDescriptor* descriptor) { @@ -435,8 +438,7 @@ void* BufferBase::GetMappedRange(size_t offset, size_t size, bool writable) { return static_cast(mStagingBuffer->GetMappedPointer()) + offset; } if (mSize == 0) { - static uint32_t zeroRange = 0xCAFED00D; - return &zeroRange; + return &sZeroSizedMappingData; } uint8_t* start = static_cast(GetMappedPointer()); return start == nullptr ? nullptr : start + offset;