forked from Themaister/GLFFT
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathglfft_interface.hpp
More file actions
131 lines (105 loc) · 4.41 KB
/
glfft_interface.hpp
File metadata and controls
131 lines (105 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* Copyright (C) 2015 Hans-Kristian Arntzen <maister@archlinux.us>
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef GLFFT_INTERFACE_HPP__
#define GLFFT_INTERFACE_HPP__
#include <memory>
namespace GLFFT
{
class Context;
class Resource
{
public:
virtual ~Resource() = default;
// Non-movable, non-copyable to make things simpler.
Resource(Resource&&) = delete;
void operator=(const Resource&) = delete;
protected:
Resource() = default;
};
class Texture : public Resource {};
class Sampler : public Resource {};
class Buffer : public Resource {};
class Program
{
public:
virtual ~Program() = default;
protected:
friend class Context;
Program() = default;
};
enum AccessMode
{
AccessStreamCopy,
AccessStaticCopy,
AccessStreamRead
};
enum Format
{
FormatUnknown,
FormatR16G16B16A16Float,
FormatR32G32B32A32Float,
FormatR32G32Float,
FormatR32Float,
FormatR16G16Float,
FormatR32Uint
};
class CommandBuffer;
class Context
{
public:
virtual ~Context() = default;
virtual std::unique_ptr<Texture> create_texture(const void *initial_data,
unsigned width, unsigned height,
Format format) = 0;
virtual std::unique_ptr<Buffer> create_buffer(const void *initial_data, size_t size, AccessMode access) = 0;
virtual std::unique_ptr<Program> compile_compute_shader(const char *source) = 0;
virtual CommandBuffer* request_command_buffer() = 0;
virtual void submit_command_buffer(CommandBuffer *cmd) = 0;
virtual void wait_idle() = 0;
virtual const char* get_renderer_string() = 0;
virtual void log(const char *fmt, ...) = 0;
virtual double get_time() = 0;
virtual unsigned get_max_work_group_threads() = 0;
virtual const void* map(Buffer *buffer, size_t offset, size_t size) = 0;
virtual void unmap(Buffer *buffer) = 0;
virtual bool supports_texture_readback() = 0;
virtual void read_texture(void *buffer, Texture *texture, Format format) = 0;
protected:
Context() = default;
};
class CommandBuffer
{
public:
virtual ~CommandBuffer() = default;
virtual void bind_program(Program *program) = 0;
virtual void bind_storage_texture(unsigned binding, Texture *texture, Format format) = 0;
virtual void bind_texture(unsigned binding, Texture *texture) = 0;
virtual void bind_sampler(unsigned binding, Sampler *sampler) = 0;
virtual void bind_storage_buffer(unsigned binding, Buffer *texture) = 0;
virtual void bind_storage_buffer_range(unsigned binding, size_t offset, size_t length, Buffer *texture) = 0;
virtual void dispatch(unsigned x, unsigned y, unsigned z) = 0;
virtual void barrier(Buffer *buffer) = 0;
virtual void barrier(Texture *buffer) = 0;
virtual void barrier() = 0;
enum { MaxConstantDataSize = 64 };
virtual void push_constant_data(unsigned binding, const void *data, size_t size) = 0;
protected:
CommandBuffer() = default;
};
}
#endif