mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 16:37:08 +00:00
Remove size_t from wire transfer structs
This makes the primitives in the serialized wire protocol the same across platforms and architectures which is better for both fuzzing and remoting Dawn. Commands that used size_t are updated to use uint64_t, and the server-side implementation checks if conversion to size_t would narrow. Bug: dawn:680 Change-Id: Icef9dc11a72699685ed7191c34d6a922b652c887 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/41582 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
f0f6d2f8e1
commit
f104fea367
@@ -48,8 +48,8 @@ namespace dawn_wire { namespace server {
|
||||
bool Server::DoBufferMapAsync(ObjectId bufferId,
|
||||
uint32_t requestSerial,
|
||||
WGPUMapModeFlags mode,
|
||||
size_t offset,
|
||||
size_t size,
|
||||
uint64_t offset64,
|
||||
uint64_t size64,
|
||||
uint64_t handleCreateInfoLength,
|
||||
const uint8_t* handleCreateInfo) {
|
||||
// These requests are just forwarded to the buffer, with userdata containing what the
|
||||
@@ -72,19 +72,24 @@ namespace dawn_wire { namespace server {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (handleCreateInfoLength > std::numeric_limits<size_t>::max()) {
|
||||
// This is the size of data deserialized from the command stream, which must be
|
||||
// CPU-addressable.
|
||||
return false;
|
||||
}
|
||||
|
||||
std::unique_ptr<MapUserdata> userdata = MakeUserdata<MapUserdata>();
|
||||
userdata->buffer = ObjectHandle{bufferId, buffer->generation};
|
||||
userdata->bufferObj = buffer->handle;
|
||||
userdata->requestSerial = requestSerial;
|
||||
userdata->mode = mode;
|
||||
|
||||
if (offset64 > std::numeric_limits<size_t>::max() ||
|
||||
size64 > std::numeric_limits<size_t>::max() ||
|
||||
handleCreateInfoLength > std::numeric_limits<size_t>::max()) {
|
||||
OnBufferMapAsyncCallback(WGPUBufferMapAsyncStatus_Error, userdata.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t offset = static_cast<size_t>(offset64);
|
||||
size_t size = static_cast<size_t>(size64);
|
||||
|
||||
userdata->offset = offset;
|
||||
userdata->size = size;
|
||||
userdata->mode = mode;
|
||||
|
||||
// The handle will point to the mapped memory or staging memory for the mapping.
|
||||
// Store it on the map request.
|
||||
|
||||
Reference in New Issue
Block a user