Return a pointer to a global static for zero-length GetMappedRange
Bug: chromium:1430985 Change-Id: Iaca7a21487a5a7e2b41dd9a363a7efd913a0f208 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129180 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Loko Kung <lokokung@google.com> Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Brendon Tiszka <tiszka@google.com>
This commit is contained in:
parent
69108d048b
commit
d0d6fc911c
|
@ -101,6 +101,9 @@ class ErrorBuffer final : public BufferBase {
|
||||||
std::unique_ptr<uint8_t[]> mFakeMappedData;
|
std::unique_ptr<uint8_t[]> mFakeMappedData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// GetMappedRange on a zero-sized buffer returns a pointer to this value.
|
||||||
|
static uint32_t sZeroSizedMappingData = 0xCAFED00D;
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
MaybeError ValidateBufferDescriptor(DeviceBase* device, const BufferDescriptor* descriptor) {
|
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<uint8_t*>(mStagingBuffer->GetMappedPointer()) + offset;
|
return static_cast<uint8_t*>(mStagingBuffer->GetMappedPointer()) + offset;
|
||||||
}
|
}
|
||||||
if (mSize == 0) {
|
if (mSize == 0) {
|
||||||
static uint32_t zeroRange = 0xCAFED00D;
|
return &sZeroSizedMappingData;
|
||||||
return &zeroRange;
|
|
||||||
}
|
}
|
||||||
uint8_t* start = static_cast<uint8_t*>(GetMappedPointer());
|
uint8_t* start = static_cast<uint8_t*>(GetMappedPointer());
|
||||||
return start == nullptr ? nullptr : start + offset;
|
return start == nullptr ? nullptr : start + offset;
|
||||||
|
|
Loading…
Reference in New Issue