Remove |start| and |size| from buffer mapping
This is part of making buffer mapping match WebGPU Bug: dawn:7 Change-Id: Ia97c872e398112aef0f93c98618c8a7f3ff0c19a Reviewed-on: https://dawn-review.googlesource.com/c/4580 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
1198270483
commit
1541c8ba7a
|
@ -164,21 +164,15 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_comment": "Contrary to set sub data, this is in char size",
|
|
||||||
"name": "map read async",
|
"name": "map read async",
|
||||||
"args": [
|
"args": [
|
||||||
{"name": "start", "type": "uint32_t"},
|
|
||||||
{"name": "size", "type": "uint32_t"},
|
|
||||||
{"name": "callback", "type": "buffer map read callback"},
|
{"name": "callback", "type": "buffer map read callback"},
|
||||||
{"name": "userdata", "type": "callback userdata"}
|
{"name": "userdata", "type": "callback userdata"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_comment": "Contrary to set sub data, this is in char size",
|
|
||||||
"name": "map write async",
|
"name": "map write async",
|
||||||
"args": [
|
"args": [
|
||||||
{"name": "start", "type": "uint32_t"},
|
|
||||||
{"name": "size", "type": "uint32_t"},
|
|
||||||
{"name": "callback", "type": "buffer map write callback"},
|
{"name": "callback", "type": "buffer map write callback"},
|
||||||
{"name": "userdata", "type": "callback userdata"}
|
{"name": "userdata", "type": "callback userdata"}
|
||||||
]
|
]
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
"buffer map async": [
|
"buffer map async": [
|
||||||
{ "name": "buffer id", "type": "ObjectId" },
|
{ "name": "buffer id", "type": "ObjectId" },
|
||||||
{ "name": "request serial", "type": "uint32_t" },
|
{ "name": "request serial", "type": "uint32_t" },
|
||||||
{ "name": "start", "type": "uint32_t" },
|
|
||||||
{ "name": "size", "type": "uint32_t" },
|
|
||||||
{ "name": "is write", "type": "bool" }
|
{ "name": "is write", "type": "bool" }
|
||||||
],
|
],
|
||||||
"buffer update mapped data": [
|
"buffer update mapped data": [
|
||||||
|
@ -43,7 +41,8 @@
|
||||||
"buffer map write async callback": [
|
"buffer map write async callback": [
|
||||||
{ "name": "buffer", "type": "ObjectHandle", "handle_type": "buffer" },
|
{ "name": "buffer", "type": "ObjectHandle", "handle_type": "buffer" },
|
||||||
{ "name": "request serial", "type": "uint32_t" },
|
{ "name": "request serial", "type": "uint32_t" },
|
||||||
{ "name": "status", "type": "uint32_t" }
|
{ "name": "status", "type": "uint32_t" },
|
||||||
|
{ "name": "data length", "type": "uint32_t" }
|
||||||
],
|
],
|
||||||
"device error callback": [
|
"device error callback": [
|
||||||
{ "name": "message", "type": "char", "annotation": "const*", "length": "strlen" }
|
{ "name": "message", "type": "char", "annotation": "const*", "length": "strlen" }
|
||||||
|
|
|
@ -51,8 +51,8 @@
|
||||||
typedef uint64_t dawnCallbackUserdata;
|
typedef uint64_t dawnCallbackUserdata;
|
||||||
typedef void (*dawnDeviceErrorCallback)(const char* message, dawnCallbackUserdata userdata);
|
typedef void (*dawnDeviceErrorCallback)(const char* message, dawnCallbackUserdata userdata);
|
||||||
typedef void (*dawnBuilderErrorCallback)(dawnBuilderErrorStatus status, const char* message, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2);
|
typedef void (*dawnBuilderErrorCallback)(dawnBuilderErrorStatus status, const char* message, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2);
|
||||||
typedef void (*dawnBufferMapReadCallback)(dawnBufferMapAsyncStatus status, const void* data, dawnCallbackUserdata userdata);
|
typedef void (*dawnBufferMapReadCallback)(dawnBufferMapAsyncStatus status, const void* data, uint32_t dataLength, dawnCallbackUserdata userdata);
|
||||||
typedef void (*dawnBufferMapWriteCallback)(dawnBufferMapAsyncStatus status, void* data, dawnCallbackUserdata userdata);
|
typedef void (*dawnBufferMapWriteCallback)(dawnBufferMapAsyncStatus status, void* data, uint32_t dataLength, dawnCallbackUserdata userdata);
|
||||||
typedef void (*dawnFenceOnCompletionCallback)(dawnFenceCompletionStatus status,
|
typedef void (*dawnFenceOnCompletionCallback)(dawnFenceCompletionStatus status,
|
||||||
dawnCallbackUserdata userdata);
|
dawnCallbackUserdata userdata);
|
||||||
|
|
||||||
|
|
|
@ -56,20 +56,20 @@ void ProcTableAsClass::DeviceSetErrorCallback(dawnDevice self, dawnDeviceErrorCa
|
||||||
OnDeviceSetErrorCallback(self, callback, userdata);
|
OnDeviceSetErrorCallback(self, callback, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcTableAsClass::BufferMapReadAsync(dawnBuffer self, uint32_t start, uint32_t size, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata) {
|
void ProcTableAsClass::BufferMapReadAsync(dawnBuffer self, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata) {
|
||||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||||
object->mapReadCallback = callback;
|
object->mapReadCallback = callback;
|
||||||
object->userdata1 = userdata;
|
object->userdata1 = userdata;
|
||||||
|
|
||||||
OnBufferMapReadAsyncCallback(self, start, size, callback, userdata);
|
OnBufferMapReadAsyncCallback(self, callback, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcTableAsClass::BufferMapWriteAsync(dawnBuffer self, uint32_t start, uint32_t size, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata) {
|
void ProcTableAsClass::BufferMapWriteAsync(dawnBuffer self, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata) {
|
||||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
||||||
object->mapWriteCallback = callback;
|
object->mapWriteCallback = callback;
|
||||||
object->userdata1 = userdata;
|
object->userdata1 = userdata;
|
||||||
|
|
||||||
OnBufferMapWriteAsyncCallback(self, start, size, callback, userdata);
|
OnBufferMapWriteAsyncCallback(self, callback, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcTableAsClass::FenceOnCompletion(dawnFence self,
|
void ProcTableAsClass::FenceOnCompletion(dawnFence self,
|
||||||
|
@ -91,14 +91,14 @@ void ProcTableAsClass::CallBuilderErrorCallback(void* builder , dawnBuilderError
|
||||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(builder);
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(builder);
|
||||||
object->builderErrorCallback(status, message, object->userdata1, object->userdata2);
|
object->builderErrorCallback(status, message, object->userdata1, object->userdata2);
|
||||||
}
|
}
|
||||||
void ProcTableAsClass::CallMapReadCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, const void* data) {
|
void ProcTableAsClass::CallMapReadCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, const void* data, uint32_t dataLength) {
|
||||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
|
||||||
object->mapReadCallback(status, data, object->userdata1);
|
object->mapReadCallback(status, data, dataLength, object->userdata1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcTableAsClass::CallMapWriteCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, void* data) {
|
void ProcTableAsClass::CallMapWriteCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, void* data, uint32_t dataLength) {
|
||||||
auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
|
||||||
object->mapWriteCallback(status, data, object->userdata1);
|
object->mapWriteCallback(status, data, dataLength, object->userdata1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcTableAsClass::CallFenceOnCompletionCallback(dawnFence fence,
|
void ProcTableAsClass::CallFenceOnCompletionCallback(dawnFence fence,
|
||||||
|
|
|
@ -57,8 +57,8 @@ class ProcTableAsClass {
|
||||||
|
|
||||||
// Stores callback and userdata and calls the On* methods
|
// Stores callback and userdata and calls the On* methods
|
||||||
void DeviceSetErrorCallback(dawnDevice self, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata);
|
void DeviceSetErrorCallback(dawnDevice self, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata);
|
||||||
void BufferMapReadAsync(dawnBuffer self, uint32_t start, uint32_t size, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata);
|
void BufferMapReadAsync(dawnBuffer self, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata);
|
||||||
void BufferMapWriteAsync(dawnBuffer self, uint32_t start, uint32_t size, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata);
|
void BufferMapWriteAsync(dawnBuffer self, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata);
|
||||||
void FenceOnCompletion(dawnFence self,
|
void FenceOnCompletion(dawnFence self,
|
||||||
uint64_t value,
|
uint64_t value,
|
||||||
dawnFenceOnCompletionCallback callback,
|
dawnFenceOnCompletionCallback callback,
|
||||||
|
@ -67,8 +67,8 @@ class ProcTableAsClass {
|
||||||
// Special cased mockable methods
|
// Special cased mockable methods
|
||||||
virtual void OnDeviceSetErrorCallback(dawnDevice device, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata) = 0;
|
virtual void OnDeviceSetErrorCallback(dawnDevice device, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata) = 0;
|
||||||
virtual void OnBuilderSetErrorCallback(dawnBufferBuilder builder, dawnBuilderErrorCallback callback, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2) = 0;
|
virtual void OnBuilderSetErrorCallback(dawnBufferBuilder builder, dawnBuilderErrorCallback callback, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2) = 0;
|
||||||
virtual void OnBufferMapReadAsyncCallback(dawnBuffer buffer, uint32_t start, uint32_t size, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata) = 0;
|
virtual void OnBufferMapReadAsyncCallback(dawnBuffer buffer, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata) = 0;
|
||||||
virtual void OnBufferMapWriteAsyncCallback(dawnBuffer buffer, uint32_t start, uint32_t size, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata) = 0;
|
virtual void OnBufferMapWriteAsyncCallback(dawnBuffer buffer, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata) = 0;
|
||||||
virtual void OnFenceOnCompletionCallback(dawnFence fence,
|
virtual void OnFenceOnCompletionCallback(dawnFence fence,
|
||||||
uint64_t value,
|
uint64_t value,
|
||||||
dawnFenceOnCompletionCallback callback,
|
dawnFenceOnCompletionCallback callback,
|
||||||
|
@ -77,8 +77,8 @@ class ProcTableAsClass {
|
||||||
// Calls the stored callbacks
|
// Calls the stored callbacks
|
||||||
void CallDeviceErrorCallback(dawnDevice device, const char* message);
|
void CallDeviceErrorCallback(dawnDevice device, const char* message);
|
||||||
void CallBuilderErrorCallback(void* builder , dawnBuilderErrorStatus status, const char* message);
|
void CallBuilderErrorCallback(void* builder , dawnBuilderErrorStatus status, const char* message);
|
||||||
void CallMapReadCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, const void* data);
|
void CallMapReadCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, const void* data, uint32_t dataLength);
|
||||||
void CallMapWriteCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, void* data);
|
void CallMapWriteCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, void* data, uint32_t dataLength);
|
||||||
void CallFenceOnCompletionCallback(dawnFence fence, dawnFenceCompletionStatus status);
|
void CallFenceOnCompletionCallback(dawnFence fence, dawnFenceCompletionStatus status);
|
||||||
|
|
||||||
struct Object {
|
struct Object {
|
||||||
|
@ -119,8 +119,8 @@ class MockProcTable : public ProcTableAsClass {
|
||||||
|
|
||||||
MOCK_METHOD3(OnDeviceSetErrorCallback, void(dawnDevice device, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata));
|
MOCK_METHOD3(OnDeviceSetErrorCallback, void(dawnDevice device, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata));
|
||||||
MOCK_METHOD4(OnBuilderSetErrorCallback, void(dawnBufferBuilder builder, dawnBuilderErrorCallback callback, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2));
|
MOCK_METHOD4(OnBuilderSetErrorCallback, void(dawnBufferBuilder builder, dawnBuilderErrorCallback callback, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2));
|
||||||
MOCK_METHOD5(OnBufferMapReadAsyncCallback, void(dawnBuffer buffer, uint32_t start, uint32_t size, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata));
|
MOCK_METHOD3(OnBufferMapReadAsyncCallback, void(dawnBuffer buffer, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata));
|
||||||
MOCK_METHOD5(OnBufferMapWriteAsyncCallback, void(dawnBuffer buffer, uint32_t start, uint32_t size, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata));
|
MOCK_METHOD3(OnBufferMapWriteAsyncCallback, void(dawnBuffer buffer, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata));
|
||||||
MOCK_METHOD4(OnFenceOnCompletionCallback,
|
MOCK_METHOD4(OnFenceOnCompletionCallback,
|
||||||
void(dawnFence fence,
|
void(dawnFence fence,
|
||||||
uint64_t value,
|
uint64_t value,
|
||||||
|
|
|
@ -37,10 +37,10 @@ namespace dawn_native {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t size) override {
|
void MapReadAsyncImpl(uint32_t serial) override {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
void MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t size) override {
|
void MapWriteAsyncImpl(uint32_t serial) override {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
void UnmapImpl() override {
|
void UnmapImpl() override {
|
||||||
|
@ -90,8 +90,8 @@ namespace dawn_native {
|
||||||
BufferBase::~BufferBase() {
|
BufferBase::~BufferBase() {
|
||||||
if (mState == BufferState::Mapped) {
|
if (mState == BufferState::Mapped) {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
CallMapReadCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
|
CallMapReadCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u);
|
||||||
CallMapWriteCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
|
CallMapWriteCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,31 +125,31 @@ namespace dawn_native {
|
||||||
|
|
||||||
void BufferBase::CallMapReadCallback(uint32_t serial,
|
void BufferBase::CallMapReadCallback(uint32_t serial,
|
||||||
dawnBufferMapAsyncStatus status,
|
dawnBufferMapAsyncStatus status,
|
||||||
const void* pointer) {
|
const void* pointer,
|
||||||
|
uint32_t dataLength) {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
|
|
||||||
if (mMapReadCallback != nullptr && serial == mMapSerial) {
|
if (mMapReadCallback != nullptr && serial == mMapSerial) {
|
||||||
ASSERT(mMapWriteCallback == nullptr);
|
ASSERT(mMapWriteCallback == nullptr);
|
||||||
// Tag the callback as fired before firing it, otherwise it could fire a second time if
|
// Tag the callback as fired before firing it, otherwise it could fire a second time if
|
||||||
// for example buffer.Unmap() is called inside the application-provided callback.
|
// for example buffer.Unmap() is called inside the application-provided callback.
|
||||||
dawnBufferMapReadCallback callback = mMapReadCallback;
|
dawnBufferMapReadCallback callback = mMapReadCallback;
|
||||||
mMapReadCallback = nullptr;
|
mMapReadCallback = nullptr;
|
||||||
callback(status, pointer, mMapUserdata);
|
callback(status, pointer, dataLength, mMapUserdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBase::CallMapWriteCallback(uint32_t serial,
|
void BufferBase::CallMapWriteCallback(uint32_t serial,
|
||||||
dawnBufferMapAsyncStatus status,
|
dawnBufferMapAsyncStatus status,
|
||||||
void* pointer) {
|
void* pointer,
|
||||||
|
uint32_t dataLength) {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
|
|
||||||
if (mMapWriteCallback != nullptr && serial == mMapSerial) {
|
if (mMapWriteCallback != nullptr && serial == mMapSerial) {
|
||||||
ASSERT(mMapReadCallback == nullptr);
|
ASSERT(mMapReadCallback == nullptr);
|
||||||
// Tag the callback as fired before firing it, otherwise it could fire a second time if
|
// Tag the callback as fired before firing it, otherwise it could fire a second time if
|
||||||
// for example buffer.Unmap() is called inside the application-provided callback.
|
// for example buffer.Unmap() is called inside the application-provided callback.
|
||||||
dawnBufferMapWriteCallback callback = mMapWriteCallback;
|
dawnBufferMapWriteCallback callback = mMapWriteCallback;
|
||||||
mMapWriteCallback = nullptr;
|
mMapWriteCallback = nullptr;
|
||||||
callback(status, pointer, mMapUserdata);
|
callback(status, pointer, dataLength, mMapUserdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,12 +164,10 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBase::MapReadAsync(uint32_t start,
|
void BufferBase::MapReadAsync(dawnBufferMapReadCallback callback,
|
||||||
uint32_t size,
|
|
||||||
dawnBufferMapReadCallback callback,
|
|
||||||
dawnCallbackUserdata userdata) {
|
dawnCallbackUserdata userdata) {
|
||||||
if (GetDevice()->ConsumedError(ValidateMap(start, size, dawn::BufferUsageBit::MapRead))) {
|
if (GetDevice()->ConsumedError(ValidateMap(dawn::BufferUsageBit::MapRead))) {
|
||||||
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
|
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
|
@ -182,15 +180,13 @@ namespace dawn_native {
|
||||||
mMapUserdata = userdata;
|
mMapUserdata = userdata;
|
||||||
mState = BufferState::Mapped;
|
mState = BufferState::Mapped;
|
||||||
|
|
||||||
MapReadAsyncImpl(mMapSerial, start, size);
|
MapReadAsyncImpl(mMapSerial);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBase::MapWriteAsync(uint32_t start,
|
void BufferBase::MapWriteAsync(dawnBufferMapWriteCallback callback,
|
||||||
uint32_t size,
|
|
||||||
dawnBufferMapWriteCallback callback,
|
|
||||||
dawnCallbackUserdata userdata) {
|
dawnCallbackUserdata userdata) {
|
||||||
if (GetDevice()->ConsumedError(ValidateMap(start, size, dawn::BufferUsageBit::MapWrite))) {
|
if (GetDevice()->ConsumedError(ValidateMap(dawn::BufferUsageBit::MapWrite))) {
|
||||||
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
|
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
|
@ -203,7 +199,7 @@ namespace dawn_native {
|
||||||
mMapUserdata = userdata;
|
mMapUserdata = userdata;
|
||||||
mState = BufferState::Mapped;
|
mState = BufferState::Mapped;
|
||||||
|
|
||||||
MapWriteAsyncImpl(mMapSerial, start, size);
|
MapWriteAsyncImpl(mMapSerial);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBase::Destroy() {
|
void BufferBase::Destroy() {
|
||||||
|
@ -226,8 +222,8 @@ namespace dawn_native {
|
||||||
|
|
||||||
// A map request can only be called once, so this will fire only if the request wasn't
|
// A map request can only be called once, so this will fire only if the request wasn't
|
||||||
// completed before the Unmap
|
// completed before the Unmap
|
||||||
CallMapReadCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
|
CallMapReadCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u);
|
||||||
CallMapWriteCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
|
CallMapWriteCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u);
|
||||||
UnmapImpl();
|
UnmapImpl();
|
||||||
mState = BufferState::Unmapped;
|
mState = BufferState::Unmapped;
|
||||||
mMapReadCallback = nullptr;
|
mMapReadCallback = nullptr;
|
||||||
|
@ -262,20 +258,9 @@ namespace dawn_native {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError BufferBase::ValidateMap(uint32_t start,
|
MaybeError BufferBase::ValidateMap(dawn::BufferUsageBit requiredUsage) const {
|
||||||
uint32_t size,
|
|
||||||
dawn::BufferUsageBit requiredUsage) const {
|
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||||
|
|
||||||
if (size > GetSize()) {
|
|
||||||
return DAWN_VALIDATION_ERROR("Buffer mapping with too big a region");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note that no overflow can happen because we already checked for GetSize() >= size
|
|
||||||
if (start > GetSize() - size) {
|
|
||||||
return DAWN_VALIDATION_ERROR("Buffer mapping out of range");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mState == BufferState::Destroyed) {
|
if (mState == BufferState::Destroyed) {
|
||||||
return DAWN_VALIDATION_ERROR("Buffer is destroyed");
|
return DAWN_VALIDATION_ERROR("Buffer is destroyed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,14 +54,8 @@ namespace dawn_native {
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void SetSubData(uint32_t start, uint32_t count, const uint8_t* data);
|
void SetSubData(uint32_t start, uint32_t count, const uint8_t* data);
|
||||||
void MapReadAsync(uint32_t start,
|
void MapReadAsync(dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata);
|
||||||
uint32_t size,
|
void MapWriteAsync(dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata);
|
||||||
dawnBufferMapReadCallback callback,
|
|
||||||
dawnCallbackUserdata userdata);
|
|
||||||
void MapWriteAsync(uint32_t start,
|
|
||||||
uint32_t size,
|
|
||||||
dawnBufferMapWriteCallback callback,
|
|
||||||
dawnCallbackUserdata userdata);
|
|
||||||
void Unmap();
|
void Unmap();
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
|
||||||
|
@ -70,19 +64,21 @@ namespace dawn_native {
|
||||||
|
|
||||||
void CallMapReadCallback(uint32_t serial,
|
void CallMapReadCallback(uint32_t serial,
|
||||||
dawnBufferMapAsyncStatus status,
|
dawnBufferMapAsyncStatus status,
|
||||||
const void* pointer);
|
const void* pointer,
|
||||||
void CallMapWriteCallback(uint32_t serial, dawnBufferMapAsyncStatus status, void* pointer);
|
uint32_t dataLength);
|
||||||
|
void CallMapWriteCallback(uint32_t serial,
|
||||||
|
dawnBufferMapAsyncStatus status,
|
||||||
|
void* pointer,
|
||||||
|
uint32_t dataLength);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) = 0;
|
virtual MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) = 0;
|
||||||
virtual void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t size) = 0;
|
virtual void MapReadAsyncImpl(uint32_t serial) = 0;
|
||||||
virtual void MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t size) = 0;
|
virtual void MapWriteAsyncImpl(uint32_t serial) = 0;
|
||||||
virtual void UnmapImpl() = 0;
|
virtual void UnmapImpl() = 0;
|
||||||
|
|
||||||
MaybeError ValidateSetSubData(uint32_t start, uint32_t count) const;
|
MaybeError ValidateSetSubData(uint32_t start, uint32_t count) const;
|
||||||
MaybeError ValidateMap(uint32_t start,
|
MaybeError ValidateMap(dawn::BufferUsageBit requiredUsage) const;
|
||||||
uint32_t size,
|
|
||||||
dawn::BufferUsageBit requiredUsage) const;
|
|
||||||
MaybeError ValidateUnmap() const;
|
MaybeError ValidateUnmap() const;
|
||||||
MaybeError ValidateDestroy() const;
|
MaybeError ValidateDestroy() const;
|
||||||
|
|
||||||
|
|
|
@ -155,9 +155,9 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
void Buffer::OnMapCommandSerialFinished(uint32_t mapSerial, void* data, bool isWrite) {
|
void Buffer::OnMapCommandSerialFinished(uint32_t mapSerial, void* data, bool isWrite) {
|
||||||
if (isWrite) {
|
if (isWrite) {
|
||||||
CallMapWriteCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
CallMapWriteCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||||
} else {
|
} else {
|
||||||
CallMapReadCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
CallMapReadCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,27 +179,27 @@ namespace dawn_native { namespace d3d12 {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) {
|
void Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||||
mWrittenMappedRange = {};
|
mWrittenMappedRange = {};
|
||||||
D3D12_RANGE readRange = {start, start + count};
|
D3D12_RANGE readRange = {0, GetSize()};
|
||||||
char* data = nullptr;
|
char* data = nullptr;
|
||||||
ASSERT_SUCCESS(mResource->Map(0, &readRange, reinterpret_cast<void**>(&data)));
|
ASSERT_SUCCESS(mResource->Map(0, &readRange, reinterpret_cast<void**>(&data)));
|
||||||
|
|
||||||
// There is no need to transition the resource to a new state: D3D12 seems to make the GPU
|
// There is no need to transition the resource to a new state: D3D12 seems to make the GPU
|
||||||
// writes available when the fence is passed.
|
// writes available when the fence is passed.
|
||||||
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapRequestTracker();
|
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapRequestTracker();
|
||||||
tracker->Track(this, serial, data + start, false);
|
tracker->Track(this, serial, data, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) {
|
void Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||||
mWrittenMappedRange = {start, start + count};
|
mWrittenMappedRange = {0, GetSize()};
|
||||||
char* data = nullptr;
|
char* data = nullptr;
|
||||||
ASSERT_SUCCESS(mResource->Map(0, &mWrittenMappedRange, reinterpret_cast<void**>(&data)));
|
ASSERT_SUCCESS(mResource->Map(0, &mWrittenMappedRange, reinterpret_cast<void**>(&data)));
|
||||||
|
|
||||||
// There is no need to transition the resource to a new state: D3D12 seems to make the CPU
|
// There is no need to transition the resource to a new state: D3D12 seems to make the CPU
|
||||||
// writes available on queue submission.
|
// writes available on queue submission.
|
||||||
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapRequestTracker();
|
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapRequestTracker();
|
||||||
tracker->Track(this, serial, data + start, true);
|
tracker->Track(this, serial, data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::UnmapImpl() {
|
void Buffer::UnmapImpl() {
|
||||||
|
|
|
@ -40,8 +40,8 @@ namespace dawn_native { namespace d3d12 {
|
||||||
private:
|
private:
|
||||||
// Dawn API
|
// Dawn API
|
||||||
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
|
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
|
||||||
void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
|
void MapReadAsyncImpl(uint32_t serial) override;
|
||||||
void MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
|
void MapWriteAsyncImpl(uint32_t serial) override;
|
||||||
void UnmapImpl() override;
|
void UnmapImpl() override;
|
||||||
|
|
||||||
// TODO(b-brber): Remove once alignment constraint is added to validation (dawn:73).
|
// TODO(b-brber): Remove once alignment constraint is added to validation (dawn:73).
|
||||||
|
|
|
@ -31,12 +31,12 @@ namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
id<MTLBuffer> GetMTLBuffer();
|
id<MTLBuffer> GetMTLBuffer();
|
||||||
|
|
||||||
void OnMapCommandSerialFinished(uint32_t mapSerial, uint32_t offset, bool isWrite);
|
void OnMapCommandSerialFinished(uint32_t mapSerial, bool isWrite);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
|
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
|
||||||
void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
|
void MapReadAsyncImpl(uint32_t serial) override;
|
||||||
void MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
|
void MapWriteAsyncImpl(uint32_t serial) override;
|
||||||
void UnmapImpl() override;
|
void UnmapImpl() override;
|
||||||
|
|
||||||
id<MTLBuffer> mMtlBuffer = nil;
|
id<MTLBuffer> mMtlBuffer = nil;
|
||||||
|
@ -47,7 +47,7 @@ namespace dawn_native { namespace metal {
|
||||||
MapRequestTracker(Device* device);
|
MapRequestTracker(Device* device);
|
||||||
~MapRequestTracker();
|
~MapRequestTracker();
|
||||||
|
|
||||||
void Track(Buffer* buffer, uint32_t mapSerial, uint32_t offset, bool isWrite);
|
void Track(Buffer* buffer, uint32_t mapSerial, bool isWrite);
|
||||||
void Tick(Serial finishedSerial);
|
void Tick(Serial finishedSerial);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -56,7 +56,6 @@ namespace dawn_native { namespace metal {
|
||||||
struct Request {
|
struct Request {
|
||||||
Ref<Buffer> buffer;
|
Ref<Buffer> buffer;
|
||||||
uint32_t mapSerial;
|
uint32_t mapSerial;
|
||||||
uint32_t offset;
|
|
||||||
bool isWrite;
|
bool isWrite;
|
||||||
};
|
};
|
||||||
SerialQueue<Request> mInflightRequests;
|
SerialQueue<Request> mInflightRequests;
|
||||||
|
|
|
@ -40,12 +40,12 @@ namespace dawn_native { namespace metal {
|
||||||
return mMtlBuffer;
|
return mMtlBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::OnMapCommandSerialFinished(uint32_t mapSerial, uint32_t offset, bool isWrite) {
|
void Buffer::OnMapCommandSerialFinished(uint32_t mapSerial, bool isWrite) {
|
||||||
char* data = reinterpret_cast<char*>([mMtlBuffer contents]);
|
char* data = reinterpret_cast<char*>([mMtlBuffer contents]);
|
||||||
if (isWrite) {
|
if (isWrite) {
|
||||||
CallMapWriteCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data + offset);
|
CallMapWriteCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||||
} else {
|
} else {
|
||||||
CallMapReadCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data + offset);
|
CallMapReadCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,14 +55,14 @@ namespace dawn_native { namespace metal {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t) {
|
void Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||||
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapTracker();
|
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapTracker();
|
||||||
tracker->Track(this, serial, start, false);
|
tracker->Track(this, serial, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t) {
|
void Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||||
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapTracker();
|
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapTracker();
|
||||||
tracker->Track(this, serial, start, true);
|
tracker->Track(this, serial, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::UnmapImpl() {
|
void Buffer::UnmapImpl() {
|
||||||
|
@ -78,12 +78,10 @@ namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
void MapRequestTracker::Track(Buffer* buffer,
|
void MapRequestTracker::Track(Buffer* buffer,
|
||||||
uint32_t mapSerial,
|
uint32_t mapSerial,
|
||||||
uint32_t offset,
|
|
||||||
bool isWrite) {
|
bool isWrite) {
|
||||||
Request request;
|
Request request;
|
||||||
request.buffer = buffer;
|
request.buffer = buffer;
|
||||||
request.mapSerial = mapSerial;
|
request.mapSerial = mapSerial;
|
||||||
request.offset = offset;
|
|
||||||
request.isWrite = isWrite;
|
request.isWrite = isWrite;
|
||||||
|
|
||||||
mInflightRequests.Enqueue(std::move(request), mDevice->GetPendingCommandSerial());
|
mInflightRequests.Enqueue(std::move(request), mDevice->GetPendingCommandSerial());
|
||||||
|
@ -91,8 +89,7 @@ namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
void MapRequestTracker::Tick(Serial finishedSerial) {
|
void MapRequestTracker::Tick(Serial finishedSerial) {
|
||||||
for (auto& request : mInflightRequests.IterateUpTo(finishedSerial)) {
|
for (auto& request : mInflightRequests.IterateUpTo(finishedSerial)) {
|
||||||
request.buffer->OnMapCommandSerialFinished(request.mapSerial, request.offset,
|
request.buffer->OnMapCommandSerialFinished(request.mapSerial, request.isWrite);
|
||||||
request.isWrite);
|
|
||||||
}
|
}
|
||||||
mInflightRequests.ClearUpTo(finishedSerial);
|
mInflightRequests.ClearUpTo(finishedSerial);
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,9 +193,9 @@ namespace dawn_native { namespace null {
|
||||||
|
|
||||||
void Buffer::MapReadOperationCompleted(uint32_t serial, void* ptr, bool isWrite) {
|
void Buffer::MapReadOperationCompleted(uint32_t serial, void* ptr, bool isWrite) {
|
||||||
if (isWrite) {
|
if (isWrite) {
|
||||||
CallMapWriteCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, ptr);
|
CallMapWriteCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, ptr, GetSize());
|
||||||
} else {
|
} else {
|
||||||
CallMapReadCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, ptr);
|
CallMapReadCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, ptr, GetSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,21 +206,20 @@ namespace dawn_native { namespace null {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) {
|
void Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||||
MapAsyncImplCommon(serial, start, count, false);
|
MapAsyncImplCommon(serial, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) {
|
void Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||||
MapAsyncImplCommon(serial, start, count, true);
|
MapAsyncImplCommon(serial, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapAsyncImplCommon(uint32_t serial, uint32_t start, uint32_t count, bool isWrite) {
|
void Buffer::MapAsyncImplCommon(uint32_t serial, bool isWrite) {
|
||||||
ASSERT(start + count <= GetSize());
|
|
||||||
ASSERT(mBackingData);
|
ASSERT(mBackingData);
|
||||||
|
|
||||||
auto operation = new BufferMapReadOperation;
|
auto operation = new BufferMapReadOperation;
|
||||||
operation->buffer = this;
|
operation->buffer = this;
|
||||||
operation->ptr = mBackingData.get() + start;
|
operation->ptr = mBackingData.get();
|
||||||
operation->serial = serial;
|
operation->serial = serial;
|
||||||
operation->isWrite = isWrite;
|
operation->isWrite = isWrite;
|
||||||
|
|
||||||
|
|
|
@ -147,11 +147,11 @@ namespace dawn_native { namespace null {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
|
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
|
||||||
void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
|
void MapReadAsyncImpl(uint32_t serial) override;
|
||||||
void MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
|
void MapWriteAsyncImpl(uint32_t serial) override;
|
||||||
void UnmapImpl() override;
|
void UnmapImpl() override;
|
||||||
|
|
||||||
void MapAsyncImplCommon(uint32_t serial, uint32_t start, uint32_t count, bool isWrite);
|
void MapAsyncImplCommon(uint32_t serial, bool isWrite);
|
||||||
|
|
||||||
std::unique_ptr<char[]> mBackingData;
|
std::unique_ptr<char[]> mBackingData;
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,20 +37,20 @@ namespace dawn_native { namespace opengl {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) {
|
void Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||||
// TODO(cwallez@chromium.org): this does GPU->CPU synchronization, we could require a high
|
// TODO(cwallez@chromium.org): this does GPU->CPU synchronization, we could require a high
|
||||||
// version of OpenGL that would let us map the buffer unsynchronized.
|
// version of OpenGL that would let us map the buffer unsynchronized.
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
||||||
void* data = glMapBufferRange(GL_ARRAY_BUFFER, start, count, GL_MAP_READ_BIT);
|
void* data = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY);
|
||||||
CallMapReadCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
CallMapReadCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) {
|
void Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||||
// TODO(cwallez@chromium.org): this does GPU->CPU synchronization, we could require a high
|
// TODO(cwallez@chromium.org): this does GPU->CPU synchronization, we could require a high
|
||||||
// version of OpenGL that would let us map the buffer unsynchronized.
|
// version of OpenGL that would let us map the buffer unsynchronized.
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
||||||
void* data = glMapBufferRange(GL_ARRAY_BUFFER, start, count, GL_MAP_WRITE_BIT);
|
void* data = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||||
CallMapWriteCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
CallMapWriteCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::UnmapImpl() {
|
void Buffer::UnmapImpl() {
|
||||||
|
|
|
@ -31,8 +31,8 @@ namespace dawn_native { namespace opengl {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
|
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
|
||||||
void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
|
void MapReadAsyncImpl(uint32_t serial) override;
|
||||||
void MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
|
void MapWriteAsyncImpl(uint32_t serial) override;
|
||||||
void UnmapImpl() override;
|
void UnmapImpl() override;
|
||||||
|
|
||||||
GLuint mBuffer = 0;
|
GLuint mBuffer = 0;
|
||||||
|
|
|
@ -149,11 +149,11 @@ namespace dawn_native { namespace vulkan {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::OnMapReadCommandSerialFinished(uint32_t mapSerial, const void* data) {
|
void Buffer::OnMapReadCommandSerialFinished(uint32_t mapSerial, const void* data) {
|
||||||
CallMapReadCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
CallMapReadCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::OnMapWriteCommandSerialFinished(uint32_t mapSerial, void* data) {
|
void Buffer::OnMapWriteCommandSerialFinished(uint32_t mapSerial, void* data) {
|
||||||
CallMapWriteCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
|
CallMapWriteCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
VkBuffer Buffer::GetHandle() const {
|
VkBuffer Buffer::GetHandle() const {
|
||||||
|
@ -214,7 +214,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t /*count*/) {
|
void Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
|
|
||||||
VkCommandBuffer commands = device->GetPendingCommandBuffer();
|
VkCommandBuffer commands = device->GetPendingCommandBuffer();
|
||||||
|
@ -224,10 +224,10 @@ namespace dawn_native { namespace vulkan {
|
||||||
ASSERT(memory != nullptr);
|
ASSERT(memory != nullptr);
|
||||||
|
|
||||||
MapRequestTracker* tracker = device->GetMapRequestTracker();
|
MapRequestTracker* tracker = device->GetMapRequestTracker();
|
||||||
tracker->Track(this, serial, memory + start, false);
|
tracker->Track(this, serial, memory, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t /*count*/) {
|
void Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
|
|
||||||
VkCommandBuffer commands = device->GetPendingCommandBuffer();
|
VkCommandBuffer commands = device->GetPendingCommandBuffer();
|
||||||
|
@ -237,7 +237,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
ASSERT(memory != nullptr);
|
ASSERT(memory != nullptr);
|
||||||
|
|
||||||
MapRequestTracker* tracker = device->GetMapRequestTracker();
|
MapRequestTracker* tracker = device->GetMapRequestTracker();
|
||||||
tracker->Track(this, serial, memory + start, true);
|
tracker->Track(this, serial, memory, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::UnmapImpl() {
|
void Buffer::UnmapImpl() {
|
||||||
|
|
|
@ -42,8 +42,8 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
|
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
|
||||||
void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
|
void MapReadAsyncImpl(uint32_t serial) override;
|
||||||
void MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
|
void MapWriteAsyncImpl(uint32_t serial) override;
|
||||||
void UnmapImpl() override;
|
void UnmapImpl() override;
|
||||||
|
|
||||||
// TODO(b-brber): Remove once alignment constraint is added to validation (dawn:73).
|
// TODO(b-brber): Remove once alignment constraint is added to validation (dawn:73).
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
namespace dawn_wire { namespace client {
|
namespace dawn_wire { namespace client {
|
||||||
|
|
||||||
void ClientBufferMapReadAsync(dawnBuffer cBuffer,
|
void ClientBufferMapReadAsync(dawnBuffer cBuffer,
|
||||||
uint32_t start,
|
|
||||||
uint32_t size,
|
|
||||||
dawnBufferMapReadCallback callback,
|
dawnBufferMapReadCallback callback,
|
||||||
dawnCallbackUserdata userdata) {
|
dawnCallbackUserdata userdata) {
|
||||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||||
|
@ -31,15 +29,12 @@ namespace dawn_wire { namespace client {
|
||||||
Buffer::MapRequestData request;
|
Buffer::MapRequestData request;
|
||||||
request.readCallback = callback;
|
request.readCallback = callback;
|
||||||
request.userdata = userdata;
|
request.userdata = userdata;
|
||||||
request.size = size;
|
|
||||||
request.isWrite = false;
|
request.isWrite = false;
|
||||||
buffer->requests[serial] = request;
|
buffer->requests[serial] = request;
|
||||||
|
|
||||||
BufferMapAsyncCmd cmd;
|
BufferMapAsyncCmd cmd;
|
||||||
cmd.bufferId = buffer->id;
|
cmd.bufferId = buffer->id;
|
||||||
cmd.requestSerial = serial;
|
cmd.requestSerial = serial;
|
||||||
cmd.start = start;
|
|
||||||
cmd.size = size;
|
|
||||||
cmd.isWrite = false;
|
cmd.isWrite = false;
|
||||||
|
|
||||||
size_t requiredSize = cmd.GetRequiredSize();
|
size_t requiredSize = cmd.GetRequiredSize();
|
||||||
|
@ -49,8 +44,6 @@ namespace dawn_wire { namespace client {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientBufferMapWriteAsync(dawnBuffer cBuffer,
|
void ClientBufferMapWriteAsync(dawnBuffer cBuffer,
|
||||||
uint32_t start,
|
|
||||||
uint32_t size,
|
|
||||||
dawnBufferMapWriteCallback callback,
|
dawnBufferMapWriteCallback callback,
|
||||||
dawnCallbackUserdata userdata) {
|
dawnCallbackUserdata userdata) {
|
||||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||||
|
@ -61,15 +54,12 @@ namespace dawn_wire { namespace client {
|
||||||
Buffer::MapRequestData request;
|
Buffer::MapRequestData request;
|
||||||
request.writeCallback = callback;
|
request.writeCallback = callback;
|
||||||
request.userdata = userdata;
|
request.userdata = userdata;
|
||||||
request.size = size;
|
|
||||||
request.isWrite = true;
|
request.isWrite = true;
|
||||||
buffer->requests[serial] = request;
|
buffer->requests[serial] = request;
|
||||||
|
|
||||||
BufferMapAsyncCmd cmd;
|
BufferMapAsyncCmd cmd;
|
||||||
cmd.bufferId = buffer->id;
|
cmd.bufferId = buffer->id;
|
||||||
cmd.requestSerial = serial;
|
cmd.requestSerial = serial;
|
||||||
cmd.start = start;
|
|
||||||
cmd.size = size;
|
|
||||||
cmd.isWrite = true;
|
cmd.isWrite = true;
|
||||||
|
|
||||||
size_t requiredSize = cmd.GetRequiredSize();
|
size_t requiredSize = cmd.GetRequiredSize();
|
||||||
|
|
|
@ -29,9 +29,9 @@ namespace dawn_wire { namespace client {
|
||||||
void Buffer::ClearMapRequests(dawnBufferMapAsyncStatus status) {
|
void Buffer::ClearMapRequests(dawnBufferMapAsyncStatus status) {
|
||||||
for (auto& it : requests) {
|
for (auto& it : requests) {
|
||||||
if (it.second.isWrite) {
|
if (it.second.isWrite) {
|
||||||
it.second.writeCallback(status, nullptr, it.second.userdata);
|
it.second.writeCallback(status, nullptr, 0, it.second.userdata);
|
||||||
} else {
|
} else {
|
||||||
it.second.readCallback(status, nullptr, it.second.userdata);
|
it.second.readCallback(status, nullptr, 0, it.second.userdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
requests.clear();
|
requests.clear();
|
||||||
|
|
|
@ -36,7 +36,6 @@ namespace dawn_wire { namespace client {
|
||||||
dawnBufferMapReadCallback readCallback = nullptr;
|
dawnBufferMapReadCallback readCallback = nullptr;
|
||||||
dawnBufferMapWriteCallback writeCallback = nullptr;
|
dawnBufferMapWriteCallback writeCallback = nullptr;
|
||||||
dawnCallbackUserdata userdata = 0;
|
dawnCallbackUserdata userdata = 0;
|
||||||
uint32_t size = 0;
|
|
||||||
bool isWrite = false;
|
bool isWrite = false;
|
||||||
};
|
};
|
||||||
std::map<uint32_t, MapRequestData> requests;
|
std::map<uint32_t, MapRequestData> requests;
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace dawn_wire { namespace client {
|
||||||
bool Client::DoBufferMapReadAsyncCallback(Buffer* buffer,
|
bool Client::DoBufferMapReadAsyncCallback(Buffer* buffer,
|
||||||
uint32_t requestSerial,
|
uint32_t requestSerial,
|
||||||
uint32_t status,
|
uint32_t status,
|
||||||
uint32_t count,
|
uint32_t dataLength,
|
||||||
const uint8_t* data) {
|
const uint8_t* data) {
|
||||||
// The buffer might have been deleted or recreated so this isn't an error.
|
// The buffer might have been deleted or recreated so this isn't an error.
|
||||||
if (buffer == nullptr) {
|
if (buffer == nullptr) {
|
||||||
|
@ -53,12 +53,6 @@ namespace dawn_wire { namespace client {
|
||||||
// On success, we copy the data locally because the IPC buffer isn't valid outside of this
|
// On success, we copy the data locally because the IPC buffer isn't valid outside of this
|
||||||
// function
|
// function
|
||||||
if (status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
if (status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
||||||
// The server didn't send the right amount of data, this is an error and could cause
|
|
||||||
// the application to crash if we did call the callback.
|
|
||||||
if (request.size != count) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT(data != nullptr);
|
ASSERT(data != nullptr);
|
||||||
|
|
||||||
if (buffer->mappedData != nullptr) {
|
if (buffer->mappedData != nullptr) {
|
||||||
|
@ -66,14 +60,14 @@ namespace dawn_wire { namespace client {
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->isWriteMapped = false;
|
buffer->isWriteMapped = false;
|
||||||
buffer->mappedDataSize = request.size;
|
buffer->mappedDataSize = dataLength;
|
||||||
buffer->mappedData = malloc(request.size);
|
buffer->mappedData = malloc(dataLength);
|
||||||
memcpy(buffer->mappedData, data, request.size);
|
memcpy(buffer->mappedData, data, dataLength);
|
||||||
|
|
||||||
request.readCallback(static_cast<dawnBufferMapAsyncStatus>(status), buffer->mappedData,
|
request.readCallback(static_cast<dawnBufferMapAsyncStatus>(status), buffer->mappedData,
|
||||||
request.userdata);
|
dataLength, request.userdata);
|
||||||
} else {
|
} else {
|
||||||
request.readCallback(static_cast<dawnBufferMapAsyncStatus>(status), nullptr,
|
request.readCallback(static_cast<dawnBufferMapAsyncStatus>(status), nullptr, 0,
|
||||||
request.userdata);
|
request.userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +76,8 @@ namespace dawn_wire { namespace client {
|
||||||
|
|
||||||
bool Client::DoBufferMapWriteAsyncCallback(Buffer* buffer,
|
bool Client::DoBufferMapWriteAsyncCallback(Buffer* buffer,
|
||||||
uint32_t requestSerial,
|
uint32_t requestSerial,
|
||||||
uint32_t status) {
|
uint32_t status,
|
||||||
|
uint32_t dataLength) {
|
||||||
// The buffer might have been deleted or recreated so this isn't an error.
|
// The buffer might have been deleted or recreated so this isn't an error.
|
||||||
if (buffer == nullptr) {
|
if (buffer == nullptr) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -112,14 +107,14 @@ namespace dawn_wire { namespace client {
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->isWriteMapped = true;
|
buffer->isWriteMapped = true;
|
||||||
buffer->mappedDataSize = request.size;
|
buffer->mappedDataSize = dataLength;
|
||||||
buffer->mappedData = malloc(request.size);
|
buffer->mappedData = malloc(dataLength);
|
||||||
memset(buffer->mappedData, 0, request.size);
|
memset(buffer->mappedData, 0, dataLength);
|
||||||
|
|
||||||
request.writeCallback(static_cast<dawnBufferMapAsyncStatus>(status), buffer->mappedData,
|
request.writeCallback(static_cast<dawnBufferMapAsyncStatus>(status), buffer->mappedData,
|
||||||
request.userdata);
|
dataLength, request.userdata);
|
||||||
} else {
|
} else {
|
||||||
request.writeCallback(static_cast<dawnBufferMapAsyncStatus>(status), nullptr,
|
request.writeCallback(static_cast<dawnBufferMapAsyncStatus>(status), nullptr, 0,
|
||||||
request.userdata);
|
request.userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,11 @@ namespace dawn_wire { namespace server {
|
||||||
static void ForwardDeviceError(const char* message, dawnCallbackUserdata userdata);
|
static void ForwardDeviceError(const char* message, dawnCallbackUserdata userdata);
|
||||||
static void ForwardBufferMapReadAsync(dawnBufferMapAsyncStatus status,
|
static void ForwardBufferMapReadAsync(dawnBufferMapAsyncStatus status,
|
||||||
const void* ptr,
|
const void* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
dawnCallbackUserdata userdata);
|
dawnCallbackUserdata userdata);
|
||||||
static void ForwardBufferMapWriteAsync(dawnBufferMapAsyncStatus status,
|
static void ForwardBufferMapWriteAsync(dawnBufferMapAsyncStatus status,
|
||||||
void* ptr,
|
void* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
dawnCallbackUserdata userdata);
|
dawnCallbackUserdata userdata);
|
||||||
static void ForwardFenceCompletedValue(dawnFenceCompletionStatus status,
|
static void ForwardFenceCompletedValue(dawnFenceCompletionStatus status,
|
||||||
dawnCallbackUserdata userdata);
|
dawnCallbackUserdata userdata);
|
||||||
|
@ -60,9 +62,11 @@ namespace dawn_wire { namespace server {
|
||||||
void OnDeviceError(const char* message);
|
void OnDeviceError(const char* message);
|
||||||
void OnBufferMapReadAsyncCallback(dawnBufferMapAsyncStatus status,
|
void OnBufferMapReadAsyncCallback(dawnBufferMapAsyncStatus status,
|
||||||
const void* ptr,
|
const void* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
MapUserdata* userdata);
|
MapUserdata* userdata);
|
||||||
void OnBufferMapWriteAsyncCallback(dawnBufferMapAsyncStatus status,
|
void OnBufferMapWriteAsyncCallback(dawnBufferMapAsyncStatus status,
|
||||||
void* ptr,
|
void* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
MapUserdata* userdata);
|
MapUserdata* userdata);
|
||||||
void OnFenceCompletedValueUpdated(FenceCompletionUserdata* userdata);
|
void OnFenceCompletedValueUpdated(FenceCompletionUserdata* userdata);
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,6 @@ namespace dawn_wire { namespace server {
|
||||||
|
|
||||||
bool Server::DoBufferMapAsync(ObjectId bufferId,
|
bool Server::DoBufferMapAsync(ObjectId bufferId,
|
||||||
uint32_t requestSerial,
|
uint32_t requestSerial,
|
||||||
uint32_t start,
|
|
||||||
uint32_t size,
|
|
||||||
bool isWrite) {
|
bool isWrite) {
|
||||||
// These requests are just forwarded to the buffer, with userdata containing what the
|
// These requests are just forwarded to the buffer, with userdata containing what the
|
||||||
// client will require in the return command.
|
// client will require in the return command.
|
||||||
|
@ -50,7 +48,6 @@ namespace dawn_wire { namespace server {
|
||||||
data->server = this;
|
data->server = this;
|
||||||
data->buffer = ObjectHandle{bufferId, buffer->serial};
|
data->buffer = ObjectHandle{bufferId, buffer->serial};
|
||||||
data->requestSerial = requestSerial;
|
data->requestSerial = requestSerial;
|
||||||
data->size = size;
|
|
||||||
data->isWrite = isWrite;
|
data->isWrite = isWrite;
|
||||||
|
|
||||||
auto userdata = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(data));
|
auto userdata = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(data));
|
||||||
|
@ -58,19 +55,18 @@ namespace dawn_wire { namespace server {
|
||||||
if (!buffer->valid) {
|
if (!buffer->valid) {
|
||||||
// Fake the buffer returning a failure, data will be freed in this call.
|
// Fake the buffer returning a failure, data will be freed in this call.
|
||||||
if (isWrite) {
|
if (isWrite) {
|
||||||
ForwardBufferMapWriteAsync(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
|
ForwardBufferMapWriteAsync(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0,
|
||||||
|
userdata);
|
||||||
} else {
|
} else {
|
||||||
ForwardBufferMapReadAsync(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
|
ForwardBufferMapReadAsync(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isWrite) {
|
if (isWrite) {
|
||||||
mProcs.bufferMapWriteAsync(buffer->handle, start, size, ForwardBufferMapWriteAsync,
|
mProcs.bufferMapWriteAsync(buffer->handle, ForwardBufferMapWriteAsync, userdata);
|
||||||
userdata);
|
|
||||||
} else {
|
} else {
|
||||||
mProcs.bufferMapReadAsync(buffer->handle, start, size, ForwardBufferMapReadAsync,
|
mProcs.bufferMapReadAsync(buffer->handle, ForwardBufferMapReadAsync, userdata);
|
||||||
userdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -99,20 +95,23 @@ namespace dawn_wire { namespace server {
|
||||||
|
|
||||||
void Server::ForwardBufferMapReadAsync(dawnBufferMapAsyncStatus status,
|
void Server::ForwardBufferMapReadAsync(dawnBufferMapAsyncStatus status,
|
||||||
const void* ptr,
|
const void* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
dawnCallbackUserdata userdata) {
|
dawnCallbackUserdata userdata) {
|
||||||
auto data = reinterpret_cast<MapUserdata*>(static_cast<uintptr_t>(userdata));
|
auto data = reinterpret_cast<MapUserdata*>(static_cast<uintptr_t>(userdata));
|
||||||
data->server->OnBufferMapReadAsyncCallback(status, ptr, data);
|
data->server->OnBufferMapReadAsyncCallback(status, ptr, dataLength, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::ForwardBufferMapWriteAsync(dawnBufferMapAsyncStatus status,
|
void Server::ForwardBufferMapWriteAsync(dawnBufferMapAsyncStatus status,
|
||||||
void* ptr,
|
void* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
dawnCallbackUserdata userdata) {
|
dawnCallbackUserdata userdata) {
|
||||||
auto data = reinterpret_cast<MapUserdata*>(static_cast<uintptr_t>(userdata));
|
auto data = reinterpret_cast<MapUserdata*>(static_cast<uintptr_t>(userdata));
|
||||||
data->server->OnBufferMapWriteAsyncCallback(status, ptr, data);
|
data->server->OnBufferMapWriteAsyncCallback(status, ptr, dataLength, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::OnBufferMapReadAsyncCallback(dawnBufferMapAsyncStatus status,
|
void Server::OnBufferMapReadAsyncCallback(dawnBufferMapAsyncStatus status,
|
||||||
const void* ptr,
|
const void* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
MapUserdata* userdata) {
|
MapUserdata* userdata) {
|
||||||
std::unique_ptr<MapUserdata> data(userdata);
|
std::unique_ptr<MapUserdata> data(userdata);
|
||||||
|
|
||||||
|
@ -130,7 +129,7 @@ namespace dawn_wire { namespace server {
|
||||||
cmd.data = reinterpret_cast<const uint8_t*>(ptr);
|
cmd.data = reinterpret_cast<const uint8_t*>(ptr);
|
||||||
|
|
||||||
if (status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
if (status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
||||||
cmd.dataLength = data->size;
|
cmd.dataLength = dataLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t requiredSize = cmd.GetRequiredSize();
|
size_t requiredSize = cmd.GetRequiredSize();
|
||||||
|
@ -140,6 +139,7 @@ namespace dawn_wire { namespace server {
|
||||||
|
|
||||||
void Server::OnBufferMapWriteAsyncCallback(dawnBufferMapAsyncStatus status,
|
void Server::OnBufferMapWriteAsyncCallback(dawnBufferMapAsyncStatus status,
|
||||||
void* ptr,
|
void* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
MapUserdata* userdata) {
|
MapUserdata* userdata) {
|
||||||
std::unique_ptr<MapUserdata> data(userdata);
|
std::unique_ptr<MapUserdata> data(userdata);
|
||||||
|
|
||||||
|
@ -153,6 +153,7 @@ namespace dawn_wire { namespace server {
|
||||||
cmd.buffer = data->buffer;
|
cmd.buffer = data->buffer;
|
||||||
cmd.requestSerial = data->requestSerial;
|
cmd.requestSerial = data->requestSerial;
|
||||||
cmd.status = status;
|
cmd.status = status;
|
||||||
|
cmd.dataLength = dataLength;
|
||||||
|
|
||||||
size_t requiredSize = cmd.GetRequiredSize();
|
size_t requiredSize = cmd.GetRequiredSize();
|
||||||
char* allocatedBuffer = static_cast<char*>(GetCmdSpace(requiredSize));
|
char* allocatedBuffer = static_cast<char*>(GetCmdSpace(requiredSize));
|
||||||
|
@ -160,7 +161,7 @@ namespace dawn_wire { namespace server {
|
||||||
|
|
||||||
if (status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
if (status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
||||||
bufferData->mappedData = ptr;
|
bufferData->mappedData = ptr;
|
||||||
bufferData->mappedDataSize = data->size;
|
bufferData->mappedDataSize = dataLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -386,9 +386,8 @@ void DawnTest::MapSlotsSynchronously() {
|
||||||
auto userdata = new MapReadUserdata{this, i};
|
auto userdata = new MapReadUserdata{this, i};
|
||||||
|
|
||||||
auto& slot = mReadbackSlots[i];
|
auto& slot = mReadbackSlots[i];
|
||||||
slot.buffer.MapReadAsync(
|
slot.buffer.MapReadAsync(SlotMapReadCallback, static_cast<dawn::CallbackUserdata>(
|
||||||
0, slot.bufferSize, SlotMapReadCallback,
|
reinterpret_cast<uintptr_t>(userdata)));
|
||||||
static_cast<dawn::CallbackUserdata>(reinterpret_cast<uintptr_t>(userdata)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Busy wait until all map operations are done.
|
// Busy wait until all map operations are done.
|
||||||
|
@ -400,6 +399,7 @@ void DawnTest::MapSlotsSynchronously() {
|
||||||
// static
|
// static
|
||||||
void DawnTest::SlotMapReadCallback(dawnBufferMapAsyncStatus status,
|
void DawnTest::SlotMapReadCallback(dawnBufferMapAsyncStatus status,
|
||||||
const void* data,
|
const void* data,
|
||||||
|
uint32_t,
|
||||||
dawnCallbackUserdata userdata_) {
|
dawnCallbackUserdata userdata_) {
|
||||||
DAWN_ASSERT(status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS);
|
DAWN_ASSERT(status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS);
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,7 @@ class DawnTest : public ::testing::TestWithParam<dawn_native::BackendType> {
|
||||||
void MapSlotsSynchronously();
|
void MapSlotsSynchronously();
|
||||||
static void SlotMapReadCallback(dawnBufferMapAsyncStatus status,
|
static void SlotMapReadCallback(dawnBufferMapAsyncStatus status,
|
||||||
const void* data,
|
const void* data,
|
||||||
|
uint32_t dataLength,
|
||||||
dawnCallbackUserdata userdata);
|
dawnCallbackUserdata userdata);
|
||||||
size_t mNumPendingMapOperations = 0;
|
size_t mNumPendingMapOperations = 0;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,10 @@
|
||||||
|
|
||||||
class BufferMapReadTests : public DawnTest {
|
class BufferMapReadTests : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
static void MapReadCallback(dawnBufferMapAsyncStatus status, const void* data, dawnCallbackUserdata userdata) {
|
static void MapReadCallback(dawnBufferMapAsyncStatus status,
|
||||||
|
const void* data,
|
||||||
|
uint32_t,
|
||||||
|
dawnCallbackUserdata userdata) {
|
||||||
ASSERT_EQ(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, status);
|
ASSERT_EQ(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, status);
|
||||||
ASSERT_NE(nullptr, data);
|
ASSERT_NE(nullptr, data);
|
||||||
|
|
||||||
|
@ -26,8 +29,9 @@ class BufferMapReadTests : public DawnTest {
|
||||||
test->mappedData = data;
|
test->mappedData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const void* MapReadAsyncAndWait(const dawn::Buffer& buffer, uint32_t start, uint32_t offset) {
|
const void* MapReadAsyncAndWait(const dawn::Buffer& buffer) {
|
||||||
buffer.MapReadAsync(start, offset, MapReadCallback, static_cast<dawn::CallbackUserdata>(reinterpret_cast<uintptr_t>(this)));
|
buffer.MapReadAsync(MapReadCallback, static_cast<dawn::CallbackUserdata>(
|
||||||
|
reinterpret_cast<uintptr_t>(this)));
|
||||||
|
|
||||||
while (mappedData == nullptr) {
|
while (mappedData == nullptr) {
|
||||||
WaitABit();
|
WaitABit();
|
||||||
|
@ -40,7 +44,7 @@ class BufferMapReadTests : public DawnTest {
|
||||||
const void* mappedData = nullptr;
|
const void* mappedData = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Test that the simplest map read (one u8 at offset 0) works.
|
// Test that the simplest map read works.
|
||||||
TEST_P(BufferMapReadTests, SmallReadAtZero) {
|
TEST_P(BufferMapReadTests, SmallReadAtZero) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 1;
|
descriptor.size = 1;
|
||||||
|
@ -50,45 +54,13 @@ TEST_P(BufferMapReadTests, SmallReadAtZero) {
|
||||||
uint8_t myData = 187;
|
uint8_t myData = 187;
|
||||||
buffer.SetSubData(0, sizeof(myData), &myData);
|
buffer.SetSubData(0, sizeof(myData), &myData);
|
||||||
|
|
||||||
const void* mappedData = MapReadAsyncAndWait(buffer, 0, 1);
|
const void* mappedData = MapReadAsyncAndWait(buffer);
|
||||||
ASSERT_EQ(myData, *reinterpret_cast<const uint8_t*>(mappedData));
|
ASSERT_EQ(myData, *reinterpret_cast<const uint8_t*>(mappedData));
|
||||||
|
|
||||||
buffer.Unmap();
|
buffer.Unmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test mapping a buffer at an offset.
|
// Test mapping a large buffer.
|
||||||
TEST_P(BufferMapReadTests, SmallReadAtOffset) {
|
|
||||||
dawn::BufferDescriptor descriptor;
|
|
||||||
descriptor.size = 4000;
|
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::TransferDst;
|
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
|
||||||
|
|
||||||
uint8_t myData = 234;
|
|
||||||
buffer.SetSubData(2048, sizeof(myData), &myData);
|
|
||||||
|
|
||||||
const void* mappedData = MapReadAsyncAndWait(buffer, 2048, 4);
|
|
||||||
ASSERT_EQ(myData, *reinterpret_cast<const uint8_t*>(mappedData));
|
|
||||||
|
|
||||||
buffer.Unmap();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test mapping a buffer at an offset that's not uint32-aligned.
|
|
||||||
TEST_P(BufferMapReadTests, SmallReadAtUnalignedOffset) {
|
|
||||||
dawn::BufferDescriptor descriptor;
|
|
||||||
descriptor.size = 4000;
|
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::TransferDst;
|
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
|
||||||
|
|
||||||
uint8_t myData = 213;
|
|
||||||
buffer.SetSubData(3, 1, &myData);
|
|
||||||
|
|
||||||
const void* mappedData = MapReadAsyncAndWait(buffer, 3, 1);
|
|
||||||
ASSERT_EQ(myData, *reinterpret_cast<const uint8_t*>(mappedData));
|
|
||||||
|
|
||||||
buffer.Unmap();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test mapping large ranges of a buffer.
|
|
||||||
TEST_P(BufferMapReadTests, LargeRead) {
|
TEST_P(BufferMapReadTests, LargeRead) {
|
||||||
constexpr uint32_t kDataSize = 1000 * 1000;
|
constexpr uint32_t kDataSize = 1000 * 1000;
|
||||||
std::vector<uint32_t> myData;
|
std::vector<uint32_t> myData;
|
||||||
|
@ -103,7 +75,7 @@ TEST_P(BufferMapReadTests, LargeRead) {
|
||||||
|
|
||||||
buffer.SetSubData(0, kDataSize * sizeof(uint32_t), reinterpret_cast<uint8_t*>(myData.data()));
|
buffer.SetSubData(0, kDataSize * sizeof(uint32_t), reinterpret_cast<uint8_t*>(myData.data()));
|
||||||
|
|
||||||
const void* mappedData = MapReadAsyncAndWait(buffer, 0, static_cast<uint32_t>(kDataSize * sizeof(uint32_t)));
|
const void* mappedData = MapReadAsyncAndWait(buffer);
|
||||||
ASSERT_EQ(0, memcmp(mappedData, myData.data(), kDataSize * sizeof(uint32_t)));
|
ASSERT_EQ(0, memcmp(mappedData, myData.data(), kDataSize * sizeof(uint32_t)));
|
||||||
|
|
||||||
buffer.Unmap();
|
buffer.Unmap();
|
||||||
|
@ -113,8 +85,10 @@ DAWN_INSTANTIATE_TEST(BufferMapReadTests, D3D12Backend, MetalBackend, OpenGLBack
|
||||||
|
|
||||||
class BufferMapWriteTests : public DawnTest {
|
class BufferMapWriteTests : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
|
static void MapWriteCallback(dawnBufferMapAsyncStatus status,
|
||||||
static void MapWriteCallback(dawnBufferMapAsyncStatus status, void* data, dawnCallbackUserdata userdata) {
|
void* data,
|
||||||
|
uint32_t,
|
||||||
|
dawnCallbackUserdata userdata) {
|
||||||
ASSERT_EQ(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, status);
|
ASSERT_EQ(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, status);
|
||||||
ASSERT_NE(nullptr, data);
|
ASSERT_NE(nullptr, data);
|
||||||
|
|
||||||
|
@ -122,8 +96,9 @@ class BufferMapWriteTests : public DawnTest {
|
||||||
test->mappedData = data;
|
test->mappedData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* MapWriteAsyncAndWait(const dawn::Buffer& buffer, uint32_t start, uint32_t offset) {
|
void* MapWriteAsyncAndWait(const dawn::Buffer& buffer) {
|
||||||
buffer.MapWriteAsync(start, offset, MapWriteCallback, static_cast<dawn::CallbackUserdata>(reinterpret_cast<uintptr_t>(this)));
|
buffer.MapWriteAsync(MapWriteCallback, static_cast<dawn::CallbackUserdata>(
|
||||||
|
reinterpret_cast<uintptr_t>(this)));
|
||||||
|
|
||||||
while (mappedData == nullptr) {
|
while (mappedData == nullptr) {
|
||||||
WaitABit();
|
WaitABit();
|
||||||
|
@ -136,7 +111,7 @@ class BufferMapWriteTests : public DawnTest {
|
||||||
void* mappedData = nullptr;
|
void* mappedData = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Test that the simplest map write (one u32 at offset 0) works.
|
// Test that the simplest map write works.
|
||||||
TEST_P(BufferMapWriteTests, SmallWriteAtZero) {
|
TEST_P(BufferMapWriteTests, SmallWriteAtZero) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
|
@ -144,29 +119,14 @@ TEST_P(BufferMapWriteTests, SmallWriteAtZero) {
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
uint32_t myData = 2934875;
|
uint32_t myData = 2934875;
|
||||||
void* mappedData = MapWriteAsyncAndWait(buffer, 0, 4);
|
void* mappedData = MapWriteAsyncAndWait(buffer);
|
||||||
memcpy(mappedData, &myData, sizeof(myData));
|
memcpy(mappedData, &myData, sizeof(myData));
|
||||||
buffer.Unmap();
|
buffer.Unmap();
|
||||||
|
|
||||||
EXPECT_BUFFER_U32_EQ(myData, buffer, 0);
|
EXPECT_BUFFER_U32_EQ(myData, buffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test mapping a buffer at an offset.
|
// Test mapping a large buffer.
|
||||||
TEST_P(BufferMapWriteTests, SmallWriteAtOffset) {
|
|
||||||
dawn::BufferDescriptor descriptor;
|
|
||||||
descriptor.size = 4000;
|
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::TransferSrc;
|
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
|
||||||
|
|
||||||
uint32_t myData = 2934875;
|
|
||||||
void* mappedData = MapWriteAsyncAndWait(buffer, 2048, 4);
|
|
||||||
memcpy(mappedData, &myData, sizeof(myData));
|
|
||||||
buffer.Unmap();
|
|
||||||
|
|
||||||
EXPECT_BUFFER_U32_EQ(myData, buffer, 2048);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test mapping large ranges of a buffer.
|
|
||||||
TEST_P(BufferMapWriteTests, LargeWrite) {
|
TEST_P(BufferMapWriteTests, LargeWrite) {
|
||||||
constexpr uint32_t kDataSize = 1000 * 1000;
|
constexpr uint32_t kDataSize = 1000 * 1000;
|
||||||
std::vector<uint32_t> myData;
|
std::vector<uint32_t> myData;
|
||||||
|
@ -179,7 +139,7 @@ TEST_P(BufferMapWriteTests, LargeWrite) {
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::TransferSrc;
|
descriptor.usage = dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::TransferSrc;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
void* mappedData = MapWriteAsyncAndWait(buffer, 0, kDataSize * sizeof(uint32_t));
|
void* mappedData = MapWriteAsyncAndWait(buffer);
|
||||||
memcpy(mappedData, myData.data(), kDataSize * sizeof(uint32_t));
|
memcpy(mappedData, myData.data(), kDataSize * sizeof(uint32_t));
|
||||||
buffer.Unmap();
|
buffer.Unmap();
|
||||||
|
|
||||||
|
|
|
@ -22,24 +22,40 @@ using namespace testing;
|
||||||
|
|
||||||
class MockBufferMapReadCallback {
|
class MockBufferMapReadCallback {
|
||||||
public:
|
public:
|
||||||
MOCK_METHOD3(Call, void(dawnBufferMapAsyncStatus status, const uint32_t* ptr, dawnCallbackUserdata userdata));
|
MOCK_METHOD4(Call,
|
||||||
|
void(dawnBufferMapAsyncStatus status,
|
||||||
|
const uint32_t* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
|
dawnCallbackUserdata userdata));
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::unique_ptr<MockBufferMapReadCallback> mockBufferMapReadCallback;
|
static std::unique_ptr<MockBufferMapReadCallback> mockBufferMapReadCallback;
|
||||||
static void ToMockBufferMapReadCallback(dawnBufferMapAsyncStatus status, const void* ptr, dawnCallbackUserdata userdata) {
|
static void ToMockBufferMapReadCallback(dawnBufferMapAsyncStatus status,
|
||||||
|
const void* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
|
dawnCallbackUserdata userdata) {
|
||||||
// Assume the data is uint32_t to make writing matchers easier
|
// Assume the data is uint32_t to make writing matchers easier
|
||||||
mockBufferMapReadCallback->Call(status, reinterpret_cast<const uint32_t*>(ptr), userdata);
|
mockBufferMapReadCallback->Call(status, reinterpret_cast<const uint32_t*>(ptr), dataLength,
|
||||||
|
userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockBufferMapWriteCallback {
|
class MockBufferMapWriteCallback {
|
||||||
public:
|
public:
|
||||||
MOCK_METHOD3(Call, void(dawnBufferMapAsyncStatus status, uint32_t* ptr, dawnCallbackUserdata userdata));
|
MOCK_METHOD4(Call,
|
||||||
|
void(dawnBufferMapAsyncStatus status,
|
||||||
|
uint32_t* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
|
dawnCallbackUserdata userdata));
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::unique_ptr<MockBufferMapWriteCallback> mockBufferMapWriteCallback;
|
static std::unique_ptr<MockBufferMapWriteCallback> mockBufferMapWriteCallback;
|
||||||
static void ToMockBufferMapWriteCallback(dawnBufferMapAsyncStatus status, void* ptr, dawnCallbackUserdata userdata) {
|
static void ToMockBufferMapWriteCallback(dawnBufferMapAsyncStatus status,
|
||||||
|
void* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
|
dawnCallbackUserdata userdata) {
|
||||||
// Assume the data is uint32_t to make writing matchers easier
|
// Assume the data is uint32_t to make writing matchers easier
|
||||||
mockBufferMapWriteCallback->Call(status, reinterpret_cast<uint32_t*>(ptr), userdata);
|
mockBufferMapWriteCallback->Call(status, reinterpret_cast<uint32_t*>(ptr), dataLength,
|
||||||
|
userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
class BufferValidationTest : public ValidationTest {
|
class BufferValidationTest : public ValidationTest {
|
||||||
|
@ -142,9 +158,10 @@ TEST_F(BufferValidationTest, MapReadSuccess) {
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40598;
|
dawn::CallbackUserdata userdata = 40598;
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
|
|
||||||
|
@ -156,67 +173,16 @@ TEST_F(BufferValidationTest, MapWriteSuccess) {
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40598;
|
dawn::CallbackUserdata userdata = 40598;
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
|
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test map reading out of range causes an error
|
|
||||||
TEST_F(BufferValidationTest, MapReadOutOfRange) {
|
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40599;
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
|
||||||
.Times(1);
|
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(0, 5, ToMockBufferMapReadCallback, userdata));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test map writing out of range causes an error
|
|
||||||
TEST_F(BufferValidationTest, MapWriteOutOfRange) {
|
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40599;
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
|
||||||
.Times(1);
|
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(0, 5, ToMockBufferMapWriteCallback, userdata));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test map reading out of range causes an error, with an overflow
|
|
||||||
TEST_F(BufferValidationTest, MapReadOutOfRangeOverflow) {
|
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40599;
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
|
||||||
.Times(1);
|
|
||||||
|
|
||||||
// An offset that when added to "2" would overflow to be zero and pass validation without
|
|
||||||
// overflow checks.
|
|
||||||
uint32_t offset = uint32_t(int32_t(0) - int32_t(2));
|
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(offset, 2, ToMockBufferMapReadCallback, userdata));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test map writing out of range causes an error, with an overflow
|
|
||||||
TEST_F(BufferValidationTest, MapWriteOutOfRangeOverflow) {
|
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40599;
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
|
||||||
.Times(1);
|
|
||||||
|
|
||||||
// An offset that when added to "2" would overflow to be zero and pass validation without
|
|
||||||
// overflow checks.
|
|
||||||
uint32_t offset = uint32_t(int32_t(0) - int32_t(2));
|
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(offset, 5, ToMockBufferMapWriteCallback, userdata));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test map reading a buffer with wrong current usage
|
// Test map reading a buffer with wrong current usage
|
||||||
TEST_F(BufferValidationTest, MapReadWrongUsage) {
|
TEST_F(BufferValidationTest, MapReadWrongUsage) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
|
@ -226,10 +192,11 @@ TEST_F(BufferValidationTest, MapReadWrongUsage) {
|
||||||
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40600;
|
dawn::CallbackUserdata userdata = 40600;
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata));
|
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test map writing a buffer with wrong current usage
|
// Test map writing a buffer with wrong current usage
|
||||||
|
@ -241,10 +208,11 @@ TEST_F(BufferValidationTest, MapWriteWrongUsage) {
|
||||||
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40600;
|
dawn::CallbackUserdata userdata = 40600;
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata));
|
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test map reading a buffer that is already mapped
|
// Test map reading a buffer that is already mapped
|
||||||
|
@ -252,14 +220,16 @@ TEST_F(BufferValidationTest, MapReadAlreadyMapped) {
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata1 = 40601;
|
dawn::CallbackUserdata userdata1 = 40601;
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata1);
|
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata1);
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata1))
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata1))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata2 = 40602;
|
dawn::CallbackUserdata userdata2 = 40602;
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata2))
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, userdata2))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata2));
|
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, userdata2));
|
||||||
|
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -269,14 +239,16 @@ TEST_F(BufferValidationTest, MapWriteAlreadyMapped) {
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata1 = 40601;
|
dawn::CallbackUserdata userdata1 = 40601;
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata1);
|
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata1);
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata1))
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata1))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata2 = 40602;
|
dawn::CallbackUserdata userdata2 = 40602;
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata2))
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, userdata2))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata2));
|
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata2));
|
||||||
|
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -287,9 +259,10 @@ TEST_F(BufferValidationTest, MapReadUnmapBeforeResult) {
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40603;
|
dawn::CallbackUserdata userdata = 40603;
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
|
|
||||||
|
@ -303,9 +276,10 @@ TEST_F(BufferValidationTest, MapWriteUnmapBeforeResult) {
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40603;
|
dawn::CallbackUserdata userdata = 40603;
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
|
|
||||||
|
@ -322,9 +296,10 @@ TEST_F(BufferValidationTest, DISABLED_MapReadDestroyBeforeResult) {
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40604;
|
dawn::CallbackUserdata userdata = 40604;
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,9 +316,10 @@ TEST_F(BufferValidationTest, DISABLED_MapWriteDestroyBeforeResult) {
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40604;
|
dawn::CallbackUserdata userdata = 40604;
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,17 +334,19 @@ TEST_F(BufferValidationTest, MapReadUnmapBeforeResultThenMapAgain) {
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40605;
|
dawn::CallbackUserdata userdata = 40605;
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
|
|
||||||
userdata ++;
|
userdata ++;
|
||||||
|
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -380,17 +358,19 @@ TEST_F(BufferValidationTest, MapWriteUnmapBeforeResultThenMapAgain) {
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40605;
|
dawn::CallbackUserdata userdata = 40605;
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
|
|
||||||
userdata ++;
|
userdata ++;
|
||||||
|
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -400,12 +380,11 @@ TEST_F(BufferValidationTest, UnmapInsideMapReadCallback) {
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40678;
|
dawn::CallbackUserdata userdata = 40678;
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||||
buf.Unmap();
|
.WillOnce(InvokeWithoutArgs([&]() { buf.Unmap(); }));
|
||||||
}));
|
|
||||||
|
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -415,12 +394,11 @@ TEST_F(BufferValidationTest, UnmapInsideMapWriteCallback) {
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40678;
|
dawn::CallbackUserdata userdata = 40678;
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||||
buf.Unmap();
|
.WillOnce(InvokeWithoutArgs([&]() { buf.Unmap(); }));
|
||||||
}));
|
|
||||||
|
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -430,12 +408,11 @@ TEST_F(BufferValidationTest, DestroyInsideMapReadCallback) {
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40679;
|
dawn::CallbackUserdata userdata = 40679;
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||||
buf = dawn::Buffer();
|
.WillOnce(InvokeWithoutArgs([&]() { buf = dawn::Buffer(); }));
|
||||||
}));
|
|
||||||
|
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -445,12 +422,11 @@ TEST_F(BufferValidationTest, DestroyInsideMapWriteCallback) {
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||||
|
|
||||||
dawn::CallbackUserdata userdata = 40679;
|
dawn::CallbackUserdata userdata = 40679;
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, userdata))
|
||||||
buf = dawn::Buffer();
|
.WillOnce(InvokeWithoutArgs([&]() { buf = dawn::Buffer(); }));
|
||||||
}));
|
|
||||||
|
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -512,12 +488,12 @@ TEST_F(BufferValidationTest, DestroyUnmappedBuffer) {
|
||||||
TEST_F(BufferValidationTest, DestroyMappedBuffer) {
|
TEST_F(BufferValidationTest, DestroyMappedBuffer) {
|
||||||
{
|
{
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, 30303);
|
buf.MapReadAsync(ToMockBufferMapReadCallback, 30303);
|
||||||
buf.Destroy();
|
buf.Destroy();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, 30233);
|
buf.MapWriteAsync(ToMockBufferMapWriteCallback, 30233);
|
||||||
buf.Destroy();
|
buf.Destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,10 +503,10 @@ TEST_F(BufferValidationTest, DestroyMappedBufferCausesImplicitUnmap) {
|
||||||
{
|
{
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||||
dawn::CallbackUserdata userdata = 40598;
|
dawn::CallbackUserdata userdata = 40598;
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
|
buf.MapReadAsync(ToMockBufferMapReadCallback, userdata);
|
||||||
// Buffer is destroyed. Callback should be called with UNKNOWN status
|
// Buffer is destroyed. Callback should be called with UNKNOWN status
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
buf.Destroy();
|
buf.Destroy();
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
|
@ -538,10 +514,10 @@ TEST_F(BufferValidationTest, DestroyMappedBufferCausesImplicitUnmap) {
|
||||||
{
|
{
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||||
dawn::CallbackUserdata userdata = 23980;
|
dawn::CallbackUserdata userdata = 23980;
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
|
buf.MapWriteAsync(ToMockBufferMapWriteCallback, userdata);
|
||||||
// Buffer is destroyed. Callback should be called with UNKNOWN status
|
// Buffer is destroyed. Callback should be called with UNKNOWN status
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
buf.Destroy();
|
buf.Destroy();
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
|
@ -574,12 +550,12 @@ TEST_F(BufferValidationTest, MapDestroyedBuffer) {
|
||||||
{
|
{
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||||
buf.Destroy();
|
buf.Destroy();
|
||||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, 11303));
|
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, 11303));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||||
buf.Destroy();
|
buf.Destroy();
|
||||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, 56303));
|
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, 56303));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,14 +571,14 @@ TEST_F(BufferValidationTest, SetSubDataDestroyedBuffer) {
|
||||||
TEST_F(BufferValidationTest, MapMappedbuffer) {
|
TEST_F(BufferValidationTest, MapMappedbuffer) {
|
||||||
{
|
{
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, 43309);
|
buf.MapReadAsync(ToMockBufferMapReadCallback, 43309);
|
||||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, 34309));
|
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, 34309));
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, 20301);
|
buf.MapWriteAsync(ToMockBufferMapWriteCallback, 20301);
|
||||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, 40303));
|
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, 40303));
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -611,14 +587,14 @@ TEST_F(BufferValidationTest, MapMappedbuffer) {
|
||||||
TEST_F(BufferValidationTest, SetSubDataMappedBuffer) {
|
TEST_F(BufferValidationTest, SetSubDataMappedBuffer) {
|
||||||
{
|
{
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, 42899);
|
buf.MapReadAsync(ToMockBufferMapReadCallback, 42899);
|
||||||
uint8_t foo = 0;
|
uint8_t foo = 0;
|
||||||
ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(foo), &foo));
|
ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(foo), &foo));
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, 40329);
|
buf.MapWriteAsync(ToMockBufferMapWriteCallback, 40329);
|
||||||
uint8_t foo = 0;
|
uint8_t foo = 0;
|
||||||
ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(foo), &foo));
|
ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(foo), &foo));
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
|
@ -657,7 +633,7 @@ TEST_F(BufferValidationTest, SubmitMappedBuffer) {
|
||||||
dawn::Buffer bufA = device.CreateBuffer(&descriptorA);
|
dawn::Buffer bufA = device.CreateBuffer(&descriptorA);
|
||||||
dawn::Buffer bufB = device.CreateBuffer(&descriptorB);
|
dawn::Buffer bufB = device.CreateBuffer(&descriptorB);
|
||||||
|
|
||||||
bufA.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, 40329);
|
bufA.MapWriteAsync(ToMockBufferMapWriteCallback, 40329);
|
||||||
|
|
||||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||||
builder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
|
builder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
|
||||||
|
@ -669,7 +645,7 @@ TEST_F(BufferValidationTest, SubmitMappedBuffer) {
|
||||||
dawn::Buffer bufA = device.CreateBuffer(&descriptorA);
|
dawn::Buffer bufA = device.CreateBuffer(&descriptorA);
|
||||||
dawn::Buffer bufB = device.CreateBuffer(&descriptorB);
|
dawn::Buffer bufB = device.CreateBuffer(&descriptorB);
|
||||||
|
|
||||||
bufB.MapReadAsync(0, 4, ToMockBufferMapReadCallback, 11329);
|
bufB.MapReadAsync(ToMockBufferMapReadCallback, 11329);
|
||||||
|
|
||||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||||
builder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
|
builder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
|
||||||
|
@ -711,7 +687,7 @@ TEST_F(BufferValidationTest, UnmapUnmappedBuffer) {
|
||||||
dawn::Buffer buf = CreateMapReadBuffer(4);
|
dawn::Buffer buf = CreateMapReadBuffer(4);
|
||||||
// Buffer starts unmapped. Unmap should succeed.
|
// Buffer starts unmapped. Unmap should succeed.
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, 30603);
|
buf.MapReadAsync(ToMockBufferMapReadCallback, 30603);
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
// Unmapping twice should succeed
|
// Unmapping twice should succeed
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
|
@ -720,7 +696,7 @@ TEST_F(BufferValidationTest, UnmapUnmappedBuffer) {
|
||||||
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
dawn::Buffer buf = CreateMapWriteBuffer(4);
|
||||||
// Buffer starts unmapped. Unmap should succeed.
|
// Buffer starts unmapped. Unmap should succeed.
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, 23890);
|
buf.MapWriteAsync(ToMockBufferMapWriteCallback, 23890);
|
||||||
// Unmapping twice should succeed
|
// Unmapping twice should succeed
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
buf.Unmap();
|
buf.Unmap();
|
||||||
|
|
|
@ -21,7 +21,10 @@ namespace {
|
||||||
class QueueSubmitValidationTest : public ValidationTest {
|
class QueueSubmitValidationTest : public ValidationTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void StoreTrueMapWriteCallback(dawnBufferMapAsyncStatus status, void*, dawnCallbackUserdata userdata) {
|
static void StoreTrueMapWriteCallback(dawnBufferMapAsyncStatus status,
|
||||||
|
void*,
|
||||||
|
uint32_t,
|
||||||
|
dawnCallbackUserdata userdata) {
|
||||||
bool* userdataPtr = reinterpret_cast<bool*>(static_cast<intptr_t>(userdata));
|
bool* userdataPtr = reinterpret_cast<bool*>(static_cast<intptr_t>(userdata));
|
||||||
*userdataPtr = true;
|
*userdataPtr = true;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +58,7 @@ TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {
|
||||||
// Map the buffer, submitting when the buffer is mapped should fail
|
// Map the buffer, submitting when the buffer is mapped should fail
|
||||||
bool mapWriteFinished = false;
|
bool mapWriteFinished = false;
|
||||||
dawnCallbackUserdata userdata = static_cast<dawnCallbackUserdata>(reinterpret_cast<intptr_t>(&mapWriteFinished));
|
dawnCallbackUserdata userdata = static_cast<dawnCallbackUserdata>(reinterpret_cast<intptr_t>(&mapWriteFinished));
|
||||||
buffer.MapWriteAsync(0, 4, StoreTrueMapWriteCallback, userdata);
|
buffer.MapWriteAsync(StoreTrueMapWriteCallback, userdata);
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
ASSERT_TRUE(mapWriteFinished);
|
ASSERT_TRUE(mapWriteFinished);
|
||||||
|
|
||||||
|
|
|
@ -22,25 +22,29 @@ namespace {
|
||||||
// Mock classes to add expectations on the wire calling callbacks
|
// Mock classes to add expectations on the wire calling callbacks
|
||||||
class MockBufferMapReadCallback {
|
class MockBufferMapReadCallback {
|
||||||
public:
|
public:
|
||||||
MOCK_METHOD3(Call,
|
MOCK_METHOD4(Call,
|
||||||
void(dawnBufferMapAsyncStatus status,
|
void(dawnBufferMapAsyncStatus status,
|
||||||
const uint32_t* ptr,
|
const uint32_t* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
dawnCallbackUserdata userdata));
|
dawnCallbackUserdata userdata));
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<MockBufferMapReadCallback> mockBufferMapReadCallback;
|
std::unique_ptr<MockBufferMapReadCallback> mockBufferMapReadCallback;
|
||||||
void ToMockBufferMapReadCallback(dawnBufferMapAsyncStatus status,
|
void ToMockBufferMapReadCallback(dawnBufferMapAsyncStatus status,
|
||||||
const void* ptr,
|
const void* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
dawnCallbackUserdata userdata) {
|
dawnCallbackUserdata userdata) {
|
||||||
// Assume the data is uint32_t to make writing matchers easier
|
// Assume the data is uint32_t to make writing matchers easier
|
||||||
mockBufferMapReadCallback->Call(status, static_cast<const uint32_t*>(ptr), userdata);
|
mockBufferMapReadCallback->Call(status, static_cast<const uint32_t*>(ptr), dataLength,
|
||||||
|
userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockBufferMapWriteCallback {
|
class MockBufferMapWriteCallback {
|
||||||
public:
|
public:
|
||||||
MOCK_METHOD3(Call,
|
MOCK_METHOD4(Call,
|
||||||
void(dawnBufferMapAsyncStatus status,
|
void(dawnBufferMapAsyncStatus status,
|
||||||
uint32_t* ptr,
|
uint32_t* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
dawnCallbackUserdata userdata));
|
dawnCallbackUserdata userdata));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -48,10 +52,11 @@ namespace {
|
||||||
uint32_t* lastMapWritePointer = nullptr;
|
uint32_t* lastMapWritePointer = nullptr;
|
||||||
void ToMockBufferMapWriteCallback(dawnBufferMapAsyncStatus status,
|
void ToMockBufferMapWriteCallback(dawnBufferMapAsyncStatus status,
|
||||||
void* ptr,
|
void* ptr,
|
||||||
|
uint32_t dataLength,
|
||||||
dawnCallbackUserdata userdata) {
|
dawnCallbackUserdata userdata) {
|
||||||
// Assume the data is uint32_t to make writing matchers easier
|
// Assume the data is uint32_t to make writing matchers easier
|
||||||
lastMapWritePointer = static_cast<uint32_t*>(ptr);
|
lastMapWritePointer = static_cast<uint32_t*>(ptr);
|
||||||
mockBufferMapWriteCallback->Call(status, lastMapWritePointer, userdata);
|
mockBufferMapWriteCallback->Call(status, lastMapWritePointer, dataLength, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
@ -116,19 +121,20 @@ class WireBufferMappingTests : public WireTest {
|
||||||
// Check mapping for reading a succesfully created buffer
|
// Check mapping for reading a succesfully created buffer
|
||||||
TEST_F(WireBufferMappingTests, MappingForReadSuccessBuffer) {
|
TEST_F(WireBufferMappingTests, MappingForReadSuccessBuffer) {
|
||||||
dawnCallbackUserdata userdata = 8653;
|
dawnCallbackUserdata userdata = 8653;
|
||||||
dawnBufferMapReadAsync(buffer, 40, sizeof(uint32_t), ToMockBufferMapReadCallback, userdata);
|
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, 40, sizeof(uint32_t), _, _))
|
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, &bufferContent,
|
||||||
&bufferContent);
|
sizeof(uint32_t));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(bufferContent)), userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(bufferContent)),
|
||||||
|
sizeof(uint32_t), userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
@ -143,17 +149,17 @@ TEST_F(WireBufferMappingTests, MappingForReadSuccessBuffer) {
|
||||||
// reading
|
// reading
|
||||||
TEST_F(WireBufferMappingTests, ErrorWhileMappingForRead) {
|
TEST_F(WireBufferMappingTests, ErrorWhileMappingForRead) {
|
||||||
dawnCallbackUserdata userdata = 8654;
|
dawnCallbackUserdata userdata = 8654;
|
||||||
dawnBufferMapReadAsync(buffer, 40, sizeof(uint32_t), ToMockBufferMapReadCallback, userdata);
|
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, 40, sizeof(uint32_t), _, _))
|
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr);
|
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
@ -162,13 +168,12 @@ TEST_F(WireBufferMappingTests, ErrorWhileMappingForRead) {
|
||||||
// Check mapping for reading a buffer that didn't get created on the server side
|
// Check mapping for reading a buffer that didn't get created on the server side
|
||||||
TEST_F(WireBufferMappingTests, MappingForReadErrorBuffer) {
|
TEST_F(WireBufferMappingTests, MappingForReadErrorBuffer) {
|
||||||
dawnCallbackUserdata userdata = 8655;
|
dawnCallbackUserdata userdata = 8655;
|
||||||
dawnBufferMapReadAsync(errorBuffer, 40, sizeof(uint32_t), ToMockBufferMapReadCallback,
|
dawnBufferMapReadAsync(errorBuffer, ToMockBufferMapReadCallback, userdata);
|
||||||
userdata);
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
@ -182,11 +187,10 @@ TEST_F(WireBufferMappingTests, MappingForReadErrorBuffer) {
|
||||||
// request is finished
|
// request is finished
|
||||||
TEST_F(WireBufferMappingTests, DestroyBeforeReadRequestEnd) {
|
TEST_F(WireBufferMappingTests, DestroyBeforeReadRequestEnd) {
|
||||||
dawnCallbackUserdata userdata = 8656;
|
dawnCallbackUserdata userdata = 8656;
|
||||||
dawnBufferMapReadAsync(errorBuffer, 40, sizeof(uint32_t), ToMockBufferMapReadCallback,
|
dawnBufferMapReadAsync(errorBuffer, ToMockBufferMapReadCallback, userdata);
|
||||||
userdata);
|
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
dawnBufferRelease(errorBuffer);
|
dawnBufferRelease(errorBuffer);
|
||||||
|
@ -196,20 +200,20 @@ TEST_F(WireBufferMappingTests, DestroyBeforeReadRequestEnd) {
|
||||||
// Unmap was called
|
// Unmap was called
|
||||||
TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForRead) {
|
TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForRead) {
|
||||||
dawnCallbackUserdata userdata = 8657;
|
dawnCallbackUserdata userdata = 8657;
|
||||||
dawnBufferMapReadAsync(buffer, 40, sizeof(uint32_t), ToMockBufferMapReadCallback, userdata);
|
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, 40, sizeof(uint32_t), _, _))
|
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, &bufferContent,
|
||||||
&bufferContent);
|
sizeof(uint32_t));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
// Oh no! We are calling Unmap too early!
|
// Oh no! We are calling Unmap too early!
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
dawnBufferUnmap(buffer);
|
dawnBufferUnmap(buffer);
|
||||||
|
|
||||||
|
@ -221,36 +225,37 @@ TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForRead) {
|
||||||
TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullptr) {
|
TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullptr) {
|
||||||
// Successful map
|
// Successful map
|
||||||
dawnCallbackUserdata userdata = 34098;
|
dawnCallbackUserdata userdata = 34098;
|
||||||
dawnBufferMapReadAsync(buffer, 40, sizeof(uint32_t), ToMockBufferMapReadCallback, userdata);
|
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, 40, sizeof(uint32_t), _, _))
|
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, &bufferContent,
|
||||||
&bufferContent);
|
sizeof(uint32_t));
|
||||||
}))
|
}))
|
||||||
.RetiresOnSaturation();
|
.RetiresOnSaturation();
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(bufferContent)), userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(bufferContent)),
|
||||||
|
sizeof(uint32_t), userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
|
||||||
// Map failure while the buffer is already mapped
|
// Map failure while the buffer is already mapped
|
||||||
userdata++;
|
userdata++;
|
||||||
dawnBufferMapReadAsync(buffer, 40, sizeof(uint32_t), ToMockBufferMapReadCallback, userdata);
|
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, 40, sizeof(uint32_t), _, _))
|
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr);
|
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
@ -259,19 +264,20 @@ TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullp
|
||||||
// Test that the MapReadCallback isn't fired twice when unmap() is called inside the callback
|
// Test that the MapReadCallback isn't fired twice when unmap() is called inside the callback
|
||||||
TEST_F(WireBufferMappingTests, UnmapInsideMapReadCallback) {
|
TEST_F(WireBufferMappingTests, UnmapInsideMapReadCallback) {
|
||||||
dawnCallbackUserdata userdata = 2039;
|
dawnCallbackUserdata userdata = 2039;
|
||||||
dawnBufferMapReadAsync(buffer, 40, sizeof(uint32_t), ToMockBufferMapReadCallback, userdata);
|
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, 40, sizeof(uint32_t), _, _))
|
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, &bufferContent,
|
||||||
&bufferContent);
|
sizeof(uint32_t));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(bufferContent)), userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(bufferContent)),
|
||||||
|
sizeof(uint32_t), userdata))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferUnmap(buffer); }));
|
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferUnmap(buffer); }));
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
@ -285,19 +291,20 @@ TEST_F(WireBufferMappingTests, UnmapInsideMapReadCallback) {
|
||||||
// callback
|
// callback
|
||||||
TEST_F(WireBufferMappingTests, DestroyInsideMapReadCallback) {
|
TEST_F(WireBufferMappingTests, DestroyInsideMapReadCallback) {
|
||||||
dawnCallbackUserdata userdata = 2039;
|
dawnCallbackUserdata userdata = 2039;
|
||||||
dawnBufferMapReadAsync(buffer, 40, sizeof(uint32_t), ToMockBufferMapReadCallback, userdata);
|
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, 40, sizeof(uint32_t), _, _))
|
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, &bufferContent,
|
||||||
&bufferContent);
|
sizeof(uint32_t));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapReadCallback,
|
EXPECT_CALL(*mockBufferMapReadCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(bufferContent)), userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(bufferContent)),
|
||||||
|
sizeof(uint32_t), userdata))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferRelease(buffer); }));
|
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferRelease(buffer); }));
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
@ -310,23 +317,23 @@ TEST_F(WireBufferMappingTests, DestroyInsideMapReadCallback) {
|
||||||
// Check mapping for writing a succesfully created buffer
|
// Check mapping for writing a succesfully created buffer
|
||||||
TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
|
TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
|
||||||
dawnCallbackUserdata userdata = 8653;
|
dawnCallbackUserdata userdata = 8653;
|
||||||
dawnBufferMapWriteAsync(buffer, 40, sizeof(uint32_t), ToMockBufferMapWriteCallback, userdata);
|
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
uint32_t serverBufferContent = 31337;
|
uint32_t serverBufferContent = 31337;
|
||||||
uint32_t updatedContent = 4242;
|
uint32_t updatedContent = 4242;
|
||||||
uint32_t zero = 0;
|
uint32_t zero = 0;
|
||||||
|
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, 40, sizeof(uint32_t), _, _))
|
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||||
&serverBufferContent);
|
&serverBufferContent, sizeof(uint32_t));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
// The map write callback always gets a buffer full of zeroes.
|
// The map write callback always gets a buffer full of zeroes.
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(zero)), userdata))
|
Pointee(Eq(zero)), sizeof(uint32_t), userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
@ -347,17 +354,17 @@ TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
|
||||||
// writing
|
// writing
|
||||||
TEST_F(WireBufferMappingTests, ErrorWhileMappingForWrite) {
|
TEST_F(WireBufferMappingTests, ErrorWhileMappingForWrite) {
|
||||||
dawnCallbackUserdata userdata = 8654;
|
dawnCallbackUserdata userdata = 8654;
|
||||||
dawnBufferMapWriteAsync(buffer, 40, sizeof(uint32_t), ToMockBufferMapWriteCallback, userdata);
|
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, 40, sizeof(uint32_t), _, _))
|
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr);
|
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
@ -366,13 +373,12 @@ TEST_F(WireBufferMappingTests, ErrorWhileMappingForWrite) {
|
||||||
// Check mapping for writing a buffer that didn't get created on the server side
|
// Check mapping for writing a buffer that didn't get created on the server side
|
||||||
TEST_F(WireBufferMappingTests, MappingForWriteErrorBuffer) {
|
TEST_F(WireBufferMappingTests, MappingForWriteErrorBuffer) {
|
||||||
dawnCallbackUserdata userdata = 8655;
|
dawnCallbackUserdata userdata = 8655;
|
||||||
dawnBufferMapWriteAsync(errorBuffer, 40, sizeof(uint32_t), ToMockBufferMapWriteCallback,
|
dawnBufferMapWriteAsync(errorBuffer, ToMockBufferMapWriteCallback, userdata);
|
||||||
userdata);
|
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
@ -386,11 +392,10 @@ TEST_F(WireBufferMappingTests, MappingForWriteErrorBuffer) {
|
||||||
// request is finished
|
// request is finished
|
||||||
TEST_F(WireBufferMappingTests, DestroyBeforeWriteRequestEnd) {
|
TEST_F(WireBufferMappingTests, DestroyBeforeWriteRequestEnd) {
|
||||||
dawnCallbackUserdata userdata = 8656;
|
dawnCallbackUserdata userdata = 8656;
|
||||||
dawnBufferMapWriteAsync(errorBuffer, 40, sizeof(uint32_t), ToMockBufferMapWriteCallback,
|
dawnBufferMapWriteAsync(errorBuffer, ToMockBufferMapWriteCallback, userdata);
|
||||||
userdata);
|
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
dawnBufferRelease(errorBuffer);
|
dawnBufferRelease(errorBuffer);
|
||||||
|
@ -400,20 +405,20 @@ TEST_F(WireBufferMappingTests, DestroyBeforeWriteRequestEnd) {
|
||||||
// Unmap was called
|
// Unmap was called
|
||||||
TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForWrite) {
|
TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForWrite) {
|
||||||
dawnCallbackUserdata userdata = 8657;
|
dawnCallbackUserdata userdata = 8657;
|
||||||
dawnBufferMapWriteAsync(buffer, 40, sizeof(uint32_t), ToMockBufferMapWriteCallback, userdata);
|
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, 40, sizeof(uint32_t), _, _))
|
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||||
&bufferContent);
|
&bufferContent, sizeof(uint32_t));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
// Oh no! We are calling Unmap too early!
|
// Oh no! We are calling Unmap too early!
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
dawnBufferUnmap(buffer);
|
dawnBufferUnmap(buffer);
|
||||||
|
|
||||||
|
@ -425,37 +430,37 @@ TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForWrite) {
|
||||||
TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullptr) {
|
TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullptr) {
|
||||||
// Successful map
|
// Successful map
|
||||||
dawnCallbackUserdata userdata = 34098;
|
dawnCallbackUserdata userdata = 34098;
|
||||||
dawnBufferMapWriteAsync(buffer, 40, sizeof(uint32_t), ToMockBufferMapWriteCallback, userdata);
|
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
uint32_t zero = 0;
|
uint32_t zero = 0;
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, 40, sizeof(uint32_t), _, _))
|
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||||
&bufferContent);
|
&bufferContent, sizeof(uint32_t));
|
||||||
}))
|
}))
|
||||||
.RetiresOnSaturation();
|
.RetiresOnSaturation();
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(zero)), userdata))
|
Pointee(Eq(zero)), sizeof(uint32_t), userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
|
||||||
// Map failure while the buffer is already mapped
|
// Map failure while the buffer is already mapped
|
||||||
userdata++;
|
userdata++;
|
||||||
dawnBufferMapWriteAsync(buffer, 40, sizeof(uint32_t), ToMockBufferMapWriteCallback, userdata);
|
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, 40, sizeof(uint32_t), _, _))
|
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr);
|
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
EXPECT_CALL(*mockBufferMapWriteCallback,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
@ -464,20 +469,20 @@ TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullp
|
||||||
// Test that the MapWriteCallback isn't fired twice when unmap() is called inside the callback
|
// Test that the MapWriteCallback isn't fired twice when unmap() is called inside the callback
|
||||||
TEST_F(WireBufferMappingTests, UnmapInsideMapWriteCallback) {
|
TEST_F(WireBufferMappingTests, UnmapInsideMapWriteCallback) {
|
||||||
dawnCallbackUserdata userdata = 2039;
|
dawnCallbackUserdata userdata = 2039;
|
||||||
dawnBufferMapWriteAsync(buffer, 40, sizeof(uint32_t), ToMockBufferMapWriteCallback, userdata);
|
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
uint32_t zero = 0;
|
uint32_t zero = 0;
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, 40, sizeof(uint32_t), _, _))
|
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||||
&bufferContent);
|
&bufferContent, sizeof(uint32_t));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(zero)), userdata))
|
Pointee(Eq(zero)), sizeof(uint32_t), userdata))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferUnmap(buffer); }));
|
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferUnmap(buffer); }));
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
@ -491,20 +496,20 @@ TEST_F(WireBufferMappingTests, UnmapInsideMapWriteCallback) {
|
||||||
// callback
|
// callback
|
||||||
TEST_F(WireBufferMappingTests, DestroyInsideMapWriteCallback) {
|
TEST_F(WireBufferMappingTests, DestroyInsideMapWriteCallback) {
|
||||||
dawnCallbackUserdata userdata = 2039;
|
dawnCallbackUserdata userdata = 2039;
|
||||||
dawnBufferMapWriteAsync(buffer, 40, sizeof(uint32_t), ToMockBufferMapWriteCallback, userdata);
|
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
|
||||||
|
|
||||||
uint32_t bufferContent = 31337;
|
uint32_t bufferContent = 31337;
|
||||||
uint32_t zero = 0;
|
uint32_t zero = 0;
|
||||||
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, 40, sizeof(uint32_t), _, _))
|
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||||
&bufferContent);
|
&bufferContent, sizeof(uint32_t));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockBufferMapWriteCallback,
|
EXPECT_CALL(*mockBufferMapWriteCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS,
|
||||||
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(zero)), userdata))
|
Pointee(Eq(zero)), sizeof(uint32_t), userdata))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferRelease(buffer); }));
|
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferRelease(buffer); }));
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
|
Loading…
Reference in New Issue