webgpu/dawn/include/dawn/wire/Wire.h
1// Copyright 2017 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 INCLUDE_DAWN_WIRE_WIRE_H_
16#define INCLUDE_DAWN_WIRE_WIRE_H_
17
18#include <cstdint>
19#include <limits>
20
21#include "dawn/webgpu.h"
22#include "dawn/wire/dawn_wire_export.h"
23
24namespace dawn::wire {
25
26class DAWN_WIRE_EXPORT CommandSerializer {
27 public:
28 CommandSerializer();
29 virtual ~CommandSerializer();
30 CommandSerializer(const CommandSerializer& rhs) = delete;
31 CommandSerializer& operator=(const CommandSerializer& rhs) = delete;
32
33 // Get space for serializing commands.
34 // GetCmdSpace will never be called with a value larger than
35 // what GetMaximumAllocationSize returns. Return nullptr to indicate
36 // a fatal error.
37 virtual void* GetCmdSpace(size_t size) = 0;
38 virtual bool Flush() = 0;
39 virtual size_t GetMaximumAllocationSize() const = 0;
40 virtual void OnSerializeError();
41};
42
43class DAWN_WIRE_EXPORT CommandHandler {
44 public:
45 CommandHandler();
46 virtual ~CommandHandler();
47 CommandHandler(const CommandHandler& rhs) = delete;
48 CommandHandler& operator=(const CommandHandler& rhs) = delete;
49
50 virtual const volatile char* HandleCommands(const volatile char* commands, size_t size) = 0;
51};
52
53} // namespace dawn::wire
54
55#endif // INCLUDE_DAWN_WIRE_WIRE_H_