mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 16:37:08 +00:00
Use MapAsync callback for server->client map callbacks.
This changes the format of the server->client callback for async mapping to match MapAsync. Previously there were two callbacks, one for MapReadAsync and one for MapWriteAsync. Bug: dawn:445 Change-Id: I3330c07ac8bb6d1fa9019563e9c946875e852639 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24821 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
b92a363a1a
commit
450b6f4f84
@@ -235,15 +235,34 @@ namespace dawn_wire { namespace server {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data->mode & WGPUMapMode_Write) {
|
||||
ReturnBufferMapWriteAsyncCallbackCmd cmd;
|
||||
cmd.buffer = data->buffer;
|
||||
cmd.requestSerial = data->requestSerial;
|
||||
cmd.status = status;
|
||||
bool isRead = data->mode & WGPUMapMode_Read;
|
||||
bool isSuccess = status == WGPUBufferMapAsyncStatus_Success;
|
||||
|
||||
SerializeCommand(cmd);
|
||||
ReturnBufferMapAsyncCallbackCmd cmd;
|
||||
cmd.buffer = data->buffer;
|
||||
cmd.requestSerial = data->requestSerial;
|
||||
cmd.status = status;
|
||||
cmd.readInitialDataInfoLength = 0;
|
||||
cmd.readInitialDataInfo = nullptr;
|
||||
|
||||
if (status == WGPUBufferMapAsyncStatus_Success) {
|
||||
const void* readData = nullptr;
|
||||
if (isSuccess && isRead) {
|
||||
// Get the serialization size of the message to initialize ReadHandle data.
|
||||
readData = mProcs.bufferGetConstMappedRange(data->bufferObj);
|
||||
cmd.readInitialDataInfoLength =
|
||||
data->readHandle->SerializeInitialDataSize(readData, data->size);
|
||||
}
|
||||
|
||||
char* readHandleSpace = SerializeCommand(cmd, cmd.readInitialDataInfoLength);
|
||||
|
||||
if (isSuccess) {
|
||||
if (isRead) {
|
||||
// Serialize the initialization message into the space after the command.
|
||||
data->readHandle->SerializeInitialData(readData, data->size, readHandleSpace);
|
||||
// The in-flight map request returned successfully.
|
||||
// Move the ReadHandle so it is owned by the buffer.
|
||||
bufferData->readHandle = std::move(data->readHandle);
|
||||
} else {
|
||||
// The in-flight map request returned successfully.
|
||||
// Move the WriteHandle so it is owned by the buffer.
|
||||
bufferData->writeHandle = std::move(data->writeHandle);
|
||||
@@ -252,38 +271,6 @@ namespace dawn_wire { namespace server {
|
||||
bufferData->writeHandle->SetTarget(mProcs.bufferGetMappedRange(data->bufferObj),
|
||||
data->size);
|
||||
}
|
||||
} else {
|
||||
ASSERT(data->mode & WGPUMapMode_Read);
|
||||
|
||||
size_t initialDataInfoLength = 0;
|
||||
size_t mappedDataLength = 0;
|
||||
const void* mappedData = nullptr;
|
||||
if (status == WGPUBufferMapAsyncStatus_Success) {
|
||||
// Get the serialization size of the message to initialize ReadHandle data.
|
||||
mappedDataLength = data->size;
|
||||
mappedData = mProcs.bufferGetConstMappedRange(data->bufferObj);
|
||||
initialDataInfoLength =
|
||||
data->readHandle->SerializeInitialDataSize(mappedData, mappedDataLength);
|
||||
}
|
||||
|
||||
ReturnBufferMapReadAsyncCallbackCmd cmd;
|
||||
cmd.buffer = data->buffer;
|
||||
cmd.requestSerial = data->requestSerial;
|
||||
cmd.status = status;
|
||||
cmd.initialDataInfoLength = initialDataInfoLength;
|
||||
cmd.initialDataInfo = nullptr;
|
||||
|
||||
char* readHandleSpace = SerializeCommand(cmd, initialDataInfoLength);
|
||||
|
||||
if (status == WGPUBufferMapAsyncStatus_Success) {
|
||||
// Serialize the initialization message into the space after the command.
|
||||
data->readHandle->SerializeInitialData(mappedData, mappedDataLength,
|
||||
readHandleSpace);
|
||||
|
||||
// The in-flight map request returned successfully.
|
||||
// Move the ReadHandle so it is owned by the buffer.
|
||||
bufferData->readHandle = std::move(data->readHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user