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,65 +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);
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t initialDataInfoLength = 0;
|
|
||||||
if (status == WGPUBufferMapAsyncStatus_Success) {
|
|
||||||
// Get the serialization size of the message to initialize ReadHandle data.
|
|
||||||
initialDataInfoLength = data->readHandle->SerializeInitialDataSize(ptr, dataLength);
|
|
||||||
} else {
|
|
||||||
dataLength = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
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(ptr, dataLength, readHandleSpace);
|
|
||||||
|
|
||||||
// The in-flight map request returned successfully.
|
|
||||||
// Move the ReadHandle so it is owned by the buffer.
|
|
||||||
bufferData->readHandle = std::move(data->readHandle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Server::OnBufferMapWriteAsyncCallback(WGPUBufferMapAsyncStatus status,
|
|
||||||
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.
|
||||||
|
@ -276,6 +235,7 @@ namespace dawn_wire { namespace server {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data->mode & WGPUMapMode_Write) {
|
||||||
ReturnBufferMapWriteAsyncCallbackCmd cmd;
|
ReturnBufferMapWriteAsyncCallbackCmd cmd;
|
||||||
cmd.buffer = data->buffer;
|
cmd.buffer = data->buffer;
|
||||||
cmd.requestSerial = data->requestSerial;
|
cmd.requestSerial = data->requestSerial;
|
||||||
|
@ -289,7 +249,41 @@ namespace dawn_wire { namespace server {
|
||||||
bufferData->writeHandle = std::move(data->writeHandle);
|
bufferData->writeHandle = std::move(data->writeHandle);
|
||||||
bufferData->mapWriteState = BufferMapWriteState::Mapped;
|
bufferData->mapWriteState = BufferMapWriteState::Mapped;
|
||||||
// Set the target of the WriteHandle to the mapped buffer data.
|
// Set the target of the WriteHandle to the mapped buffer data.
|
||||||
bufferData->writeHandle->SetTarget(ptr, dataLength);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,9 +149,8 @@ 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,9 +226,8 @@ 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,9 +326,8 @@ 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,9 +404,8 @@ 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,9 +581,8 @@ 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,9 +430,8 @@ 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.
|
||||||
|
@ -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,9 +667,8 @@ 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.
|
||||||
|
@ -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