dawn_wire/server: Use MapAsync to do Map[Read/Write]Async
This changes the format of the client->server command for async mapping to match MapAsync and updates the doer on the server to implement it via MapAsync. Previously the command had an isWrite boolean that routed to either MapReadAsync or MapWriteAsync. Also updates the Wire tests using mock_webgpu.h for the new server-side traces. Bug: dawn:445 Change-Id: I673cbe5e08b7c71539e8678dbb07b4043a9fadb2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24820 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
2a232ba399
commit
c15c6eb9d8
|
@ -14,11 +14,16 @@
|
||||||
"See the License for the specific language governing permissions and",
|
"See the License for the specific language governing permissions and",
|
||||||
"limitations under the License."
|
"limitations under the License."
|
||||||
],
|
],
|
||||||
|
"_todos": [
|
||||||
|
"Remove usage of size_t because it is not network transparent"
|
||||||
|
],
|
||||||
"commands": {
|
"commands": {
|
||||||
"buffer map async": [
|
"buffer map async": [
|
||||||
{ "name": "buffer id", "type": "ObjectId" },
|
{ "name": "buffer id", "type": "ObjectId" },
|
||||||
{ "name": "request serial", "type": "uint32_t" },
|
{ "name": "request serial", "type": "uint32_t" },
|
||||||
{ "name": "is write", "type": "bool" },
|
{ "name": "mode", "type": "map mode" },
|
||||||
|
{ "name": "offset", "type": "size_t"},
|
||||||
|
{ "name": "size", "type": "size_t"},
|
||||||
{ "name": "handle create info length", "type": "uint64_t" },
|
{ "name": "handle create info length", "type": "uint64_t" },
|
||||||
{ "name": "handle create info", "type": "uint8_t", "annotation": "const*", "length": "handle create info length", "skip_serialize": true}
|
{ "name": "handle create info", "type": "uint8_t", "annotation": "const*", "length": "handle create info length", "skip_serialize": true}
|
||||||
],
|
],
|
||||||
|
|
|
@ -21,7 +21,10 @@ namespace dawn_wire { namespace client {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
template <typename Handle>
|
template <typename Handle>
|
||||||
void SerializeBufferMapAsync(const Buffer* buffer, uint32_t serial, Handle* handle) {
|
void SerializeBufferMapAsync(const Buffer* buffer,
|
||||||
|
uint32_t serial,
|
||||||
|
Handle* handle,
|
||||||
|
size_t size) {
|
||||||
// TODO(enga): Remove the template when Read/Write handles are combined in a tagged
|
// TODO(enga): Remove the template when Read/Write handles are combined in a tagged
|
||||||
// pointer.
|
// pointer.
|
||||||
constexpr bool isWrite =
|
constexpr bool isWrite =
|
||||||
|
@ -33,9 +36,11 @@ namespace dawn_wire { namespace client {
|
||||||
BufferMapAsyncCmd cmd;
|
BufferMapAsyncCmd cmd;
|
||||||
cmd.bufferId = buffer->id;
|
cmd.bufferId = buffer->id;
|
||||||
cmd.requestSerial = serial;
|
cmd.requestSerial = serial;
|
||||||
cmd.isWrite = isWrite;
|
cmd.mode = isWrite ? WGPUMapMode_Write : WGPUMapMode_Read;
|
||||||
cmd.handleCreateInfoLength = handleCreateInfoLength;
|
cmd.handleCreateInfoLength = handleCreateInfoLength;
|
||||||
cmd.handleCreateInfo = nullptr;
|
cmd.handleCreateInfo = nullptr;
|
||||||
|
cmd.offset = 0;
|
||||||
|
cmd.size = size;
|
||||||
|
|
||||||
char* writeHandleSpace =
|
char* writeHandleSpace =
|
||||||
buffer->device->GetClient()->SerializeCommand(cmd, handleCreateInfoLength);
|
buffer->device->GetClient()->SerializeCommand(cmd, handleCreateInfoLength);
|
||||||
|
@ -200,7 +205,7 @@ namespace dawn_wire { namespace client {
|
||||||
// operations are returned by the server so multiple requests may be in flight.
|
// operations are returned by the server so multiple requests may be in flight.
|
||||||
mRequests[serial] = std::move(request);
|
mRequests[serial] = std::move(request);
|
||||||
|
|
||||||
SerializeBufferMapAsync(this, serial, readHandle);
|
SerializeBufferMapAsync(this, serial, readHandle, mSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapWriteAsync(WGPUBufferMapWriteCallback callback, void* userdata) {
|
void Buffer::MapWriteAsync(WGPUBufferMapWriteCallback callback, void* userdata) {
|
||||||
|
@ -236,7 +241,7 @@ namespace dawn_wire { namespace client {
|
||||||
// operations are returned by the server so multiple requests may be in flight.
|
// operations are returned by the server so multiple requests may be in flight.
|
||||||
mRequests[serial] = std::move(request);
|
mRequests[serial] = std::move(request);
|
||||||
|
|
||||||
SerializeBufferMapAsync(this, serial, writeHandle);
|
SerializeBufferMapAsync(this, serial, writeHandle, mSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapAsync(WGPUMapModeFlags mode,
|
void Buffer::MapAsync(WGPUMapModeFlags mode,
|
||||||
|
|
|
@ -25,8 +25,10 @@ namespace dawn_wire { namespace server {
|
||||||
struct MapUserdata {
|
struct MapUserdata {
|
||||||
Server* server;
|
Server* server;
|
||||||
ObjectHandle buffer;
|
ObjectHandle buffer;
|
||||||
|
WGPUBuffer bufferObj;
|
||||||
uint32_t requestSerial;
|
uint32_t requestSerial;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
|
WGPUMapModeFlags mode;
|
||||||
// TODO(enga): Use a tagged pointer to save space.
|
// TODO(enga): Use a tagged pointer to save space.
|
||||||
std::unique_ptr<MemoryTransferService::ReadHandle> readHandle = nullptr;
|
std::unique_ptr<MemoryTransferService::ReadHandle> readHandle = nullptr;
|
||||||
std::unique_ptr<MemoryTransferService::WriteHandle> writeHandle = nullptr;
|
std::unique_ptr<MemoryTransferService::WriteHandle> writeHandle = nullptr;
|
||||||
|
@ -72,14 +74,7 @@ namespace dawn_wire { namespace server {
|
||||||
static void ForwardUncapturedError(WGPUErrorType type, const char* message, void* userdata);
|
static void ForwardUncapturedError(WGPUErrorType type, const char* message, void* userdata);
|
||||||
static void ForwardDeviceLost(const char* message, void* userdata);
|
static void ForwardDeviceLost(const char* message, void* userdata);
|
||||||
static void ForwardPopErrorScope(WGPUErrorType type, const char* message, void* userdata);
|
static void ForwardPopErrorScope(WGPUErrorType type, const char* message, void* userdata);
|
||||||
static void ForwardBufferMapReadAsync(WGPUBufferMapAsyncStatus status,
|
static void ForwardBufferMapAsync(WGPUBufferMapAsyncStatus status, void* userdata);
|
||||||
const void* ptr,
|
|
||||||
uint64_t dataLength,
|
|
||||||
void* userdata);
|
|
||||||
static void ForwardBufferMapWriteAsync(WGPUBufferMapAsyncStatus status,
|
|
||||||
void* ptr,
|
|
||||||
uint64_t dataLength,
|
|
||||||
void* userdata);
|
|
||||||
static void ForwardFenceCompletedValue(WGPUFenceCompletionStatus status, void* userdata);
|
static void ForwardFenceCompletedValue(WGPUFenceCompletionStatus status, void* userdata);
|
||||||
|
|
||||||
// Error callbacks
|
// Error callbacks
|
||||||
|
@ -88,14 +83,7 @@ namespace dawn_wire { namespace server {
|
||||||
void OnDevicePopErrorScope(WGPUErrorType type,
|
void OnDevicePopErrorScope(WGPUErrorType type,
|
||||||
const char* message,
|
const char* message,
|
||||||
ErrorScopeUserdata* userdata);
|
ErrorScopeUserdata* userdata);
|
||||||
void OnBufferMapReadAsyncCallback(WGPUBufferMapAsyncStatus status,
|
void OnBufferMapAsyncCallback(WGPUBufferMapAsyncStatus status, MapUserdata* userdata);
|
||||||
const void* ptr,
|
|
||||||
uint64_t dataLength,
|
|
||||||
MapUserdata* userdata);
|
|
||||||
void OnBufferMapWriteAsyncCallback(WGPUBufferMapAsyncStatus status,
|
|
||||||
void* ptr,
|
|
||||||
uint64_t dataLength,
|
|
||||||
MapUserdata* userdata);
|
|
||||||
void OnFenceCompletedValueUpdated(WGPUFenceCompletionStatus status,
|
void OnFenceCompletedValueUpdated(WGPUFenceCompletionStatus status,
|
||||||
FenceCompletionUserdata* userdata);
|
FenceCompletionUserdata* userdata);
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,9 @@ namespace dawn_wire { namespace server {
|
||||||
|
|
||||||
bool Server::DoBufferMapAsync(ObjectId bufferId,
|
bool Server::DoBufferMapAsync(ObjectId bufferId,
|
||||||
uint32_t requestSerial,
|
uint32_t requestSerial,
|
||||||
bool isWrite,
|
WGPUMapModeFlags mode,
|
||||||
|
size_t offset,
|
||||||
|
size_t size,
|
||||||
uint64_t handleCreateInfoLength,
|
uint64_t handleCreateInfoLength,
|
||||||
const uint8_t* handleCreateInfo) {
|
const uint8_t* handleCreateInfo) {
|
||||||
// These requests are just forwarded to the buffer, with userdata containing what the
|
// These requests are just forwarded to the buffer, with userdata containing what the
|
||||||
|
@ -62,6 +64,13 @@ namespace dawn_wire { namespace server {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The server only knows how to deal with write XOR read. Validate that.
|
||||||
|
bool isReadMode = mode & WGPUMapMode_Read;
|
||||||
|
bool isWriteMode = mode & WGPUMapMode_Write;
|
||||||
|
if (!(isReadMode ^ isWriteMode)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (handleCreateInfoLength > std::numeric_limits<size_t>::max()) {
|
if (handleCreateInfoLength > std::numeric_limits<size_t>::max()) {
|
||||||
// This is the size of data deserialized from the command stream, which must be
|
// This is the size of data deserialized from the command stream, which must be
|
||||||
// CPU-addressable.
|
// CPU-addressable.
|
||||||
|
@ -71,11 +80,14 @@ namespace dawn_wire { namespace server {
|
||||||
std::unique_ptr<MapUserdata> userdata = std::make_unique<MapUserdata>();
|
std::unique_ptr<MapUserdata> userdata = std::make_unique<MapUserdata>();
|
||||||
userdata->server = this;
|
userdata->server = this;
|
||||||
userdata->buffer = ObjectHandle{bufferId, buffer->generation};
|
userdata->buffer = ObjectHandle{bufferId, buffer->generation};
|
||||||
|
userdata->bufferObj = buffer->handle;
|
||||||
userdata->requestSerial = requestSerial;
|
userdata->requestSerial = requestSerial;
|
||||||
|
userdata->size = size;
|
||||||
|
userdata->mode = mode;
|
||||||
|
|
||||||
// The handle will point to the mapped memory or staging memory for the mapping.
|
// The handle will point to the mapped memory or staging memory for the mapping.
|
||||||
// Store it on the map request.
|
// Store it on the map request.
|
||||||
if (isWrite) {
|
if (isWriteMode) {
|
||||||
// Deserialize metadata produced from the client to create a companion server handle.
|
// Deserialize metadata produced from the client to create a companion server handle.
|
||||||
MemoryTransferService::WriteHandle* writeHandle = nullptr;
|
MemoryTransferService::WriteHandle* writeHandle = nullptr;
|
||||||
if (!mMemoryTransferService->DeserializeWriteHandle(
|
if (!mMemoryTransferService->DeserializeWriteHandle(
|
||||||
|
@ -86,9 +98,8 @@ namespace dawn_wire { namespace server {
|
||||||
|
|
||||||
userdata->writeHandle =
|
userdata->writeHandle =
|
||||||
std::unique_ptr<MemoryTransferService::WriteHandle>(writeHandle);
|
std::unique_ptr<MemoryTransferService::WriteHandle>(writeHandle);
|
||||||
mProcs.bufferMapWriteAsync(buffer->handle, ForwardBufferMapWriteAsync,
|
|
||||||
userdata.release());
|
|
||||||
} else {
|
} else {
|
||||||
|
ASSERT(isReadMode);
|
||||||
// Deserialize metadata produced from the client to create a companion server handle.
|
// Deserialize metadata produced from the client to create a companion server handle.
|
||||||
MemoryTransferService::ReadHandle* readHandle = nullptr;
|
MemoryTransferService::ReadHandle* readHandle = nullptr;
|
||||||
if (!mMemoryTransferService->DeserializeReadHandle(
|
if (!mMemoryTransferService->DeserializeReadHandle(
|
||||||
|
@ -98,10 +109,11 @@ namespace dawn_wire { namespace server {
|
||||||
ASSERT(readHandle != nullptr);
|
ASSERT(readHandle != nullptr);
|
||||||
|
|
||||||
userdata->readHandle = std::unique_ptr<MemoryTransferService::ReadHandle>(readHandle);
|
userdata->readHandle = std::unique_ptr<MemoryTransferService::ReadHandle>(readHandle);
|
||||||
mProcs.bufferMapReadAsync(buffer->handle, ForwardBufferMapReadAsync,
|
|
||||||
userdata.release());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mProcs.bufferMapAsync(buffer->handle, mode, offset, size, ForwardBufferMapAsync,
|
||||||
|
userdata.release());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,26 +221,12 @@ namespace dawn_wire { namespace server {
|
||||||
static_cast<size_t>(writeFlushInfoLength));
|
static_cast<size_t>(writeFlushInfoLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::ForwardBufferMapReadAsync(WGPUBufferMapAsyncStatus status,
|
void Server::ForwardBufferMapAsync(WGPUBufferMapAsyncStatus status, void* userdata) {
|
||||||
const void* ptr,
|
|
||||||
uint64_t dataLength,
|
|
||||||
void* userdata) {
|
|
||||||
auto data = static_cast<MapUserdata*>(userdata);
|
auto data = static_cast<MapUserdata*>(userdata);
|
||||||
data->server->OnBufferMapReadAsyncCallback(status, ptr, dataLength, data);
|
data->server->OnBufferMapAsyncCallback(status, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::ForwardBufferMapWriteAsync(WGPUBufferMapAsyncStatus status,
|
void Server::OnBufferMapAsyncCallback(WGPUBufferMapAsyncStatus status, MapUserdata* userdata) {
|
||||||
void* ptr,
|
|
||||||
uint64_t dataLength,
|
|
||||||
void* userdata) {
|
|
||||||
auto data = static_cast<MapUserdata*>(userdata);
|
|
||||||
data->server->OnBufferMapWriteAsyncCallback(status, ptr, dataLength, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Server::OnBufferMapReadAsyncCallback(WGPUBufferMapAsyncStatus status,
|
|
||||||
const void* ptr,
|
|
||||||
uint64_t dataLength,
|
|
||||||
MapUserdata* userdata) {
|
|
||||||
std::unique_ptr<MapUserdata> data(userdata);
|
std::unique_ptr<MapUserdata> data(userdata);
|
||||||
|
|
||||||
// Skip sending the callback if the buffer has already been destroyed.
|
// Skip sending the callback if the buffer has already been destroyed.
|
||||||
|
@ -237,59 +235,55 @@ namespace dawn_wire { namespace server {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t initialDataInfoLength = 0;
|
if (data->mode & WGPUMapMode_Write) {
|
||||||
if (status == WGPUBufferMapAsyncStatus_Success) {
|
ReturnBufferMapWriteAsyncCallbackCmd cmd;
|
||||||
// Get the serialization size of the message to initialize ReadHandle data.
|
cmd.buffer = data->buffer;
|
||||||
initialDataInfoLength = data->readHandle->SerializeInitialDataSize(ptr, dataLength);
|
cmd.requestSerial = data->requestSerial;
|
||||||
|
cmd.status = status;
|
||||||
|
|
||||||
|
SerializeCommand(cmd);
|
||||||
|
|
||||||
|
if (status == WGPUBufferMapAsyncStatus_Success) {
|
||||||
|
// The in-flight map request returned successfully.
|
||||||
|
// Move the WriteHandle so it is owned by the buffer.
|
||||||
|
bufferData->writeHandle = std::move(data->writeHandle);
|
||||||
|
bufferData->mapWriteState = BufferMapWriteState::Mapped;
|
||||||
|
// Set the target of the WriteHandle to the mapped buffer data.
|
||||||
|
bufferData->writeHandle->SetTarget(mProcs.bufferGetMappedRange(data->bufferObj),
|
||||||
|
data->size);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dataLength = 0;
|
ASSERT(data->mode & WGPUMapMode_Read);
|
||||||
}
|
|
||||||
|
|
||||||
ReturnBufferMapReadAsyncCallbackCmd cmd;
|
size_t initialDataInfoLength = 0;
|
||||||
cmd.buffer = data->buffer;
|
size_t mappedDataLength = 0;
|
||||||
cmd.requestSerial = data->requestSerial;
|
const void* mappedData = nullptr;
|
||||||
cmd.status = status;
|
if (status == WGPUBufferMapAsyncStatus_Success) {
|
||||||
cmd.initialDataInfoLength = initialDataInfoLength;
|
// Get the serialization size of the message to initialize ReadHandle data.
|
||||||
cmd.initialDataInfo = nullptr;
|
mappedDataLength = data->size;
|
||||||
|
mappedData = mProcs.bufferGetConstMappedRange(data->bufferObj);
|
||||||
|
initialDataInfoLength =
|
||||||
|
data->readHandle->SerializeInitialDataSize(mappedData, mappedDataLength);
|
||||||
|
}
|
||||||
|
|
||||||
char* readHandleSpace = SerializeCommand(cmd, initialDataInfoLength);
|
ReturnBufferMapReadAsyncCallbackCmd cmd;
|
||||||
|
cmd.buffer = data->buffer;
|
||||||
|
cmd.requestSerial = data->requestSerial;
|
||||||
|
cmd.status = status;
|
||||||
|
cmd.initialDataInfoLength = initialDataInfoLength;
|
||||||
|
cmd.initialDataInfo = nullptr;
|
||||||
|
|
||||||
if (status == WGPUBufferMapAsyncStatus_Success) {
|
char* readHandleSpace = SerializeCommand(cmd, initialDataInfoLength);
|
||||||
// Serialize the initialization message into the space after the command.
|
|
||||||
data->readHandle->SerializeInitialData(ptr, dataLength, readHandleSpace);
|
|
||||||
|
|
||||||
// The in-flight map request returned successfully.
|
if (status == WGPUBufferMapAsyncStatus_Success) {
|
||||||
// Move the ReadHandle so it is owned by the buffer.
|
// Serialize the initialization message into the space after the command.
|
||||||
bufferData->readHandle = std::move(data->readHandle);
|
data->readHandle->SerializeInitialData(mappedData, mappedDataLength,
|
||||||
}
|
readHandleSpace);
|
||||||
}
|
|
||||||
|
|
||||||
void Server::OnBufferMapWriteAsyncCallback(WGPUBufferMapAsyncStatus status,
|
// The in-flight map request returned successfully.
|
||||||
void* ptr,
|
// Move the ReadHandle so it is owned by the buffer.
|
||||||
uint64_t dataLength,
|
bufferData->readHandle = std::move(data->readHandle);
|
||||||
MapUserdata* userdata) {
|
}
|
||||||
std::unique_ptr<MapUserdata> data(userdata);
|
|
||||||
|
|
||||||
// Skip sending the callback if the buffer has already been destroyed.
|
|
||||||
auto* bufferData = BufferObjects().Get(data->buffer.id);
|
|
||||||
if (bufferData == nullptr || bufferData->generation != data->buffer.generation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnBufferMapWriteAsyncCallbackCmd cmd;
|
|
||||||
cmd.buffer = data->buffer;
|
|
||||||
cmd.requestSerial = data->requestSerial;
|
|
||||||
cmd.status = status;
|
|
||||||
|
|
||||||
SerializeCommand(cmd);
|
|
||||||
|
|
||||||
if (status == WGPUBufferMapAsyncStatus_Success) {
|
|
||||||
// The in-flight map request returned successfully.
|
|
||||||
// Move the WriteHandle so it is owned by the buffer.
|
|
||||||
bufferData->writeHandle = std::move(data->writeHandle);
|
|
||||||
bufferData->mapWriteState = BufferMapWriteState::Mapped;
|
|
||||||
// Set the target of the WriteHandle to the mapped buffer data.
|
|
||||||
bufferData->writeHandle->SetTarget(ptr, dataLength);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,11 +125,10 @@ TEST_F(WireBufferMappingTests, MappingForReadSuccessBuffer) {
|
||||||
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
|
}));
|
||||||
kBufferSize);
|
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer)).WillOnce(Return(&bufferContent));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -150,10 +149,9 @@ TEST_F(WireBufferMappingTests, MappingForReadSuccessBuffer) {
|
||||||
TEST_F(WireBufferMappingTests, ErrorWhileMappingForRead) {
|
TEST_F(WireBufferMappingTests, ErrorWhileMappingForRead) {
|
||||||
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||||
|
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||||
api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error, nullptr, 0);
|
}));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -169,10 +167,11 @@ TEST_F(WireBufferMappingTests, DestroyBeforeReadRequestEnd) {
|
||||||
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||||
|
|
||||||
// Return success
|
// Return success
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
uint32_t bufferContent = 0;
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, nullptr, 0);
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
}));
|
}));
|
||||||
|
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer)).WillOnce(Return(&bufferContent));
|
||||||
|
|
||||||
// Destroy before the client gets the success, so the callback is called with unknown.
|
// Destroy before the client gets the success, so the callback is called with unknown.
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0, _))
|
EXPECT_CALL(*mockBufferMapReadCallback, Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0, _))
|
||||||
|
@ -190,11 +189,10 @@ TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForRead) {
|
||||||
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
|
}));
|
||||||
kBufferSize);
|
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer)).WillOnce(Return(&bufferContent));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -213,12 +211,10 @@ TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullp
|
||||||
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
|
}));
|
||||||
kBufferSize);
|
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer)).WillOnce(Return(&bufferContent));
|
||||||
}))
|
|
||||||
.RetiresOnSaturation();
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -230,10 +226,9 @@ TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullp
|
||||||
|
|
||||||
// Map failure while the buffer is already mapped
|
// Map failure while the buffer is already mapped
|
||||||
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||||
api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error, nullptr, 0);
|
}));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -248,11 +243,10 @@ TEST_F(WireBufferMappingTests, UnmapInsideMapReadCallback) {
|
||||||
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
|
}));
|
||||||
kBufferSize);
|
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer)).WillOnce(Return(&bufferContent));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -273,11 +267,10 @@ TEST_F(WireBufferMappingTests, DestroyInsideMapReadCallback) {
|
||||||
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
|
}));
|
||||||
kBufferSize);
|
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer)).WillOnce(Return(&bufferContent));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -302,11 +295,10 @@ TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
|
||||||
uint32_t updatedContent = 4242;
|
uint32_t updatedContent = 4242;
|
||||||
uint32_t zero = 0;
|
uint32_t zero = 0;
|
||||||
|
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success,
|
}));
|
||||||
&serverBufferContent, kBufferSize);
|
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer)).WillOnce(Return(&serverBufferContent));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -334,10 +326,9 @@ TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
|
||||||
TEST_F(WireBufferMappingTests, ErrorWhileMappingForWrite) {
|
TEST_F(WireBufferMappingTests, ErrorWhileMappingForWrite) {
|
||||||
wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||||
|
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||||
api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error, nullptr, 0);
|
}));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -353,10 +344,11 @@ TEST_F(WireBufferMappingTests, DestroyBeforeWriteRequestEnd) {
|
||||||
wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||||
|
|
||||||
// Return success
|
// Return success
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
uint32_t bufferContent = 31337;
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, nullptr, 0);
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
}));
|
}));
|
||||||
|
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer)).WillOnce(Return(&bufferContent));
|
||||||
|
|
||||||
// Destroy before the client gets the success, so the callback is called with unknown.
|
// Destroy before the client gets the success, so the callback is called with unknown.
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0, _))
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0, _))
|
||||||
|
@ -374,11 +366,10 @@ TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForWrite) {
|
||||||
wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
|
}));
|
||||||
kBufferSize);
|
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer)).WillOnce(Return(&bufferContent));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -398,12 +389,10 @@ TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullp
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
uint32_t zero = 0;
|
uint32_t zero = 0;
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
|
}));
|
||||||
kBufferSize);
|
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer)).WillOnce(Return(&bufferContent));
|
||||||
}))
|
|
||||||
.RetiresOnSaturation();
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -415,10 +404,9 @@ TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullp
|
||||||
|
|
||||||
// Map failure while the buffer is already mapped
|
// Map failure while the buffer is already mapped
|
||||||
wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||||
api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error, nullptr, 0);
|
}));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -434,11 +422,10 @@ TEST_F(WireBufferMappingTests, UnmapInsideMapWriteCallback) {
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
uint32_t zero = 0;
|
uint32_t zero = 0;
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
|
}));
|
||||||
kBufferSize);
|
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer)).WillOnce(Return(&bufferContent));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -460,11 +447,10 @@ TEST_F(WireBufferMappingTests, DestroyInsideMapWriteCallback) {
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
uint32_t zero = 0;
|
uint32_t zero = 0;
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
|
}));
|
||||||
kBufferSize);
|
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer)).WillOnce(Return(&bufferContent));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -559,11 +545,10 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapSuccess) {
|
||||||
wgpuBufferMapWriteAsync(result.buffer, ToMockBufferMapWriteCallback, nullptr);
|
wgpuBufferMapWriteAsync(result.buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||||
|
|
||||||
uint32_t zero = 0;
|
uint32_t zero = 0;
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &apiBufferData,
|
}));
|
||||||
kBufferSize);
|
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer)).WillOnce(Return(&apiBufferData));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -596,10 +581,9 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapFailure) {
|
||||||
|
|
||||||
wgpuBufferMapWriteAsync(result.buffer, ToMockBufferMapWriteCallback, nullptr);
|
wgpuBufferMapWriteAsync(result.buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||||
|
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||||
api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error, nullptr, 0);
|
}));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
|
|
@ -386,11 +386,10 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadSuccess) {
|
||||||
ExpectServerReadHandleInitialize(serverHandle);
|
ExpectServerReadHandleInitialize(serverHandle);
|
||||||
|
|
||||||
// Mock a successful callback
|
// Mock a successful callback
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &mBufferContent,
|
}));
|
||||||
sizeof(mBufferContent));
|
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer)).WillOnce(Return(&mBufferContent));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -431,10 +430,9 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadError) {
|
||||||
ServerReadHandle* serverHandle = ExpectServerReadHandleDeserialize();
|
ServerReadHandle* serverHandle = ExpectServerReadHandleDeserialize();
|
||||||
|
|
||||||
// Mock a failed callback.
|
// Mock a failed callback.
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||||
api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error, nullptr, 0);
|
}));
|
||||||
}));
|
|
||||||
|
|
||||||
// Since the mapping failed, the handle is immediately destroyed.
|
// Since the mapping failed, the handle is immediately destroyed.
|
||||||
EXPECT_CALL(serverMemoryTransferService, OnReadHandleDestroy(serverHandle)).Times(1);
|
EXPECT_CALL(serverMemoryTransferService, OnReadHandleDestroy(serverHandle)).Times(1);
|
||||||
|
@ -520,11 +518,10 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadDeserializeInitialDataFailur
|
||||||
ExpectServerReadHandleInitialize(serverHandle);
|
ExpectServerReadHandleInitialize(serverHandle);
|
||||||
|
|
||||||
// Mock a successful callback
|
// Mock a successful callback
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &mBufferContent,
|
}));
|
||||||
sizeof(mBufferContent));
|
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer)).WillOnce(Return(&mBufferContent));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -565,11 +562,10 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadDestroyBeforeUnmap) {
|
||||||
ExpectServerReadHandleInitialize(serverHandle);
|
ExpectServerReadHandleInitialize(serverHandle);
|
||||||
|
|
||||||
// Mock a successful callback
|
// Mock a successful callback
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &mBufferContent,
|
}));
|
||||||
sizeof(mBufferContent));
|
EXPECT_CALL(api, BufferGetConstMappedRange(apiBuffer)).WillOnce(Return(&mBufferContent));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -617,11 +613,10 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteSuccess) {
|
||||||
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
|
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
|
||||||
|
|
||||||
// Mock a successful callback.
|
// Mock a successful callback.
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success,
|
}));
|
||||||
&mMappedBufferContent, sizeof(mMappedBufferContent));
|
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer)).WillOnce(Return(&mMappedBufferContent));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -672,10 +667,9 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteError) {
|
||||||
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
|
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
|
||||||
|
|
||||||
// Mock an error callback.
|
// Mock an error callback.
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error);
|
||||||
api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error, nullptr, 0);
|
}));
|
||||||
}));
|
|
||||||
|
|
||||||
// Since the mapping fails, the handle is immediately destroyed because it won't be written.
|
// Since the mapping fails, the handle is immediately destroyed because it won't be written.
|
||||||
EXPECT_CALL(serverMemoryTransferService, OnWriteHandleDestroy(serverHandle)).Times(1);
|
EXPECT_CALL(serverMemoryTransferService, OnWriteHandleDestroy(serverHandle)).Times(1);
|
||||||
|
@ -758,11 +752,10 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteHandleOpenFailure) {
|
||||||
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
|
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
|
||||||
|
|
||||||
// Mock a successful callback.
|
// Mock a successful callback.
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success,
|
}));
|
||||||
&mMappedBufferContent, sizeof(mMappedBufferContent));
|
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer)).WillOnce(Return(&mMappedBufferContent));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -799,11 +792,10 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteDeserializeFlushFailure) {
|
||||||
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
|
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
|
||||||
|
|
||||||
// Mock a successful callback.
|
// Mock a successful callback.
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success,
|
}));
|
||||||
&mMappedBufferContent, sizeof(mMappedBufferContent));
|
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer)).WillOnce(Return(&mMappedBufferContent));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
@ -851,11 +843,10 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteDestroyBeforeUnmap) {
|
||||||
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
|
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
|
||||||
|
|
||||||
// Mock a successful callback.
|
// Mock a successful callback.
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
EXPECT_CALL(api, OnBufferMapAsyncCallback(apiBuffer, _, _)).WillOnce(InvokeWithoutArgs([&]() {
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
api.CallMapAsyncCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success);
|
||||||
api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success,
|
}));
|
||||||
&mMappedBufferContent, sizeof(mMappedBufferContent));
|
EXPECT_CALL(api, BufferGetMappedRange(apiBuffer)).WillOnce(Return(&mMappedBufferContent));
|
||||||
}));
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue