dawn_native: Use correct integer width for SetSubData.
SetSubData's count is a uint64_t while Queue::WriteBuffer's is a size_t so we add a small validation check that no narrowing will occur. No test is added because SetSubData will be removed soon, and it will be hard to test because of the Null backend's artificial OOM. This was found while debugging an unrelated fuzzer issue. Bug: chromium:1099621 Change-Id: I27a9da2b94f51e889c5573f88d4a0a73fea5985c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23961 Reviewed-by: Stephen White <senorblanco@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
00d6215be9
commit
f7fab5a259
|
@ -249,11 +249,15 @@ namespace dawn_native {
|
|||
}
|
||||
}
|
||||
|
||||
void BufferBase::SetSubData(uint32_t start, uint32_t count, const void* data) {
|
||||
void BufferBase::SetSubData(uint64_t start, uint64_t count, const void* data) {
|
||||
if (count > uint64_t(std::numeric_limits<size_t>::max())) {
|
||||
GetDevice()->HandleError(InternalErrorType::Validation, "count too big");
|
||||
}
|
||||
|
||||
Ref<QueueBase> queue = AcquireRef(GetDevice()->GetDefaultQueue());
|
||||
GetDevice()->EmitDeprecationWarning(
|
||||
"Buffer::SetSubData is deprecated, use Queue::WriteBuffer instead");
|
||||
queue->WriteBuffer(this, start, data, count);
|
||||
queue->WriteBuffer(this, start, data, static_cast<size_t>(count));
|
||||
}
|
||||
|
||||
void BufferBase::MapReadAsync(WGPUBufferMapReadCallback callback, void* userdata) {
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace dawn_native {
|
|||
MaybeError ValidateCanUseOnQueueNow() const;
|
||||
|
||||
// Dawn API
|
||||
void SetSubData(uint32_t start, uint32_t count, const void* data);
|
||||
void SetSubData(uint64_t start, uint64_t count, const void* data);
|
||||
void MapReadAsync(WGPUBufferMapReadCallback callback, void* userdata);
|
||||
void MapWriteAsync(WGPUBufferMapWriteCallback callback, void* userdata);
|
||||
void* GetMappedRange();
|
||||
|
|
Loading…
Reference in New Issue