dawn_wire: Make ApiProcs call into objects directly.
This CL modifies code generation so that the generated client procs call the handwritten methods on client objects directly. Previously the flow was: - wgpuBarDoStuff - ClientBarDoStuff - ClientHandwrittenBarDoStuff - client::Bar::DoStuff With this CL the flow is: - wgpuBarDoStuff - ClientBarDoStuff - client::Bar::DoStuff This required adding Buffer creation methods on client::Device instead of calling client::Buffer static methods directly. Bug: dawn:445 Change-Id: I1b332b71ac7a03685afcf8fd0617d3d27da468cf Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24062 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
9fa68833b2
commit
d411726003
|
@ -23,6 +23,7 @@
|
|||
#include <vector>
|
||||
|
||||
namespace dawn_wire { namespace client {
|
||||
|
||||
namespace {
|
||||
|
||||
//* Outputs an rvalue that's the number of elements a pointer member points to.
|
||||
|
@ -176,8 +177,8 @@ namespace dawn_wire { namespace client {
|
|||
}
|
||||
{% endif %}
|
||||
|
||||
auto self = reinterpret_cast<{{as_wireType(type)}}>(cSelf);
|
||||
{% if Suffix not in client_handwritten_commands %}
|
||||
auto self = reinterpret_cast<{{as_wireType(type)}}>(cSelf);
|
||||
Device* device = self->device;
|
||||
{{Suffix}}Cmd cmd;
|
||||
|
||||
|
@ -202,9 +203,9 @@ namespace dawn_wire { namespace client {
|
|||
return reinterpret_cast<{{as_cType(method.return_type.name)}}>(allocation->object.get());
|
||||
{% endif %}
|
||||
{% else %}
|
||||
return ClientHandwritten{{Suffix}}(cSelf
|
||||
return self->{{method.name.CamelCase()}}(
|
||||
{%- for arg in method.arguments -%}
|
||||
, {{as_varName(arg.name)}}
|
||||
{%if not loop.first %}, {% endif %} {{as_varName(arg.name)}}
|
||||
{%- endfor -%});
|
||||
{% endif %}
|
||||
}
|
||||
|
@ -235,6 +236,12 @@ namespace dawn_wire { namespace client {
|
|||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
void ClientDeviceReference(WGPUDevice) {
|
||||
}
|
||||
|
||||
void ClientDeviceRelease(WGPUDevice) {
|
||||
}
|
||||
|
||||
namespace {
|
||||
WGPUInstance ClientCreateInstance(WGPUInstanceDescriptor const* descriptor) {
|
||||
UNREACHABLE();
|
||||
|
|
|
@ -64,7 +64,6 @@ dawn_component("dawn_wire") {
|
|||
"WireDeserializeAllocator.h",
|
||||
"WireServer.cpp",
|
||||
"client/ApiObjects.h",
|
||||
"client/ApiProcs.cpp",
|
||||
"client/Buffer.cpp",
|
||||
"client/Buffer.h",
|
||||
"client/Client.cpp",
|
||||
|
|
|
@ -30,7 +30,6 @@ target_sources(dawn_wire PRIVATE
|
|||
"WireDeserializeAllocator.h"
|
||||
"WireServer.cpp"
|
||||
"client/ApiObjects.h"
|
||||
"client/ApiProcs.cpp"
|
||||
"client/Buffer.cpp"
|
||||
"client/Buffer.h"
|
||||
"client/Client.cpp"
|
||||
|
|
|
@ -1,145 +0,0 @@
|
|||
// Copyright 2019 The Dawn Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "dawn_wire/client/ApiObjects.h"
|
||||
#include "dawn_wire/client/ApiProcs_autogen.h"
|
||||
#include "dawn_wire/client/Client.h"
|
||||
|
||||
namespace dawn_wire { namespace client {
|
||||
|
||||
void ClientHandwrittenBufferMapReadAsync(WGPUBuffer cBuffer,
|
||||
WGPUBufferMapReadCallback callback,
|
||||
void* userdata) {
|
||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||
buffer->MapReadAsync(callback, userdata);
|
||||
}
|
||||
|
||||
void ClientHandwrittenBufferMapWriteAsync(WGPUBuffer cBuffer,
|
||||
WGPUBufferMapWriteCallback callback,
|
||||
void* userdata) {
|
||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||
buffer->MapWriteAsync(callback, userdata);
|
||||
}
|
||||
|
||||
void ClientHandwrittenBufferSetSubData(WGPUBuffer cBuffer,
|
||||
uint64_t start,
|
||||
uint64_t count,
|
||||
const void* data) {
|
||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||
buffer->SetSubData(start, count, data);
|
||||
}
|
||||
|
||||
void* ClientHandwrittenBufferGetMappedRange(WGPUBuffer cBuffer) {
|
||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||
return buffer->GetMappedRange();
|
||||
}
|
||||
|
||||
const void* ClientHandwrittenBufferGetConstMappedRange(WGPUBuffer cBuffer) {
|
||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||
return buffer->GetConstMappedRange();
|
||||
}
|
||||
|
||||
void ClientHandwrittenBufferUnmap(WGPUBuffer cBuffer) {
|
||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||
buffer->Unmap();
|
||||
}
|
||||
|
||||
void ClientHandwrittenBufferDestroy(WGPUBuffer cBuffer) {
|
||||
Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
|
||||
buffer->Destroy();
|
||||
}
|
||||
|
||||
WGPUBuffer ClientHandwrittenDeviceCreateBuffer(WGPUDevice cDevice,
|
||||
const WGPUBufferDescriptor* descriptor) {
|
||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||
return Buffer::Create(device, descriptor);
|
||||
}
|
||||
|
||||
WGPUCreateBufferMappedResult ClientHandwrittenDeviceCreateBufferMapped(
|
||||
WGPUDevice cDevice,
|
||||
const WGPUBufferDescriptor* descriptor) {
|
||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||
return Buffer::CreateMapped(device, descriptor);
|
||||
}
|
||||
|
||||
void ClientHandwrittenDevicePushErrorScope(WGPUDevice cDevice, WGPUErrorFilter filter) {
|
||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||
device->PushErrorScope(filter);
|
||||
}
|
||||
|
||||
bool ClientHandwrittenDevicePopErrorScope(WGPUDevice cDevice,
|
||||
WGPUErrorCallback callback,
|
||||
void* userdata) {
|
||||
Device* device = reinterpret_cast<Device*>(cDevice);
|
||||
return device->RequestPopErrorScope(callback, userdata);
|
||||
}
|
||||
|
||||
uint64_t ClientHandwrittenFenceGetCompletedValue(WGPUFence cSelf) {
|
||||
Fence* fence = reinterpret_cast<Fence*>(cSelf);
|
||||
return fence->GetCompletedValue();
|
||||
}
|
||||
|
||||
void ClientHandwrittenFenceOnCompletion(WGPUFence cFence,
|
||||
uint64_t value,
|
||||
WGPUFenceOnCompletionCallback callback,
|
||||
void* userdata) {
|
||||
Fence* fence = reinterpret_cast<Fence*>(cFence);
|
||||
fence->OnCompletion(value, callback, userdata);
|
||||
}
|
||||
|
||||
WGPUFence ClientHandwrittenQueueCreateFence(WGPUQueue cSelf,
|
||||
WGPUFenceDescriptor const* descriptor) {
|
||||
Queue* queue = reinterpret_cast<Queue*>(cSelf);
|
||||
return queue->CreateFence(descriptor);
|
||||
}
|
||||
|
||||
void ClientHandwrittenQueueSignal(WGPUQueue cQueue, WGPUFence cFence, uint64_t signalValue) {
|
||||
Queue* queue = reinterpret_cast<Queue*>(cQueue);
|
||||
queue->Signal(cFence, signalValue);
|
||||
}
|
||||
|
||||
void ClientHandwrittenQueueWriteBuffer(WGPUQueue cQueue,
|
||||
WGPUBuffer cBuffer,
|
||||
uint64_t bufferOffset,
|
||||
const void* data,
|
||||
size_t size) {
|
||||
Queue* queue = reinterpret_cast<Queue*>(cQueue);
|
||||
queue->WriteBuffer(cBuffer, bufferOffset, data, size);
|
||||
}
|
||||
|
||||
void ClientDeviceReference(WGPUDevice) {
|
||||
}
|
||||
|
||||
void ClientDeviceRelease(WGPUDevice) {
|
||||
}
|
||||
|
||||
WGPUQueue ClientHandwrittenDeviceGetDefaultQueue(WGPUDevice cSelf) {
|
||||
Device* device = reinterpret_cast<Device*>(cSelf);
|
||||
return device->GetDefaultQueue();
|
||||
}
|
||||
|
||||
void ClientHandwrittenDeviceSetUncapturedErrorCallback(WGPUDevice cSelf,
|
||||
WGPUErrorCallback callback,
|
||||
void* userdata) {
|
||||
Device* device = reinterpret_cast<Device*>(cSelf);
|
||||
device->SetUncapturedErrorCallback(callback, userdata);
|
||||
}
|
||||
void ClientHandwrittenDeviceSetDeviceLostCallback(WGPUDevice cSelf,
|
||||
WGPUDeviceLostCallback callback,
|
||||
void* userdata) {
|
||||
Device* device = reinterpret_cast<Device*>(cSelf);
|
||||
device->SetDeviceLostCallback(callback, userdata);
|
||||
}
|
||||
|
||||
}} // namespace dawn_wire::client
|
|
@ -43,7 +43,7 @@ namespace dawn_wire { namespace client {
|
|||
bool Client::DoDevicePopErrorScopeCallback(uint64_t requestSerial,
|
||||
WGPUErrorType errorType,
|
||||
const char* message) {
|
||||
return mDevice->PopErrorScope(requestSerial, errorType, message);
|
||||
return mDevice->OnPopErrorScopeCallback(requestSerial, errorType, message);
|
||||
}
|
||||
|
||||
bool Client::DoBufferMapReadAsyncCallback(Buffer* buffer,
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace dawn_wire { namespace client {
|
|||
mClient->SerializeCommand(cmd);
|
||||
}
|
||||
|
||||
bool Device::RequestPopErrorScope(WGPUErrorCallback callback, void* userdata) {
|
||||
bool Device::PopErrorScope(WGPUErrorCallback callback, void* userdata) {
|
||||
if (mErrorScopeStackSize == 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -111,7 +111,9 @@ namespace dawn_wire { namespace client {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Device::PopErrorScope(uint64_t requestSerial, WGPUErrorType type, const char* message) {
|
||||
bool Device::OnPopErrorScopeCallback(uint64_t requestSerial,
|
||||
WGPUErrorType type,
|
||||
const char* message) {
|
||||
switch (type) {
|
||||
case WGPUErrorType_NoError:
|
||||
case WGPUErrorType_Validation:
|
||||
|
@ -135,6 +137,15 @@ namespace dawn_wire { namespace client {
|
|||
return true;
|
||||
}
|
||||
|
||||
WGPUBuffer Device::CreateBuffer(const WGPUBufferDescriptor* descriptor) {
|
||||
return Buffer::Create(this, descriptor);
|
||||
}
|
||||
|
||||
WGPUCreateBufferMappedResult Device::CreateBufferMapped(
|
||||
const WGPUBufferDescriptor* descriptor) {
|
||||
return Buffer::CreateMapped(this, descriptor);
|
||||
}
|
||||
|
||||
WGPUQueue Device::GetDefaultQueue() {
|
||||
mDefaultQueue->refcount++;
|
||||
return reinterpret_cast<WGPUQueue>(mDefaultQueue);
|
||||
|
|
|
@ -32,14 +32,18 @@ namespace dawn_wire { namespace client {
|
|||
~Device();
|
||||
|
||||
Client* GetClient();
|
||||
void HandleError(WGPUErrorType errorType, const char* message);
|
||||
void HandleDeviceLost(const char* message);
|
||||
void SetUncapturedErrorCallback(WGPUErrorCallback errorCallback, void* errorUserdata);
|
||||
void SetDeviceLostCallback(WGPUDeviceLostCallback errorCallback, void* errorUserdata);
|
||||
|
||||
void PushErrorScope(WGPUErrorFilter filter);
|
||||
bool RequestPopErrorScope(WGPUErrorCallback callback, void* userdata);
|
||||
bool PopErrorScope(uint64_t requestSerial, WGPUErrorType type, const char* message);
|
||||
bool PopErrorScope(WGPUErrorCallback callback, void* userdata);
|
||||
WGPUBuffer CreateBuffer(const WGPUBufferDescriptor* descriptor);
|
||||
WGPUCreateBufferMappedResult CreateBufferMapped(const WGPUBufferDescriptor* descriptor);
|
||||
|
||||
void HandleError(WGPUErrorType errorType, const char* message);
|
||||
void HandleDeviceLost(const char* message);
|
||||
bool OnPopErrorScopeCallback(uint64_t requestSerial,
|
||||
WGPUErrorType type,
|
||||
const char* message);
|
||||
|
||||
WGPUQueue GetDefaultQueue();
|
||||
|
||||
|
|
Loading…
Reference in New Issue