Make dawn_wire use the webgpu.h header
BUG=dawn:22 Change-Id: I4963aa27322086e74947a1a6265c921e2c7d3d85 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12700 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
15e751e418
commit
1fdcb16b69
2
BUILD.gn
2
BUILD.gn
|
@ -821,7 +821,6 @@ test("dawn_unittests") {
|
||||||
"src/tests/unittests/wire/WireArgumentTests.cpp",
|
"src/tests/unittests/wire/WireArgumentTests.cpp",
|
||||||
"src/tests/unittests/wire/WireBasicTests.cpp",
|
"src/tests/unittests/wire/WireBasicTests.cpp",
|
||||||
"src/tests/unittests/wire/WireBufferMappingTests.cpp",
|
"src/tests/unittests/wire/WireBufferMappingTests.cpp",
|
||||||
"src/tests/unittests/wire/WireDawnDevicePropertiesTests.cpp",
|
|
||||||
"src/tests/unittests/wire/WireErrorCallbackTests.cpp",
|
"src/tests/unittests/wire/WireErrorCallbackTests.cpp",
|
||||||
"src/tests/unittests/wire/WireFenceTests.cpp",
|
"src/tests/unittests/wire/WireFenceTests.cpp",
|
||||||
"src/tests/unittests/wire/WireInjectTextureTests.cpp",
|
"src/tests/unittests/wire/WireInjectTextureTests.cpp",
|
||||||
|
@ -829,6 +828,7 @@ test("dawn_unittests") {
|
||||||
"src/tests/unittests/wire/WireOptionalTests.cpp",
|
"src/tests/unittests/wire/WireOptionalTests.cpp",
|
||||||
"src/tests/unittests/wire/WireTest.cpp",
|
"src/tests/unittests/wire/WireTest.cpp",
|
||||||
"src/tests/unittests/wire/WireTest.h",
|
"src/tests/unittests/wire/WireTest.h",
|
||||||
|
"src/tests/unittests/wire/WireWGPUDevicePropertiesTests.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
if (dawn_enable_d3d12) {
|
if (dawn_enable_d3d12) {
|
||||||
|
|
|
@ -458,7 +458,7 @@ def as_wireType(typ):
|
||||||
if typ.category == 'object':
|
if typ.category == 'object':
|
||||||
return typ.name.CamelCase() + '*'
|
return typ.name.CamelCase() + '*'
|
||||||
elif typ.category in ['bitmask', 'enum']:
|
elif typ.category in ['bitmask', 'enum']:
|
||||||
return 'Dawn' + typ.name.CamelCase()
|
return 'WGPU' + typ.name.CamelCase()
|
||||||
else:
|
else:
|
||||||
return as_cppType(typ.name)
|
return as_cppType(typ.name)
|
||||||
|
|
||||||
|
|
|
@ -456,13 +456,13 @@ namespace dawn_wire {
|
||||||
{{ write_command_serialization_methods(command, True) }}
|
{{ write_command_serialization_methods(command, True) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
// Implementations of serialization/deserialization of DawnDeviceProperties.
|
// Implementations of serialization/deserialization of WPGUDeviceProperties.
|
||||||
size_t SerializedWGPUDevicePropertiesSize(const DawnDeviceProperties* deviceProperties) {
|
size_t SerializedWGPUDevicePropertiesSize(const WGPUDeviceProperties* deviceProperties) {
|
||||||
return sizeof(DawnDeviceProperties) +
|
return sizeof(WGPUDeviceProperties) +
|
||||||
WGPUDevicePropertiesGetExtraRequiredSize(*deviceProperties);
|
WGPUDevicePropertiesGetExtraRequiredSize(*deviceProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SerializeWGPUDeviceProperties(const DawnDeviceProperties* deviceProperties,
|
void SerializeWGPUDeviceProperties(const WGPUDeviceProperties* deviceProperties,
|
||||||
char* serializeBuffer) {
|
char* serializeBuffer) {
|
||||||
size_t devicePropertiesSize = SerializedWGPUDevicePropertiesSize(deviceProperties);
|
size_t devicePropertiesSize = SerializedWGPUDevicePropertiesSize(deviceProperties);
|
||||||
WGPUDevicePropertiesTransfer* transfer =
|
WGPUDevicePropertiesTransfer* transfer =
|
||||||
|
@ -472,7 +472,7 @@ namespace dawn_wire {
|
||||||
WGPUDevicePropertiesSerialize(*deviceProperties, transfer, &serializeBuffer);
|
WGPUDevicePropertiesSerialize(*deviceProperties, transfer, &serializeBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeserializeWGPUDeviceProperties(DawnDeviceProperties* deviceProperties,
|
bool DeserializeWGPUDeviceProperties(WGPUDeviceProperties* deviceProperties,
|
||||||
const volatile char* deserializeBuffer) {
|
const volatile char* deserializeBuffer) {
|
||||||
size_t devicePropertiesSize = SerializedWGPUDevicePropertiesSize(deviceProperties);
|
size_t devicePropertiesSize = SerializedWGPUDevicePropertiesSize(deviceProperties);
|
||||||
const volatile WGPUDevicePropertiesTransfer* transfer = nullptr;
|
const volatile WGPUDevicePropertiesTransfer* transfer = nullptr;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef DAWNWIRE_WIRECMD_AUTOGEN_H_
|
#ifndef DAWNWIRE_WIRECMD_AUTOGEN_H_
|
||||||
#define DAWNWIRE_WIRECMD_AUTOGEN_H_
|
#define DAWNWIRE_WIRECMD_AUTOGEN_H_
|
||||||
|
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/webgpu.h>
|
||||||
|
|
||||||
namespace dawn_wire {
|
namespace dawn_wire {
|
||||||
|
|
||||||
|
|
|
@ -95,18 +95,18 @@ namespace dawn_wire { namespace client {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct ProcEntry {
|
struct ProcEntry {
|
||||||
DawnProc proc;
|
WGPUProc proc;
|
||||||
const char* name;
|
const char* name;
|
||||||
};
|
};
|
||||||
static const ProcEntry sProcMap[] = {
|
static const ProcEntry sProcMap[] = {
|
||||||
{% for (type, method) in methods_sorted_by_name %}
|
{% for (type, method) in methods_sorted_by_name %}
|
||||||
{ reinterpret_cast<DawnProc>(Client{{as_MethodSuffix(type.name, method.name)}}), "{{as_cMethod(type.name, method.name)}}" },
|
{ reinterpret_cast<WGPUProc>(Client{{as_MethodSuffix(type.name, method.name)}}), "{{as_cMethod(type.name, method.name)}}" },
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
};
|
};
|
||||||
static constexpr size_t sProcMapSize = sizeof(sProcMap) / sizeof(sProcMap[0]);
|
static constexpr size_t sProcMapSize = sizeof(sProcMap) / sizeof(sProcMap[0]);
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
DawnProc ClientGetProcAddress(DawnDevice, const char* procName) {
|
WGPUProc ClientGetProcAddress(WGPUDevice, const char* procName) {
|
||||||
if (procName == nullptr) {
|
if (procName == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ namespace dawn_wire { namespace client {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(procName, "wgpuGetProcAddress") == 0) {
|
if (strcmp(procName, "wgpuGetProcAddress") == 0) {
|
||||||
return reinterpret_cast<DawnProc>(ClientGetProcAddress);
|
return reinterpret_cast<WGPUProc>(ClientGetProcAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef DAWNWIRE_CLIENT_APIPROCS_AUTOGEN_H_
|
#ifndef DAWNWIRE_CLIENT_APIPROCS_AUTOGEN_H_
|
||||||
#define DAWNWIRE_CLIENT_APIPROCS_AUTOGEN_H_
|
#define DAWNWIRE_CLIENT_APIPROCS_AUTOGEN_H_
|
||||||
|
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/webgpu.h>
|
||||||
|
|
||||||
namespace dawn_wire { namespace client {
|
namespace dawn_wire { namespace client {
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace dawn_wire {
|
||||||
mImpl.reset();
|
mImpl.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnDevice WireClient::GetDevice() const {
|
WGPUDevice WireClient::GetDevice() const {
|
||||||
return mImpl->GetDevice();
|
return mImpl->GetDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ namespace dawn_wire {
|
||||||
return mImpl->HandleCommands(commands, size);
|
return mImpl->HandleCommands(commands, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReservedTexture WireClient::ReserveTexture(DawnDevice device) {
|
ReservedTexture WireClient::ReserveTexture(WGPUDevice device) {
|
||||||
return mImpl->ReserveTexture(device);
|
return mImpl->ReserveTexture(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,12 +45,12 @@ namespace dawn_wire {
|
||||||
MemoryTransferService::~MemoryTransferService() = default;
|
MemoryTransferService::~MemoryTransferService() = default;
|
||||||
|
|
||||||
MemoryTransferService::ReadHandle*
|
MemoryTransferService::ReadHandle*
|
||||||
MemoryTransferService::CreateReadHandle(DawnBuffer buffer, uint64_t offset, size_t size) {
|
MemoryTransferService::CreateReadHandle(WGPUBuffer buffer, uint64_t offset, size_t size) {
|
||||||
return CreateReadHandle(size);
|
return CreateReadHandle(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryTransferService::WriteHandle*
|
MemoryTransferService::WriteHandle*
|
||||||
MemoryTransferService::CreateWriteHandle(DawnBuffer buffer, uint64_t offset, size_t size) {
|
MemoryTransferService::CreateWriteHandle(WGPUBuffer buffer, uint64_t offset, size_t size) {
|
||||||
return CreateWriteHandle(size);
|
return CreateWriteHandle(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace dawn_wire {
|
||||||
return mImpl->HandleCommands(commands, size);
|
return mImpl->HandleCommands(commands, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WireServer::InjectTexture(DawnTexture texture, uint32_t id, uint32_t generation) {
|
bool WireServer::InjectTexture(WGPUTexture texture, uint32_t id, uint32_t generation) {
|
||||||
return mImpl->InjectTexture(texture, id, generation);
|
return mImpl->InjectTexture(texture, id, generation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ namespace dawn_wire { namespace client {
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void ClientBufferMapReadAsync(DawnBuffer cBuffer,
|
void ClientBufferMapReadAsync(WGPUBuffer cBuffer,
|
||||||
DawnBufferMapReadCallback callback,
|
WGPUBufferMapReadCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ namespace dawn_wire { namespace client {
|
||||||
MemoryTransferService::ReadHandle* readHandle =
|
MemoryTransferService::ReadHandle* readHandle =
|
||||||
buffer->device->GetClient()->GetMemoryTransferService()->CreateReadHandle(buffer->size);
|
buffer->device->GetClient()->GetMemoryTransferService()->CreateReadHandle(buffer->size);
|
||||||
if (readHandle == nullptr) {
|
if (readHandle == nullptr) {
|
||||||
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_DEVICE_LOST, nullptr, 0, userdata);
|
callback(WGPUBufferMapAsyncStatus_DeviceLost, nullptr, 0, userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ namespace dawn_wire { namespace client {
|
||||||
SerializeBufferMapAsync(buffer, serial, readHandle);
|
SerializeBufferMapAsync(buffer, serial, readHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientBufferMapWriteAsync(DawnBuffer cBuffer,
|
void ClientBufferMapWriteAsync(WGPUBuffer cBuffer,
|
||||||
DawnBufferMapWriteCallback callback,
|
WGPUBufferMapWriteCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ namespace dawn_wire { namespace client {
|
||||||
buffer->device->GetClient()->GetMemoryTransferService()->CreateWriteHandle(
|
buffer->device->GetClient()->GetMemoryTransferService()->CreateWriteHandle(
|
||||||
buffer->size);
|
buffer->size);
|
||||||
if (writeHandle == nullptr) {
|
if (writeHandle == nullptr) {
|
||||||
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_DEVICE_LOST, nullptr, 0, userdata);
|
callback(WGPUBufferMapAsyncStatus_DeviceLost, nullptr, 0, userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,8 +107,8 @@ namespace dawn_wire { namespace client {
|
||||||
SerializeBufferMapAsync(buffer, serial, writeHandle);
|
SerializeBufferMapAsync(buffer, serial, writeHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnBuffer ClientDeviceCreateBuffer(DawnDevice cDevice,
|
WGPUBuffer ClientDeviceCreateBuffer(WGPUDevice cDevice,
|
||||||
const DawnBufferDescriptor* descriptor) {
|
const WGPUBufferDescriptor* descriptor) {
|
||||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||||
Client* wireClient = device->GetClient();
|
Client* wireClient = device->GetClient();
|
||||||
|
|
||||||
|
@ -127,12 +127,12 @@ namespace dawn_wire { namespace client {
|
||||||
char* allocatedBuffer = static_cast<char*>(wireClient->GetCmdSpace(requiredSize));
|
char* allocatedBuffer = static_cast<char*>(wireClient->GetCmdSpace(requiredSize));
|
||||||
cmd.Serialize(allocatedBuffer, *wireClient);
|
cmd.Serialize(allocatedBuffer, *wireClient);
|
||||||
|
|
||||||
return reinterpret_cast<DawnBuffer>(buffer);
|
return reinterpret_cast<WGPUBuffer>(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnCreateBufferMappedResult ClientDeviceCreateBufferMapped(
|
WGPUCreateBufferMappedResult ClientDeviceCreateBufferMapped(
|
||||||
DawnDevice cDevice,
|
WGPUDevice cDevice,
|
||||||
const DawnBufferDescriptor* descriptor) {
|
const WGPUBufferDescriptor* descriptor) {
|
||||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||||
Client* wireClient = device->GetClient();
|
Client* wireClient = device->GetClient();
|
||||||
|
|
||||||
|
@ -140,8 +140,8 @@ namespace dawn_wire { namespace client {
|
||||||
Buffer* buffer = bufferObjectAndSerial->object.get();
|
Buffer* buffer = bufferObjectAndSerial->object.get();
|
||||||
buffer->size = descriptor->size;
|
buffer->size = descriptor->size;
|
||||||
|
|
||||||
DawnCreateBufferMappedResult result;
|
WGPUCreateBufferMappedResult result;
|
||||||
result.buffer = reinterpret_cast<DawnBuffer>(buffer);
|
result.buffer = reinterpret_cast<WGPUBuffer>(buffer);
|
||||||
result.data = nullptr;
|
result.data = nullptr;
|
||||||
result.dataLength = 0;
|
result.dataLength = 0;
|
||||||
|
|
||||||
|
@ -190,9 +190,9 @@ namespace dawn_wire { namespace client {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientDeviceCreateBufferMappedAsync(DawnDevice cDevice,
|
void ClientDeviceCreateBufferMappedAsync(WGPUDevice cDevice,
|
||||||
const DawnBufferDescriptor* descriptor,
|
const WGPUBufferDescriptor* descriptor,
|
||||||
DawnBufferCreateMappedCallback callback,
|
WGPUBufferCreateMappedCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||||
Client* wireClient = device->GetClient();
|
Client* wireClient = device->GetClient();
|
||||||
|
@ -204,13 +204,13 @@ namespace dawn_wire { namespace client {
|
||||||
uint32_t serial = buffer->requestSerial++;
|
uint32_t serial = buffer->requestSerial++;
|
||||||
|
|
||||||
struct CreateBufferMappedInfo {
|
struct CreateBufferMappedInfo {
|
||||||
DawnBuffer buffer;
|
WGPUBuffer buffer;
|
||||||
DawnBufferCreateMappedCallback callback;
|
WGPUBufferCreateMappedCallback callback;
|
||||||
void* userdata;
|
void* userdata;
|
||||||
};
|
};
|
||||||
|
|
||||||
CreateBufferMappedInfo* info = new CreateBufferMappedInfo;
|
CreateBufferMappedInfo* info = new CreateBufferMappedInfo;
|
||||||
info->buffer = reinterpret_cast<DawnBuffer>(buffer);
|
info->buffer = reinterpret_cast<WGPUBuffer>(buffer);
|
||||||
info->callback = callback;
|
info->callback = callback;
|
||||||
info->userdata = userdata;
|
info->userdata = userdata;
|
||||||
|
|
||||||
|
@ -219,21 +219,21 @@ namespace dawn_wire { namespace client {
|
||||||
MemoryTransferService::WriteHandle* writeHandle =
|
MemoryTransferService::WriteHandle* writeHandle =
|
||||||
wireClient->GetMemoryTransferService()->CreateWriteHandle(descriptor->size);
|
wireClient->GetMemoryTransferService()->CreateWriteHandle(descriptor->size);
|
||||||
if (writeHandle == nullptr) {
|
if (writeHandle == nullptr) {
|
||||||
DawnCreateBufferMappedResult result;
|
WGPUCreateBufferMappedResult result;
|
||||||
result.buffer = reinterpret_cast<DawnBuffer>(buffer);
|
result.buffer = reinterpret_cast<WGPUBuffer>(buffer);
|
||||||
result.data = nullptr;
|
result.data = nullptr;
|
||||||
result.dataLength = 0;
|
result.dataLength = 0;
|
||||||
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_DEVICE_LOST, result, userdata);
|
callback(WGPUBufferMapAsyncStatus_DeviceLost, result, userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer::MapRequestData request;
|
Buffer::MapRequestData request;
|
||||||
request.writeCallback = [](DawnBufferMapAsyncStatus status, void* data, uint64_t dataLength,
|
request.writeCallback = [](WGPUBufferMapAsyncStatus status, void* data, uint64_t dataLength,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
auto info = std::unique_ptr<CreateBufferMappedInfo>(
|
auto info = std::unique_ptr<CreateBufferMappedInfo>(
|
||||||
static_cast<CreateBufferMappedInfo*>(userdata));
|
static_cast<CreateBufferMappedInfo*>(userdata));
|
||||||
|
|
||||||
DawnCreateBufferMappedResult result;
|
WGPUCreateBufferMappedResult result;
|
||||||
result.buffer = info->buffer;
|
result.buffer = info->buffer;
|
||||||
result.data = data;
|
result.data = data;
|
||||||
result.dataLength = dataLength;
|
result.dataLength = dataLength;
|
||||||
|
@ -264,36 +264,36 @@ namespace dawn_wire { namespace client {
|
||||||
writeHandle->SerializeCreate(allocatedBuffer + commandSize);
|
writeHandle->SerializeCreate(allocatedBuffer + commandSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientDevicePushErrorScope(DawnDevice cDevice, DawnErrorFilter filter) {
|
void ClientDevicePushErrorScope(WGPUDevice cDevice, WGPUErrorFilter filter) {
|
||||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||||
device->PushErrorScope(filter);
|
device->PushErrorScope(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClientDevicePopErrorScope(DawnDevice cDevice, DawnErrorCallback callback, void* userdata) {
|
bool ClientDevicePopErrorScope(WGPUDevice cDevice, WGPUErrorCallback callback, void* userdata) {
|
||||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||||
return device->RequestPopErrorScope(callback, userdata);
|
return device->RequestPopErrorScope(callback, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ClientFenceGetCompletedValue(DawnFence cSelf) {
|
uint64_t ClientFenceGetCompletedValue(WGPUFence cSelf) {
|
||||||
auto fence = reinterpret_cast<Fence*>(cSelf);
|
auto fence = reinterpret_cast<Fence*>(cSelf);
|
||||||
return fence->completedValue;
|
return fence->completedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientFenceOnCompletion(DawnFence cFence,
|
void ClientFenceOnCompletion(WGPUFence cFence,
|
||||||
uint64_t value,
|
uint64_t value,
|
||||||
DawnFenceOnCompletionCallback callback,
|
WGPUFenceOnCompletionCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
Fence* fence = reinterpret_cast<Fence*>(cFence);
|
Fence* fence = reinterpret_cast<Fence*>(cFence);
|
||||||
if (value > fence->signaledValue) {
|
if (value > fence->signaledValue) {
|
||||||
ClientDeviceInjectError(reinterpret_cast<DawnDevice>(fence->device),
|
ClientDeviceInjectError(reinterpret_cast<WGPUDevice>(fence->device),
|
||||||
DAWN_ERROR_TYPE_VALIDATION,
|
WGPUErrorType_Validation,
|
||||||
"Value greater than fence signaled value");
|
"Value greater than fence signaled value");
|
||||||
callback(DAWN_FENCE_COMPLETION_STATUS_ERROR, userdata);
|
callback(WGPUFenceCompletionStatus_Error, userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value <= fence->completedValue) {
|
if (value <= fence->completedValue) {
|
||||||
callback(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, userdata);
|
callback(WGPUFenceCompletionStatus_Success, userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ namespace dawn_wire { namespace client {
|
||||||
fence->requests.Enqueue(std::move(request), value);
|
fence->requests.Enqueue(std::move(request), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientBufferSetSubData(DawnBuffer cBuffer,
|
void ClientBufferSetSubData(WGPUBuffer cBuffer,
|
||||||
uint64_t start,
|
uint64_t start,
|
||||||
uint64_t count,
|
uint64_t count,
|
||||||
const void* data) {
|
const void* data) {
|
||||||
|
@ -321,7 +321,7 @@ namespace dawn_wire { namespace client {
|
||||||
cmd.Serialize(allocatedBuffer);
|
cmd.Serialize(allocatedBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientBufferUnmap(DawnBuffer cBuffer) {
|
void ClientBufferUnmap(WGPUBuffer cBuffer) {
|
||||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||||
|
|
||||||
// Invalidate the local pointer, and cancel all other in-flight requests that would
|
// Invalidate the local pointer, and cancel all other in-flight requests that would
|
||||||
|
@ -358,7 +358,7 @@ namespace dawn_wire { namespace client {
|
||||||
} else if (buffer->readHandle) {
|
} else if (buffer->readHandle) {
|
||||||
buffer->readHandle = nullptr;
|
buffer->readHandle = nullptr;
|
||||||
}
|
}
|
||||||
buffer->ClearMapRequests(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN);
|
buffer->ClearMapRequests(WGPUBufferMapAsyncStatus_Unknown);
|
||||||
|
|
||||||
BufferUnmapCmd cmd;
|
BufferUnmapCmd cmd;
|
||||||
cmd.self = cBuffer;
|
cmd.self = cBuffer;
|
||||||
|
@ -368,7 +368,7 @@ namespace dawn_wire { namespace client {
|
||||||
cmd.Serialize(allocatedBuffer, *buffer->device->GetClient());
|
cmd.Serialize(allocatedBuffer, *buffer->device->GetClient());
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnFence ClientQueueCreateFence(DawnQueue cSelf, DawnFenceDescriptor const* descriptor) {
|
WGPUFence ClientQueueCreateFence(WGPUQueue cSelf, WGPUFenceDescriptor const* descriptor) {
|
||||||
Queue* queue = reinterpret_cast<Queue*>(cSelf);
|
Queue* queue = reinterpret_cast<Queue*>(cSelf);
|
||||||
Device* device = queue->device;
|
Device* device = queue->device;
|
||||||
|
|
||||||
|
@ -382,7 +382,7 @@ namespace dawn_wire { namespace client {
|
||||||
char* allocatedBuffer = static_cast<char*>(device->GetClient()->GetCmdSpace(requiredSize));
|
char* allocatedBuffer = static_cast<char*>(device->GetClient()->GetCmdSpace(requiredSize));
|
||||||
cmd.Serialize(allocatedBuffer, *device->GetClient());
|
cmd.Serialize(allocatedBuffer, *device->GetClient());
|
||||||
|
|
||||||
DawnFence cFence = reinterpret_cast<DawnFence>(allocation->object.get());
|
WGPUFence cFence = reinterpret_cast<WGPUFence>(allocation->object.get());
|
||||||
|
|
||||||
Fence* fence = reinterpret_cast<Fence*>(cFence);
|
Fence* fence = reinterpret_cast<Fence*>(cFence);
|
||||||
fence->queue = queue;
|
fence->queue = queue;
|
||||||
|
@ -391,18 +391,18 @@ namespace dawn_wire { namespace client {
|
||||||
return cFence;
|
return cFence;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientQueueSignal(DawnQueue cQueue, DawnFence cFence, uint64_t signalValue) {
|
void ClientQueueSignal(WGPUQueue cQueue, WGPUFence cFence, uint64_t signalValue) {
|
||||||
Fence* fence = reinterpret_cast<Fence*>(cFence);
|
Fence* fence = reinterpret_cast<Fence*>(cFence);
|
||||||
Queue* queue = reinterpret_cast<Queue*>(cQueue);
|
Queue* queue = reinterpret_cast<Queue*>(cQueue);
|
||||||
if (fence->queue != queue) {
|
if (fence->queue != queue) {
|
||||||
ClientDeviceInjectError(reinterpret_cast<DawnDevice>(fence->device),
|
ClientDeviceInjectError(reinterpret_cast<WGPUDevice>(fence->device),
|
||||||
DAWN_ERROR_TYPE_VALIDATION,
|
WGPUErrorType_Validation,
|
||||||
"Fence must be signaled on the queue on which it was created.");
|
"Fence must be signaled on the queue on which it was created.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (signalValue <= fence->signaledValue) {
|
if (signalValue <= fence->signaledValue) {
|
||||||
ClientDeviceInjectError(reinterpret_cast<DawnDevice>(fence->device),
|
ClientDeviceInjectError(reinterpret_cast<WGPUDevice>(fence->device),
|
||||||
DAWN_ERROR_TYPE_VALIDATION,
|
WGPUErrorType_Validation,
|
||||||
"Fence value less than or equal to signaled value");
|
"Fence value less than or equal to signaled value");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -419,14 +419,14 @@ namespace dawn_wire { namespace client {
|
||||||
cmd.Serialize(allocatedBuffer, *fence->device->GetClient());
|
cmd.Serialize(allocatedBuffer, *fence->device->GetClient());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientDeviceReference(DawnDevice) {
|
void ClientDeviceReference(WGPUDevice) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientDeviceRelease(DawnDevice) {
|
void ClientDeviceRelease(WGPUDevice) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientDeviceSetUncapturedErrorCallback(DawnDevice cSelf,
|
void ClientDeviceSetUncapturedErrorCallback(WGPUDevice cSelf,
|
||||||
DawnErrorCallback callback,
|
WGPUErrorCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
Device* device = reinterpret_cast<Device*>(cSelf);
|
Device* device = reinterpret_cast<Device*>(cSelf);
|
||||||
device->SetUncapturedErrorCallback(callback, userdata);
|
device->SetUncapturedErrorCallback(callback, userdata);
|
||||||
|
|
|
@ -19,10 +19,10 @@ namespace dawn_wire { namespace client {
|
||||||
Buffer::~Buffer() {
|
Buffer::~Buffer() {
|
||||||
// Callbacks need to be fired in all cases, as they can handle freeing resources
|
// Callbacks need to be fired in all cases, as they can handle freeing resources
|
||||||
// so we call them with "Unknown" status.
|
// so we call them with "Unknown" status.
|
||||||
ClearMapRequests(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN);
|
ClearMapRequests(WGPUBufferMapAsyncStatus_Unknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::ClearMapRequests(DawnBufferMapAsyncStatus status) {
|
void Buffer::ClearMapRequests(WGPUBufferMapAsyncStatus status) {
|
||||||
for (auto& it : requests) {
|
for (auto& it : requests) {
|
||||||
if (it.second.writeHandle) {
|
if (it.second.writeHandle) {
|
||||||
it.second.writeCallback(status, nullptr, 0, it.second.userdata);
|
it.second.writeCallback(status, nullptr, 0, it.second.userdata);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef DAWNWIRE_CLIENT_BUFFER_H_
|
#ifndef DAWNWIRE_CLIENT_BUFFER_H_
|
||||||
#define DAWNWIRE_CLIENT_BUFFER_H_
|
#define DAWNWIRE_CLIENT_BUFFER_H_
|
||||||
|
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/webgpu.h>
|
||||||
|
|
||||||
#include "dawn_wire/WireClient.h"
|
#include "dawn_wire/WireClient.h"
|
||||||
#include "dawn_wire/client/ObjectBase.h"
|
#include "dawn_wire/client/ObjectBase.h"
|
||||||
|
@ -28,15 +28,15 @@ namespace dawn_wire { namespace client {
|
||||||
using ObjectBase::ObjectBase;
|
using ObjectBase::ObjectBase;
|
||||||
|
|
||||||
~Buffer();
|
~Buffer();
|
||||||
void ClearMapRequests(DawnBufferMapAsyncStatus status);
|
void ClearMapRequests(WGPUBufferMapAsyncStatus status);
|
||||||
|
|
||||||
// We want to defer all the validation to the server, which means we could have multiple
|
// We want to defer all the validation to the server, which means we could have multiple
|
||||||
// map request in flight at a single time and need to track them separately.
|
// map request in flight at a single time and need to track them separately.
|
||||||
// On well-behaved applications, only one request should exist at a single time.
|
// On well-behaved applications, only one request should exist at a single time.
|
||||||
struct MapRequestData {
|
struct MapRequestData {
|
||||||
// TODO(enga): Use a tagged pointer to save space.
|
// TODO(enga): Use a tagged pointer to save space.
|
||||||
DawnBufferMapReadCallback readCallback = nullptr;
|
WGPUBufferMapReadCallback readCallback = nullptr;
|
||||||
DawnBufferMapWriteCallback writeCallback = nullptr;
|
WGPUBufferMapWriteCallback writeCallback = nullptr;
|
||||||
void* userdata = nullptr;
|
void* userdata = nullptr;
|
||||||
// TODO(enga): Use a tagged pointer to save space.
|
// TODO(enga): Use a tagged pointer to save space.
|
||||||
std::unique_ptr<MemoryTransferService::ReadHandle> readHandle = nullptr;
|
std::unique_ptr<MemoryTransferService::ReadHandle> readHandle = nullptr;
|
||||||
|
|
|
@ -33,12 +33,12 @@ namespace dawn_wire { namespace client {
|
||||||
DeviceAllocator().Free(mDevice);
|
DeviceAllocator().Free(mDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReservedTexture Client::ReserveTexture(DawnDevice cDevice) {
|
ReservedTexture Client::ReserveTexture(WGPUDevice cDevice) {
|
||||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||||
ObjectAllocator<Texture>::ObjectAndSerial* allocation = TextureAllocator().New(device);
|
ObjectAllocator<Texture>::ObjectAndSerial* allocation = TextureAllocator().New(device);
|
||||||
|
|
||||||
ReservedTexture result;
|
ReservedTexture result;
|
||||||
result.texture = reinterpret_cast<DawnTexture>(allocation->object.get());
|
result.texture = reinterpret_cast<WGPUTexture>(allocation->object.get());
|
||||||
result.id = allocation->object->id;
|
result.id = allocation->object->id;
|
||||||
result.generation = allocation->serial;
|
result.generation = allocation->serial;
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef DAWNWIRE_CLIENT_CLIENT_H_
|
#ifndef DAWNWIRE_CLIENT_CLIENT_H_
|
||||||
#define DAWNWIRE_CLIENT_CLIENT_H_
|
#define DAWNWIRE_CLIENT_CLIENT_H_
|
||||||
|
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/webgpu.h>
|
||||||
#include <dawn_wire/Wire.h>
|
#include <dawn_wire/Wire.h>
|
||||||
|
|
||||||
#include "dawn_wire/WireClient.h"
|
#include "dawn_wire/WireClient.h"
|
||||||
|
@ -34,14 +34,14 @@ namespace dawn_wire { namespace client {
|
||||||
~Client();
|
~Client();
|
||||||
|
|
||||||
const volatile char* HandleCommands(const volatile char* commands, size_t size);
|
const volatile char* HandleCommands(const volatile char* commands, size_t size);
|
||||||
ReservedTexture ReserveTexture(DawnDevice device);
|
ReservedTexture ReserveTexture(WGPUDevice device);
|
||||||
|
|
||||||
void* GetCmdSpace(size_t size) {
|
void* GetCmdSpace(size_t size) {
|
||||||
return mSerializer->GetCmdSpace(size);
|
return mSerializer->GetCmdSpace(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnDevice GetDevice() const {
|
WGPUDevice GetDevice() const {
|
||||||
return reinterpret_cast<DawnDeviceImpl*>(mDevice);
|
return reinterpret_cast<WGPUDeviceImpl*>(mDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryTransferService* GetMemoryTransferService() const {
|
MemoryTransferService* GetMemoryTransferService() const {
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
|
|
||||||
namespace dawn_wire { namespace client {
|
namespace dawn_wire { namespace client {
|
||||||
|
|
||||||
bool Client::DoDeviceUncapturedErrorCallback(DawnErrorType errorType, const char* message) {
|
bool Client::DoDeviceUncapturedErrorCallback(WGPUErrorType errorType, const char* message) {
|
||||||
switch (errorType) {
|
switch (errorType) {
|
||||||
case DAWN_ERROR_TYPE_NO_ERROR:
|
case WGPUErrorType_NoError:
|
||||||
case DAWN_ERROR_TYPE_VALIDATION:
|
case WGPUErrorType_Validation:
|
||||||
case DAWN_ERROR_TYPE_OUT_OF_MEMORY:
|
case WGPUErrorType_OutOfMemory:
|
||||||
case DAWN_ERROR_TYPE_UNKNOWN:
|
case WGPUErrorType_Unknown:
|
||||||
case DAWN_ERROR_TYPE_DEVICE_LOST:
|
case WGPUErrorType_DeviceLost:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -36,7 +36,7 @@ namespace dawn_wire { namespace client {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::DoDevicePopErrorScopeCallback(uint64_t requestSerial,
|
bool Client::DoDevicePopErrorScopeCallback(uint64_t requestSerial,
|
||||||
DawnErrorType errorType,
|
WGPUErrorType errorType,
|
||||||
const char* message) {
|
const char* message) {
|
||||||
return mDevice->PopErrorScope(requestSerial, errorType, message);
|
return mDevice->PopErrorScope(requestSerial, errorType, message);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ namespace dawn_wire { namespace client {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
if (status == WGPUBufferMapAsyncStatus_Success) {
|
||||||
if (buffer->readHandle || buffer->writeHandle) {
|
if (buffer->readHandle || buffer->writeHandle) {
|
||||||
// Buffer is already mapped.
|
// Buffer is already mapped.
|
||||||
return false;
|
return false;
|
||||||
|
@ -105,11 +105,10 @@ namespace dawn_wire { namespace client {
|
||||||
if (!GetMappedData()) {
|
if (!GetMappedData()) {
|
||||||
// Dawn promises that all callbacks are called in finite time. Even if a fatal error
|
// Dawn promises that all callbacks are called in finite time. Even if a fatal error
|
||||||
// occurs, the callback is called.
|
// occurs, the callback is called.
|
||||||
request.readCallback(DAWN_BUFFER_MAP_ASYNC_STATUS_DEVICE_LOST, nullptr, 0,
|
request.readCallback(WGPUBufferMapAsyncStatus_DeviceLost, nullptr, 0, request.userdata);
|
||||||
request.userdata);
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
request.readCallback(static_cast<DawnBufferMapAsyncStatus>(status), mappedData,
|
request.readCallback(static_cast<WGPUBufferMapAsyncStatus>(status), mappedData,
|
||||||
static_cast<uint64_t>(mappedDataLength), request.userdata);
|
static_cast<uint64_t>(mappedDataLength), request.userdata);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +142,7 @@ namespace dawn_wire { namespace client {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
if (status == WGPUBufferMapAsyncStatus_Success) {
|
||||||
if (buffer->readHandle || buffer->writeHandle) {
|
if (buffer->readHandle || buffer->writeHandle) {
|
||||||
// Buffer is already mapped.
|
// Buffer is already mapped.
|
||||||
return false;
|
return false;
|
||||||
|
@ -169,11 +168,11 @@ namespace dawn_wire { namespace client {
|
||||||
if (!GetMappedData()) {
|
if (!GetMappedData()) {
|
||||||
// Dawn promises that all callbacks are called in finite time. Even if a fatal error
|
// Dawn promises that all callbacks are called in finite time. Even if a fatal error
|
||||||
// occurs, the callback is called.
|
// occurs, the callback is called.
|
||||||
request.writeCallback(DAWN_BUFFER_MAP_ASYNC_STATUS_DEVICE_LOST, nullptr, 0,
|
request.writeCallback(WGPUBufferMapAsyncStatus_DeviceLost, nullptr, 0,
|
||||||
request.userdata);
|
request.userdata);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
request.writeCallback(static_cast<DawnBufferMapAsyncStatus>(status), mappedData,
|
request.writeCallback(static_cast<WGPUBufferMapAsyncStatus>(status), mappedData,
|
||||||
static_cast<uint64_t>(mappedDataLength), request.userdata);
|
static_cast<uint64_t>(mappedDataLength), request.userdata);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace dawn_wire { namespace client {
|
||||||
Device::~Device() {
|
Device::~Device() {
|
||||||
auto errorScopes = std::move(mErrorScopes);
|
auto errorScopes = std::move(mErrorScopes);
|
||||||
for (const auto& it : errorScopes) {
|
for (const auto& it : errorScopes) {
|
||||||
it.second.callback(DAWN_ERROR_TYPE_UNKNOWN, "Device destroyed", it.second.userdata);
|
it.second.callback(WGPUErrorType_Unknown, "Device destroyed", it.second.userdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,22 +36,22 @@ namespace dawn_wire { namespace client {
|
||||||
return mClient;
|
return mClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::HandleError(DawnErrorType errorType, const char* message) {
|
void Device::HandleError(WGPUErrorType errorType, const char* message) {
|
||||||
if (mErrorCallback) {
|
if (mErrorCallback) {
|
||||||
mErrorCallback(errorType, message, mErrorUserdata);
|
mErrorCallback(errorType, message, mErrorUserdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::SetUncapturedErrorCallback(DawnErrorCallback errorCallback, void* errorUserdata) {
|
void Device::SetUncapturedErrorCallback(WGPUErrorCallback errorCallback, void* errorUserdata) {
|
||||||
mErrorCallback = errorCallback;
|
mErrorCallback = errorCallback;
|
||||||
mErrorUserdata = errorUserdata;
|
mErrorUserdata = errorUserdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::PushErrorScope(DawnErrorFilter filter) {
|
void Device::PushErrorScope(WGPUErrorFilter filter) {
|
||||||
mErrorScopeStackSize++;
|
mErrorScopeStackSize++;
|
||||||
|
|
||||||
DevicePushErrorScopeCmd cmd;
|
DevicePushErrorScopeCmd cmd;
|
||||||
cmd.self = reinterpret_cast<DawnDevice>(this);
|
cmd.self = reinterpret_cast<WGPUDevice>(this);
|
||||||
cmd.filter = filter;
|
cmd.filter = filter;
|
||||||
|
|
||||||
Client* wireClient = GetClient();
|
Client* wireClient = GetClient();
|
||||||
|
@ -60,7 +60,7 @@ namespace dawn_wire { namespace client {
|
||||||
cmd.Serialize(allocatedBuffer, *wireClient);
|
cmd.Serialize(allocatedBuffer, *wireClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Device::RequestPopErrorScope(DawnErrorCallback callback, void* userdata) {
|
bool Device::RequestPopErrorScope(WGPUErrorCallback callback, void* userdata) {
|
||||||
if (mErrorScopeStackSize == 0) {
|
if (mErrorScopeStackSize == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ namespace dawn_wire { namespace client {
|
||||||
mErrorScopes[serial] = {callback, userdata};
|
mErrorScopes[serial] = {callback, userdata};
|
||||||
|
|
||||||
DevicePopErrorScopeCmd cmd;
|
DevicePopErrorScopeCmd cmd;
|
||||||
cmd.device = reinterpret_cast<DawnDevice>(this);
|
cmd.device = reinterpret_cast<WGPUDevice>(this);
|
||||||
cmd.requestSerial = serial;
|
cmd.requestSerial = serial;
|
||||||
|
|
||||||
Client* wireClient = GetClient();
|
Client* wireClient = GetClient();
|
||||||
|
@ -83,13 +83,13 @@ namespace dawn_wire { namespace client {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Device::PopErrorScope(uint64_t requestSerial, DawnErrorType type, const char* message) {
|
bool Device::PopErrorScope(uint64_t requestSerial, WGPUErrorType type, const char* message) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DAWN_ERROR_TYPE_NO_ERROR:
|
case WGPUErrorType_NoError:
|
||||||
case DAWN_ERROR_TYPE_VALIDATION:
|
case WGPUErrorType_Validation:
|
||||||
case DAWN_ERROR_TYPE_OUT_OF_MEMORY:
|
case WGPUErrorType_OutOfMemory:
|
||||||
case DAWN_ERROR_TYPE_UNKNOWN:
|
case WGPUErrorType_Unknown:
|
||||||
case DAWN_ERROR_TYPE_DEVICE_LOST:
|
case WGPUErrorType_DeviceLost:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef DAWNWIRE_CLIENT_DEVICE_H_
|
#ifndef DAWNWIRE_CLIENT_DEVICE_H_
|
||||||
#define DAWNWIRE_CLIENT_DEVICE_H_
|
#define DAWNWIRE_CLIENT_DEVICE_H_
|
||||||
|
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/webgpu.h>
|
||||||
|
|
||||||
#include "dawn_wire/client/ObjectBase.h"
|
#include "dawn_wire/client/ObjectBase.h"
|
||||||
|
|
||||||
|
@ -31,16 +31,16 @@ namespace dawn_wire { namespace client {
|
||||||
~Device();
|
~Device();
|
||||||
|
|
||||||
Client* GetClient();
|
Client* GetClient();
|
||||||
void HandleError(DawnErrorType errorType, const char* message);
|
void HandleError(WGPUErrorType errorType, const char* message);
|
||||||
void SetUncapturedErrorCallback(DawnErrorCallback errorCallback, void* errorUserdata);
|
void SetUncapturedErrorCallback(WGPUErrorCallback errorCallback, void* errorUserdata);
|
||||||
|
|
||||||
void PushErrorScope(DawnErrorFilter filter);
|
void PushErrorScope(WGPUErrorFilter filter);
|
||||||
bool RequestPopErrorScope(DawnErrorCallback callback, void* userdata);
|
bool RequestPopErrorScope(WGPUErrorCallback callback, void* userdata);
|
||||||
bool PopErrorScope(uint64_t requestSerial, DawnErrorType type, const char* message);
|
bool PopErrorScope(uint64_t requestSerial, WGPUErrorType type, const char* message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ErrorScopeData {
|
struct ErrorScopeData {
|
||||||
DawnErrorCallback callback = nullptr;
|
WGPUErrorCallback callback = nullptr;
|
||||||
void* userdata = nullptr;
|
void* userdata = nullptr;
|
||||||
};
|
};
|
||||||
std::map<uint64_t, ErrorScopeData> mErrorScopes;
|
std::map<uint64_t, ErrorScopeData> mErrorScopes;
|
||||||
|
@ -48,7 +48,7 @@ namespace dawn_wire { namespace client {
|
||||||
uint64_t mErrorScopeStackSize = 0;
|
uint64_t mErrorScopeStackSize = 0;
|
||||||
|
|
||||||
Client* mClient = nullptr;
|
Client* mClient = nullptr;
|
||||||
DawnErrorCallback mErrorCallback = nullptr;
|
WGPUErrorCallback mErrorCallback = nullptr;
|
||||||
void* mErrorUserdata;
|
void* mErrorUserdata;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,14 @@ namespace dawn_wire { namespace client {
|
||||||
// Callbacks need to be fired in all cases, as they can handle freeing resources
|
// Callbacks need to be fired in all cases, as they can handle freeing resources
|
||||||
// so we call them with "Unknown" status.
|
// so we call them with "Unknown" status.
|
||||||
for (auto& request : requests.IterateAll()) {
|
for (auto& request : requests.IterateAll()) {
|
||||||
request.completionCallback(DAWN_FENCE_COMPLETION_STATUS_UNKNOWN, request.userdata);
|
request.completionCallback(WGPUFenceCompletionStatus_Unknown, request.userdata);
|
||||||
}
|
}
|
||||||
requests.Clear();
|
requests.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fence::CheckPassedFences() {
|
void Fence::CheckPassedFences() {
|
||||||
for (auto& request : requests.IterateUpTo(completedValue)) {
|
for (auto& request : requests.IterateUpTo(completedValue)) {
|
||||||
request.completionCallback(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, request.userdata);
|
request.completionCallback(WGPUFenceCompletionStatus_Success, request.userdata);
|
||||||
}
|
}
|
||||||
requests.ClearUpTo(completedValue);
|
requests.ClearUpTo(completedValue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef DAWNWIRE_CLIENT_FENCE_H_
|
#ifndef DAWNWIRE_CLIENT_FENCE_H_
|
||||||
#define DAWNWIRE_CLIENT_FENCE_H_
|
#define DAWNWIRE_CLIENT_FENCE_H_
|
||||||
|
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/webgpu.h>
|
||||||
|
|
||||||
#include "common/SerialMap.h"
|
#include "common/SerialMap.h"
|
||||||
#include "dawn_wire/client/ObjectBase.h"
|
#include "dawn_wire/client/ObjectBase.h"
|
||||||
|
@ -30,7 +30,7 @@ namespace dawn_wire { namespace client {
|
||||||
void CheckPassedFences();
|
void CheckPassedFences();
|
||||||
|
|
||||||
struct OnCompletionData {
|
struct OnCompletionData {
|
||||||
DawnFenceOnCompletionCallback completionCallback = nullptr;
|
WGPUFenceOnCompletionCallback completionCallback = nullptr;
|
||||||
void* userdata = nullptr;
|
void* userdata = nullptr;
|
||||||
};
|
};
|
||||||
Queue* queue = nullptr;
|
Queue* queue = nullptr;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef DAWNWIRE_CLIENT_OBJECTBASE_H_
|
#ifndef DAWNWIRE_CLIENT_OBJECTBASE_H_
|
||||||
#define DAWNWIRE_CLIENT_OBJECTBASE_H_
|
#define DAWNWIRE_CLIENT_OBJECTBASE_H_
|
||||||
|
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/webgpu.h>
|
||||||
|
|
||||||
namespace dawn_wire { namespace client {
|
namespace dawn_wire { namespace client {
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace dawn_wire { namespace server {
|
||||||
enum class BufferMapWriteState { Unmapped, Mapped, MapError };
|
enum class BufferMapWriteState { Unmapped, Mapped, MapError };
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ObjectData<DawnBuffer> : public ObjectDataBase<DawnBuffer> {
|
struct ObjectData<WGPUBuffer> : public ObjectDataBase<WGPUBuffer> {
|
||||||
// TODO(enga): Use a tagged pointer to save space.
|
// TODO(enga): Use a tagged pointer to save space.
|
||||||
std::unique_ptr<MemoryTransferService::ReadHandle> readHandle;
|
std::unique_ptr<MemoryTransferService::ReadHandle> readHandle;
|
||||||
std::unique_ptr<MemoryTransferService::WriteHandle> writeHandle;
|
std::unique_ptr<MemoryTransferService::WriteHandle> writeHandle;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace dawn_wire { namespace server {
|
namespace dawn_wire { namespace server {
|
||||||
|
|
||||||
Server::Server(DawnDevice device,
|
Server::Server(WGPUDevice device,
|
||||||
const DawnProcTable& procs,
|
const DawnProcTable& procs,
|
||||||
CommandSerializer* serializer,
|
CommandSerializer* serializer,
|
||||||
MemoryTransferService* memoryTransferService)
|
MemoryTransferService* memoryTransferService)
|
||||||
|
@ -42,8 +42,8 @@ namespace dawn_wire { namespace server {
|
||||||
return mSerializer->GetCmdSpace(size);
|
return mSerializer->GetCmdSpace(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::InjectTexture(DawnTexture texture, uint32_t id, uint32_t generation) {
|
bool Server::InjectTexture(WGPUTexture texture, uint32_t id, uint32_t generation) {
|
||||||
ObjectData<DawnTexture>* data = TextureObjects().Allocate(id);
|
ObjectData<WGPUTexture>* data = TextureObjects().Allocate(id);
|
||||||
if (data == nullptr) {
|
if (data == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace dawn_wire { namespace server {
|
||||||
|
|
||||||
class Server : public ServerBase {
|
class Server : public ServerBase {
|
||||||
public:
|
public:
|
||||||
Server(DawnDevice device,
|
Server(WGPUDevice device,
|
||||||
const DawnProcTable& procs,
|
const DawnProcTable& procs,
|
||||||
CommandSerializer* serializer,
|
CommandSerializer* serializer,
|
||||||
MemoryTransferService* memoryTransferService);
|
MemoryTransferService* memoryTransferService);
|
||||||
|
@ -55,38 +55,38 @@ namespace dawn_wire { namespace server {
|
||||||
|
|
||||||
const volatile char* HandleCommands(const volatile char* commands, size_t size);
|
const volatile char* HandleCommands(const volatile char* commands, size_t size);
|
||||||
|
|
||||||
bool InjectTexture(DawnTexture texture, uint32_t id, uint32_t generation);
|
bool InjectTexture(WGPUTexture texture, uint32_t id, uint32_t generation);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void* GetCmdSpace(size_t size);
|
void* GetCmdSpace(size_t size);
|
||||||
|
|
||||||
// Forwarding callbacks
|
// Forwarding callbacks
|
||||||
static void ForwardUncapturedError(DawnErrorType type, const char* message, void* userdata);
|
static void ForwardUncapturedError(WGPUErrorType type, const char* message, void* userdata);
|
||||||
static void ForwardPopErrorScope(DawnErrorType type, const char* message, void* userdata);
|
static void ForwardPopErrorScope(WGPUErrorType type, const char* message, void* userdata);
|
||||||
static void ForwardBufferMapReadAsync(DawnBufferMapAsyncStatus status,
|
static void ForwardBufferMapReadAsync(WGPUBufferMapAsyncStatus status,
|
||||||
const void* ptr,
|
const void* ptr,
|
||||||
uint64_t dataLength,
|
uint64_t dataLength,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
static void ForwardBufferMapWriteAsync(DawnBufferMapAsyncStatus status,
|
static void ForwardBufferMapWriteAsync(WGPUBufferMapAsyncStatus status,
|
||||||
void* ptr,
|
void* ptr,
|
||||||
uint64_t dataLength,
|
uint64_t dataLength,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
static void ForwardFenceCompletedValue(DawnFenceCompletionStatus status, void* userdata);
|
static void ForwardFenceCompletedValue(WGPUFenceCompletionStatus status, void* userdata);
|
||||||
|
|
||||||
// Error callbacks
|
// Error callbacks
|
||||||
void OnUncapturedError(DawnErrorType type, const char* message);
|
void OnUncapturedError(WGPUErrorType type, const char* message);
|
||||||
void OnDevicePopErrorScope(DawnErrorType type,
|
void OnDevicePopErrorScope(WGPUErrorType type,
|
||||||
const char* message,
|
const char* message,
|
||||||
ErrorScopeUserdata* userdata);
|
ErrorScopeUserdata* userdata);
|
||||||
void OnBufferMapReadAsyncCallback(DawnBufferMapAsyncStatus status,
|
void OnBufferMapReadAsyncCallback(WGPUBufferMapAsyncStatus status,
|
||||||
const void* ptr,
|
const void* ptr,
|
||||||
uint64_t dataLength,
|
uint64_t dataLength,
|
||||||
MapUserdata* userdata);
|
MapUserdata* userdata);
|
||||||
void OnBufferMapWriteAsyncCallback(DawnBufferMapAsyncStatus status,
|
void OnBufferMapWriteAsyncCallback(WGPUBufferMapAsyncStatus status,
|
||||||
void* ptr,
|
void* ptr,
|
||||||
uint64_t dataLength,
|
uint64_t dataLength,
|
||||||
MapUserdata* userdata);
|
MapUserdata* userdata);
|
||||||
void OnFenceCompletedValueUpdated(DawnFenceCompletionStatus status,
|
void OnFenceCompletedValueUpdated(WGPUFenceCompletionStatus status,
|
||||||
FenceCompletionUserdata* userdata);
|
FenceCompletionUserdata* userdata);
|
||||||
|
|
||||||
#include "dawn_wire/server/ServerPrototypes_autogen.inc"
|
#include "dawn_wire/server/ServerPrototypes_autogen.inc"
|
||||||
|
|
|
@ -92,8 +92,8 @@ namespace dawn_wire { namespace server {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::DoDeviceCreateBufferMapped(DawnDevice device,
|
bool Server::DoDeviceCreateBufferMapped(WGPUDevice device,
|
||||||
const DawnBufferDescriptor* descriptor,
|
const WGPUBufferDescriptor* descriptor,
|
||||||
ObjectHandle bufferResult,
|
ObjectHandle bufferResult,
|
||||||
uint64_t handleCreateInfoLength,
|
uint64_t handleCreateInfoLength,
|
||||||
const uint8_t* handleCreateInfo) {
|
const uint8_t* handleCreateInfo) {
|
||||||
|
@ -109,7 +109,7 @@ namespace dawn_wire { namespace server {
|
||||||
}
|
}
|
||||||
resultData->serial = bufferResult.serial;
|
resultData->serial = bufferResult.serial;
|
||||||
|
|
||||||
DawnCreateBufferMappedResult result = mProcs.deviceCreateBufferMapped(device, descriptor);
|
WGPUCreateBufferMappedResult result = mProcs.deviceCreateBufferMapped(device, descriptor);
|
||||||
ASSERT(result.buffer != nullptr);
|
ASSERT(result.buffer != nullptr);
|
||||||
if (result.data == nullptr && result.dataLength != 0) {
|
if (result.data == nullptr && result.dataLength != 0) {
|
||||||
// Non-zero dataLength but null data is used to indicate an allocation error.
|
// Non-zero dataLength but null data is used to indicate an allocation error.
|
||||||
|
@ -140,8 +140,8 @@ namespace dawn_wire { namespace server {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::DoDeviceCreateBufferMappedAsync(DawnDevice device,
|
bool Server::DoDeviceCreateBufferMappedAsync(WGPUDevice device,
|
||||||
const DawnBufferDescriptor* descriptor,
|
const WGPUBufferDescriptor* descriptor,
|
||||||
uint32_t requestSerial,
|
uint32_t requestSerial,
|
||||||
ObjectHandle bufferResult,
|
ObjectHandle bufferResult,
|
||||||
uint64_t handleCreateInfoLength,
|
uint64_t handleCreateInfoLength,
|
||||||
|
@ -158,8 +158,8 @@ namespace dawn_wire { namespace server {
|
||||||
cmd.buffer = ObjectHandle{bufferResult.id, bufferResult.serial};
|
cmd.buffer = ObjectHandle{bufferResult.id, bufferResult.serial};
|
||||||
cmd.requestSerial = requestSerial;
|
cmd.requestSerial = requestSerial;
|
||||||
cmd.status = bufferData->mapWriteState == BufferMapWriteState::Mapped
|
cmd.status = bufferData->mapWriteState == BufferMapWriteState::Mapped
|
||||||
? DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS
|
? WGPUBufferMapAsyncStatus_Success
|
||||||
: DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR;
|
: WGPUBufferMapAsyncStatus_Error;
|
||||||
|
|
||||||
size_t requiredSize = cmd.GetRequiredSize();
|
size_t requiredSize = cmd.GetRequiredSize();
|
||||||
char* allocatedBuffer = static_cast<char*>(GetCmdSpace(requiredSize));
|
char* allocatedBuffer = static_cast<char*>(GetCmdSpace(requiredSize));
|
||||||
|
@ -223,7 +223,7 @@ namespace dawn_wire { namespace server {
|
||||||
static_cast<size_t>(writeFlushInfoLength));
|
static_cast<size_t>(writeFlushInfoLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::ForwardBufferMapReadAsync(DawnBufferMapAsyncStatus status,
|
void Server::ForwardBufferMapReadAsync(WGPUBufferMapAsyncStatus status,
|
||||||
const void* ptr,
|
const void* ptr,
|
||||||
uint64_t dataLength,
|
uint64_t dataLength,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
|
@ -231,7 +231,7 @@ namespace dawn_wire { namespace server {
|
||||||
data->server->OnBufferMapReadAsyncCallback(status, ptr, dataLength, data);
|
data->server->OnBufferMapReadAsyncCallback(status, ptr, dataLength, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::ForwardBufferMapWriteAsync(DawnBufferMapAsyncStatus status,
|
void Server::ForwardBufferMapWriteAsync(WGPUBufferMapAsyncStatus status,
|
||||||
void* ptr,
|
void* ptr,
|
||||||
uint64_t dataLength,
|
uint64_t dataLength,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
|
@ -239,7 +239,7 @@ namespace dawn_wire { namespace server {
|
||||||
data->server->OnBufferMapWriteAsyncCallback(status, ptr, dataLength, data);
|
data->server->OnBufferMapWriteAsyncCallback(status, ptr, dataLength, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::OnBufferMapReadAsyncCallback(DawnBufferMapAsyncStatus status,
|
void Server::OnBufferMapReadAsyncCallback(WGPUBufferMapAsyncStatus status,
|
||||||
const void* ptr,
|
const void* ptr,
|
||||||
uint64_t dataLength,
|
uint64_t dataLength,
|
||||||
MapUserdata* userdata) {
|
MapUserdata* userdata) {
|
||||||
|
@ -252,7 +252,7 @@ namespace dawn_wire { namespace server {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t initialDataInfoLength = 0;
|
size_t initialDataInfoLength = 0;
|
||||||
if (status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
if (status == WGPUBufferMapAsyncStatus_Success) {
|
||||||
// Get the serialization size of the message to initialize ReadHandle data.
|
// Get the serialization size of the message to initialize ReadHandle data.
|
||||||
initialDataInfoLength = data->readHandle->SerializeInitialDataSize(ptr, dataLength);
|
initialDataInfoLength = data->readHandle->SerializeInitialDataSize(ptr, dataLength);
|
||||||
} else {
|
} else {
|
||||||
|
@ -271,7 +271,7 @@ namespace dawn_wire { namespace server {
|
||||||
char* allocatedBuffer = static_cast<char*>(GetCmdSpace(requiredSize));
|
char* allocatedBuffer = static_cast<char*>(GetCmdSpace(requiredSize));
|
||||||
cmd.Serialize(allocatedBuffer);
|
cmd.Serialize(allocatedBuffer);
|
||||||
|
|
||||||
if (status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
if (status == WGPUBufferMapAsyncStatus_Success) {
|
||||||
// Serialize the initialization message into the space after the command.
|
// Serialize the initialization message into the space after the command.
|
||||||
data->readHandle->SerializeInitialData(ptr, dataLength, allocatedBuffer + commandSize);
|
data->readHandle->SerializeInitialData(ptr, dataLength, allocatedBuffer + commandSize);
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ namespace dawn_wire { namespace server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::OnBufferMapWriteAsyncCallback(DawnBufferMapAsyncStatus status,
|
void Server::OnBufferMapWriteAsyncCallback(WGPUBufferMapAsyncStatus status,
|
||||||
void* ptr,
|
void* ptr,
|
||||||
uint64_t dataLength,
|
uint64_t dataLength,
|
||||||
MapUserdata* userdata) {
|
MapUserdata* userdata) {
|
||||||
|
@ -302,7 +302,7 @@ namespace dawn_wire { namespace server {
|
||||||
char* allocatedBuffer = static_cast<char*>(GetCmdSpace(requiredSize));
|
char* allocatedBuffer = static_cast<char*>(GetCmdSpace(requiredSize));
|
||||||
cmd.Serialize(allocatedBuffer);
|
cmd.Serialize(allocatedBuffer);
|
||||||
|
|
||||||
if (status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
|
if (status == WGPUBufferMapAsyncStatus_Success) {
|
||||||
// The in-flight map request returned successfully.
|
// The in-flight map request returned successfully.
|
||||||
// Move the WriteHandle so it is owned by the buffer.
|
// Move the WriteHandle so it is owned by the buffer.
|
||||||
bufferData->writeHandle = std::move(data->writeHandle);
|
bufferData->writeHandle = std::move(data->writeHandle);
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
|
|
||||||
namespace dawn_wire { namespace server {
|
namespace dawn_wire { namespace server {
|
||||||
|
|
||||||
void Server::ForwardUncapturedError(DawnErrorType type, const char* message, void* userdata) {
|
void Server::ForwardUncapturedError(WGPUErrorType type, const char* message, void* userdata) {
|
||||||
auto server = static_cast<Server*>(userdata);
|
auto server = static_cast<Server*>(userdata);
|
||||||
server->OnUncapturedError(type, message);
|
server->OnUncapturedError(type, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::OnUncapturedError(DawnErrorType type, const char* message) {
|
void Server::OnUncapturedError(WGPUErrorType type, const char* message) {
|
||||||
ReturnDeviceUncapturedErrorCallbackCmd cmd;
|
ReturnDeviceUncapturedErrorCallbackCmd cmd;
|
||||||
cmd.type = type;
|
cmd.type = type;
|
||||||
cmd.message = message;
|
cmd.message = message;
|
||||||
|
@ -31,7 +31,7 @@ namespace dawn_wire { namespace server {
|
||||||
cmd.Serialize(allocatedBuffer);
|
cmd.Serialize(allocatedBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::DoDevicePopErrorScope(DawnDevice cDevice, uint64_t requestSerial) {
|
bool Server::DoDevicePopErrorScope(WGPUDevice cDevice, uint64_t requestSerial) {
|
||||||
ErrorScopeUserdata* userdata = new ErrorScopeUserdata;
|
ErrorScopeUserdata* userdata = new ErrorScopeUserdata;
|
||||||
userdata->server = this;
|
userdata->server = this;
|
||||||
userdata->requestSerial = requestSerial;
|
userdata->requestSerial = requestSerial;
|
||||||
|
@ -44,12 +44,12 @@ namespace dawn_wire { namespace server {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Server::ForwardPopErrorScope(DawnErrorType type, const char* message, void* userdata) {
|
void Server::ForwardPopErrorScope(WGPUErrorType type, const char* message, void* userdata) {
|
||||||
auto* data = reinterpret_cast<ErrorScopeUserdata*>(userdata);
|
auto* data = reinterpret_cast<ErrorScopeUserdata*>(userdata);
|
||||||
data->server->OnDevicePopErrorScope(type, message, data);
|
data->server->OnDevicePopErrorScope(type, message, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::OnDevicePopErrorScope(DawnErrorType type,
|
void Server::OnDevicePopErrorScope(WGPUErrorType type,
|
||||||
const char* message,
|
const char* message,
|
||||||
ErrorScopeUserdata* userdata) {
|
ErrorScopeUserdata* userdata) {
|
||||||
std::unique_ptr<ErrorScopeUserdata> data{userdata};
|
std::unique_ptr<ErrorScopeUserdata> data{userdata};
|
||||||
|
|
|
@ -18,16 +18,16 @@
|
||||||
|
|
||||||
namespace dawn_wire { namespace server {
|
namespace dawn_wire { namespace server {
|
||||||
|
|
||||||
void Server::ForwardFenceCompletedValue(DawnFenceCompletionStatus status, void* userdata) {
|
void Server::ForwardFenceCompletedValue(WGPUFenceCompletionStatus status, void* userdata) {
|
||||||
auto data = static_cast<FenceCompletionUserdata*>(userdata);
|
auto data = static_cast<FenceCompletionUserdata*>(userdata);
|
||||||
data->server->OnFenceCompletedValueUpdated(status, data);
|
data->server->OnFenceCompletedValueUpdated(status, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::OnFenceCompletedValueUpdated(DawnFenceCompletionStatus status,
|
void Server::OnFenceCompletedValueUpdated(WGPUFenceCompletionStatus status,
|
||||||
FenceCompletionUserdata* userdata) {
|
FenceCompletionUserdata* userdata) {
|
||||||
std::unique_ptr<FenceCompletionUserdata> data(userdata);
|
std::unique_ptr<FenceCompletionUserdata> data(userdata);
|
||||||
|
|
||||||
if (status != DAWN_FENCE_COMPLETION_STATUS_SUCCESS) {
|
if (status != WGPUFenceCompletionStatus_Success) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
namespace dawn_wire { namespace server {
|
namespace dawn_wire { namespace server {
|
||||||
|
|
||||||
bool Server::DoQueueSignal(DawnQueue cSelf, DawnFence cFence, uint64_t signalValue) {
|
bool Server::DoQueueSignal(WGPUQueue cSelf, WGPUFence cFence, uint64_t signalValue) {
|
||||||
if (cFence == nullptr) {
|
if (cFence == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#include "dawn/dawn.h"
|
#include "dawn/webgpu.h"
|
||||||
#include "dawn_wire/dawn_wire_export.h"
|
#include "dawn_wire/dawn_wire_export.h"
|
||||||
|
|
||||||
namespace dawn_wire {
|
namespace dawn_wire {
|
||||||
|
@ -36,13 +36,13 @@ namespace dawn_wire {
|
||||||
};
|
};
|
||||||
|
|
||||||
DAWN_WIRE_EXPORT size_t
|
DAWN_WIRE_EXPORT size_t
|
||||||
SerializedWGPUDevicePropertiesSize(const DawnDeviceProperties* deviceProperties);
|
SerializedWGPUDevicePropertiesSize(const WGPUDeviceProperties* deviceProperties);
|
||||||
|
|
||||||
DAWN_WIRE_EXPORT void SerializeWGPUDeviceProperties(
|
DAWN_WIRE_EXPORT void SerializeWGPUDeviceProperties(
|
||||||
const DawnDeviceProperties* deviceProperties,
|
const WGPUDeviceProperties* deviceProperties,
|
||||||
char* serializeBuffer);
|
char* serializeBuffer);
|
||||||
|
|
||||||
DAWN_WIRE_EXPORT bool DeserializeWGPUDeviceProperties(DawnDeviceProperties* deviceProperties,
|
DAWN_WIRE_EXPORT bool DeserializeWGPUDeviceProperties(WGPUDeviceProperties* deviceProperties,
|
||||||
const volatile char* deserializeBuffer);
|
const volatile char* deserializeBuffer);
|
||||||
|
|
||||||
} // namespace dawn_wire
|
} // namespace dawn_wire
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace dawn_wire {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ReservedTexture {
|
struct ReservedTexture {
|
||||||
DawnTexture texture;
|
WGPUTexture texture;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
uint32_t generation;
|
uint32_t generation;
|
||||||
};
|
};
|
||||||
|
@ -44,12 +44,12 @@ namespace dawn_wire {
|
||||||
WireClient(const WireClientDescriptor& descriptor);
|
WireClient(const WireClientDescriptor& descriptor);
|
||||||
~WireClient();
|
~WireClient();
|
||||||
|
|
||||||
DawnDevice GetDevice() const;
|
WGPUDevice GetDevice() const;
|
||||||
DawnProcTable GetProcs() const;
|
DawnProcTable GetProcs() const;
|
||||||
const volatile char* HandleCommands(const volatile char* commands,
|
const volatile char* HandleCommands(const volatile char* commands,
|
||||||
size_t size) override final;
|
size_t size) override final;
|
||||||
|
|
||||||
ReservedTexture ReserveTexture(DawnDevice device);
|
ReservedTexture ReserveTexture(WGPUDevice device);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<client::Client> mImpl;
|
std::unique_ptr<client::Client> mImpl;
|
||||||
|
@ -74,8 +74,8 @@ namespace dawn_wire {
|
||||||
// Imported memory implementation needs to override these to create Read/Write
|
// Imported memory implementation needs to override these to create Read/Write
|
||||||
// handles associated with a particular buffer. The client should receive a file
|
// handles associated with a particular buffer. The client should receive a file
|
||||||
// descriptor for the buffer out-of-band.
|
// descriptor for the buffer out-of-band.
|
||||||
virtual ReadHandle* CreateReadHandle(DawnBuffer, uint64_t offset, size_t size);
|
virtual ReadHandle* CreateReadHandle(WGPUBuffer, uint64_t offset, size_t size);
|
||||||
virtual WriteHandle* CreateWriteHandle(DawnBuffer, uint64_t offset, size_t size);
|
virtual WriteHandle* CreateWriteHandle(WGPUBuffer, uint64_t offset, size_t size);
|
||||||
|
|
||||||
class DAWN_WIRE_EXPORT ReadHandle {
|
class DAWN_WIRE_EXPORT ReadHandle {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace dawn_wire {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DAWN_WIRE_EXPORT WireServerDescriptor {
|
struct DAWN_WIRE_EXPORT WireServerDescriptor {
|
||||||
DawnDevice device;
|
WGPUDevice device;
|
||||||
const DawnProcTable* procs;
|
const DawnProcTable* procs;
|
||||||
CommandSerializer* serializer;
|
CommandSerializer* serializer;
|
||||||
server::MemoryTransferService* memoryTransferService = nullptr;
|
server::MemoryTransferService* memoryTransferService = nullptr;
|
||||||
|
@ -43,7 +43,7 @@ namespace dawn_wire {
|
||||||
const volatile char* HandleCommands(const volatile char* commands,
|
const volatile char* HandleCommands(const volatile char* commands,
|
||||||
size_t size) override final;
|
size_t size) override final;
|
||||||
|
|
||||||
bool InjectTexture(DawnTexture texture, uint32_t id, uint32_t generation);
|
bool InjectTexture(WGPUTexture texture, uint32_t id, uint32_t generation);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<server::Server> mImpl;
|
std::unique_ptr<server::Server> mImpl;
|
||||||
|
|
|
@ -17,20 +17,20 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class WireDawnDevicePropertiesTests : public testing::Test {};
|
class WireWGPUDevicePropertiesTests : public testing::Test {};
|
||||||
|
|
||||||
// Test that the serialization and deserialization of DawnDeviceProperties can work correctly.
|
// Test that the serialization and deserialization of WGPUDeviceProperties can work correctly.
|
||||||
TEST_F(WireDawnDevicePropertiesTests, SerializeDawnDeviceProperties) {
|
TEST_F(WireWGPUDevicePropertiesTests, SerializeWGPUDeviceProperties) {
|
||||||
DawnDeviceProperties sentDawnDeviceProperties;
|
WGPUDeviceProperties sentWGPUDeviceProperties;
|
||||||
sentDawnDeviceProperties.textureCompressionBC = true;
|
sentWGPUDeviceProperties.textureCompressionBC = true;
|
||||||
|
|
||||||
size_t sentDawnDevicePropertiesSize =
|
size_t sentWGPUDevicePropertiesSize =
|
||||||
dawn_wire::SerializedWGPUDevicePropertiesSize(&sentDawnDeviceProperties);
|
dawn_wire::SerializedWGPUDevicePropertiesSize(&sentWGPUDeviceProperties);
|
||||||
std::vector<char> buffer;
|
std::vector<char> buffer;
|
||||||
buffer.resize(sentDawnDevicePropertiesSize);
|
buffer.resize(sentWGPUDevicePropertiesSize);
|
||||||
dawn_wire::SerializeWGPUDeviceProperties(&sentDawnDeviceProperties, buffer.data());
|
dawn_wire::SerializeWGPUDeviceProperties(&sentWGPUDeviceProperties, buffer.data());
|
||||||
|
|
||||||
DawnDeviceProperties receivedDawnDeviceProperties;
|
WGPUDeviceProperties receivedWGPUDeviceProperties;
|
||||||
dawn_wire::DeserializeWGPUDeviceProperties(&receivedDawnDeviceProperties, buffer.data());
|
dawn_wire::DeserializeWGPUDeviceProperties(&receivedWGPUDeviceProperties, buffer.data());
|
||||||
ASSERT_TRUE(receivedDawnDeviceProperties.textureCompressionBC);
|
ASSERT_TRUE(receivedWGPUDeviceProperties.textureCompressionBC);
|
||||||
}
|
}
|
Loading…
Reference in New Issue