Kore 3
Loading...
Searching...
No Matches
device.h
Go to the documentation of this file.
1#ifndef KORE_GPU_DEVICE_HEADER
2#define KORE_GPU_DEVICE_HEADER
3
4#include <kore3/global.h>
5
6#include <kore3/math/matrix.h>
7
8#include "api.h"
9#include "buffer.h"
10#include "commandlist.h"
11#include "fence.h"
12#include "raytracing.h"
13#include "sampler.h"
14#include "textureformat.h"
15
16#if defined(KORE_DIRECT3D11)
17#include <kore3/direct3d11/device_structs.h>
18#elif defined(KORE_DIRECT3D12)
19#include <kore3/direct3d12/device_structs.h>
20#elif defined(KORE_METAL)
21#include <kore3/metal/device_structs.h>
22#elif defined(KORE_OPENGL)
23#include <kore3/opengl/device_structs.h>
24#elif defined(KORE_VULKAN)
25#include <kore3/vulkan/device_structs.h>
26#elif defined(KORE_WEBGPU)
27#include <kore3/webgpu/device_structs.h>
28#elif defined(KORE_KOMPJUTA)
29#include <kore3/kompjuta/device_structs.h>
30#elif defined(KORE_CONSOLE)
31#include <kore3/console/device_structs.h>
32#else
33#error ("Unknown GPU backend")
34#endif
35
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
45 int nothing;
47
48typedef struct kore_gpu_device {
49 KORE_GPU_IMPL(device);
51
52KORE_FUNC void kore_gpu_device_create(kore_gpu_device *device, const kore_gpu_device_wishlist *wishlist);
53
54KORE_FUNC void kore_gpu_device_destroy(kore_gpu_device *device);
55
56KORE_FUNC void kore_gpu_device_set_name(kore_gpu_device *device, const char *name);
57
58// sixteen bits for us, sixteen bits for the backend
59typedef enum kore_gpu_buffer_usage {
60 KORE_GPU_BUFFER_USAGE_CPU_READ = 0x0001,
61 KORE_GPU_BUFFER_USAGE_CPU_WRITE = 0x0002,
62 KORE_GPU_BUFFER_USAGE_COPY_SRC = 0x0004,
63 KORE_GPU_BUFFER_USAGE_COPY_DST = 0x0008,
64 KORE_GPU_BUFFER_USAGE_INDEX = 0x0010,
65 KORE_GPU_BUFFER_USAGE_INDIRECT = 0x0020,
66 KORE_GPU_BUFFER_USAGE_QUERY_RESOLVE = 0x0040,
67 KORE_GPU_BUFFER_USAGE_RAYTRACING_VOLUME = 0x0080,
68} kore_gpu_buffer_usage;
69
71 uint64_t size;
72 uint32_t usage_flags;
74
75KORE_FUNC void kore_gpu_device_create_buffer(kore_gpu_device *device, const kore_gpu_buffer_parameters *parameters, kore_gpu_buffer *buffer);
76
77typedef enum kore_gpu_texture_dimension {
78 KORE_GPU_TEXTURE_DIMENSION_1D,
79 KORE_GPU_TEXTURE_DIMENSION_2D,
80 KORE_GPU_TEXTURE_DIMENSION_3D
81} kore_gpu_texture_dimension;
82
83// sixteen bits for us, sixteen bits for the backend
84typedef enum kore_gpu_texture_usage {
85 KORE_GPU_TEXTURE_USAGE_COPY_SRC = 0x0001,
86 KORE_GPU_TEXTURE_USAGE_COPY_DST = 0x0002,
87 KORE_GPU_TEXTURE_USAGE_RENDER_ATTACHMENT = 0x0004,
88} kore_gpu_texture_usage;
89
91 uint32_t width;
92 uint32_t height;
93 uint32_t depth_or_array_layers;
94 uint32_t mip_level_count;
95 uint32_t sample_count;
96 kore_gpu_texture_dimension dimension;
97 kore_gpu_texture_format format;
98 uint32_t usage;
99 kore_gpu_texture_format view_formats[8]; // necessary?
101
102KORE_FUNC void kore_gpu_device_create_texture(kore_gpu_device *device, const kore_gpu_texture_parameters *parameters, kore_gpu_texture *texture);
103
104#define KORE_GPU_MAX_FRAMEBUFFERS 3
105
106KORE_FUNC kore_gpu_texture *kore_gpu_device_get_framebuffer(kore_gpu_device *device);
107
108KORE_FUNC kore_gpu_texture_format kore_gpu_device_framebuffer_format(kore_gpu_device *device);
109
110typedef enum kore_gpu_address_mode {
111 KORE_GPU_ADDRESS_MODE_CLAMP_TO_EDGE,
112 KORE_GPU_ADDRESS_MODE_REPEAT,
113 KORE_GPU_ADDRESS_MODE_MIRROR_REPEAT
114} kore_gpu_address_mode;
115
116typedef enum kore_gpu_filter_mode { KORE_GPU_FILTER_MODE_NEAREST, KORE_GPU_FILTER_MODE_LINEAR } kore_gpu_filter_mode;
117
118typedef enum kore_gpu_mipmap_filter_mode { KORE_GPU_MIPMAP_FILTER_MODE_NEAREST, KORE_GPU_MIPMAP_FILTER_MODE_LINEAR } kore_gpu_mipmap_filter_mode;
119
120typedef enum kore_gpu_compare_function {
121 KORE_GPU_COMPARE_FUNCTION_UNDEFINED,
122 KORE_GPU_COMPARE_FUNCTION_NEVER,
123 KORE_GPU_COMPARE_FUNCTION_LESS,
124 KORE_GPU_COMPARE_FUNCTION_EQUAL,
125 KORE_GPU_COMPARE_FUNCTION_LESS_EQUAL,
126 KORE_GPU_COMPARE_FUNCTION_GREATER,
127 KORE_GPU_COMPARE_FUNCTION_NOT_EQUAL,
128 KORE_GPU_COMPARE_FUNCTION_GREATER_EQUAL,
129 KORE_GPU_COMPARE_FUNCTION_ALWAYS
130} kore_gpu_compare_function;
131
133 kore_gpu_address_mode address_mode_u;
134 kore_gpu_address_mode address_mode_v;
135 kore_gpu_address_mode address_mode_w;
136 kore_gpu_filter_mode min_filter;
137 kore_gpu_filter_mode mag_filter;
138 kore_gpu_mipmap_filter_mode mipmap_filter;
139 float lod_min_clamp;
140 float lod_max_clamp;
141 kore_gpu_compare_function compare;
142 uint16_t max_anisotropy;
144
145KORE_FUNC void kore_gpu_device_create_sampler(kore_gpu_device *device, const kore_gpu_sampler_parameters *parameters, kore_gpu_sampler *sampler);
146
147typedef enum kore_gpu_command_list_type {
148 KORE_GPU_COMMAND_LIST_TYPE_GRAPHICS,
149 KORE_GPU_COMMAND_LIST_TYPE_COMPUTE,
150 KORE_GPU_COMMAND_LIST_TYPE_COPY
151} kore_gpu_command_list_type;
152
153KORE_FUNC void kore_gpu_device_create_command_list(kore_gpu_device *device, kore_gpu_command_list_type type, kore_gpu_command_list *list);
154
155typedef struct kore_gpu_query_set {
156 KORE_GPU_IMPL(query_set);
158
159typedef enum kore_gpu_query_type { KORE_GPU_QUERY_TYPE_OCCLUSION, KORE_GPU_QUERY_TYPE_TIMESTAMP } kore_gpu_query_type;
160
162 kore_gpu_query_type type;
163 uint32_t count;
165
166KORE_FUNC void kore_gpu_device_create_query_set(kore_gpu_device *device, const kore_gpu_query_set_parameters *parameters, kore_gpu_query_set *query_set);
167
168KORE_FUNC void kore_gpu_device_create_fence(kore_gpu_device *device, kore_gpu_fence *fence);
169
170KORE_FUNC void kore_gpu_device_execute_command_list(kore_gpu_device *device, kore_gpu_command_list *list);
171
172KORE_FUNC void kore_gpu_device_wait_until_idle(kore_gpu_device *device);
173
174KORE_FUNC void kore_gpu_device_create_raytracing_volume(kore_gpu_device *device, kore_gpu_buffer *vertex_buffer, uint64_t vertex_count,
175 kore_gpu_buffer *index_buffer, uint32_t index_count, kore_gpu_raytracing_volume *volume);
176
177KORE_FUNC void kore_gpu_device_create_raytracing_hierarchy(kore_gpu_device *device, kore_gpu_raytracing_volume **volumes, kore_matrix4x4 *volume_transforms,
178 uint32_t volumes_count, kore_gpu_raytracing_hierarchy *hierarchy);
179
180KORE_FUNC uint32_t kore_gpu_device_align_texture_row_bytes(kore_gpu_device *device, uint32_t row_bytes);
181
182KORE_FUNC void kore_gpu_device_signal(kore_gpu_device *device, kore_gpu_command_list_type list_type, kore_gpu_fence *fence, uint64_t value);
183
184KORE_FUNC void kore_gpu_device_wait(kore_gpu_device *device, kore_gpu_command_list_type list_type, kore_gpu_fence *fence, uint64_t value);
185
186#ifdef __cplusplus
187}
188#endif
189
190#endif
Provides various functions for GPU buffers.
The command list is used to send commands to the GPU.
Provides various functions for GPU fences which are used for synchronizing GPU queues.
Provides basic functionality that's used all over the place. There's usually no need to manually incl...
Provides basic matrix types and a few functions which create transformation-matrices....
Provides raytracing support functions.
Provides functions for handling samplers.
Definition device.h:70
Definition buffer.h:38
Definition commandlist.h:134
Definition device.h:44
Definition device.h:48
Definition fence.h:36
Definition device.h:161
Definition device.h:155
Definition raytracing.h:40
Definition raytracing.h:36
Definition device.h:132
Definition sampler.h:36
Definition device.h:90
Definition texture.h:37
Definition matrix.h:33
Provides an enum containing all supported texture formats and some companion functions.