blob: f7d311f3c9ac248b42379773a0bdb42e9851da8f [file] [log] [blame]
Austin Engacd8b7d2019-01-16 02:18:06 +00001// Copyright 2019 The Dawn Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef DAWNWIRE_CLIENT_CLIENT_H_
16#define DAWNWIRE_CLIENT_CLIENT_H_
17
Corentin Wallez1fdcb162019-10-24 22:27:27 +000018#include <dawn/webgpu.h>
Austin Engacd8b7d2019-01-16 02:18:06 +000019#include <dawn_wire/Wire.h>
20
Corentin Wallez339bd9d2019-03-28 12:57:11 +000021#include "dawn_wire/WireClient.h"
Austin Engacd8b7d2019-01-16 02:18:06 +000022#include "dawn_wire/WireCmd_autogen.h"
23#include "dawn_wire/WireDeserializeAllocator.h"
Austin Engcd4fd8e2019-01-30 02:31:37 +000024#include "dawn_wire/client/ClientBase_autogen.h"
Austin Engacd8b7d2019-01-16 02:18:06 +000025
26namespace dawn_wire { namespace client {
27
28 class Device;
Austin Eng6a5418a2019-07-19 16:01:48 +000029 class MemoryTransferService;
Austin Engacd8b7d2019-01-16 02:18:06 +000030
Austin Enge2c85132019-02-11 21:50:16 +000031 class Client : public ClientBase {
Austin Engacd8b7d2019-01-16 02:18:06 +000032 public:
Austin Eng6a5418a2019-07-19 16:01:48 +000033 Client(CommandSerializer* serializer, MemoryTransferService* memoryTransferService);
Austin Engcd4fd8e2019-01-30 02:31:37 +000034 ~Client();
35
Austin Eng8eb83852019-10-07 20:38:47 +000036 const volatile char* HandleCommands(const volatile char* commands, size_t size);
Corentin Wallez1fdcb162019-10-24 22:27:27 +000037 ReservedTexture ReserveTexture(WGPUDevice device);
Austin Engacd8b7d2019-01-16 02:18:06 +000038
Austin Engcd4fd8e2019-01-30 02:31:37 +000039 void* GetCmdSpace(size_t size) {
40 return mSerializer->GetCmdSpace(size);
41 }
42
Corentin Wallez1fdcb162019-10-24 22:27:27 +000043 WGPUDevice GetDevice() const {
44 return reinterpret_cast<WGPUDeviceImpl*>(mDevice);
Austin Enge2c85132019-02-11 21:50:16 +000045 }
46
Austin Eng6a5418a2019-07-19 16:01:48 +000047 MemoryTransferService* GetMemoryTransferService() const {
48 return mMemoryTransferService;
49 }
50
Austin Engacd8b7d2019-01-16 02:18:06 +000051 private:
Austin Eng3a8aa312019-05-17 20:42:33 +000052#include "dawn_wire/client/ClientPrototypes_autogen.inc"
Austin Engacd8b7d2019-01-16 02:18:06 +000053
Austin Engcd4fd8e2019-01-30 02:31:37 +000054 Device* mDevice = nullptr;
55 CommandSerializer* mSerializer = nullptr;
Austin Engacd8b7d2019-01-16 02:18:06 +000056 WireDeserializeAllocator mAllocator;
Austin Eng6a5418a2019-07-19 16:01:48 +000057 MemoryTransferService* mMemoryTransferService = nullptr;
58 std::unique_ptr<MemoryTransferService> mOwnedMemoryTransferService = nullptr;
Austin Engacd8b7d2019-01-16 02:18:06 +000059 };
60
Austin Eng45f97302019-03-11 16:52:42 +000061 DawnProcTable GetProcs();
Austin Engacd8b7d2019-01-16 02:18:06 +000062
Austin Eng6a5418a2019-07-19 16:01:48 +000063 std::unique_ptr<MemoryTransferService> CreateInlineMemoryTransferService();
64
Austin Engacd8b7d2019-01-16 02:18:06 +000065}} // namespace dawn_wire::client
66
67#endif // DAWNWIRE_CLIENT_CLIENT_H_