Corentin Wallez 2f616dd108 dawn_wire: Remove client/ApiProcs_autogen.h
This header was only used to call DeviceCreateErrorBuffer and
DeviceInjectError that are used in some handwritten client commands.
We remove the need for the header by making these two commands
handwritten.

This also improves readability, previously injecting errors read:

  ClientDeviceInjectError(reinterpret_cast<WGPUDevice>(device),
                           WGPUErrorType_Validation,
                           "Some validation message");

And now reads:

  device->InjectError(WGPUErrorType_Validation, "Some validation message");

Bug: dawn:445

Change-Id: Ie11570aacf3036e13abd174d91670ecb84661226
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24080
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-06-30 18:26:30 +00:00

74 lines
2.6 KiB
C++

// 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.
#ifndef DAWNWIRE_CLIENT_DEVICE_H_
#define DAWNWIRE_CLIENT_DEVICE_H_
#include <dawn/webgpu.h>
#include "dawn_wire/client/ObjectBase.h"
#include <map>
namespace dawn_wire { namespace client {
class Client;
class Queue;
class Device : public ObjectBase {
public:
Device(Client* client, uint32_t refcount, uint32_t id);
~Device();
Client* GetClient();
void SetUncapturedErrorCallback(WGPUErrorCallback errorCallback, void* errorUserdata);
void SetDeviceLostCallback(WGPUDeviceLostCallback errorCallback, void* errorUserdata);
void InjectError(WGPUErrorType type, const char* message);
void PushErrorScope(WGPUErrorFilter filter);
bool PopErrorScope(WGPUErrorCallback callback, void* userdata);
WGPUBuffer CreateBuffer(const WGPUBufferDescriptor* descriptor);
WGPUCreateBufferMappedResult CreateBufferMapped(const WGPUBufferDescriptor* descriptor);
WGPUBuffer CreateErrorBuffer();
void HandleError(WGPUErrorType errorType, const char* message);
void HandleDeviceLost(const char* message);
bool OnPopErrorScopeCallback(uint64_t requestSerial,
WGPUErrorType type,
const char* message);
WGPUQueue GetDefaultQueue();
private:
struct ErrorScopeData {
WGPUErrorCallback callback = nullptr;
void* userdata = nullptr;
};
std::map<uint64_t, ErrorScopeData> mErrorScopes;
uint64_t mErrorScopeRequestSerial = 0;
uint64_t mErrorScopeStackSize = 0;
Client* mClient = nullptr;
WGPUErrorCallback mErrorCallback = nullptr;
WGPUDeviceLostCallback mDeviceLostCallback = nullptr;
bool mDidRunLostCallback = false;
void* mErrorUserdata = nullptr;
void* mDeviceLostUserdata = nullptr;
Queue* mDefaultQueue = nullptr;
};
}} // namespace dawn_wire::client
#endif // DAWNWIRE_CLIENT_DEVICE_H_