mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-19 01:46:35 +00:00
dawn_wire::server: Simplify ForwardToServer usage with C++17
This uses template parameter type deduction to pass the member function pointer and then extract the types that compose it. Which means that the member function pointer only needs to be written once. The order of arguments of the Server::On*Callback methods is changed to put the userdata first. This helps make template type deduction simpler. Bug: dawn:824 Change-Id: I4e2bc33dfd52a11620dea51b40508eca6c878d72 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75071 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Brandon Jones <bajones@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
2994d2e7b9
commit
31f12242da
@@ -91,19 +91,16 @@ namespace dawn_wire { namespace server {
|
||||
|
||||
ErrorScopeUserdata* unownedUserdata = userdata.release();
|
||||
bool success = mProcs.devicePopErrorScope(
|
||||
device->handle,
|
||||
ForwardToServer<decltype(
|
||||
&Server::OnDevicePopErrorScope)>::Func<&Server::OnDevicePopErrorScope>(),
|
||||
unownedUserdata);
|
||||
device->handle, ForwardToServer<&Server::OnDevicePopErrorScope>, unownedUserdata);
|
||||
if (!success) {
|
||||
delete unownedUserdata;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void Server::OnDevicePopErrorScope(WGPUErrorType type,
|
||||
const char* message,
|
||||
ErrorScopeUserdata* userdata) {
|
||||
void Server::OnDevicePopErrorScope(ErrorScopeUserdata* userdata,
|
||||
WGPUErrorType type,
|
||||
const char* message) {
|
||||
ReturnDevicePopErrorScopeCallbackCmd cmd;
|
||||
cmd.device = userdata->device;
|
||||
cmd.requestSerial = userdata->requestSerial;
|
||||
@@ -139,16 +136,14 @@ namespace dawn_wire { namespace server {
|
||||
|
||||
mProcs.deviceCreateComputePipelineAsync(
|
||||
device->handle, descriptor,
|
||||
ForwardToServer<decltype(&Server::OnCreateComputePipelineAsyncCallback)>::Func<
|
||||
&Server::OnCreateComputePipelineAsyncCallback>(),
|
||||
userdata.release());
|
||||
ForwardToServer<&Server::OnCreateComputePipelineAsyncCallback>, userdata.release());
|
||||
return true;
|
||||
}
|
||||
|
||||
void Server::OnCreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus status,
|
||||
void Server::OnCreateComputePipelineAsyncCallback(CreatePipelineAsyncUserData* data,
|
||||
WGPUCreatePipelineAsyncStatus status,
|
||||
WGPUComputePipeline pipeline,
|
||||
const char* message,
|
||||
CreatePipelineAsyncUserData* data) {
|
||||
const char* message) {
|
||||
HandleCreateRenderPipelineAsyncCallbackResult<ObjectType::ComputePipeline>(
|
||||
&ComputePipelineObjects(), status, pipeline, data);
|
||||
|
||||
@@ -186,16 +181,14 @@ namespace dawn_wire { namespace server {
|
||||
|
||||
mProcs.deviceCreateRenderPipelineAsync(
|
||||
device->handle, descriptor,
|
||||
ForwardToServer<decltype(&Server::OnCreateRenderPipelineAsyncCallback)>::Func<
|
||||
&Server::OnCreateRenderPipelineAsyncCallback>(),
|
||||
userdata.release());
|
||||
ForwardToServer<&Server::OnCreateRenderPipelineAsyncCallback>, userdata.release());
|
||||
return true;
|
||||
}
|
||||
|
||||
void Server::OnCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus status,
|
||||
void Server::OnCreateRenderPipelineAsyncCallback(CreatePipelineAsyncUserData* data,
|
||||
WGPUCreatePipelineAsyncStatus status,
|
||||
WGPURenderPipeline pipeline,
|
||||
const char* message,
|
||||
CreatePipelineAsyncUserData* data) {
|
||||
const char* message) {
|
||||
HandleCreateRenderPipelineAsyncCallbackResult<ObjectType::RenderPipeline>(
|
||||
&RenderPipelineObjects(), status, pipeline, data);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user