Commit 53e3ce3c authored by Corentin Wallez's avatar Corentin Wallez Committed by Commit Bot

WebGPU: Replace deprecated use of Buffer::SetSubData

Bug: 1069302
Change-Id: Ib8c2e8c3f38ccaf1699f7f368b34f39c1be41d90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2225406Reviewed-by: default avatarAustin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776110}
parent ffd2e9e7
...@@ -238,11 +238,19 @@ void GPUQueue::WriteBufferImpl(GPUBuffer* buffer, ...@@ -238,11 +238,19 @@ void GPUQueue::WriteBufferImpl(GPUBuffer* buffer,
return; return;
} }
// Check that the write size can be cast to a size_t. This should always be
// the case since data_byte_length comes from an ArrayBuffer size.
if (write_byte_size > uint64_t(std::numeric_limits<size_t>::max())) {
exception_state.ThrowRangeError(
"writeSize larger than size_t (please report a bug if you see this)");
return;
}
const uint8_t* data_base_ptr_bytes = const uint8_t* data_base_ptr_bytes =
static_cast<const uint8_t*>(data_base_ptr); static_cast<const uint8_t*>(data_base_ptr);
const uint8_t* data_ptr = data_base_ptr_bytes + data_byte_offset; const uint8_t* data_ptr = data_base_ptr_bytes + data_byte_offset;
GetProcs().bufferSetSubData(buffer->GetHandle(), buffer_offset, GetProcs().queueWriteBuffer(GetHandle(), buffer->GetHandle(), buffer_offset,
write_byte_size, data_ptr); data_ptr, static_cast<size_t>(write_byte_size));
} }
// TODO(shaobo.yan@intel.com): Implement this function // TODO(shaobo.yan@intel.com): Implement this function
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment