Replace dawn::CallbackUserdata with void*
This initial reasoning for having a u64 userdata was to be able to pack two u32s in a single userdata but that was never used, and made a bunch of code uglier than it should. BUG=dawn:160 Change-Id: Ia0d20bc23f09f5d8f3748ca4edd1a331604f2ba8 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7561 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
26d3cf08c2
commit
839053b90c
11
dawn.json
11
dawn.json
|
@ -142,14 +142,14 @@
|
|||
"name": "map read async",
|
||||
"args": [
|
||||
{"name": "callback", "type": "buffer map read callback"},
|
||||
{"name": "userdata", "type": "callback userdata"}
|
||||
{"name": "userdata", "type": "void", "annotation": "*"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "map write async",
|
||||
"args": [
|
||||
{"name": "callback", "type": "buffer map write callback"},
|
||||
{"name": "userdata", "type": "callback userdata"}
|
||||
{"name": "userdata", "type": "void", "annotation": "*"}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -207,9 +207,6 @@
|
|||
{"value": 128, "name": "storage"}
|
||||
]
|
||||
},
|
||||
"callback userdata": {
|
||||
"category": "natively defined"
|
||||
},
|
||||
"char": {
|
||||
"category": "native"
|
||||
},
|
||||
|
@ -489,7 +486,7 @@
|
|||
"name": "set error callback",
|
||||
"args": [
|
||||
{"name": "callback", "type": "device error callback"},
|
||||
{"name": "userdata", "type": "callback userdata"}
|
||||
{"name": "userdata", "type": "void", "annotation": "*"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -539,7 +536,7 @@
|
|||
"args": [
|
||||
{"name": "value", "type": "uint64_t"},
|
||||
{"name": "callback", "type": "fence on completion callback"},
|
||||
{"name": "userdata", "type": "callback userdata"}
|
||||
{"name": "userdata", "type": "void", "annotation": "*"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
void PrintDeviceError(const char* message, dawn::CallbackUserdata) {
|
||||
void PrintDeviceError(const char* message, void*) {
|
||||
std::cout << "Device error: " << message << std::endl;
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ dawn::Device CreateCppDawnDevice() {
|
|||
}
|
||||
|
||||
dawnSetProcs(&procs);
|
||||
procs.deviceSetErrorCallback(cDevice, PrintDeviceError, 0);
|
||||
procs.deviceSetErrorCallback(cDevice, PrintDeviceError, nullptr);
|
||||
return dawn::Device::Acquire(cDevice);
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ def linked_record_members(json_data, types):
|
|||
for (member, m) in zip(members, json_data):
|
||||
if member.annotation != 'value':
|
||||
if not 'length' in m:
|
||||
if member.type.category == 'structure':
|
||||
if member.type.category != 'object':
|
||||
member.length = "constant"
|
||||
member.constant_length = 1
|
||||
else:
|
||||
|
|
|
@ -48,12 +48,16 @@
|
|||
{% endfor %}
|
||||
|
||||
// Custom types depending on the target language
|
||||
typedef uint64_t DawnCallbackUserdata;
|
||||
typedef void (*DawnDeviceErrorCallback)(const char* message, DawnCallbackUserdata userdata);
|
||||
typedef void (*DawnBufferMapReadCallback)(DawnBufferMapAsyncStatus status, const void* data, uint64_t dataLength, DawnCallbackUserdata userdata);
|
||||
typedef void (*DawnBufferMapWriteCallback)(DawnBufferMapAsyncStatus status, void* data, uint64_t dataLength, DawnCallbackUserdata userdata);
|
||||
typedef void (*DawnFenceOnCompletionCallback)(DawnFenceCompletionStatus status,
|
||||
DawnCallbackUserdata userdata);
|
||||
typedef void (*DawnDeviceErrorCallback)(const char* message, void* userdata);
|
||||
typedef void (*DawnBufferMapReadCallback)(DawnBufferMapAsyncStatus status,
|
||||
const void* data,
|
||||
uint64_t dataLength,
|
||||
void* userdata);
|
||||
typedef void (*DawnBufferMapWriteCallback)(DawnBufferMapAsyncStatus status,
|
||||
void* data,
|
||||
uint64_t dataLength,
|
||||
void* userdata);
|
||||
typedef void (*DawnFenceOnCompletionCallback)(DawnFenceCompletionStatus status, void* userdata);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -50,7 +50,9 @@ void ProcTableAsClass::GetProcTableAndDevice(DawnProcTable* table, DawnDevice* d
|
|||
{% endfor %}
|
||||
}
|
||||
|
||||
void ProcTableAsClass::DeviceSetErrorCallback(DawnDevice self, DawnDeviceErrorCallback callback, DawnCallbackUserdata userdata) {
|
||||
void ProcTableAsClass::DeviceSetErrorCallback(DawnDevice self,
|
||||
DawnDeviceErrorCallback callback,
|
||||
void* userdata) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||
object->deviceErrorCallback = callback;
|
||||
object->userdata1 = userdata;
|
||||
|
@ -58,7 +60,9 @@ void ProcTableAsClass::DeviceSetErrorCallback(DawnDevice self, DawnDeviceErrorCa
|
|||
OnDeviceSetErrorCallback(self, callback, userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::BufferMapReadAsync(DawnBuffer self, DawnBufferMapReadCallback callback, DawnCallbackUserdata userdata) {
|
||||
void ProcTableAsClass::BufferMapReadAsync(DawnBuffer self,
|
||||
DawnBufferMapReadCallback callback,
|
||||
void* userdata) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||
object->mapReadCallback = callback;
|
||||
object->userdata1 = userdata;
|
||||
|
@ -66,7 +70,9 @@ void ProcTableAsClass::BufferMapReadAsync(DawnBuffer self, DawnBufferMapReadCall
|
|||
OnBufferMapReadAsyncCallback(self, callback, userdata);
|
||||
}
|
||||
|
||||
void ProcTableAsClass::BufferMapWriteAsync(DawnBuffer self, DawnBufferMapWriteCallback callback, DawnCallbackUserdata userdata) {
|
||||
void ProcTableAsClass::BufferMapWriteAsync(DawnBuffer self,
|
||||
DawnBufferMapWriteCallback callback,
|
||||
void* userdata) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||
object->mapWriteCallback = callback;
|
||||
object->userdata1 = userdata;
|
||||
|
@ -77,7 +83,7 @@ void ProcTableAsClass::BufferMapWriteAsync(DawnBuffer self, DawnBufferMapWriteCa
|
|||
void ProcTableAsClass::FenceOnCompletion(DawnFence self,
|
||||
uint64_t value,
|
||||
DawnFenceOnCompletionCallback callback,
|
||||
DawnCallbackUserdata userdata) {
|
||||
void* userdata) {
|
||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||
object->fenceOnCompletionCallback = callback;
|
||||
object->userdata1 = userdata;
|
||||
|
|
|
@ -51,22 +51,34 @@ class ProcTableAsClass {
|
|||
{% endfor %}
|
||||
|
||||
// Stores callback and userdata and calls the On* methods
|
||||
void DeviceSetErrorCallback(DawnDevice self, DawnDeviceErrorCallback callback, DawnCallbackUserdata userdata);
|
||||
void BufferMapReadAsync(DawnBuffer self, DawnBufferMapReadCallback callback, DawnCallbackUserdata userdata);
|
||||
void BufferMapWriteAsync(DawnBuffer self, DawnBufferMapWriteCallback callback, DawnCallbackUserdata userdata);
|
||||
void DeviceSetErrorCallback(DawnDevice self,
|
||||
DawnDeviceErrorCallback callback,
|
||||
void* userdata);
|
||||
void BufferMapReadAsync(DawnBuffer self,
|
||||
DawnBufferMapReadCallback callback,
|
||||
void* userdata);
|
||||
void BufferMapWriteAsync(DawnBuffer self,
|
||||
DawnBufferMapWriteCallback callback,
|
||||
void* userdata);
|
||||
void FenceOnCompletion(DawnFence self,
|
||||
uint64_t value,
|
||||
DawnFenceOnCompletionCallback callback,
|
||||
DawnCallbackUserdata userdata);
|
||||
void* userdata);
|
||||
|
||||
// Special cased mockable methods
|
||||
virtual void OnDeviceSetErrorCallback(DawnDevice device, DawnDeviceErrorCallback callback, DawnCallbackUserdata userdata) = 0;
|
||||
virtual void OnBufferMapReadAsyncCallback(DawnBuffer buffer, DawnBufferMapReadCallback callback, DawnCallbackUserdata userdata) = 0;
|
||||
virtual void OnBufferMapWriteAsyncCallback(DawnBuffer buffer, DawnBufferMapWriteCallback callback, DawnCallbackUserdata userdata) = 0;
|
||||
virtual void OnDeviceSetErrorCallback(DawnDevice device,
|
||||
DawnDeviceErrorCallback callback,
|
||||
void* userdata) = 0;
|
||||
virtual void OnBufferMapReadAsyncCallback(DawnBuffer buffer,
|
||||
DawnBufferMapReadCallback callback,
|
||||
void* userdata) = 0;
|
||||
virtual void OnBufferMapWriteAsyncCallback(DawnBuffer buffer,
|
||||
DawnBufferMapWriteCallback callback,
|
||||
void* userdata) = 0;
|
||||
virtual void OnFenceOnCompletionCallback(DawnFence fence,
|
||||
uint64_t value,
|
||||
DawnFenceOnCompletionCallback callback,
|
||||
DawnCallbackUserdata userdata) = 0;
|
||||
void* userdata) = 0;
|
||||
|
||||
// Calls the stored callbacks
|
||||
void CallDeviceErrorCallback(DawnDevice device, const char* message);
|
||||
|
@ -80,8 +92,8 @@ class ProcTableAsClass {
|
|||
DawnBufferMapReadCallback mapReadCallback = nullptr;
|
||||
DawnBufferMapWriteCallback mapWriteCallback = nullptr;
|
||||
DawnFenceOnCompletionCallback fenceOnCompletionCallback = nullptr;
|
||||
DawnCallbackUserdata userdata1 = 0;
|
||||
DawnCallbackUserdata userdata2 = 0;
|
||||
void* userdata1 = 0;
|
||||
void* userdata2 = 0;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -111,14 +123,14 @@ class MockProcTable : public ProcTableAsClass {
|
|||
MOCK_METHOD1({{as_MethodSuffix(type.name, Name("release"))}}, void({{as_cType(type.name)}} self));
|
||||
{% endfor %}
|
||||
|
||||
MOCK_METHOD3(OnDeviceSetErrorCallback, void(DawnDevice device, DawnDeviceErrorCallback callback, DawnCallbackUserdata userdata));
|
||||
MOCK_METHOD3(OnBufferMapReadAsyncCallback, void(DawnBuffer buffer, DawnBufferMapReadCallback callback, DawnCallbackUserdata userdata));
|
||||
MOCK_METHOD3(OnBufferMapWriteAsyncCallback, void(DawnBuffer buffer, DawnBufferMapWriteCallback callback, DawnCallbackUserdata userdata));
|
||||
MOCK_METHOD3(OnDeviceSetErrorCallback, void(DawnDevice device, DawnDeviceErrorCallback callback, void* userdata));
|
||||
MOCK_METHOD3(OnBufferMapReadAsyncCallback, void(DawnBuffer buffer, DawnBufferMapReadCallback callback, void* userdata));
|
||||
MOCK_METHOD3(OnBufferMapWriteAsyncCallback, void(DawnBuffer buffer, DawnBufferMapWriteCallback callback, void* userdata));
|
||||
MOCK_METHOD4(OnFenceOnCompletionCallback,
|
||||
void(DawnFence fence,
|
||||
uint64_t value,
|
||||
DawnFenceOnCompletionCallback callback,
|
||||
DawnCallbackUserdata userdata));
|
||||
void* userdata));
|
||||
};
|
||||
|
||||
#endif // MOCK_DAWN_H
|
||||
|
|
|
@ -211,8 +211,7 @@ namespace dawn_native {
|
|||
}
|
||||
}
|
||||
|
||||
void BufferBase::MapReadAsync(DawnBufferMapReadCallback callback,
|
||||
DawnCallbackUserdata userdata) {
|
||||
void BufferBase::MapReadAsync(DawnBufferMapReadCallback callback, void* userdata) {
|
||||
if (GetDevice()->ConsumedError(ValidateMap(dawn::BufferUsageBit::MapRead))) {
|
||||
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
|
||||
return;
|
||||
|
@ -250,8 +249,7 @@ namespace dawn_native {
|
|||
return {};
|
||||
}
|
||||
|
||||
void BufferBase::MapWriteAsync(DawnBufferMapWriteCallback callback,
|
||||
DawnCallbackUserdata userdata) {
|
||||
void BufferBase::MapWriteAsync(DawnBufferMapWriteCallback callback, void* userdata) {
|
||||
if (GetDevice()->ConsumedError(ValidateMap(dawn::BufferUsageBit::MapWrite))) {
|
||||
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
|
||||
return;
|
||||
|
|
|
@ -58,8 +58,8 @@ namespace dawn_native {
|
|||
|
||||
// Dawn API
|
||||
void SetSubData(uint32_t start, uint32_t count, const uint8_t* data);
|
||||
void MapReadAsync(DawnBufferMapReadCallback callback, DawnCallbackUserdata userdata);
|
||||
void MapWriteAsync(DawnBufferMapWriteCallback callback, DawnCallbackUserdata userdata);
|
||||
void MapReadAsync(DawnBufferMapReadCallback callback, void* userdata);
|
||||
void MapWriteAsync(DawnBufferMapWriteCallback callback, void* userdata);
|
||||
void Unmap();
|
||||
void Destroy();
|
||||
|
||||
|
@ -95,7 +95,7 @@ namespace dawn_native {
|
|||
|
||||
DawnBufferMapReadCallback mMapReadCallback = nullptr;
|
||||
DawnBufferMapWriteCallback mMapWriteCallback = nullptr;
|
||||
DawnCallbackUserdata mMapUserdata = 0;
|
||||
void* mMapUserdata = 0;
|
||||
uint32_t mMapSerial = 0;
|
||||
|
||||
BufferState mState;
|
||||
|
|
|
@ -75,8 +75,7 @@ namespace dawn_native {
|
|||
}
|
||||
}
|
||||
|
||||
void DeviceBase::SetErrorCallback(dawn::DeviceErrorCallback callback,
|
||||
dawn::CallbackUserdata userdata) {
|
||||
void DeviceBase::SetErrorCallback(dawn::DeviceErrorCallback callback, void* userdata) {
|
||||
mErrorCallback = callback;
|
||||
mErrorUserdata = userdata;
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace dawn_native {
|
|||
|
||||
void Tick();
|
||||
|
||||
void SetErrorCallback(dawn::DeviceErrorCallback callback, dawn::CallbackUserdata userdata);
|
||||
void SetErrorCallback(dawn::DeviceErrorCallback callback, void* userdata);
|
||||
void Reference();
|
||||
void Release();
|
||||
|
||||
|
@ -204,7 +204,7 @@ namespace dawn_native {
|
|||
std::unique_ptr<FenceSignalTracker> mFenceSignalTracker;
|
||||
|
||||
dawn::DeviceErrorCallback mErrorCallback = nullptr;
|
||||
dawn::CallbackUserdata mErrorUserdata = 0;
|
||||
void* mErrorUserdata = 0;
|
||||
uint32_t mRefCount = 1;
|
||||
|
||||
TogglesSet mTogglesSet;
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace dawn_native {
|
|||
|
||||
void FenceBase::OnCompletion(uint64_t value,
|
||||
dawn::FenceOnCompletionCallback callback,
|
||||
dawn::CallbackUserdata userdata) {
|
||||
void* userdata) {
|
||||
if (GetDevice()->ConsumedError(ValidateOnCompletion(value))) {
|
||||
callback(DAWN_FENCE_COMPLETION_STATUS_ERROR, userdata);
|
||||
return;
|
||||
|
|
|
@ -40,9 +40,7 @@ namespace dawn_native {
|
|||
|
||||
// Dawn API
|
||||
uint64_t GetCompletedValue() const;
|
||||
void OnCompletion(uint64_t value,
|
||||
dawn::FenceOnCompletionCallback callback,
|
||||
dawn::CallbackUserdata userdata);
|
||||
void OnCompletion(uint64_t value, dawn::FenceOnCompletionCallback callback, void* userdata);
|
||||
|
||||
protected:
|
||||
friend class QueueBase;
|
||||
|
@ -57,7 +55,7 @@ namespace dawn_native {
|
|||
|
||||
struct OnCompletionData {
|
||||
dawn::FenceOnCompletionCallback completionCallback = nullptr;
|
||||
dawn::CallbackUserdata userdata = 0;
|
||||
void* userdata = nullptr;
|
||||
};
|
||||
|
||||
uint64_t mSignalValue;
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace dawn_wire { namespace client {
|
|||
|
||||
void ClientBufferMapReadAsync(DawnBuffer cBuffer,
|
||||
DawnBufferMapReadCallback callback,
|
||||
DawnCallbackUserdata userdata) {
|
||||
void* userdata) {
|
||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||
|
||||
uint32_t serial = buffer->requestSerial++;
|
||||
|
@ -45,7 +45,7 @@ namespace dawn_wire { namespace client {
|
|||
|
||||
void ClientBufferMapWriteAsync(DawnBuffer cBuffer,
|
||||
DawnBufferMapWriteCallback callback,
|
||||
DawnCallbackUserdata userdata) {
|
||||
void* userdata) {
|
||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||
|
||||
uint32_t serial = buffer->requestSerial++;
|
||||
|
@ -109,7 +109,7 @@ namespace dawn_wire { namespace client {
|
|||
void ClientFenceOnCompletion(DawnFence cFence,
|
||||
uint64_t value,
|
||||
DawnFenceOnCompletionCallback callback,
|
||||
DawnCallbackUserdata userdata) {
|
||||
void* userdata) {
|
||||
Fence* fence = reinterpret_cast<Fence*>(cFence);
|
||||
if (value > fence->signaledValue) {
|
||||
fence->device->HandleError("Value greater than fence signaled value");
|
||||
|
@ -222,7 +222,7 @@ namespace dawn_wire { namespace client {
|
|||
|
||||
void ClientDeviceSetErrorCallback(DawnDevice cSelf,
|
||||
DawnDeviceErrorCallback callback,
|
||||
DawnCallbackUserdata userdata) {
|
||||
void* userdata) {
|
||||
Device* device = reinterpret_cast<Device*>(cSelf);
|
||||
device->SetErrorCallback(callback, userdata);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace dawn_wire { namespace client {
|
|||
struct MapRequestData {
|
||||
DawnBufferMapReadCallback readCallback = nullptr;
|
||||
DawnBufferMapWriteCallback writeCallback = nullptr;
|
||||
DawnCallbackUserdata userdata = 0;
|
||||
void* userdata = nullptr;
|
||||
bool isWrite = false;
|
||||
};
|
||||
std::map<uint32_t, MapRequestData> requests;
|
||||
|
|
|
@ -31,8 +31,7 @@ namespace dawn_wire { namespace client {
|
|||
}
|
||||
}
|
||||
|
||||
void Device::SetErrorCallback(DawnDeviceErrorCallback errorCallback,
|
||||
DawnCallbackUserdata errorUserdata) {
|
||||
void Device::SetErrorCallback(DawnDeviceErrorCallback errorCallback, void* errorUserdata) {
|
||||
mErrorCallback = errorCallback;
|
||||
mErrorUserdata = errorUserdata;
|
||||
}
|
||||
|
|
|
@ -29,13 +29,12 @@ namespace dawn_wire { namespace client {
|
|||
|
||||
Client* GetClient();
|
||||
void HandleError(const char* message);
|
||||
void SetErrorCallback(DawnDeviceErrorCallback errorCallback,
|
||||
DawnCallbackUserdata errorUserdata);
|
||||
void SetErrorCallback(DawnDeviceErrorCallback errorCallback, void* errorUserdata);
|
||||
|
||||
private:
|
||||
Client* mClient = nullptr;
|
||||
DawnDeviceErrorCallback mErrorCallback = nullptr;
|
||||
DawnCallbackUserdata mErrorUserdata;
|
||||
void* mErrorUserdata;
|
||||
};
|
||||
|
||||
}} // namespace dawn_wire::client
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace dawn_wire { namespace client {
|
|||
|
||||
struct OnCompletionData {
|
||||
DawnFenceOnCompletionCallback completionCallback = nullptr;
|
||||
DawnCallbackUserdata userdata = 0;
|
||||
void* userdata = nullptr;
|
||||
};
|
||||
Queue* queue = nullptr;
|
||||
uint64_t signaledValue = 0;
|
||||
|
|
|
@ -22,8 +22,7 @@ namespace dawn_wire { namespace server {
|
|||
auto* deviceData = DeviceObjects().Allocate(1);
|
||||
deviceData->handle = device;
|
||||
|
||||
auto userdata = static_cast<DawnCallbackUserdata>(reinterpret_cast<intptr_t>(this));
|
||||
mProcs.deviceSetErrorCallback(device, ForwardDeviceError, userdata);
|
||||
mProcs.deviceSetErrorCallback(device, ForwardDeviceError, this);
|
||||
}
|
||||
|
||||
Server::~Server() {
|
||||
|
|
|
@ -48,17 +48,16 @@ namespace dawn_wire { namespace server {
|
|||
void* GetCmdSpace(size_t size);
|
||||
|
||||
// Forwarding callbacks
|
||||
static void ForwardDeviceError(const char* message, DawnCallbackUserdata userdata);
|
||||
static void ForwardDeviceError(const char* message, void* userdata);
|
||||
static void ForwardBufferMapReadAsync(DawnBufferMapAsyncStatus status,
|
||||
const void* ptr,
|
||||
uint64_t dataLength,
|
||||
DawnCallbackUserdata userdata);
|
||||
void* userdata);
|
||||
static void ForwardBufferMapWriteAsync(DawnBufferMapAsyncStatus status,
|
||||
void* ptr,
|
||||
uint64_t dataLength,
|
||||
DawnCallbackUserdata userdata);
|
||||
static void ForwardFenceCompletedValue(DawnFenceCompletionStatus status,
|
||||
DawnCallbackUserdata userdata);
|
||||
void* userdata);
|
||||
static void ForwardFenceCompletedValue(DawnFenceCompletionStatus status, void* userdata);
|
||||
|
||||
// Error callbacks
|
||||
void OnDeviceError(const char* message);
|
||||
|
|
|
@ -44,13 +44,11 @@ namespace dawn_wire { namespace server {
|
|||
return false;
|
||||
}
|
||||
|
||||
auto* data = new MapUserdata;
|
||||
data->server = this;
|
||||
data->buffer = ObjectHandle{bufferId, buffer->serial};
|
||||
data->requestSerial = requestSerial;
|
||||
data->isWrite = isWrite;
|
||||
|
||||
auto userdata = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(data));
|
||||
MapUserdata* userdata = new MapUserdata;
|
||||
userdata->server = this;
|
||||
userdata->buffer = ObjectHandle{bufferId, buffer->serial};
|
||||
userdata->requestSerial = requestSerial;
|
||||
userdata->isWrite = isWrite;
|
||||
|
||||
if (isWrite) {
|
||||
mProcs.bufferMapWriteAsync(buffer->handle, ForwardBufferMapWriteAsync, userdata);
|
||||
|
@ -103,16 +101,16 @@ namespace dawn_wire { namespace server {
|
|||
void Server::ForwardBufferMapReadAsync(DawnBufferMapAsyncStatus status,
|
||||
const void* ptr,
|
||||
uint64_t dataLength,
|
||||
DawnCallbackUserdata userdata) {
|
||||
auto data = reinterpret_cast<MapUserdata*>(static_cast<uintptr_t>(userdata));
|
||||
void* userdata) {
|
||||
auto data = static_cast<MapUserdata*>(userdata);
|
||||
data->server->OnBufferMapReadAsyncCallback(status, ptr, dataLength, data);
|
||||
}
|
||||
|
||||
void Server::ForwardBufferMapWriteAsync(DawnBufferMapAsyncStatus status,
|
||||
void* ptr,
|
||||
uint64_t dataLength,
|
||||
DawnCallbackUserdata userdata) {
|
||||
auto data = reinterpret_cast<MapUserdata*>(static_cast<uintptr_t>(userdata));
|
||||
void* userdata) {
|
||||
auto data = static_cast<MapUserdata*>(userdata);
|
||||
data->server->OnBufferMapWriteAsyncCallback(status, ptr, dataLength, data);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
namespace dawn_wire { namespace server {
|
||||
|
||||
void Server::ForwardDeviceError(const char* message, DawnCallbackUserdata userdata) {
|
||||
auto server = reinterpret_cast<Server*>(static_cast<intptr_t>(userdata));
|
||||
void Server::ForwardDeviceError(const char* message, void* userdata) {
|
||||
auto server = static_cast<Server*>(userdata);
|
||||
server->OnDeviceError(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,9 +18,8 @@
|
|||
|
||||
namespace dawn_wire { namespace server {
|
||||
|
||||
void Server::ForwardFenceCompletedValue(DawnFenceCompletionStatus status,
|
||||
DawnCallbackUserdata userdata) {
|
||||
auto data = reinterpret_cast<FenceCompletionUserdata*>(static_cast<uintptr_t>(userdata));
|
||||
void Server::ForwardFenceCompletedValue(DawnFenceCompletionStatus status, void* userdata) {
|
||||
auto data = static_cast<FenceCompletionUserdata*>(userdata);
|
||||
data->server->OnFenceCompletedValueUpdated(status, data);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,12 +29,11 @@ namespace dawn_wire { namespace server {
|
|||
auto* fence = FenceObjects().Get(fenceId);
|
||||
ASSERT(fence != nullptr);
|
||||
|
||||
auto* data = new FenceCompletionUserdata;
|
||||
data->server = this;
|
||||
data->fence = ObjectHandle{fenceId, fence->serial};
|
||||
data->value = signalValue;
|
||||
FenceCompletionUserdata* userdata = new FenceCompletionUserdata;
|
||||
userdata->server = this;
|
||||
userdata->fence = ObjectHandle{fenceId, fence->serial};
|
||||
userdata->value = signalValue;
|
||||
|
||||
auto userdata = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(data));
|
||||
mProcs.fenceOnCompletion(cFence, signalValue, ForwardFenceCompletedValue, userdata);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -361,8 +361,7 @@ void DawnTest::SetUp() {
|
|||
static_cast<dawn::TextureFormat>(mBinding->GetPreferredSwapChainTextureFormat()),
|
||||
dawn::TextureUsageBit::OutputAttachment, 400, 400);
|
||||
|
||||
device.SetErrorCallback(OnDeviceError,
|
||||
static_cast<DawnCallbackUserdata>(reinterpret_cast<uintptr_t>(this)));
|
||||
device.SetErrorCallback(OnDeviceError, this);
|
||||
}
|
||||
|
||||
void DawnTest::TearDown() {
|
||||
|
@ -387,8 +386,8 @@ bool DawnTest::EndExpectDeviceError() {
|
|||
}
|
||||
|
||||
// static
|
||||
void DawnTest::OnDeviceError(const char* message, DawnCallbackUserdata userdata) {
|
||||
DawnTest* self = reinterpret_cast<DawnTest*>(static_cast<uintptr_t>(userdata));
|
||||
void DawnTest::OnDeviceError(const char* message, void* userdata) {
|
||||
DawnTest* self = static_cast<DawnTest*>(userdata);
|
||||
|
||||
ASSERT_TRUE(self->mExpectError) << "Got unexpected device error: " << message;
|
||||
ASSERT_FALSE(self->mError) << "Got two errors in expect block";
|
||||
|
@ -520,11 +519,10 @@ void DawnTest::MapSlotsSynchronously() {
|
|||
|
||||
// Map all readback slots
|
||||
for (size_t i = 0; i < mReadbackSlots.size(); ++i) {
|
||||
auto userdata = new MapReadUserdata{this, i};
|
||||
MapReadUserdata* userdata = new MapReadUserdata{this, i};
|
||||
|
||||
auto& slot = mReadbackSlots[i];
|
||||
slot.buffer.MapReadAsync(SlotMapReadCallback, static_cast<dawn::CallbackUserdata>(
|
||||
reinterpret_cast<uintptr_t>(userdata)));
|
||||
slot.buffer.MapReadAsync(SlotMapReadCallback, userdata);
|
||||
}
|
||||
|
||||
// Busy wait until all map operations are done.
|
||||
|
@ -537,10 +535,10 @@ void DawnTest::MapSlotsSynchronously() {
|
|||
void DawnTest::SlotMapReadCallback(DawnBufferMapAsyncStatus status,
|
||||
const void* data,
|
||||
uint64_t,
|
||||
DawnCallbackUserdata userdata_) {
|
||||
void* userdata_) {
|
||||
DAWN_ASSERT(status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS);
|
||||
|
||||
auto userdata = reinterpret_cast<MapReadUserdata*>(static_cast<uintptr_t>(userdata_));
|
||||
auto userdata = static_cast<MapReadUserdata*>(userdata_);
|
||||
userdata->test->mReadbackSlots[userdata->slot].mappedData = data;
|
||||
userdata->test->mNumPendingMapOperations--;
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ class DawnTest : public ::testing::TestWithParam<DawnTestParam> {
|
|||
std::unique_ptr<utils::TerribleCommandBuffer> mS2cBuf;
|
||||
|
||||
// Tracking for validation errors
|
||||
static void OnDeviceError(const char* message, DawnCallbackUserdata userdata);
|
||||
static void OnDeviceError(const char* message, void* userdata);
|
||||
bool mExpectError = false;
|
||||
bool mError = false;
|
||||
|
||||
|
@ -209,7 +209,7 @@ class DawnTest : public ::testing::TestWithParam<DawnTestParam> {
|
|||
static void SlotMapReadCallback(DawnBufferMapAsyncStatus status,
|
||||
const void* data,
|
||||
uint64_t dataLength,
|
||||
DawnCallbackUserdata userdata);
|
||||
void* userdata);
|
||||
size_t mNumPendingMapOperations = 0;
|
||||
|
||||
// Reserve space where the data for an expectation can be copied
|
||||
|
|
|
@ -21,17 +21,15 @@ class BufferMapReadTests : public DawnTest {
|
|||
static void MapReadCallback(DawnBufferMapAsyncStatus status,
|
||||
const void* data,
|
||||
uint64_t,
|
||||
DawnCallbackUserdata userdata) {
|
||||
void* userdata) {
|
||||
ASSERT_EQ(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, status);
|
||||
ASSERT_NE(nullptr, data);
|
||||
|
||||
auto test = reinterpret_cast<BufferMapReadTests*>(static_cast<uintptr_t>(userdata));
|
||||
test->mappedData = data;
|
||||
static_cast<BufferMapReadTests*>(userdata)->mappedData = data;
|
||||
}
|
||||
|
||||
const void* MapReadAsyncAndWait(const dawn::Buffer& buffer) {
|
||||
buffer.MapReadAsync(MapReadCallback, static_cast<dawn::CallbackUserdata>(
|
||||
reinterpret_cast<uintptr_t>(this)));
|
||||
buffer.MapReadAsync(MapReadCallback, this);
|
||||
|
||||
while (mappedData == nullptr) {
|
||||
WaitABit();
|
||||
|
@ -88,17 +86,15 @@ class BufferMapWriteTests : public DawnTest {
|
|||
static void MapWriteCallback(DawnBufferMapAsyncStatus status,
|
||||
void* data,
|
||||
uint64_t,
|
||||
DawnCallbackUserdata userdata) {
|
||||
void* userdata) {
|
||||
ASSERT_EQ(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, status);
|
||||
ASSERT_NE(nullptr, data);
|
||||
|
||||
auto test = reinterpret_cast<BufferMapWriteTests*>(static_cast<uintptr_t>(userdata));
|
||||
test->mappedData = data;
|
||||
static_cast<BufferMapWriteTests*>(userdata)->mappedData = data;
|
||||
}
|
||||
|
||||
void* MapWriteAsyncAndWait(const dawn::Buffer& buffer) {
|
||||
buffer.MapWriteAsync(MapWriteCallback, static_cast<dawn::CallbackUserdata>(
|
||||
reinterpret_cast<uintptr_t>(this)));
|
||||
buffer.MapWriteAsync(MapWriteCallback, this);
|
||||
|
||||
while (mappedData == nullptr) {
|
||||
WaitABit();
|
||||
|
@ -301,14 +297,14 @@ TEST_P(CreateBufferMappedTests, CreateThenMapSuccess) {
|
|||
|
||||
bool done = false;
|
||||
result.buffer.MapWriteAsync(
|
||||
[](DawnBufferMapAsyncStatus status, void* data, uint64_t, DawnCallbackUserdata userdata) {
|
||||
[](DawnBufferMapAsyncStatus status, void* data, uint64_t, void* userdata) {
|
||||
ASSERT_EQ(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, status);
|
||||
ASSERT_NE(nullptr, data);
|
||||
|
||||
*reinterpret_cast<uint32_t*>(data) = myData2;
|
||||
*reinterpret_cast<bool*>(static_cast<uintptr_t>(userdata)) = true;
|
||||
*static_cast<uint32_t*>(data) = myData2;
|
||||
*static_cast<bool*>(userdata) = true;
|
||||
},
|
||||
static_cast<DawnCallbackUserdata>(reinterpret_cast<uintptr_t>(&done)));
|
||||
&done);
|
||||
|
||||
while (!done) {
|
||||
WaitABit();
|
||||
|
@ -333,14 +329,13 @@ TEST_P(CreateBufferMappedTests, CreateThenMapBeforeUnmapFailure) {
|
|||
ASSERT_DEVICE_ERROR([&]() {
|
||||
bool done = false;
|
||||
result.buffer.MapWriteAsync(
|
||||
[](DawnBufferMapAsyncStatus status, void* data, uint64_t,
|
||||
DawnCallbackUserdata userdata) {
|
||||
[](DawnBufferMapAsyncStatus status, void* data, uint64_t, void* userdata) {
|
||||
ASSERT_EQ(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, status);
|
||||
ASSERT_EQ(nullptr, data);
|
||||
|
||||
*reinterpret_cast<bool*>(static_cast<uintptr_t>(userdata)) = true;
|
||||
*static_cast<bool*>(userdata) = true;
|
||||
},
|
||||
static_cast<DawnCallbackUserdata>(reinterpret_cast<uintptr_t>(&done)));
|
||||
&done);
|
||||
|
||||
while (!done) {
|
||||
WaitABit();
|
||||
|
|
|
@ -20,12 +20,11 @@
|
|||
|
||||
class MockFenceOnCompletionCallback {
|
||||
public:
|
||||
MOCK_METHOD2(Call, void(DawnFenceCompletionStatus status, DawnCallbackUserdata userdata));
|
||||
MOCK_METHOD2(Call, void(DawnFenceCompletionStatus status, void* userdata));
|
||||
};
|
||||
|
||||
static std::unique_ptr<MockFenceOnCompletionCallback> mockFenceOnCompletionCallback;
|
||||
static void ToMockFenceOnCompletionCallback(DawnFenceCompletionStatus status,
|
||||
DawnCallbackUserdata userdata) {
|
||||
static void ToMockFenceOnCompletionCallback(DawnFenceCompletionStatus status, void* userdata) {
|
||||
mockFenceOnCompletionCallback->Call(status, userdata);
|
||||
}
|
||||
class FenceTests : public DawnTest {
|
||||
|
@ -89,35 +88,30 @@ TEST_P(FenceTests, OnCompletionOrdering) {
|
|||
|
||||
queue.Signal(fence, 4);
|
||||
|
||||
DawnCallbackUserdata userdata0 = 1282;
|
||||
DawnCallbackUserdata userdata1 = 4382;
|
||||
DawnCallbackUserdata userdata2 = 1211;
|
||||
DawnCallbackUserdata userdata3 = 1882;
|
||||
|
||||
{
|
||||
testing::InSequence s;
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata0))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 0))
|
||||
.Times(1);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata1))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 1))
|
||||
.Times(1);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata2))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 2))
|
||||
.Times(1);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata3))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 3))
|
||||
.Times(1);
|
||||
}
|
||||
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, userdata2);
|
||||
fence.OnCompletion(0u, ToMockFenceOnCompletionCallback, userdata0);
|
||||
fence.OnCompletion(3u, ToMockFenceOnCompletionCallback, userdata3);
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletionCallback, userdata1);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, this + 2);
|
||||
fence.OnCompletion(0u, ToMockFenceOnCompletionCallback, this + 0);
|
||||
fence.OnCompletion(3u, ToMockFenceOnCompletionCallback, this + 3);
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletionCallback, this + 1);
|
||||
|
||||
WaitForCompletedValue(fence, 4);
|
||||
}
|
||||
|
@ -131,11 +125,9 @@ TEST_P(FenceTests, MultipleSignalOnCompletion) {
|
|||
queue.Signal(fence, 2);
|
||||
queue.Signal(fence, 4);
|
||||
|
||||
DawnCallbackUserdata userdata = 1234;
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata))
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, nullptr))
|
||||
.Times(1);
|
||||
fence.OnCompletion(3u, ToMockFenceOnCompletionCallback, userdata);
|
||||
fence.OnCompletion(3u, ToMockFenceOnCompletionCallback, nullptr);
|
||||
|
||||
WaitForCompletedValue(fence, 4);
|
||||
}
|
||||
|
@ -148,31 +140,26 @@ TEST_P(FenceTests, OnCompletionMultipleCallbacks) {
|
|||
|
||||
queue.Signal(fence, 4);
|
||||
|
||||
DawnCallbackUserdata userdata0 = 2341;
|
||||
DawnCallbackUserdata userdata1 = 4598;
|
||||
DawnCallbackUserdata userdata2 = 5690;
|
||||
DawnCallbackUserdata userdata3 = 2783;
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata0))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 0))
|
||||
.Times(1);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata1))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 1))
|
||||
.Times(1);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata2))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 2))
|
||||
.Times(1);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata3))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 3))
|
||||
.Times(1);
|
||||
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletionCallback, userdata0);
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletionCallback, userdata1);
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletionCallback, userdata2);
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletionCallback, userdata3);
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletionCallback, this + 0);
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletionCallback, this + 1);
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletionCallback, this + 2);
|
||||
fence.OnCompletion(4u, ToMockFenceOnCompletionCallback, this + 3);
|
||||
|
||||
WaitForCompletedValue(fence, 4u);
|
||||
}
|
||||
|
@ -192,31 +179,26 @@ TEST_P(FenceTests, DISABLED_DestroyBeforeOnCompletionEnd) {
|
|||
|
||||
queue.Signal(testFence, 4);
|
||||
|
||||
DawnCallbackUserdata userdata0 = 1341;
|
||||
DawnCallbackUserdata userdata1 = 1598;
|
||||
DawnCallbackUserdata userdata2 = 1690;
|
||||
DawnCallbackUserdata userdata3 = 1783;
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_UNKNOWN, userdata0))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_UNKNOWN, this + 0))
|
||||
.Times(1);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_UNKNOWN, userdata1))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_UNKNOWN, this + 1))
|
||||
.Times(1);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_UNKNOWN, userdata2))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_UNKNOWN, this + 2))
|
||||
.Times(1);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_UNKNOWN, userdata3))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_UNKNOWN, this + 3))
|
||||
.Times(1);
|
||||
|
||||
testFence.OnCompletion(1u, ToMockFenceOnCompletionCallback, userdata0);
|
||||
testFence.OnCompletion(2u, ToMockFenceOnCompletionCallback, userdata1);
|
||||
testFence.OnCompletion(2u, ToMockFenceOnCompletionCallback, userdata2);
|
||||
testFence.OnCompletion(3u, ToMockFenceOnCompletionCallback, userdata3);
|
||||
testFence.OnCompletion(1u, ToMockFenceOnCompletionCallback, this + 0);
|
||||
testFence.OnCompletion(2u, ToMockFenceOnCompletionCallback, this + 1);
|
||||
testFence.OnCompletion(2u, ToMockFenceOnCompletionCallback, this + 2);
|
||||
testFence.OnCompletion(3u, ToMockFenceOnCompletionCallback, this + 3);
|
||||
}
|
||||
|
||||
// Wait for another fence to be sure all callbacks have cleared
|
||||
|
|
|
@ -26,14 +26,14 @@ class MockBufferMapReadCallback {
|
|||
void(DawnBufferMapAsyncStatus status,
|
||||
const uint32_t* ptr,
|
||||
uint64_t dataLength,
|
||||
DawnCallbackUserdata userdata));
|
||||
void* userdata));
|
||||
};
|
||||
|
||||
static std::unique_ptr<MockBufferMapReadCallback> mockBufferMapReadCallback;
|
||||
static void ToMockBufferMapReadCallback(DawnBufferMapAsyncStatus status,
|
||||
const void* ptr,
|
||||
uint64_t dataLength,
|
||||
DawnCallbackUserdata userdata) {
|
||||
void* userdata) {
|
||||
// Assume the data is uint32_t to make writing matchers easier
|
||||
mockBufferMapReadCallback->Call(status, reinterpret_cast<const uint32_t*>(ptr), dataLength,
|
||||
userdata);
|
||||
|
@ -45,14 +45,14 @@ class MockBufferMapWriteCallback {
|
|||
void(DawnBufferMapAsyncStatus status,
|
||||
uint32_t* ptr,
|
||||
uint64_t dataLength,
|
||||
DawnCallbackUserdata userdata));
|
||||
void* userdata));
|
||||
};
|
||||
|
||||
static std::unique_ptr<MockBufferMapWriteCallback> mockBufferMapWriteCallback;
|
||||
static void ToMockBufferMapWriteCallback(DawnBufferMapAsyncStatus status,
|
||||
void* ptr,
|
||||
uint64_t dataLength,
|
||||
DawnCallbackUserdata userdata) {
|
||||
void* userdata) {
|
||||
// Assume the data is uint32_t to make writing matchers easier
|
||||
mockBufferMapWriteCallback->Call(status, reinterpret_cast<uint32_t*>(ptr), dataLength,
|
||||
userdata);
|
||||
|
@ -166,11 +166,10 @@ TEST_F(BufferValidationTest, CreationMapUsageRestrictions) {
|
|||
TEST_F(BufferValidationTest, MapReadSuccess) {
|
||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||
|
||||
dawn::CallbackUserdata userdata = 40598;
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, _))
|
||||
.Times(1);
|
||||
queue.Submit(0, nullptr);
|
||||
|
||||
|
@ -181,11 +180,10 @@ TEST_F(BufferValidationTest, MapReadSuccess) {
|
|||
TEST_F(BufferValidationTest, MapWriteSuccess) {
|
||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||
|
||||
dawn::CallbackUserdata userdata = 40598;
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, _))
|
||||
.Times(1);
|
||||
queue.Submit(0, nullptr);
|
||||
|
||||
|
@ -208,12 +206,11 @@ TEST_F(BufferValidationTest, MapReadWrongUsage) {
|
|||
|
||||
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
||||
|
||||
dawn::CallbackUserdata userdata = 40600;
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, _))
|
||||
.Times(1);
|
||||
|
||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, userdata));
|
||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr));
|
||||
}
|
||||
|
||||
// Test map writing a buffer with wrong current usage
|
||||
|
@ -224,29 +221,26 @@ TEST_F(BufferValidationTest, MapWriteWrongUsage) {
|
|||
|
||||
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
||||
|
||||
dawn::CallbackUserdata userdata = 40600;
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, _))
|
||||
.Times(1);
|
||||
|
||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata));
|
||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr));
|
||||
}
|
||||
|
||||
// Test map reading a buffer that is already mapped
|
||||
TEST_F(BufferValidationTest, MapReadAlreadyMapped) {
|
||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||
|
||||
dawn::CallbackUserdata userdata1 = 40601;
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata1);
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, this + 0);
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata1))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, this + 0))
|
||||
.Times(1);
|
||||
|
||||
dawn::CallbackUserdata userdata2 = 40602;
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, userdata2))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, this + 1))
|
||||
.Times(1);
|
||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, userdata2));
|
||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, this + 1));
|
||||
|
||||
queue.Submit(0, nullptr);
|
||||
}
|
||||
|
@ -255,17 +249,15 @@ TEST_F(BufferValidationTest, MapReadAlreadyMapped) {
|
|||
TEST_F(BufferValidationTest, MapWriteAlreadyMapped) {
|
||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||
|
||||
dawn::CallbackUserdata userdata1 = 40601;
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata1);
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, this + 0);
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata1))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, this + 0))
|
||||
.Times(1);
|
||||
|
||||
dawn::CallbackUserdata userdata2 = 40602;
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, userdata2))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, this + 1))
|
||||
.Times(1);
|
||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata2));
|
||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, this + 1));
|
||||
|
||||
queue.Submit(0, nullptr);
|
||||
}
|
||||
|
@ -275,11 +267,10 @@ TEST_F(BufferValidationTest, MapWriteAlreadyMapped) {
|
|||
TEST_F(BufferValidationTest, MapReadUnmapBeforeResult) {
|
||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||
|
||||
dawn::CallbackUserdata userdata = 40603;
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, _))
|
||||
.Times(1);
|
||||
buf.Unmap();
|
||||
|
||||
|
@ -292,11 +283,10 @@ TEST_F(BufferValidationTest, MapReadUnmapBeforeResult) {
|
|||
TEST_F(BufferValidationTest, MapWriteUnmapBeforeResult) {
|
||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||
|
||||
dawn::CallbackUserdata userdata = 40603;
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, _))
|
||||
.Times(1);
|
||||
buf.Unmap();
|
||||
|
||||
|
@ -312,11 +302,10 @@ TEST_F(BufferValidationTest, DISABLED_MapReadDestroyBeforeResult) {
|
|||
{
|
||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||
|
||||
dawn::CallbackUserdata userdata = 40604;
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, _))
|
||||
.Times(1);
|
||||
}
|
||||
|
||||
|
@ -332,11 +321,10 @@ TEST_F(BufferValidationTest, DISABLED_MapWriteDestroyBeforeResult) {
|
|||
{
|
||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||
|
||||
dawn::CallbackUserdata userdata = 40604;
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, _))
|
||||
.Times(1);
|
||||
}
|
||||
|
||||
|
@ -350,20 +338,17 @@ TEST_F(BufferValidationTest, DISABLED_MapWriteDestroyBeforeResult) {
|
|||
TEST_F(BufferValidationTest, MapReadUnmapBeforeResultThenMapAgain) {
|
||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||
|
||||
dawn::CallbackUserdata userdata = 40605;
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, this + 0);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, this + 0))
|
||||
.Times(1);
|
||||
buf.Unmap();
|
||||
|
||||
userdata ++;
|
||||
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, this + 1);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, this + 1))
|
||||
.Times(1);
|
||||
queue.Submit(0, nullptr);
|
||||
}
|
||||
|
@ -374,20 +359,17 @@ TEST_F(BufferValidationTest, MapReadUnmapBeforeResultThenMapAgain) {
|
|||
TEST_F(BufferValidationTest, MapWriteUnmapBeforeResultThenMapAgain) {
|
||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||
|
||||
dawn::CallbackUserdata userdata = 40605;
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, this + 0);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, this + 0))
|
||||
.Times(1);
|
||||
buf.Unmap();
|
||||
|
||||
userdata ++;
|
||||
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, this + 1);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, this + 1))
|
||||
.Times(1);
|
||||
queue.Submit(0, nullptr);
|
||||
}
|
||||
|
@ -396,11 +378,10 @@ TEST_F(BufferValidationTest, MapWriteUnmapBeforeResultThenMapAgain) {
|
|||
TEST_F(BufferValidationTest, UnmapInsideMapReadCallback) {
|
||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||
|
||||
dawn::CallbackUserdata userdata = 40678;
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() { buf.Unmap(); }));
|
||||
|
||||
queue.Submit(0, nullptr);
|
||||
|
@ -410,11 +391,10 @@ TEST_F(BufferValidationTest, UnmapInsideMapReadCallback) {
|
|||
TEST_F(BufferValidationTest, UnmapInsideMapWriteCallback) {
|
||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||
|
||||
dawn::CallbackUserdata userdata = 40678;
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() { buf.Unmap(); }));
|
||||
|
||||
queue.Submit(0, nullptr);
|
||||
|
@ -424,11 +404,10 @@ TEST_F(BufferValidationTest, UnmapInsideMapWriteCallback) {
|
|||
TEST_F(BufferValidationTest, DestroyInsideMapReadCallback) {
|
||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||
|
||||
dawn::CallbackUserdata userdata = 40679;
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() { buf = dawn::Buffer(); }));
|
||||
|
||||
queue.Submit(0, nullptr);
|
||||
|
@ -438,11 +417,10 @@ TEST_F(BufferValidationTest, DestroyInsideMapReadCallback) {
|
|||
TEST_F(BufferValidationTest, DestroyInsideMapWriteCallback) {
|
||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||
|
||||
dawn::CallbackUserdata userdata = 40679;
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() { buf = dawn::Buffer(); }));
|
||||
|
||||
queue.Submit(0, nullptr);
|
||||
|
@ -530,12 +508,12 @@ TEST_F(BufferValidationTest, DestroyUnmappedBuffer) {
|
|||
TEST_F(BufferValidationTest, DestroyMappedBuffer) {
|
||||
{
|
||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, 30303);
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
|
||||
buf.Destroy();
|
||||
}
|
||||
{
|
||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, 30233);
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
|
||||
buf.Destroy();
|
||||
}
|
||||
}
|
||||
|
@ -544,22 +522,20 @@ TEST_F(BufferValidationTest, DestroyMappedBuffer) {
|
|||
TEST_F(BufferValidationTest, DestroyMappedBufferCausesImplicitUnmap) {
|
||||
{
|
||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||
dawn::CallbackUserdata userdata = 40598;
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, this + 0);
|
||||
// Buffer is destroyed. Callback should be called with UNKNOWN status
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, this + 0))
|
||||
.Times(1);
|
||||
buf.Destroy();
|
||||
queue.Submit(0, nullptr);
|
||||
}
|
||||
{
|
||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||
dawn::CallbackUserdata userdata = 23980;
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, this + 1);
|
||||
// Buffer is destroyed. Callback should be called with UNKNOWN status
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, this + 1))
|
||||
.Times(1);
|
||||
buf.Destroy();
|
||||
queue.Submit(0, nullptr);
|
||||
|
@ -592,12 +568,12 @@ TEST_F(BufferValidationTest, MapDestroyedBuffer) {
|
|||
{
|
||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||
buf.Destroy();
|
||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, 11303));
|
||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr));
|
||||
}
|
||||
{
|
||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||
buf.Destroy();
|
||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, 56303));
|
||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -613,14 +589,14 @@ TEST_F(BufferValidationTest, SetSubDataDestroyedBuffer) {
|
|||
TEST_F(BufferValidationTest, MapMappedbuffer) {
|
||||
{
|
||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, 43309);
|
||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, 34309));
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
|
||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr));
|
||||
queue.Submit(0, nullptr);
|
||||
}
|
||||
{
|
||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, 20301);
|
||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, 40303));
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
|
||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr));
|
||||
queue.Submit(0, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -629,14 +605,14 @@ TEST_F(BufferValidationTest, MapMappedbuffer) {
|
|||
TEST_F(BufferValidationTest, SetSubDataMappedBuffer) {
|
||||
{
|
||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, 42899);
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
|
||||
uint8_t foo = 0;
|
||||
ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(foo), &foo));
|
||||
queue.Submit(0, nullptr);
|
||||
}
|
||||
{
|
||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, 40329);
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
|
||||
uint8_t foo = 0;
|
||||
ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(foo), &foo));
|
||||
queue.Submit(0, nullptr);
|
||||
|
@ -675,7 +651,7 @@ TEST_F(BufferValidationTest, SubmitMappedBuffer) {
|
|||
dawn::Buffer bufA = device.CreateBuffer(&descriptorA);
|
||||
dawn::Buffer bufB = device.CreateBuffer(&descriptorB);
|
||||
|
||||
bufA.MapWriteAsync(ToMockBufferMapWriteCallback, 40329);
|
||||
bufA.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
|
||||
|
@ -687,7 +663,7 @@ TEST_F(BufferValidationTest, SubmitMappedBuffer) {
|
|||
dawn::Buffer bufA = device.CreateBuffer(&descriptorA);
|
||||
dawn::Buffer bufB = device.CreateBuffer(&descriptorB);
|
||||
|
||||
bufB.MapReadAsync(ToMockBufferMapReadCallback, 11329);
|
||||
bufB.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
|
||||
|
@ -729,7 +705,7 @@ TEST_F(BufferValidationTest, UnmapUnmappedBuffer) {
|
|||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||
// Buffer starts unmapped. Unmap should succeed.
|
||||
buf.Unmap();
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, 30603);
|
||||
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
|
||||
buf.Unmap();
|
||||
// Unmapping twice should succeed
|
||||
buf.Unmap();
|
||||
|
@ -738,7 +714,7 @@ TEST_F(BufferValidationTest, UnmapUnmappedBuffer) {
|
|||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||
// Buffer starts unmapped. Unmap should succeed.
|
||||
buf.Unmap();
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, 23890);
|
||||
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
|
||||
// Unmapping twice should succeed
|
||||
buf.Unmap();
|
||||
buf.Unmap();
|
||||
|
|
|
@ -20,7 +20,7 @@ using namespace testing;
|
|||
|
||||
class MockFenceOnCompletionCallback {
|
||||
public:
|
||||
MOCK_METHOD2(Call, void(DawnFenceCompletionStatus status, DawnCallbackUserdata userdata));
|
||||
MOCK_METHOD2(Call, void(DawnFenceCompletionStatus status, void* userdata));
|
||||
};
|
||||
|
||||
struct FenceOnCompletionExpectation {
|
||||
|
@ -30,8 +30,7 @@ struct FenceOnCompletionExpectation {
|
|||
};
|
||||
|
||||
static std::unique_ptr<MockFenceOnCompletionCallback> mockFenceOnCompletionCallback;
|
||||
static void ToMockFenceOnCompletionCallback(DawnFenceCompletionStatus status,
|
||||
DawnCallbackUserdata userdata) {
|
||||
static void ToMockFenceOnCompletionCallback(DawnFenceCompletionStatus status, void* userdata) {
|
||||
mockFenceOnCompletionCallback->Call(status, userdata);
|
||||
}
|
||||
|
||||
|
@ -42,11 +41,9 @@ class FenceValidationTest : public ValidationTest {
|
|||
expectation->fence = fence;
|
||||
expectation->value = value;
|
||||
expectation->status = status;
|
||||
DawnCallbackUserdata userdata =
|
||||
static_cast<DawnCallbackUserdata>(reinterpret_cast<uintptr_t>(expectation));
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(status, userdata)).Times(1);
|
||||
fence.OnCompletion(value, ToMockFenceOnCompletionCallback, userdata);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(status, expectation)).Times(1);
|
||||
fence.OnCompletion(value, ToMockFenceOnCompletionCallback, expectation);
|
||||
}
|
||||
|
||||
void Flush() {
|
||||
|
@ -98,13 +95,15 @@ TEST_F(FenceValidationTest, OnCompletionImmediate) {
|
|||
descriptor.initialValue = 1;
|
||||
dawn::Fence fence = queue.CreateFence(&descriptor);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, 0))
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 0))
|
||||
.Times(1);
|
||||
fence.OnCompletion(0u, ToMockFenceOnCompletionCallback, 0);
|
||||
fence.OnCompletion(0u, ToMockFenceOnCompletionCallback, this + 0);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, 1))
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 1))
|
||||
.Times(1);
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletionCallback, 1);
|
||||
fence.OnCompletion(1u, ToMockFenceOnCompletionCallback, this + 1);
|
||||
}
|
||||
|
||||
// Test setting OnCompletion handlers for values > signaled value
|
||||
|
@ -114,15 +113,15 @@ TEST_F(FenceValidationTest, OnCompletionLargerThanSignaled) {
|
|||
dawn::Fence fence = queue.CreateFence(&descriptor);
|
||||
|
||||
// Cannot signal for values > signaled value
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_ERROR, 0))
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_ERROR, nullptr))
|
||||
.Times(1);
|
||||
ASSERT_DEVICE_ERROR(fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, 0));
|
||||
ASSERT_DEVICE_ERROR(fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr));
|
||||
|
||||
// Can set handler after signaling
|
||||
queue.Signal(fence, 2);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, 0))
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, nullptr))
|
||||
.Times(1);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, 0);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr);
|
||||
|
||||
Flush();
|
||||
}
|
||||
|
@ -133,9 +132,9 @@ TEST_F(FenceValidationTest, GetCompletedValueInsideCallback) {
|
|||
dawn::Fence fence = queue.CreateFence(&descriptor);
|
||||
|
||||
queue.Signal(fence, 3);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, 0);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, 0))
|
||||
.WillOnce(Invoke([&](DawnFenceCompletionStatus status, DawnCallbackUserdata userdata) {
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, nullptr))
|
||||
.WillOnce(Invoke([&](DawnFenceCompletionStatus status, void* userdata) {
|
||||
EXPECT_EQ(fence.GetCompletedValue(), 3u);
|
||||
}));
|
||||
|
||||
|
@ -148,8 +147,8 @@ TEST_F(FenceValidationTest, GetCompletedValueAfterCallback) {
|
|||
dawn::Fence fence = queue.CreateFence(&descriptor);
|
||||
|
||||
queue.Signal(fence, 2);
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, 0);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, 0))
|
||||
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, nullptr))
|
||||
.Times(1);
|
||||
|
||||
Flush();
|
||||
|
|
|
@ -24,9 +24,8 @@ class QueueSubmitValidationTest : public ValidationTest {
|
|||
static void StoreTrueMapWriteCallback(DawnBufferMapAsyncStatus status,
|
||||
void*,
|
||||
uint64_t,
|
||||
DawnCallbackUserdata userdata) {
|
||||
bool* userdataPtr = reinterpret_cast<bool*>(static_cast<intptr_t>(userdata));
|
||||
*userdataPtr = true;
|
||||
void* userdata) {
|
||||
*static_cast<bool*>(userdata) = true;
|
||||
}
|
||||
|
||||
// Test submitting with a mapped buffer is disallowed
|
||||
|
@ -56,8 +55,7 @@ TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {
|
|||
|
||||
// Map the buffer, submitting when the buffer is mapped should fail
|
||||
bool mapWriteFinished = false;
|
||||
DawnCallbackUserdata userdata = static_cast<DawnCallbackUserdata>(reinterpret_cast<intptr_t>(&mapWriteFinished));
|
||||
buffer.MapWriteAsync(StoreTrueMapWriteCallback, userdata);
|
||||
buffer.MapWriteAsync(StoreTrueMapWriteCallback, &mapWriteFinished);
|
||||
queue.Submit(0, nullptr);
|
||||
ASSERT_TRUE(mapWriteFinished);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ ValidationTest::ValidationTest() {
|
|||
DawnProcTable procs = dawn_native::GetProcs();
|
||||
dawnSetProcs(&procs);
|
||||
|
||||
device.SetErrorCallback(ValidationTest::OnDeviceError, static_cast<DawnCallbackUserdata>(reinterpret_cast<uintptr_t>(this)));
|
||||
device.SetErrorCallback(ValidationTest::OnDeviceError, this);
|
||||
}
|
||||
|
||||
ValidationTest::~ValidationTest() {
|
||||
|
@ -67,8 +67,8 @@ std::string ValidationTest::GetLastDeviceErrorMessage() const {
|
|||
}
|
||||
|
||||
// static
|
||||
void ValidationTest::OnDeviceError(const char* message, DawnCallbackUserdata userdata) {
|
||||
auto self = reinterpret_cast<ValidationTest*>(static_cast<uintptr_t>(userdata));
|
||||
void ValidationTest::OnDeviceError(const char* message, void* userdata) {
|
||||
auto self = static_cast<ValidationTest*>(userdata);
|
||||
self->mDeviceErrorMessage = message;
|
||||
|
||||
ASSERT_TRUE(self->mExpectError) << "Got unexpected device error: " << message;
|
||||
|
|
|
@ -25,41 +25,41 @@
|
|||
ASSERT_TRUE(EndExpectDeviceError());
|
||||
|
||||
class ValidationTest : public testing::Test {
|
||||
public:
|
||||
ValidationTest();
|
||||
~ValidationTest();
|
||||
public:
|
||||
ValidationTest();
|
||||
~ValidationTest();
|
||||
|
||||
void TearDown() override;
|
||||
void TearDown() override;
|
||||
|
||||
void StartExpectDeviceError();
|
||||
bool EndExpectDeviceError();
|
||||
std::string GetLastDeviceErrorMessage() const;
|
||||
void StartExpectDeviceError();
|
||||
bool EndExpectDeviceError();
|
||||
std::string GetLastDeviceErrorMessage() const;
|
||||
|
||||
// Helper functions to create objects to test validation.
|
||||
// Helper functions to create objects to test validation.
|
||||
|
||||
struct DummyRenderPass : public dawn::RenderPassDescriptor{
|
||||
public:
|
||||
DummyRenderPass(const dawn::Device& device);
|
||||
dawn::Texture attachment;
|
||||
dawn::TextureFormat attachmentFormat;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
struct DummyRenderPass : public dawn::RenderPassDescriptor {
|
||||
public:
|
||||
DummyRenderPass(const dawn::Device& device);
|
||||
dawn::Texture attachment;
|
||||
dawn::TextureFormat attachmentFormat;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
|
||||
private:
|
||||
dawn::RenderPassColorAttachmentDescriptor mColorAttachment;
|
||||
dawn::RenderPassColorAttachmentDescriptor* mColorAttachments[1];
|
||||
};
|
||||
private:
|
||||
dawn::RenderPassColorAttachmentDescriptor mColorAttachment;
|
||||
dawn::RenderPassColorAttachmentDescriptor* mColorAttachments[1];
|
||||
};
|
||||
|
||||
protected:
|
||||
dawn::Device device;
|
||||
dawn_native::Adapter adapter;
|
||||
std::unique_ptr<dawn_native::Instance> instance;
|
||||
protected:
|
||||
dawn::Device device;
|
||||
dawn_native::Adapter adapter;
|
||||
std::unique_ptr<dawn_native::Instance> instance;
|
||||
|
||||
private:
|
||||
static void OnDeviceError(const char* message, DawnCallbackUserdata userdata);
|
||||
std::string mDeviceErrorMessage;
|
||||
bool mExpectError = false;
|
||||
bool mError = false;
|
||||
private:
|
||||
static void OnDeviceError(const char* message, void* userdata);
|
||||
std::string mDeviceErrorMessage;
|
||||
bool mExpectError = false;
|
||||
bool mError = false;
|
||||
};
|
||||
|
||||
#endif // TESTS_UNITTESTS_VALIDATIONTEST_H_
|
||||
|
|
|
@ -26,14 +26,14 @@ namespace {
|
|||
void(DawnBufferMapAsyncStatus status,
|
||||
const uint32_t* ptr,
|
||||
uint64_t dataLength,
|
||||
DawnCallbackUserdata userdata));
|
||||
void* userdata));
|
||||
};
|
||||
|
||||
std::unique_ptr<StrictMock<MockBufferMapReadCallback>> mockBufferMapReadCallback;
|
||||
void ToMockBufferMapReadCallback(DawnBufferMapAsyncStatus status,
|
||||
const void* ptr,
|
||||
uint64_t dataLength,
|
||||
DawnCallbackUserdata userdata) {
|
||||
void* userdata) {
|
||||
// Assume the data is uint32_t to make writing matchers easier
|
||||
mockBufferMapReadCallback->Call(status, static_cast<const uint32_t*>(ptr), dataLength,
|
||||
userdata);
|
||||
|
@ -45,7 +45,7 @@ namespace {
|
|||
void(DawnBufferMapAsyncStatus status,
|
||||
uint32_t* ptr,
|
||||
uint64_t dataLength,
|
||||
DawnCallbackUserdata userdata));
|
||||
void* userdata));
|
||||
};
|
||||
|
||||
std::unique_ptr<StrictMock<MockBufferMapWriteCallback>> mockBufferMapWriteCallback;
|
||||
|
@ -53,7 +53,7 @@ namespace {
|
|||
void ToMockBufferMapWriteCallback(DawnBufferMapAsyncStatus status,
|
||||
void* ptr,
|
||||
uint64_t dataLength,
|
||||
DawnCallbackUserdata userdata) {
|
||||
void* userdata) {
|
||||
// Assume the data is uint32_t to make writing matchers easier
|
||||
lastMapWritePointer = static_cast<uint32_t*>(ptr);
|
||||
mockBufferMapWriteCallback->Call(status, lastMapWritePointer, dataLength, userdata);
|
||||
|
@ -110,8 +110,7 @@ class WireBufferMappingTests : public WireTest {
|
|||
|
||||
// Check mapping for reading a succesfully created buffer
|
||||
TEST_F(WireBufferMappingTests, MappingForReadSuccessBuffer) {
|
||||
DawnCallbackUserdata userdata = 8653;
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||
|
@ -122,9 +121,8 @@ TEST_F(WireBufferMappingTests, MappingForReadSuccessBuffer) {
|
|||
|
||||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(bufferContent)),
|
||||
sizeof(uint32_t), userdata))
|
||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||
Pointee(Eq(bufferContent)), sizeof(uint32_t), _))
|
||||
.Times(1);
|
||||
|
||||
FlushServer();
|
||||
|
@ -138,8 +136,7 @@ TEST_F(WireBufferMappingTests, MappingForReadSuccessBuffer) {
|
|||
// Check that things work correctly when a validation error happens when mapping the buffer for
|
||||
// reading
|
||||
TEST_F(WireBufferMappingTests, ErrorWhileMappingForRead) {
|
||||
DawnCallbackUserdata userdata = 8654;
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
|
@ -148,8 +145,7 @@ TEST_F(WireBufferMappingTests, ErrorWhileMappingForRead) {
|
|||
|
||||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata))
|
||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, _))
|
||||
.Times(1);
|
||||
|
||||
FlushServer();
|
||||
|
@ -158,8 +154,7 @@ TEST_F(WireBufferMappingTests, ErrorWhileMappingForRead) {
|
|||
// Check that the map read callback is called with UNKNOWN when the buffer is destroyed before the
|
||||
// request is finished
|
||||
TEST_F(WireBufferMappingTests, DestroyBeforeReadRequestEnd) {
|
||||
DawnCallbackUserdata userdata = 8656;
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||
|
||||
// Return success
|
||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||
|
@ -169,7 +164,7 @@ TEST_F(WireBufferMappingTests, DestroyBeforeReadRequestEnd) {
|
|||
|
||||
// Destroy before the client gets the success, so the callback is called with unknown.
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, _))
|
||||
.Times(1);
|
||||
dawnBufferRelease(buffer);
|
||||
EXPECT_CALL(api, BufferRelease(apiBuffer));
|
||||
|
@ -181,8 +176,7 @@ TEST_F(WireBufferMappingTests, DestroyBeforeReadRequestEnd) {
|
|||
// Check the map read callback is called with UNKNOWN when the map request would have worked, but
|
||||
// Unmap was called
|
||||
TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForRead) {
|
||||
DawnCallbackUserdata userdata = 8657;
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||
|
@ -195,7 +189,7 @@ TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForRead) {
|
|||
|
||||
// Oh no! We are calling Unmap too early!
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, _))
|
||||
.Times(1);
|
||||
dawnBufferUnmap(buffer);
|
||||
|
||||
|
@ -206,8 +200,7 @@ TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForRead) {
|
|||
// Check that an error map read callback gets nullptr while a buffer is already mapped
|
||||
TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullptr) {
|
||||
// Successful map
|
||||
DawnCallbackUserdata userdata = 34098;
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||
|
@ -219,16 +212,14 @@ TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullp
|
|||
|
||||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(bufferContent)),
|
||||
sizeof(uint32_t), userdata))
|
||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||
Pointee(Eq(bufferContent)), sizeof(uint32_t), _))
|
||||
.Times(1);
|
||||
|
||||
FlushServer();
|
||||
|
||||
// Map failure while the buffer is already mapped
|
||||
userdata++;
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0);
|
||||
|
@ -236,8 +227,7 @@ TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullp
|
|||
|
||||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata))
|
||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, _))
|
||||
.Times(1);
|
||||
|
||||
FlushServer();
|
||||
|
@ -245,8 +235,7 @@ TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullp
|
|||
|
||||
// Test that the MapReadCallback isn't fired twice when unmap() is called inside the callback
|
||||
TEST_F(WireBufferMappingTests, UnmapInsideMapReadCallback) {
|
||||
DawnCallbackUserdata userdata = 2039;
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||
|
@ -257,9 +246,8 @@ TEST_F(WireBufferMappingTests, UnmapInsideMapReadCallback) {
|
|||
|
||||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(bufferContent)),
|
||||
sizeof(uint32_t), userdata))
|
||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||
Pointee(Eq(bufferContent)), sizeof(uint32_t), _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferUnmap(buffer); }));
|
||||
|
||||
FlushServer();
|
||||
|
@ -272,8 +260,7 @@ TEST_F(WireBufferMappingTests, UnmapInsideMapReadCallback) {
|
|||
// Test that the MapReadCallback isn't fired twice the buffer external refcount reaches 0 in the
|
||||
// callback
|
||||
TEST_F(WireBufferMappingTests, DestroyInsideMapReadCallback) {
|
||||
DawnCallbackUserdata userdata = 2039;
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||
|
@ -284,9 +271,8 @@ TEST_F(WireBufferMappingTests, DestroyInsideMapReadCallback) {
|
|||
|
||||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(bufferContent)),
|
||||
sizeof(uint32_t), userdata))
|
||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||
Pointee(Eq(bufferContent)), sizeof(uint32_t), _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferRelease(buffer); }));
|
||||
|
||||
FlushServer();
|
||||
|
@ -300,8 +286,7 @@ TEST_F(WireBufferMappingTests, DestroyInsideMapReadCallback) {
|
|||
|
||||
// Check mapping for writing a succesfully created buffer
|
||||
TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
|
||||
DawnCallbackUserdata userdata = 8653;
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||
|
||||
uint32_t serverBufferContent = 31337;
|
||||
uint32_t updatedContent = 4242;
|
||||
|
@ -316,8 +301,8 @@ TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
|
|||
FlushClient();
|
||||
|
||||
// The map write callback always gets a buffer full of zeroes.
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||
Pointee(Eq(zero)), sizeof(uint32_t), userdata))
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(zero)), sizeof(uint32_t), _))
|
||||
.Times(1);
|
||||
|
||||
FlushServer();
|
||||
|
@ -337,8 +322,7 @@ TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
|
|||
// Check that things work correctly when a validation error happens when mapping the buffer for
|
||||
// writing
|
||||
TEST_F(WireBufferMappingTests, ErrorWhileMappingForWrite) {
|
||||
DawnCallbackUserdata userdata = 8654;
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
|
@ -348,7 +332,7 @@ TEST_F(WireBufferMappingTests, ErrorWhileMappingForWrite) {
|
|||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, _))
|
||||
.Times(1);
|
||||
|
||||
FlushServer();
|
||||
|
@ -357,8 +341,7 @@ TEST_F(WireBufferMappingTests, ErrorWhileMappingForWrite) {
|
|||
// Check that the map write callback is called with UNKNOWN when the buffer is destroyed before the
|
||||
// request is finished
|
||||
TEST_F(WireBufferMappingTests, DestroyBeforeWriteRequestEnd) {
|
||||
DawnCallbackUserdata userdata = 8656;
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||
|
||||
// Return success
|
||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
||||
|
@ -368,7 +351,7 @@ TEST_F(WireBufferMappingTests, DestroyBeforeWriteRequestEnd) {
|
|||
|
||||
// Destroy before the client gets the success, so the callback is called with unknown.
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, _))
|
||||
.Times(1);
|
||||
dawnBufferRelease(buffer);
|
||||
EXPECT_CALL(api, BufferRelease(apiBuffer));
|
||||
|
@ -380,8 +363,7 @@ TEST_F(WireBufferMappingTests, DestroyBeforeWriteRequestEnd) {
|
|||
// Check the map read callback is called with UNKNOWN when the map request would have worked, but
|
||||
// Unmap was called
|
||||
TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForWrite) {
|
||||
DawnCallbackUserdata userdata = 8657;
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
||||
|
@ -394,7 +376,7 @@ TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForWrite) {
|
|||
|
||||
// Oh no! We are calling Unmap too early!
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, _))
|
||||
.Times(1);
|
||||
dawnBufferUnmap(buffer);
|
||||
|
||||
|
@ -405,8 +387,7 @@ TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForWrite) {
|
|||
// Check that an error map read callback gets nullptr while a buffer is already mapped
|
||||
TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullptr) {
|
||||
// Successful map
|
||||
DawnCallbackUserdata userdata = 34098;
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
uint32_t zero = 0;
|
||||
|
@ -419,15 +400,14 @@ TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullp
|
|||
|
||||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||
Pointee(Eq(zero)), sizeof(uint32_t), userdata))
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(zero)), sizeof(uint32_t), _))
|
||||
.Times(1);
|
||||
|
||||
FlushServer();
|
||||
|
||||
// Map failure while the buffer is already mapped
|
||||
userdata++;
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0);
|
||||
|
@ -436,7 +416,7 @@ TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullp
|
|||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, _))
|
||||
.Times(1);
|
||||
|
||||
FlushServer();
|
||||
|
@ -444,8 +424,7 @@ TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullp
|
|||
|
||||
// Test that the MapWriteCallback isn't fired twice when unmap() is called inside the callback
|
||||
TEST_F(WireBufferMappingTests, UnmapInsideMapWriteCallback) {
|
||||
DawnCallbackUserdata userdata = 2039;
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
uint32_t zero = 0;
|
||||
|
@ -457,8 +436,8 @@ TEST_F(WireBufferMappingTests, UnmapInsideMapWriteCallback) {
|
|||
|
||||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||
Pointee(Eq(zero)), sizeof(uint32_t), userdata))
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(zero)), sizeof(uint32_t), _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferUnmap(buffer); }));
|
||||
|
||||
FlushServer();
|
||||
|
@ -471,8 +450,7 @@ TEST_F(WireBufferMappingTests, UnmapInsideMapWriteCallback) {
|
|||
// Test that the MapWriteCallback isn't fired twice the buffer external refcount reaches 0 in the
|
||||
// callback
|
||||
TEST_F(WireBufferMappingTests, DestroyInsideMapWriteCallback) {
|
||||
DawnCallbackUserdata userdata = 2039;
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||
|
||||
uint32_t bufferContent = 31337;
|
||||
uint32_t zero = 0;
|
||||
|
@ -484,8 +462,8 @@ TEST_F(WireBufferMappingTests, DestroyInsideMapWriteCallback) {
|
|||
|
||||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||
Pointee(Eq(zero)), sizeof(uint32_t), userdata))
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(zero)), sizeof(uint32_t), _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferRelease(buffer); }));
|
||||
|
||||
FlushServer();
|
||||
|
@ -575,8 +553,7 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapSuccess) {
|
|||
|
||||
FlushClient();
|
||||
|
||||
DawnCallbackUserdata userdata = 2499;
|
||||
dawnBufferMapWriteAsync(result.buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
dawnBufferMapWriteAsync(result.buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||
|
||||
uint32_t zero = 0;
|
||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
||||
|
@ -588,8 +565,7 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapSuccess) {
|
|||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||
Pointee(Eq(zero)), sizeof(uint32_t), userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(zero)), sizeof(uint32_t), _))
|
||||
.Times(1);
|
||||
|
||||
FlushServer();
|
||||
|
@ -616,8 +592,7 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapFailure) {
|
|||
|
||||
FlushClient();
|
||||
|
||||
DawnCallbackUserdata userdata = 2499;
|
||||
dawnBufferMapWriteAsync(result.buffer, ToMockBufferMapWriteCallback, userdata);
|
||||
dawnBufferMapWriteAsync(result.buffer, ToMockBufferMapWriteCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
|
@ -627,7 +602,7 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapFailure) {
|
|||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata))
|
||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, _))
|
||||
.Times(1);
|
||||
|
||||
FlushServer();
|
||||
|
|
|
@ -22,11 +22,11 @@ namespace {
|
|||
// Mock classes to add expectations on the wire calling callbacks
|
||||
class MockDeviceErrorCallback {
|
||||
public:
|
||||
MOCK_METHOD2(Call, void(const char* message, DawnCallbackUserdata userdata));
|
||||
MOCK_METHOD2(Call, void(const char* message, void* userdata));
|
||||
};
|
||||
|
||||
std::unique_ptr<StrictMock<MockDeviceErrorCallback>> mockDeviceErrorCallback;
|
||||
void ToMockDeviceErrorCallback(const char* message, DawnCallbackUserdata userdata) {
|
||||
void ToMockDeviceErrorCallback(const char* message, void* userdata) {
|
||||
mockDeviceErrorCallback->Call(message, userdata);
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,7 @@ class WireErrorCallbackTests : public WireTest {
|
|||
|
||||
// Test the return wire for device error callbacks
|
||||
TEST_F(WireErrorCallbackTests, DeviceErrorCallback) {
|
||||
uint64_t userdata = 3049785;
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, userdata);
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, this);
|
||||
|
||||
// Setting the error callback should stay on the client side and do nothing
|
||||
FlushClient();
|
||||
|
@ -69,7 +68,7 @@ TEST_F(WireErrorCallbackTests, DeviceErrorCallback) {
|
|||
// client side
|
||||
api.CallDeviceErrorCallback(apiDevice, "Some error message");
|
||||
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(StrEq("Some error message"), userdata)).Times(1);
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(StrEq("Some error message"), this)).Times(1);
|
||||
|
||||
FlushServer();
|
||||
}
|
||||
|
|
|
@ -22,22 +22,21 @@ namespace {
|
|||
// Mock classes to add expectations on the wire calling callbacks
|
||||
class MockDeviceErrorCallback {
|
||||
public:
|
||||
MOCK_METHOD2(Call, void(const char* message, DawnCallbackUserdata userdata));
|
||||
MOCK_METHOD2(Call, void(const char* message, void* userdata));
|
||||
};
|
||||
|
||||
std::unique_ptr<StrictMock<MockDeviceErrorCallback>> mockDeviceErrorCallback;
|
||||
void ToMockDeviceErrorCallback(const char* message, DawnCallbackUserdata userdata) {
|
||||
void ToMockDeviceErrorCallback(const char* message, void* userdata) {
|
||||
mockDeviceErrorCallback->Call(message, userdata);
|
||||
}
|
||||
|
||||
class MockFenceOnCompletionCallback {
|
||||
public:
|
||||
MOCK_METHOD2(Call, void(DawnFenceCompletionStatus status, DawnCallbackUserdata userdata));
|
||||
MOCK_METHOD2(Call, void(DawnFenceCompletionStatus status, void* userdata));
|
||||
};
|
||||
|
||||
std::unique_ptr<StrictMock<MockFenceOnCompletionCallback>> mockFenceOnCompletionCallback;
|
||||
void ToMockFenceOnCompletionCallback(DawnFenceCompletionStatus status,
|
||||
DawnCallbackUserdata userdata) {
|
||||
void ToMockFenceOnCompletionCallback(DawnFenceCompletionStatus status, void* userdata) {
|
||||
mockFenceOnCompletionCallback->Call(status, userdata);
|
||||
}
|
||||
|
||||
|
@ -121,9 +120,8 @@ TEST_F(WireFenceTests, QueueSignalSuccess) {
|
|||
// Without any flushes, it is valid to signal a value greater than the current
|
||||
// signaled value
|
||||
TEST_F(WireFenceTests, QueueSignalSynchronousValidationSuccess) {
|
||||
DawnCallbackUserdata userdata = 9157;
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, userdata);
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, userdata)).Times(0);
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, nullptr);
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, _)).Times(0);
|
||||
|
||||
dawnQueueSignal(queue, fence, 2u);
|
||||
dawnQueueSignal(queue, fence, 4u);
|
||||
|
@ -133,22 +131,21 @@ TEST_F(WireFenceTests, QueueSignalSynchronousValidationSuccess) {
|
|||
// Without any flushes, errors should be generated when signaling a value less
|
||||
// than or equal to the current signaled value
|
||||
TEST_F(WireFenceTests, QueueSignalSynchronousValidationError) {
|
||||
DawnCallbackUserdata userdata = 3157;
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, userdata);
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, nullptr);
|
||||
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, userdata)).Times(1);
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, _)).Times(1);
|
||||
dawnQueueSignal(queue, fence, 0u); // Error
|
||||
EXPECT_TRUE(Mock::VerifyAndClear(mockDeviceErrorCallback.get()));
|
||||
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, userdata)).Times(1);
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, _)).Times(1);
|
||||
dawnQueueSignal(queue, fence, 1u); // Error
|
||||
EXPECT_TRUE(Mock::VerifyAndClear(mockDeviceErrorCallback.get()));
|
||||
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, userdata)).Times(0);
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, _)).Times(0);
|
||||
dawnQueueSignal(queue, fence, 4u); // Success
|
||||
EXPECT_TRUE(Mock::VerifyAndClear(mockDeviceErrorCallback.get()));
|
||||
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, userdata)).Times(1);
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, _)).Times(1);
|
||||
dawnQueueSignal(queue, fence, 3u); // Error
|
||||
EXPECT_TRUE(Mock::VerifyAndClear(mockDeviceErrorCallback.get()));
|
||||
}
|
||||
|
@ -157,20 +154,16 @@ TEST_F(WireFenceTests, QueueSignalSynchronousValidationError) {
|
|||
TEST_F(WireFenceTests, OnCompletionImmediate) {
|
||||
// Can call on value < (initial) signaled value happens immediately
|
||||
{
|
||||
DawnCallbackUserdata userdata = 9847;
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata))
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, _))
|
||||
.Times(1);
|
||||
dawnFenceOnCompletion(fence, 0, ToMockFenceOnCompletionCallback, userdata);
|
||||
dawnFenceOnCompletion(fence, 0, ToMockFenceOnCompletionCallback, nullptr);
|
||||
}
|
||||
|
||||
// Can call on value == (initial) signaled value happens immediately
|
||||
{
|
||||
DawnCallbackUserdata userdata = 4347;
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata))
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, _))
|
||||
.Times(1);
|
||||
dawnFenceOnCompletion(fence, 1, ToMockFenceOnCompletionCallback, userdata);
|
||||
dawnFenceOnCompletion(fence, 1, ToMockFenceOnCompletionCallback, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,34 +172,29 @@ TEST_F(WireFenceTests, OnCompletionMultiple) {
|
|||
DoQueueSignal(3u);
|
||||
DoQueueSignal(6u);
|
||||
|
||||
DawnCallbackUserdata userdata0 = 2134;
|
||||
DawnCallbackUserdata userdata1 = 7134;
|
||||
DawnCallbackUserdata userdata2 = 3144;
|
||||
DawnCallbackUserdata userdata3 = 1130;
|
||||
|
||||
// Add callbacks in a non-monotonic order. They should still be called
|
||||
// in order of increasing fence value.
|
||||
// Add multiple callbacks for the same value.
|
||||
dawnFenceOnCompletion(fence, 6, ToMockFenceOnCompletionCallback, userdata0);
|
||||
dawnFenceOnCompletion(fence, 2, ToMockFenceOnCompletionCallback, userdata1);
|
||||
dawnFenceOnCompletion(fence, 3, ToMockFenceOnCompletionCallback, userdata2);
|
||||
dawnFenceOnCompletion(fence, 2, ToMockFenceOnCompletionCallback, userdata3);
|
||||
dawnFenceOnCompletion(fence, 6, ToMockFenceOnCompletionCallback, this + 0);
|
||||
dawnFenceOnCompletion(fence, 2, ToMockFenceOnCompletionCallback, this + 1);
|
||||
dawnFenceOnCompletion(fence, 3, ToMockFenceOnCompletionCallback, this + 2);
|
||||
dawnFenceOnCompletion(fence, 2, ToMockFenceOnCompletionCallback, this + 3);
|
||||
|
||||
Sequence s1, s2;
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata1))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 1))
|
||||
.Times(1)
|
||||
.InSequence(s1);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata3))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 3))
|
||||
.Times(1)
|
||||
.InSequence(s2);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata2))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 2))
|
||||
.Times(1)
|
||||
.InSequence(s1, s2);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata0))
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 0))
|
||||
.Times(1)
|
||||
.InSequence(s1, s2);
|
||||
|
||||
|
@ -229,15 +217,13 @@ TEST_F(WireFenceTests, OnCompletionSynchronousValidationSuccess) {
|
|||
// Without any flushes, errors should be generated when waiting on a value greater
|
||||
// than the last signaled value
|
||||
TEST_F(WireFenceTests, OnCompletionSynchronousValidationError) {
|
||||
DawnCallbackUserdata userdata1 = 3817;
|
||||
DawnCallbackUserdata userdata2 = 3857;
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, userdata2);
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, this + 1);
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_ERROR, userdata1))
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_ERROR, this + 0))
|
||||
.Times(1);
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, userdata2)).Times(1);
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, this + 1)).Times(1);
|
||||
|
||||
dawnFenceOnCompletion(fence, 2u, ToMockFenceOnCompletionCallback, userdata1);
|
||||
dawnFenceOnCompletion(fence, 2u, ToMockFenceOnCompletionCallback, this + 0);
|
||||
}
|
||||
|
||||
// Check that the fence completed value is initialized
|
||||
|
@ -263,11 +249,9 @@ TEST_F(WireFenceTests, GetCompletedValueNoUpdate) {
|
|||
// Check that the callback is called with UNKNOWN when the fence is destroyed
|
||||
// before the completed value is updated
|
||||
TEST_F(WireFenceTests, DestroyBeforeOnCompletionEnd) {
|
||||
DawnCallbackUserdata userdata = 8616;
|
||||
dawnQueueSignal(queue, fence, 3u);
|
||||
dawnFenceOnCompletion(fence, 2u, ToMockFenceOnCompletionCallback, userdata);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback,
|
||||
Call(DAWN_FENCE_COMPLETION_STATUS_UNKNOWN, userdata))
|
||||
dawnFenceOnCompletion(fence, 2u, ToMockFenceOnCompletionCallback, nullptr);
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_UNKNOWN, _))
|
||||
.Times(1);
|
||||
}
|
||||
|
||||
|
@ -278,10 +262,8 @@ TEST_F(WireFenceTests, SignalWrongQueue) {
|
|||
EXPECT_CALL(api, DeviceCreateQueue(apiDevice)).WillOnce(Return(apiQueue2));
|
||||
FlushClient();
|
||||
|
||||
DawnCallbackUserdata userdata = 1520;
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, userdata);
|
||||
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, userdata)).Times(1);
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, nullptr);
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, _)).Times(1);
|
||||
dawnQueueSignal(queue2, fence, 2u); // error
|
||||
}
|
||||
|
||||
|
@ -292,10 +274,8 @@ TEST_F(WireFenceTests, SignalWrongQueueDoesNotUpdateValue) {
|
|||
EXPECT_CALL(api, DeviceCreateQueue(apiDevice)).WillOnce(Return(apiQueue2));
|
||||
FlushClient();
|
||||
|
||||
DawnCallbackUserdata userdata = 1024;
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, userdata);
|
||||
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, userdata)).Times(1);
|
||||
dawnDeviceSetErrorCallback(device, ToMockDeviceErrorCallback, nullptr);
|
||||
EXPECT_CALL(*mockDeviceErrorCallback, Call(_, _)).Times(1);
|
||||
dawnQueueSignal(queue2, fence, 2u); // error
|
||||
|
||||
// Fence value should be unchanged.
|
||||
|
|
Loading…
Reference in New Issue