Austin Eng | acd8b7d | 2019-01-16 02:18:06 +0000 | [diff] [blame] | 1 | // 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 Wallez | 1fdcb16 | 2019-10-24 22:27:27 +0000 | [diff] [blame^] | 18 | #include <dawn/webgpu.h> |
Austin Eng | acd8b7d | 2019-01-16 02:18:06 +0000 | [diff] [blame] | 19 | #include <dawn_wire/Wire.h> |
| 20 | |
Corentin Wallez | 339bd9d | 2019-03-28 12:57:11 +0000 | [diff] [blame] | 21 | #include "dawn_wire/WireClient.h" |
Austin Eng | acd8b7d | 2019-01-16 02:18:06 +0000 | [diff] [blame] | 22 | #include "dawn_wire/WireCmd_autogen.h" |
| 23 | #include "dawn_wire/WireDeserializeAllocator.h" |
Austin Eng | cd4fd8e | 2019-01-30 02:31:37 +0000 | [diff] [blame] | 24 | #include "dawn_wire/client/ClientBase_autogen.h" |
Austin Eng | acd8b7d | 2019-01-16 02:18:06 +0000 | [diff] [blame] | 25 | |
| 26 | namespace dawn_wire { namespace client { |
| 27 | |
| 28 | class Device; |
Austin Eng | 6a5418a | 2019-07-19 16:01:48 +0000 | [diff] [blame] | 29 | class MemoryTransferService; |
Austin Eng | acd8b7d | 2019-01-16 02:18:06 +0000 | [diff] [blame] | 30 | |
Austin Eng | e2c8513 | 2019-02-11 21:50:16 +0000 | [diff] [blame] | 31 | class Client : public ClientBase { |
Austin Eng | acd8b7d | 2019-01-16 02:18:06 +0000 | [diff] [blame] | 32 | public: |
Austin Eng | 6a5418a | 2019-07-19 16:01:48 +0000 | [diff] [blame] | 33 | Client(CommandSerializer* serializer, MemoryTransferService* memoryTransferService); |
Austin Eng | cd4fd8e | 2019-01-30 02:31:37 +0000 | [diff] [blame] | 34 | ~Client(); |
| 35 | |
Austin Eng | 8eb8385 | 2019-10-07 20:38:47 +0000 | [diff] [blame] | 36 | const volatile char* HandleCommands(const volatile char* commands, size_t size); |
Corentin Wallez | 1fdcb16 | 2019-10-24 22:27:27 +0000 | [diff] [blame^] | 37 | ReservedTexture ReserveTexture(WGPUDevice device); |
Austin Eng | acd8b7d | 2019-01-16 02:18:06 +0000 | [diff] [blame] | 38 | |
Austin Eng | cd4fd8e | 2019-01-30 02:31:37 +0000 | [diff] [blame] | 39 | void* GetCmdSpace(size_t size) { |
| 40 | return mSerializer->GetCmdSpace(size); |
| 41 | } |
| 42 | |
Corentin Wallez | 1fdcb16 | 2019-10-24 22:27:27 +0000 | [diff] [blame^] | 43 | WGPUDevice GetDevice() const { |
| 44 | return reinterpret_cast<WGPUDeviceImpl*>(mDevice); |
Austin Eng | e2c8513 | 2019-02-11 21:50:16 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Austin Eng | 6a5418a | 2019-07-19 16:01:48 +0000 | [diff] [blame] | 47 | MemoryTransferService* GetMemoryTransferService() const { |
| 48 | return mMemoryTransferService; |
| 49 | } |
| 50 | |
Austin Eng | acd8b7d | 2019-01-16 02:18:06 +0000 | [diff] [blame] | 51 | private: |
Austin Eng | 3a8aa31 | 2019-05-17 20:42:33 +0000 | [diff] [blame] | 52 | #include "dawn_wire/client/ClientPrototypes_autogen.inc" |
Austin Eng | acd8b7d | 2019-01-16 02:18:06 +0000 | [diff] [blame] | 53 | |
Austin Eng | cd4fd8e | 2019-01-30 02:31:37 +0000 | [diff] [blame] | 54 | Device* mDevice = nullptr; |
| 55 | CommandSerializer* mSerializer = nullptr; |
Austin Eng | acd8b7d | 2019-01-16 02:18:06 +0000 | [diff] [blame] | 56 | WireDeserializeAllocator mAllocator; |
Austin Eng | 6a5418a | 2019-07-19 16:01:48 +0000 | [diff] [blame] | 57 | MemoryTransferService* mMemoryTransferService = nullptr; |
| 58 | std::unique_ptr<MemoryTransferService> mOwnedMemoryTransferService = nullptr; |
Austin Eng | acd8b7d | 2019-01-16 02:18:06 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
Austin Eng | 45f9730 | 2019-03-11 16:52:42 +0000 | [diff] [blame] | 61 | DawnProcTable GetProcs(); |
Austin Eng | acd8b7d | 2019-01-16 02:18:06 +0000 | [diff] [blame] | 62 | |
Austin Eng | 6a5418a | 2019-07-19 16:01:48 +0000 | [diff] [blame] | 63 | std::unique_ptr<MemoryTransferService> CreateInlineMemoryTransferService(); |
| 64 | |
Austin Eng | acd8b7d | 2019-01-16 02:18:06 +0000 | [diff] [blame] | 65 | }} // namespace dawn_wire::client |
| 66 | |
| 67 | #endif // DAWNWIRE_CLIENT_CLIENT_H_ |