1/**************************************************************************/
2/* rendering_device.cpp */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#include "rendering_device.h"
32#include "rendering_device.compat.inc"
33
34#include "rendering_device_binds.h"
35
36#include "thirdparty/spirv-reflect/spirv_reflect.h"
37
38RenderingDevice *RenderingDevice::singleton = nullptr;
39
40const char *RenderingDevice::shader_stage_names[RenderingDevice::SHADER_STAGE_MAX] = {
41 "Vertex",
42 "Fragment",
43 "TesselationControl",
44 "TesselationEvaluation",
45 "Compute",
46};
47
48RenderingDevice *RenderingDevice::get_singleton() {
49 return singleton;
50}
51
52RenderingDevice::ShaderCompileToSPIRVFunction RenderingDevice::compile_to_spirv_function = nullptr;
53RenderingDevice::ShaderCacheFunction RenderingDevice::cache_function = nullptr;
54RenderingDevice::ShaderSPIRVGetCacheKeyFunction RenderingDevice::get_spirv_cache_key_function = nullptr;
55
56void RenderingDevice::shader_set_compile_to_spirv_function(ShaderCompileToSPIRVFunction p_function) {
57 compile_to_spirv_function = p_function;
58}
59
60void RenderingDevice::shader_set_spirv_cache_function(ShaderCacheFunction p_function) {
61 cache_function = p_function;
62}
63
64void RenderingDevice::shader_set_get_cache_key_function(ShaderSPIRVGetCacheKeyFunction p_function) {
65 get_spirv_cache_key_function = p_function;
66}
67
68Vector<uint8_t> RenderingDevice::shader_compile_spirv_from_source(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language, String *r_error, bool p_allow_cache) {
69 if (p_allow_cache && cache_function) {
70 Vector<uint8_t> cache = cache_function(p_stage, p_source_code, p_language);
71 if (cache.size()) {
72 return cache;
73 }
74 }
75
76 ERR_FAIL_COND_V(!compile_to_spirv_function, Vector<uint8_t>());
77
78 return compile_to_spirv_function(p_stage, p_source_code, p_language, r_error, this);
79}
80
81String RenderingDevice::shader_get_spirv_cache_key() const {
82 if (get_spirv_cache_key_function) {
83 return get_spirv_cache_key_function(this);
84 }
85 return String();
86}
87
88RID RenderingDevice::shader_create_from_spirv(const Vector<ShaderStageSPIRVData> &p_spirv, const String &p_shader_name) {
89 Vector<uint8_t> bytecode = shader_compile_binary_from_spirv(p_spirv, p_shader_name);
90 ERR_FAIL_COND_V(bytecode.size() == 0, RID());
91 return shader_create_from_bytecode(bytecode);
92}
93
94RID RenderingDevice::_texture_create(const Ref<RDTextureFormat> &p_format, const Ref<RDTextureView> &p_view, const TypedArray<PackedByteArray> &p_data) {
95 ERR_FAIL_COND_V(p_format.is_null(), RID());
96 ERR_FAIL_COND_V(p_view.is_null(), RID());
97 Vector<Vector<uint8_t>> data;
98 for (int i = 0; i < p_data.size(); i++) {
99 Vector<uint8_t> byte_slice = p_data[i];
100 ERR_FAIL_COND_V(byte_slice.is_empty(), RID());
101 data.push_back(byte_slice);
102 }
103 return texture_create(p_format->base, p_view->base, data);
104}
105
106RID RenderingDevice::_texture_create_shared(const Ref<RDTextureView> &p_view, RID p_with_texture) {
107 ERR_FAIL_COND_V(p_view.is_null(), RID());
108
109 return texture_create_shared(p_view->base, p_with_texture);
110}
111
112RID RenderingDevice::_texture_create_shared_from_slice(const Ref<RDTextureView> &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, uint32_t p_mipmaps, TextureSliceType p_slice_type) {
113 ERR_FAIL_COND_V(p_view.is_null(), RID());
114
115 return texture_create_shared_from_slice(p_view->base, p_with_texture, p_layer, p_mipmap, p_mipmaps, p_slice_type);
116}
117
118Ref<RDTextureFormat> RenderingDevice::_texture_get_format(RID p_rd_texture) {
119 Ref<RDTextureFormat> rtf;
120 rtf.instantiate();
121 rtf->base = texture_get_format(p_rd_texture);
122
123 return rtf;
124}
125
126RenderingDevice::FramebufferFormatID RenderingDevice::_framebuffer_format_create(const TypedArray<RDAttachmentFormat> &p_attachments, uint32_t p_view_count) {
127 Vector<AttachmentFormat> attachments;
128 attachments.resize(p_attachments.size());
129
130 for (int i = 0; i < p_attachments.size(); i++) {
131 Ref<RDAttachmentFormat> af = p_attachments[i];
132 ERR_FAIL_COND_V(af.is_null(), INVALID_FORMAT_ID);
133 attachments.write[i] = af->base;
134 }
135 return framebuffer_format_create(attachments, p_view_count);
136}
137
138RenderingDevice::FramebufferFormatID RenderingDevice::_framebuffer_format_create_multipass(const TypedArray<RDAttachmentFormat> &p_attachments, const TypedArray<RDFramebufferPass> &p_passes, uint32_t p_view_count) {
139 Vector<AttachmentFormat> attachments;
140 attachments.resize(p_attachments.size());
141
142 for (int i = 0; i < p_attachments.size(); i++) {
143 Ref<RDAttachmentFormat> af = p_attachments[i];
144 ERR_FAIL_COND_V(af.is_null(), INVALID_FORMAT_ID);
145 attachments.write[i] = af->base;
146 }
147
148 Vector<FramebufferPass> passes;
149 for (int i = 0; i < p_passes.size(); i++) {
150 Ref<RDFramebufferPass> pass = p_passes[i];
151 ERR_CONTINUE(pass.is_null());
152 passes.push_back(pass->base);
153 }
154
155 return framebuffer_format_create_multipass(attachments, passes, p_view_count);
156}
157
158RID RenderingDevice::_framebuffer_create(const TypedArray<RID> &p_textures, FramebufferFormatID p_format_check, uint32_t p_view_count) {
159 Vector<RID> textures = Variant(p_textures);
160 return framebuffer_create(textures, p_format_check, p_view_count);
161}
162
163RID RenderingDevice::_framebuffer_create_multipass(const TypedArray<RID> &p_textures, const TypedArray<RDFramebufferPass> &p_passes, FramebufferFormatID p_format_check, uint32_t p_view_count) {
164 Vector<RID> textures = Variant(p_textures);
165 Vector<FramebufferPass> passes;
166 for (int i = 0; i < p_passes.size(); i++) {
167 Ref<RDFramebufferPass> pass = p_passes[i];
168 ERR_CONTINUE(pass.is_null());
169 passes.push_back(pass->base);
170 }
171 return framebuffer_create_multipass(textures, passes, p_format_check, p_view_count);
172}
173
174RID RenderingDevice::_sampler_create(const Ref<RDSamplerState> &p_state) {
175 ERR_FAIL_COND_V(p_state.is_null(), RID());
176
177 return sampler_create(p_state->base);
178}
179
180RenderingDevice::VertexFormatID RenderingDevice::_vertex_format_create(const TypedArray<RDVertexAttribute> &p_vertex_formats) {
181 Vector<VertexAttribute> descriptions;
182 descriptions.resize(p_vertex_formats.size());
183
184 for (int i = 0; i < p_vertex_formats.size(); i++) {
185 Ref<RDVertexAttribute> af = p_vertex_formats[i];
186 ERR_FAIL_COND_V(af.is_null(), INVALID_FORMAT_ID);
187 descriptions.write[i] = af->base;
188 }
189 return vertex_format_create(descriptions);
190}
191
192RID RenderingDevice::_vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const TypedArray<RID> &p_src_buffers, const Vector<int64_t> &p_offsets) {
193 Vector<RID> buffers = Variant(p_src_buffers);
194
195 Vector<uint64_t> offsets;
196 offsets.resize(p_offsets.size());
197 for (int i = 0; i < p_offsets.size(); i++) {
198 offsets.write[i] = p_offsets[i];
199 }
200
201 return vertex_array_create(p_vertex_count, p_vertex_format, buffers, offsets);
202}
203
204Ref<RDShaderSPIRV> RenderingDevice::_shader_compile_spirv_from_source(const Ref<RDShaderSource> &p_source, bool p_allow_cache) {
205 ERR_FAIL_COND_V(p_source.is_null(), Ref<RDShaderSPIRV>());
206
207 Ref<RDShaderSPIRV> bytecode;
208 bytecode.instantiate();
209 for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) {
210 String error;
211
212 ShaderStage stage = ShaderStage(i);
213 String source = p_source->get_stage_source(stage);
214
215 if (!source.is_empty()) {
216 Vector<uint8_t> spirv = shader_compile_spirv_from_source(stage, source, p_source->get_language(), &error, p_allow_cache);
217 bytecode->set_stage_bytecode(stage, spirv);
218 bytecode->set_stage_compile_error(stage, error);
219 }
220 }
221 return bytecode;
222}
223
224Vector<uint8_t> RenderingDevice::_shader_compile_binary_from_spirv(const Ref<RDShaderSPIRV> &p_spirv, const String &p_shader_name) {
225 ERR_FAIL_COND_V(p_spirv.is_null(), Vector<uint8_t>());
226
227 Vector<ShaderStageSPIRVData> stage_data;
228 for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) {
229 ShaderStage stage = ShaderStage(i);
230 ShaderStageSPIRVData sd;
231 sd.shader_stage = stage;
232 String error = p_spirv->get_stage_compile_error(stage);
233 ERR_FAIL_COND_V_MSG(!error.is_empty(), Vector<uint8_t>(), "Can't create a shader from an errored bytecode. Check errors in source bytecode.");
234 sd.spir_v = p_spirv->get_stage_bytecode(stage);
235 if (sd.spir_v.is_empty()) {
236 continue;
237 }
238 stage_data.push_back(sd);
239 }
240
241 return shader_compile_binary_from_spirv(stage_data, p_shader_name);
242}
243
244RID RenderingDevice::_shader_create_from_spirv(const Ref<RDShaderSPIRV> &p_spirv, const String &p_shader_name) {
245 ERR_FAIL_COND_V(p_spirv.is_null(), RID());
246
247 Vector<ShaderStageSPIRVData> stage_data;
248 for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) {
249 ShaderStage stage = ShaderStage(i);
250 ShaderStageSPIRVData sd;
251 sd.shader_stage = stage;
252 String error = p_spirv->get_stage_compile_error(stage);
253 ERR_FAIL_COND_V_MSG(!error.is_empty(), RID(), "Can't create a shader from an errored bytecode. Check errors in source bytecode.");
254 sd.spir_v = p_spirv->get_stage_bytecode(stage);
255 if (sd.spir_v.is_empty()) {
256 continue;
257 }
258 stage_data.push_back(sd);
259 }
260 return shader_create_from_spirv(stage_data);
261}
262
263RID RenderingDevice::_uniform_set_create(const TypedArray<RDUniform> &p_uniforms, RID p_shader, uint32_t p_shader_set) {
264 Vector<Uniform> uniforms;
265 uniforms.resize(p_uniforms.size());
266 for (int i = 0; i < p_uniforms.size(); i++) {
267 Ref<RDUniform> uniform = p_uniforms[i];
268 ERR_FAIL_COND_V(!uniform.is_valid(), RID());
269 uniforms.write[i] = uniform->base;
270 }
271 return uniform_set_create(uniforms, p_shader, p_shader_set);
272}
273
274Error RenderingDevice::_buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const Vector<uint8_t> &p_data, BitField<BarrierMask> p_post_barrier) {
275 return buffer_update(p_buffer, p_offset, p_size, p_data.ptr(), p_post_barrier);
276}
277
278static Vector<RenderingDevice::PipelineSpecializationConstant> _get_spec_constants(const TypedArray<RDPipelineSpecializationConstant> &p_constants) {
279 Vector<RenderingDevice::PipelineSpecializationConstant> ret;
280 ret.resize(p_constants.size());
281 for (int i = 0; i < p_constants.size(); i++) {
282 Ref<RDPipelineSpecializationConstant> c = p_constants[i];
283 ERR_CONTINUE(c.is_null());
284 RenderingDevice::PipelineSpecializationConstant &sc = ret.write[i];
285 Variant value = c->get_value();
286 switch (value.get_type()) {
287 case Variant::BOOL: {
288 sc.type = RD::PIPELINE_SPECIALIZATION_CONSTANT_TYPE_BOOL;
289 sc.bool_value = value;
290 } break;
291 case Variant::INT: {
292 sc.type = RD::PIPELINE_SPECIALIZATION_CONSTANT_TYPE_INT;
293 sc.int_value = value;
294 } break;
295 case Variant::FLOAT: {
296 sc.type = RD::PIPELINE_SPECIALIZATION_CONSTANT_TYPE_FLOAT;
297 sc.float_value = value;
298 } break;
299 default: {
300 }
301 }
302
303 sc.constant_id = c->get_constant_id();
304 }
305 return ret;
306}
307
308RID RenderingDevice::_render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const Ref<RDPipelineRasterizationState> &p_rasterization_state, const Ref<RDPipelineMultisampleState> &p_multisample_state, const Ref<RDPipelineDepthStencilState> &p_depth_stencil_state, const Ref<RDPipelineColorBlendState> &p_blend_state, BitField<PipelineDynamicStateFlags> p_dynamic_state_flags, uint32_t p_for_render_pass, const TypedArray<RDPipelineSpecializationConstant> &p_specialization_constants) {
309 PipelineRasterizationState rasterization_state;
310 if (p_rasterization_state.is_valid()) {
311 rasterization_state = p_rasterization_state->base;
312 }
313
314 PipelineMultisampleState multisample_state;
315 if (p_multisample_state.is_valid()) {
316 multisample_state = p_multisample_state->base;
317 for (int i = 0; i < p_multisample_state->sample_masks.size(); i++) {
318 int64_t mask = p_multisample_state->sample_masks[i];
319 multisample_state.sample_mask.push_back(mask);
320 }
321 }
322
323 PipelineDepthStencilState depth_stencil_state;
324 if (p_depth_stencil_state.is_valid()) {
325 depth_stencil_state = p_depth_stencil_state->base;
326 }
327
328 PipelineColorBlendState color_blend_state;
329 if (p_blend_state.is_valid()) {
330 color_blend_state = p_blend_state->base;
331 for (int i = 0; i < p_blend_state->attachments.size(); i++) {
332 Ref<RDPipelineColorBlendStateAttachment> attachment = p_blend_state->attachments[i];
333 if (attachment.is_valid()) {
334 color_blend_state.attachments.push_back(attachment->base);
335 }
336 }
337 }
338
339 return render_pipeline_create(p_shader, p_framebuffer_format, p_vertex_format, p_render_primitive, rasterization_state, multisample_state, depth_stencil_state, color_blend_state, p_dynamic_state_flags, p_for_render_pass, _get_spec_constants(p_specialization_constants));
340}
341
342RID RenderingDevice::_compute_pipeline_create(RID p_shader, const TypedArray<RDPipelineSpecializationConstant> &p_specialization_constants = TypedArray<RDPipelineSpecializationConstant>()) {
343 return compute_pipeline_create(p_shader, _get_spec_constants(p_specialization_constants));
344}
345
346RenderingDevice::DrawListID RenderingDevice::_draw_list_begin(RID p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values, float p_clear_depth, uint32_t p_clear_stencil, const Rect2 &p_region, const TypedArray<RID> &p_storage_textures) {
347 Vector<RID> stextures;
348 for (int i = 0; i < p_storage_textures.size(); i++) {
349 stextures.push_back(p_storage_textures[i]);
350 }
351 return draw_list_begin(p_framebuffer, p_initial_color_action, p_final_color_action, p_initial_depth_action, p_final_depth_action, p_clear_color_values, p_clear_depth, p_clear_stencil, p_region, stextures);
352}
353
354Vector<int64_t> RenderingDevice::_draw_list_begin_split(RID p_framebuffer, uint32_t p_splits, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values, float p_clear_depth, uint32_t p_clear_stencil, const Rect2 &p_region, const TypedArray<RID> &p_storage_textures) {
355 Vector<DrawListID> splits;
356 splits.resize(p_splits);
357 Vector<RID> stextures;
358 for (int i = 0; i < p_storage_textures.size(); i++) {
359 stextures.push_back(p_storage_textures[i]);
360 }
361 draw_list_begin_split(p_framebuffer, p_splits, splits.ptrw(), p_initial_color_action, p_final_color_action, p_initial_depth_action, p_final_depth_action, p_clear_color_values, p_clear_depth, p_clear_stencil, p_region, stextures);
362
363 Vector<int64_t> split_ids;
364 split_ids.resize(splits.size());
365 for (int i = 0; i < splits.size(); i++) {
366 split_ids.write[i] = splits[i];
367 }
368
369 return split_ids;
370}
371
372Vector<int64_t> RenderingDevice::_draw_list_switch_to_next_pass_split(uint32_t p_splits) {
373 Vector<DrawListID> splits;
374 splits.resize(p_splits);
375
376 Error err = draw_list_switch_to_next_pass_split(p_splits, splits.ptrw());
377 ERR_FAIL_COND_V(err != OK, Vector<int64_t>());
378
379 Vector<int64_t> split_ids;
380 split_ids.resize(splits.size());
381 for (int i = 0; i < splits.size(); i++) {
382 split_ids.write[i] = splits[i];
383 }
384
385 return split_ids;
386}
387
388void RenderingDevice::_draw_list_set_push_constant(DrawListID p_list, const Vector<uint8_t> &p_data, uint32_t p_data_size) {
389 ERR_FAIL_COND((uint32_t)p_data.size() > p_data_size);
390 draw_list_set_push_constant(p_list, p_data.ptr(), p_data_size);
391}
392
393void RenderingDevice::_compute_list_set_push_constant(ComputeListID p_list, const Vector<uint8_t> &p_data, uint32_t p_data_size) {
394 ERR_FAIL_COND((uint32_t)p_data.size() > p_data_size);
395 compute_list_set_push_constant(p_list, p_data.ptr(), p_data_size);
396}
397
398Error RenderingDevice::_reflect_spirv(const Vector<ShaderStageSPIRVData> &p_spirv, SpirvReflectionData &r_reflection_data) {
399 r_reflection_data = {};
400
401 for (int i = 0; i < p_spirv.size(); i++) {
402 ShaderStage stage = p_spirv[i].shader_stage;
403 ShaderStage stage_flag = (ShaderStage)(1 << p_spirv[i].shader_stage);
404
405 if (p_spirv[i].shader_stage == SHADER_STAGE_COMPUTE) {
406 r_reflection_data.is_compute = true;
407 ERR_FAIL_COND_V_MSG(p_spirv.size() != 1, FAILED,
408 "Compute shaders can only receive one stage, dedicated to compute.");
409 }
410 ERR_FAIL_COND_V_MSG(r_reflection_data.stages_mask.has_flag(stage_flag), FAILED,
411 "Stage " + String(shader_stage_names[p_spirv[i].shader_stage]) + " submitted more than once.");
412
413 {
414 SpvReflectShaderModule module;
415 const uint8_t *spirv = p_spirv[i].spir_v.ptr();
416 SpvReflectResult result = spvReflectCreateShaderModule(p_spirv[i].spir_v.size(), spirv, &module);
417 ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, FAILED,
418 "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed parsing shader.");
419
420 if (r_reflection_data.is_compute) {
421 r_reflection_data.compute_local_size[0] = module.entry_points->local_size.x;
422 r_reflection_data.compute_local_size[1] = module.entry_points->local_size.y;
423 r_reflection_data.compute_local_size[2] = module.entry_points->local_size.z;
424 }
425 uint32_t binding_count = 0;
426 result = spvReflectEnumerateDescriptorBindings(&module, &binding_count, nullptr);
427 ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, FAILED,
428 "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed enumerating descriptor bindings.");
429
430 if (binding_count > 0) {
431 // Parse bindings.
432
433 Vector<SpvReflectDescriptorBinding *> bindings;
434 bindings.resize(binding_count);
435 result = spvReflectEnumerateDescriptorBindings(&module, &binding_count, bindings.ptrw());
436
437 ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, FAILED,
438 "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed getting descriptor bindings.");
439
440 for (uint32_t j = 0; j < binding_count; j++) {
441 const SpvReflectDescriptorBinding &binding = *bindings[j];
442
443 SpirvReflectionData::Uniform info{};
444
445 bool need_array_dimensions = false;
446 bool need_block_size = false;
447 bool may_be_writable = false;
448
449 switch (binding.descriptor_type) {
450 case SPV_REFLECT_DESCRIPTOR_TYPE_SAMPLER: {
451 info.type = UNIFORM_TYPE_SAMPLER;
452 need_array_dimensions = true;
453 } break;
454 case SPV_REFLECT_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: {
455 info.type = UNIFORM_TYPE_SAMPLER_WITH_TEXTURE;
456 need_array_dimensions = true;
457 } break;
458 case SPV_REFLECT_DESCRIPTOR_TYPE_SAMPLED_IMAGE: {
459 info.type = UNIFORM_TYPE_TEXTURE;
460 need_array_dimensions = true;
461 } break;
462 case SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_IMAGE: {
463 info.type = UNIFORM_TYPE_IMAGE;
464 need_array_dimensions = true;
465 may_be_writable = true;
466 } break;
467 case SPV_REFLECT_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: {
468 info.type = UNIFORM_TYPE_TEXTURE_BUFFER;
469 need_array_dimensions = true;
470 } break;
471 case SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: {
472 info.type = UNIFORM_TYPE_IMAGE_BUFFER;
473 need_array_dimensions = true;
474 may_be_writable = true;
475 } break;
476 case SPV_REFLECT_DESCRIPTOR_TYPE_UNIFORM_BUFFER: {
477 info.type = UNIFORM_TYPE_UNIFORM_BUFFER;
478 need_block_size = true;
479 } break;
480 case SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_BUFFER: {
481 info.type = UNIFORM_TYPE_STORAGE_BUFFER;
482 need_block_size = true;
483 may_be_writable = true;
484 } break;
485 case SPV_REFLECT_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: {
486 ERR_PRINT("Dynamic uniform buffer not supported.");
487 continue;
488 } break;
489 case SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: {
490 ERR_PRINT("Dynamic storage buffer not supported.");
491 continue;
492 } break;
493 case SPV_REFLECT_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: {
494 info.type = UNIFORM_TYPE_INPUT_ATTACHMENT;
495 need_array_dimensions = true;
496 } break;
497 case SPV_REFLECT_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR: {
498 ERR_PRINT("Acceleration structure not supported.");
499 continue;
500 } break;
501 }
502
503 if (need_array_dimensions) {
504 if (binding.array.dims_count == 0) {
505 info.length = 1;
506 } else {
507 for (uint32_t k = 0; k < binding.array.dims_count; k++) {
508 if (k == 0) {
509 info.length = binding.array.dims[0];
510 } else {
511 info.length *= binding.array.dims[k];
512 }
513 }
514 }
515
516 } else if (need_block_size) {
517 info.length = binding.block.size;
518 } else {
519 info.length = 0;
520 }
521
522 if (may_be_writable) {
523 info.writable = !(binding.type_description->decoration_flags & SPV_REFLECT_DECORATION_NON_WRITABLE) && !(binding.block.decoration_flags & SPV_REFLECT_DECORATION_NON_WRITABLE);
524 } else {
525 info.writable = false;
526 }
527
528 info.binding = binding.binding;
529 uint32_t set = binding.set;
530
531 ERR_FAIL_COND_V_MSG(set >= MAX_UNIFORM_SETS, FAILED,
532 "On shader stage '" + String(shader_stage_names[stage]) + "', uniform '" + binding.name + "' uses a set (" + itos(set) + ") index larger than what is supported (" + itos(MAX_UNIFORM_SETS) + ").");
533
534 if (set < (uint32_t)r_reflection_data.uniforms.size()) {
535 // Check if this already exists.
536 bool exists = false;
537 for (int k = 0; k < r_reflection_data.uniforms[set].size(); k++) {
538 if (r_reflection_data.uniforms[set][k].binding == (uint32_t)info.binding) {
539 // Already exists, verify that it's the same type.
540 ERR_FAIL_COND_V_MSG(r_reflection_data.uniforms[set][k].type != info.type, FAILED,
541 "On shader stage '" + String(shader_stage_names[stage]) + "', uniform '" + binding.name + "' trying to reuse location for set=" + itos(set) + ", binding=" + itos(info.binding) + " with different uniform type.");
542
543 // Also, verify that it's the same size.
544 ERR_FAIL_COND_V_MSG(r_reflection_data.uniforms[set][k].length != info.length, FAILED,
545 "On shader stage '" + String(shader_stage_names[stage]) + "', uniform '" + binding.name + "' trying to reuse location for set=" + itos(set) + ", binding=" + itos(info.binding) + " with different uniform size.");
546
547 // Also, verify that it has the same writability.
548 ERR_FAIL_COND_V_MSG(r_reflection_data.uniforms[set][k].writable != info.writable, FAILED,
549 "On shader stage '" + String(shader_stage_names[stage]) + "', uniform '" + binding.name + "' trying to reuse location for set=" + itos(set) + ", binding=" + itos(info.binding) + " with different writability.");
550
551 // Just append stage mask and return.
552 r_reflection_data.uniforms.write[set].write[k].stages_mask.set_flag(stage_flag);
553 exists = true;
554 break;
555 }
556 }
557
558 if (exists) {
559 continue; // Merged.
560 }
561 }
562
563 info.stages_mask.set_flag(stage_flag);
564
565 if (set >= (uint32_t)r_reflection_data.uniforms.size()) {
566 r_reflection_data.uniforms.resize(set + 1);
567 }
568
569 r_reflection_data.uniforms.write[set].push_back(info);
570 }
571 }
572
573 {
574 // Specialization constants.
575
576 uint32_t sc_count = 0;
577 result = spvReflectEnumerateSpecializationConstants(&module, &sc_count, nullptr);
578 ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, FAILED,
579 "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed enumerating specialization constants.");
580
581 if (sc_count) {
582 Vector<SpvReflectSpecializationConstant *> spec_constants;
583 spec_constants.resize(sc_count);
584
585 result = spvReflectEnumerateSpecializationConstants(&module, &sc_count, spec_constants.ptrw());
586 ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, FAILED,
587 "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed obtaining specialization constants.");
588
589 for (uint32_t j = 0; j < sc_count; j++) {
590 int32_t existing = -1;
591 SpirvReflectionData::SpecializationConstant sconst{};
592 SpvReflectSpecializationConstant *spc = spec_constants[j];
593
594 sconst.constant_id = spc->constant_id;
595 sconst.int_value = 0; // Clear previous value JIC.
596 switch (spc->constant_type) {
597 case SPV_REFLECT_SPECIALIZATION_CONSTANT_BOOL: {
598 sconst.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_BOOL;
599 sconst.bool_value = spc->default_value.int_bool_value != 0;
600 } break;
601 case SPV_REFLECT_SPECIALIZATION_CONSTANT_INT: {
602 sconst.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_INT;
603 sconst.int_value = spc->default_value.int_bool_value;
604 } break;
605 case SPV_REFLECT_SPECIALIZATION_CONSTANT_FLOAT: {
606 sconst.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_FLOAT;
607 sconst.float_value = spc->default_value.float_value;
608 } break;
609 }
610 sconst.stages_mask.set_flag(stage_flag);
611
612 for (int k = 0; k < r_reflection_data.specialization_constants.size(); k++) {
613 if (r_reflection_data.specialization_constants[k].constant_id == sconst.constant_id) {
614 ERR_FAIL_COND_V_MSG(r_reflection_data.specialization_constants[k].type != sconst.type, FAILED, "More than one specialization constant used for id (" + itos(sconst.constant_id) + "), but their types differ.");
615 ERR_FAIL_COND_V_MSG(r_reflection_data.specialization_constants[k].int_value != sconst.int_value, FAILED, "More than one specialization constant used for id (" + itos(sconst.constant_id) + "), but their default values differ.");
616 existing = k;
617 break;
618 }
619 }
620
621 if (existing > 0) {
622 r_reflection_data.specialization_constants.write[existing].stages_mask.set_flag(stage_flag);
623 } else {
624 r_reflection_data.specialization_constants.push_back(sconst);
625 }
626 }
627 }
628 }
629
630 if (stage == SHADER_STAGE_VERTEX) {
631 uint32_t iv_count = 0;
632 result = spvReflectEnumerateInputVariables(&module, &iv_count, nullptr);
633 ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, FAILED,
634 "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed enumerating input variables.");
635
636 if (iv_count) {
637 Vector<SpvReflectInterfaceVariable *> input_vars;
638 input_vars.resize(iv_count);
639
640 result = spvReflectEnumerateInputVariables(&module, &iv_count, input_vars.ptrw());
641 ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, FAILED,
642 "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed obtaining input variables.");
643
644 for (uint32_t j = 0; j < iv_count; j++) {
645 if (input_vars[j] && input_vars[j]->decoration_flags == 0) { // Regular input.
646 r_reflection_data.vertex_input_mask |= (1 << uint32_t(input_vars[j]->location));
647 }
648 }
649 }
650 }
651
652 if (stage == SHADER_STAGE_FRAGMENT) {
653 uint32_t ov_count = 0;
654 result = spvReflectEnumerateOutputVariables(&module, &ov_count, nullptr);
655 ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, FAILED,
656 "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed enumerating output variables.");
657
658 if (ov_count) {
659 Vector<SpvReflectInterfaceVariable *> output_vars;
660 output_vars.resize(ov_count);
661
662 result = spvReflectEnumerateOutputVariables(&module, &ov_count, output_vars.ptrw());
663 ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, FAILED,
664 "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed obtaining output variables.");
665
666 for (uint32_t j = 0; j < ov_count; j++) {
667 const SpvReflectInterfaceVariable *refvar = output_vars[j];
668 if (refvar != nullptr && refvar->built_in != SpvBuiltInFragDepth) {
669 r_reflection_data.fragment_output_mask |= 1 << refvar->location;
670 }
671 }
672 }
673 }
674
675 uint32_t pc_count = 0;
676 result = spvReflectEnumeratePushConstantBlocks(&module, &pc_count, nullptr);
677 ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, FAILED,
678 "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed enumerating push constants.");
679
680 if (pc_count) {
681 ERR_FAIL_COND_V_MSG(pc_count > 1, FAILED,
682 "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "': Only one push constant is supported, which should be the same across shader stages.");
683
684 Vector<SpvReflectBlockVariable *> pconstants;
685 pconstants.resize(pc_count);
686 result = spvReflectEnumeratePushConstantBlocks(&module, &pc_count, pconstants.ptrw());
687 ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, FAILED,
688 "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed obtaining push constants.");
689#if 0
690 if (pconstants[0] == nullptr) {
691 Ref<FileAccess> f = FileAccess::open("res://popo.spv", FileAccess::WRITE);
692 f->store_buffer((const uint8_t *)&SpirV[0], SpirV.size() * sizeof(uint32_t));
693 }
694#endif
695
696 ERR_FAIL_COND_V_MSG(r_reflection_data.push_constant_size && r_reflection_data.push_constant_size != pconstants[0]->size, FAILED,
697 "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "': Push constant block must be the same across shader stages.");
698
699 r_reflection_data.push_constant_size = pconstants[0]->size;
700 r_reflection_data.push_constant_stages_mask.set_flag(stage_flag);
701
702 //print_line("Stage: " + String(shader_stage_names[stage]) + " push constant of size=" + itos(push_constant.push_constant_size));
703 }
704
705 // Destroy the reflection data when no longer required.
706 spvReflectDestroyShaderModule(&module);
707 }
708
709 r_reflection_data.stages_mask.set_flag(stage_flag);
710 }
711
712 return OK;
713}
714
715void RenderingDevice::_bind_methods() {
716 ClassDB::bind_method(D_METHOD("texture_create", "format", "view", "data"), &RenderingDevice::_texture_create, DEFVAL(Array()));
717 ClassDB::bind_method(D_METHOD("texture_create_shared", "view", "with_texture"), &RenderingDevice::_texture_create_shared);
718 ClassDB::bind_method(D_METHOD("texture_create_shared_from_slice", "view", "with_texture", "layer", "mipmap", "mipmaps", "slice_type"), &RenderingDevice::_texture_create_shared_from_slice, DEFVAL(1), DEFVAL(TEXTURE_SLICE_2D));
719
720 ClassDB::bind_method(D_METHOD("texture_update", "texture", "layer", "data", "post_barrier"), &RenderingDevice::texture_update, DEFVAL(BARRIER_MASK_ALL_BARRIERS));
721 ClassDB::bind_method(D_METHOD("texture_get_data", "texture", "layer"), &RenderingDevice::texture_get_data);
722
723 ClassDB::bind_method(D_METHOD("texture_is_format_supported_for_usage", "format", "usage_flags"), &RenderingDevice::texture_is_format_supported_for_usage);
724
725 ClassDB::bind_method(D_METHOD("texture_is_shared", "texture"), &RenderingDevice::texture_is_shared);
726 ClassDB::bind_method(D_METHOD("texture_is_valid", "texture"), &RenderingDevice::texture_is_valid);
727
728 ClassDB::bind_method(D_METHOD("texture_copy", "from_texture", "to_texture", "from_pos", "to_pos", "size", "src_mipmap", "dst_mipmap", "src_layer", "dst_layer", "post_barrier"), &RenderingDevice::texture_copy, DEFVAL(BARRIER_MASK_ALL_BARRIERS));
729 ClassDB::bind_method(D_METHOD("texture_clear", "texture", "color", "base_mipmap", "mipmap_count", "base_layer", "layer_count", "post_barrier"), &RenderingDevice::texture_clear, DEFVAL(BARRIER_MASK_ALL_BARRIERS));
730 ClassDB::bind_method(D_METHOD("texture_resolve_multisample", "from_texture", "to_texture", "post_barrier"), &RenderingDevice::texture_resolve_multisample, DEFVAL(BARRIER_MASK_ALL_BARRIERS));
731
732 ClassDB::bind_method(D_METHOD("texture_get_format", "texture"), &RenderingDevice::_texture_get_format);
733 ClassDB::bind_method(D_METHOD("texture_get_native_handle", "texture"), &RenderingDevice::texture_get_native_handle);
734
735 ClassDB::bind_method(D_METHOD("framebuffer_format_create", "attachments", "view_count"), &RenderingDevice::_framebuffer_format_create, DEFVAL(1));
736 ClassDB::bind_method(D_METHOD("framebuffer_format_create_multipass", "attachments", "passes", "view_count"), &RenderingDevice::_framebuffer_format_create_multipass, DEFVAL(1));
737 ClassDB::bind_method(D_METHOD("framebuffer_format_create_empty", "samples"), &RenderingDevice::framebuffer_format_create_empty, DEFVAL(TEXTURE_SAMPLES_1));
738 ClassDB::bind_method(D_METHOD("framebuffer_format_get_texture_samples", "format", "render_pass"), &RenderingDevice::framebuffer_format_get_texture_samples, DEFVAL(0));
739 ClassDB::bind_method(D_METHOD("framebuffer_create", "textures", "validate_with_format", "view_count"), &RenderingDevice::_framebuffer_create, DEFVAL(INVALID_FORMAT_ID), DEFVAL(1));
740 ClassDB::bind_method(D_METHOD("framebuffer_create_multipass", "textures", "passes", "validate_with_format", "view_count"), &RenderingDevice::_framebuffer_create_multipass, DEFVAL(INVALID_FORMAT_ID), DEFVAL(1));
741 ClassDB::bind_method(D_METHOD("framebuffer_create_empty", "size", "samples", "validate_with_format"), &RenderingDevice::framebuffer_create_empty, DEFVAL(TEXTURE_SAMPLES_1), DEFVAL(INVALID_FORMAT_ID));
742 ClassDB::bind_method(D_METHOD("framebuffer_get_format", "framebuffer"), &RenderingDevice::framebuffer_get_format);
743 ClassDB::bind_method(D_METHOD("framebuffer_is_valid", "framebuffer"), &RenderingDevice::framebuffer_is_valid);
744
745 ClassDB::bind_method(D_METHOD("sampler_create", "state"), &RenderingDevice::_sampler_create);
746 ClassDB::bind_method(D_METHOD("sampler_is_format_supported_for_filter", "format", "sampler_filter"), &RenderingDevice::sampler_is_format_supported_for_filter);
747
748 ClassDB::bind_method(D_METHOD("vertex_buffer_create", "size_bytes", "data", "use_as_storage"), &RenderingDevice::vertex_buffer_create, DEFVAL(Vector<uint8_t>()), DEFVAL(false));
749 ClassDB::bind_method(D_METHOD("vertex_format_create", "vertex_descriptions"), &RenderingDevice::_vertex_format_create);
750 ClassDB::bind_method(D_METHOD("vertex_array_create", "vertex_count", "vertex_format", "src_buffers", "offsets"), &RenderingDevice::_vertex_array_create, DEFVAL(Vector<int64_t>()));
751
752 ClassDB::bind_method(D_METHOD("index_buffer_create", "size_indices", "format", "data", "use_restart_indices"), &RenderingDevice::index_buffer_create, DEFVAL(Vector<uint8_t>()), DEFVAL(false));
753 ClassDB::bind_method(D_METHOD("index_array_create", "index_buffer", "index_offset", "index_count"), &RenderingDevice::index_array_create);
754
755 ClassDB::bind_method(D_METHOD("shader_compile_spirv_from_source", "shader_source", "allow_cache"), &RenderingDevice::_shader_compile_spirv_from_source, DEFVAL(true));
756 ClassDB::bind_method(D_METHOD("shader_compile_binary_from_spirv", "spirv_data", "name"), &RenderingDevice::_shader_compile_binary_from_spirv, DEFVAL(""));
757 ClassDB::bind_method(D_METHOD("shader_create_from_spirv", "spirv_data", "name"), &RenderingDevice::_shader_create_from_spirv, DEFVAL(""));
758 ClassDB::bind_method(D_METHOD("shader_create_from_bytecode", "binary_data", "placeholder_rid"), &RenderingDevice::shader_create_from_bytecode, DEFVAL(RID()));
759 ClassDB::bind_method(D_METHOD("shader_create_placeholder"), &RenderingDevice::shader_create_placeholder);
760
761 ClassDB::bind_method(D_METHOD("shader_get_vertex_input_attribute_mask", "shader"), &RenderingDevice::shader_get_vertex_input_attribute_mask);
762
763 ClassDB::bind_method(D_METHOD("uniform_buffer_create", "size_bytes", "data"), &RenderingDevice::uniform_buffer_create, DEFVAL(Vector<uint8_t>()));
764 ClassDB::bind_method(D_METHOD("storage_buffer_create", "size_bytes", "data", "usage"), &RenderingDevice::storage_buffer_create, DEFVAL(Vector<uint8_t>()), DEFVAL(0));
765 ClassDB::bind_method(D_METHOD("texture_buffer_create", "size_bytes", "format", "data"), &RenderingDevice::texture_buffer_create, DEFVAL(Vector<uint8_t>()));
766
767 ClassDB::bind_method(D_METHOD("uniform_set_create", "uniforms", "shader", "shader_set"), &RenderingDevice::_uniform_set_create);
768 ClassDB::bind_method(D_METHOD("uniform_set_is_valid", "uniform_set"), &RenderingDevice::uniform_set_is_valid);
769
770 ClassDB::bind_method(D_METHOD("buffer_update", "buffer", "offset", "size_bytes", "data", "post_barrier"), &RenderingDevice::_buffer_update, DEFVAL(BARRIER_MASK_ALL_BARRIERS));
771 ClassDB::bind_method(D_METHOD("buffer_clear", "buffer", "offset", "size_bytes", "post_barrier"), &RenderingDevice::buffer_clear, DEFVAL(BARRIER_MASK_ALL_BARRIERS));
772 ClassDB::bind_method(D_METHOD("buffer_get_data", "buffer", "offset_bytes", "size_bytes"), &RenderingDevice::buffer_get_data, DEFVAL(0), DEFVAL(0));
773
774 ClassDB::bind_method(D_METHOD("render_pipeline_create", "shader", "framebuffer_format", "vertex_format", "primitive", "rasterization_state", "multisample_state", "stencil_state", "color_blend_state", "dynamic_state_flags", "for_render_pass", "specialization_constants"), &RenderingDevice::_render_pipeline_create, DEFVAL(0), DEFVAL(0), DEFVAL(TypedArray<RDPipelineSpecializationConstant>()));
775 ClassDB::bind_method(D_METHOD("render_pipeline_is_valid", "render_pipeline"), &RenderingDevice::render_pipeline_is_valid);
776
777 ClassDB::bind_method(D_METHOD("compute_pipeline_create", "shader", "specialization_constants"), &RenderingDevice::_compute_pipeline_create, DEFVAL(TypedArray<RDPipelineSpecializationConstant>()));
778 ClassDB::bind_method(D_METHOD("compute_pipeline_is_valid", "compute_pipeline"), &RenderingDevice::compute_pipeline_is_valid);
779
780 ClassDB::bind_method(D_METHOD("screen_get_width", "screen"), &RenderingDevice::screen_get_width, DEFVAL(DisplayServer::MAIN_WINDOW_ID));
781 ClassDB::bind_method(D_METHOD("screen_get_height", "screen"), &RenderingDevice::screen_get_height, DEFVAL(DisplayServer::MAIN_WINDOW_ID));
782 ClassDB::bind_method(D_METHOD("screen_get_framebuffer_format"), &RenderingDevice::screen_get_framebuffer_format);
783
784 ClassDB::bind_method(D_METHOD("draw_list_begin_for_screen", "screen", "clear_color"), &RenderingDevice::draw_list_begin_for_screen, DEFVAL(DisplayServer::MAIN_WINDOW_ID), DEFVAL(Color()));
785
786 ClassDB::bind_method(D_METHOD("draw_list_begin", "framebuffer", "initial_color_action", "final_color_action", "initial_depth_action", "final_depth_action", "clear_color_values", "clear_depth", "clear_stencil", "region", "storage_textures"), &RenderingDevice::_draw_list_begin, DEFVAL(Vector<Color>()), DEFVAL(1.0), DEFVAL(0), DEFVAL(Rect2()), DEFVAL(TypedArray<RID>()));
787 ClassDB::bind_method(D_METHOD("draw_list_begin_split", "framebuffer", "splits", "initial_color_action", "final_color_action", "initial_depth_action", "final_depth_action", "clear_color_values", "clear_depth", "clear_stencil", "region", "storage_textures"), &RenderingDevice::_draw_list_begin_split, DEFVAL(Vector<Color>()), DEFVAL(1.0), DEFVAL(0), DEFVAL(Rect2()), DEFVAL(TypedArray<RID>()));
788
789 ClassDB::bind_method(D_METHOD("draw_list_set_blend_constants", "draw_list", "color"), &RenderingDevice::draw_list_set_blend_constants);
790 ClassDB::bind_method(D_METHOD("draw_list_bind_render_pipeline", "draw_list", "render_pipeline"), &RenderingDevice::draw_list_bind_render_pipeline);
791 ClassDB::bind_method(D_METHOD("draw_list_bind_uniform_set", "draw_list", "uniform_set", "set_index"), &RenderingDevice::draw_list_bind_uniform_set);
792 ClassDB::bind_method(D_METHOD("draw_list_bind_vertex_array", "draw_list", "vertex_array"), &RenderingDevice::draw_list_bind_vertex_array);
793 ClassDB::bind_method(D_METHOD("draw_list_bind_index_array", "draw_list", "index_array"), &RenderingDevice::draw_list_bind_index_array);
794 ClassDB::bind_method(D_METHOD("draw_list_set_push_constant", "draw_list", "buffer", "size_bytes"), &RenderingDevice::_draw_list_set_push_constant);
795
796 ClassDB::bind_method(D_METHOD("draw_list_draw", "draw_list", "use_indices", "instances", "procedural_vertex_count"), &RenderingDevice::draw_list_draw, DEFVAL(0));
797
798 ClassDB::bind_method(D_METHOD("draw_list_enable_scissor", "draw_list", "rect"), &RenderingDevice::draw_list_enable_scissor, DEFVAL(Rect2()));
799 ClassDB::bind_method(D_METHOD("draw_list_disable_scissor", "draw_list"), &RenderingDevice::draw_list_disable_scissor);
800
801 ClassDB::bind_method(D_METHOD("draw_list_switch_to_next_pass"), &RenderingDevice::draw_list_switch_to_next_pass);
802 ClassDB::bind_method(D_METHOD("draw_list_switch_to_next_pass_split", "splits"), &RenderingDevice::_draw_list_switch_to_next_pass_split);
803
804 ClassDB::bind_method(D_METHOD("draw_list_end", "post_barrier"), &RenderingDevice::draw_list_end, DEFVAL(BARRIER_MASK_ALL_BARRIERS));
805
806 ClassDB::bind_method(D_METHOD("compute_list_begin", "allow_draw_overlap"), &RenderingDevice::compute_list_begin, DEFVAL(false));
807 ClassDB::bind_method(D_METHOD("compute_list_bind_compute_pipeline", "compute_list", "compute_pipeline"), &RenderingDevice::compute_list_bind_compute_pipeline);
808 ClassDB::bind_method(D_METHOD("compute_list_set_push_constant", "compute_list", "buffer", "size_bytes"), &RenderingDevice::_compute_list_set_push_constant);
809 ClassDB::bind_method(D_METHOD("compute_list_bind_uniform_set", "compute_list", "uniform_set", "set_index"), &RenderingDevice::compute_list_bind_uniform_set);
810 ClassDB::bind_method(D_METHOD("compute_list_dispatch", "compute_list", "x_groups", "y_groups", "z_groups"), &RenderingDevice::compute_list_dispatch);
811 ClassDB::bind_method(D_METHOD("compute_list_add_barrier", "compute_list"), &RenderingDevice::compute_list_add_barrier);
812 ClassDB::bind_method(D_METHOD("compute_list_end", "post_barrier"), &RenderingDevice::compute_list_end, DEFVAL(BARRIER_MASK_ALL_BARRIERS));
813
814 ClassDB::bind_method(D_METHOD("free_rid", "rid"), &RenderingDevice::free);
815
816 ClassDB::bind_method(D_METHOD("capture_timestamp", "name"), &RenderingDevice::capture_timestamp);
817 ClassDB::bind_method(D_METHOD("get_captured_timestamps_count"), &RenderingDevice::get_captured_timestamps_count);
818 ClassDB::bind_method(D_METHOD("get_captured_timestamps_frame"), &RenderingDevice::get_captured_timestamps_frame);
819 ClassDB::bind_method(D_METHOD("get_captured_timestamp_gpu_time", "index"), &RenderingDevice::get_captured_timestamp_gpu_time);
820 ClassDB::bind_method(D_METHOD("get_captured_timestamp_cpu_time", "index"), &RenderingDevice::get_captured_timestamp_cpu_time);
821 ClassDB::bind_method(D_METHOD("get_captured_timestamp_name", "index"), &RenderingDevice::get_captured_timestamp_name);
822
823 ClassDB::bind_method(D_METHOD("limit_get", "limit"), &RenderingDevice::limit_get);
824 ClassDB::bind_method(D_METHOD("get_frame_delay"), &RenderingDevice::get_frame_delay);
825 ClassDB::bind_method(D_METHOD("submit"), &RenderingDevice::submit);
826 ClassDB::bind_method(D_METHOD("sync"), &RenderingDevice::sync);
827
828 ClassDB::bind_method(D_METHOD("barrier", "from", "to"), &RenderingDevice::barrier, DEFVAL(BARRIER_MASK_ALL_BARRIERS), DEFVAL(BARRIER_MASK_ALL_BARRIERS));
829 ClassDB::bind_method(D_METHOD("full_barrier"), &RenderingDevice::full_barrier);
830
831 ClassDB::bind_method(D_METHOD("create_local_device"), &RenderingDevice::create_local_device);
832
833 ClassDB::bind_method(D_METHOD("set_resource_name", "id", "name"), &RenderingDevice::set_resource_name);
834
835 ClassDB::bind_method(D_METHOD("draw_command_begin_label", "name", "color"), &RenderingDevice::draw_command_begin_label);
836 ClassDB::bind_method(D_METHOD("draw_command_insert_label", "name", "color"), &RenderingDevice::draw_command_insert_label);
837 ClassDB::bind_method(D_METHOD("draw_command_end_label"), &RenderingDevice::draw_command_end_label);
838
839 ClassDB::bind_method(D_METHOD("get_device_vendor_name"), &RenderingDevice::get_device_vendor_name);
840 ClassDB::bind_method(D_METHOD("get_device_name"), &RenderingDevice::get_device_name);
841 ClassDB::bind_method(D_METHOD("get_device_pipeline_cache_uuid"), &RenderingDevice::get_device_pipeline_cache_uuid);
842
843 ClassDB::bind_method(D_METHOD("get_memory_usage", "type"), &RenderingDevice::get_memory_usage);
844
845 ClassDB::bind_method(D_METHOD("get_driver_resource", "resource", "rid", "index"), &RenderingDevice::get_driver_resource);
846
847 BIND_ENUM_CONSTANT(DEVICE_TYPE_OTHER);
848 BIND_ENUM_CONSTANT(DEVICE_TYPE_INTEGRATED_GPU);
849 BIND_ENUM_CONSTANT(DEVICE_TYPE_DISCRETE_GPU);
850 BIND_ENUM_CONSTANT(DEVICE_TYPE_VIRTUAL_GPU);
851 BIND_ENUM_CONSTANT(DEVICE_TYPE_CPU);
852 BIND_ENUM_CONSTANT(DEVICE_TYPE_MAX);
853
854 BIND_ENUM_CONSTANT(DRIVER_RESOURCE_VULKAN_DEVICE);
855 BIND_ENUM_CONSTANT(DRIVER_RESOURCE_VULKAN_PHYSICAL_DEVICE);
856 BIND_ENUM_CONSTANT(DRIVER_RESOURCE_VULKAN_INSTANCE);
857 BIND_ENUM_CONSTANT(DRIVER_RESOURCE_VULKAN_QUEUE);
858 BIND_ENUM_CONSTANT(DRIVER_RESOURCE_VULKAN_QUEUE_FAMILY_INDEX);
859 BIND_ENUM_CONSTANT(DRIVER_RESOURCE_VULKAN_IMAGE);
860 BIND_ENUM_CONSTANT(DRIVER_RESOURCE_VULKAN_IMAGE_VIEW);
861 BIND_ENUM_CONSTANT(DRIVER_RESOURCE_VULKAN_IMAGE_NATIVE_TEXTURE_FORMAT);
862 BIND_ENUM_CONSTANT(DRIVER_RESOURCE_VULKAN_SAMPLER);
863 BIND_ENUM_CONSTANT(DRIVER_RESOURCE_VULKAN_DESCRIPTOR_SET);
864 BIND_ENUM_CONSTANT(DRIVER_RESOURCE_VULKAN_BUFFER);
865 BIND_ENUM_CONSTANT(DRIVER_RESOURCE_VULKAN_COMPUTE_PIPELINE);
866 BIND_ENUM_CONSTANT(DRIVER_RESOURCE_VULKAN_RENDER_PIPELINE);
867
868 BIND_ENUM_CONSTANT(DATA_FORMAT_R4G4_UNORM_PACK8);
869 BIND_ENUM_CONSTANT(DATA_FORMAT_R4G4B4A4_UNORM_PACK16);
870 BIND_ENUM_CONSTANT(DATA_FORMAT_B4G4R4A4_UNORM_PACK16);
871 BIND_ENUM_CONSTANT(DATA_FORMAT_R5G6B5_UNORM_PACK16);
872 BIND_ENUM_CONSTANT(DATA_FORMAT_B5G6R5_UNORM_PACK16);
873 BIND_ENUM_CONSTANT(DATA_FORMAT_R5G5B5A1_UNORM_PACK16);
874 BIND_ENUM_CONSTANT(DATA_FORMAT_B5G5R5A1_UNORM_PACK16);
875 BIND_ENUM_CONSTANT(DATA_FORMAT_A1R5G5B5_UNORM_PACK16);
876 BIND_ENUM_CONSTANT(DATA_FORMAT_R8_UNORM);
877 BIND_ENUM_CONSTANT(DATA_FORMAT_R8_SNORM);
878 BIND_ENUM_CONSTANT(DATA_FORMAT_R8_USCALED);
879 BIND_ENUM_CONSTANT(DATA_FORMAT_R8_SSCALED);
880 BIND_ENUM_CONSTANT(DATA_FORMAT_R8_UINT);
881 BIND_ENUM_CONSTANT(DATA_FORMAT_R8_SINT);
882 BIND_ENUM_CONSTANT(DATA_FORMAT_R8_SRGB);
883 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8_UNORM);
884 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8_SNORM);
885 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8_USCALED);
886 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8_SSCALED);
887 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8_UINT);
888 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8_SINT);
889 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8_SRGB);
890 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8B8_UNORM);
891 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8B8_SNORM);
892 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8B8_USCALED);
893 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8B8_SSCALED);
894 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8B8_UINT);
895 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8B8_SINT);
896 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8B8_SRGB);
897 BIND_ENUM_CONSTANT(DATA_FORMAT_B8G8R8_UNORM);
898 BIND_ENUM_CONSTANT(DATA_FORMAT_B8G8R8_SNORM);
899 BIND_ENUM_CONSTANT(DATA_FORMAT_B8G8R8_USCALED);
900 BIND_ENUM_CONSTANT(DATA_FORMAT_B8G8R8_SSCALED);
901 BIND_ENUM_CONSTANT(DATA_FORMAT_B8G8R8_UINT);
902 BIND_ENUM_CONSTANT(DATA_FORMAT_B8G8R8_SINT);
903 BIND_ENUM_CONSTANT(DATA_FORMAT_B8G8R8_SRGB);
904 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8B8A8_UNORM);
905 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8B8A8_SNORM);
906 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8B8A8_USCALED);
907 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8B8A8_SSCALED);
908 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8B8A8_UINT);
909 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8B8A8_SINT);
910 BIND_ENUM_CONSTANT(DATA_FORMAT_R8G8B8A8_SRGB);
911 BIND_ENUM_CONSTANT(DATA_FORMAT_B8G8R8A8_UNORM);
912 BIND_ENUM_CONSTANT(DATA_FORMAT_B8G8R8A8_SNORM);
913 BIND_ENUM_CONSTANT(DATA_FORMAT_B8G8R8A8_USCALED);
914 BIND_ENUM_CONSTANT(DATA_FORMAT_B8G8R8A8_SSCALED);
915 BIND_ENUM_CONSTANT(DATA_FORMAT_B8G8R8A8_UINT);
916 BIND_ENUM_CONSTANT(DATA_FORMAT_B8G8R8A8_SINT);
917 BIND_ENUM_CONSTANT(DATA_FORMAT_B8G8R8A8_SRGB);
918 BIND_ENUM_CONSTANT(DATA_FORMAT_A8B8G8R8_UNORM_PACK32);
919 BIND_ENUM_CONSTANT(DATA_FORMAT_A8B8G8R8_SNORM_PACK32);
920 BIND_ENUM_CONSTANT(DATA_FORMAT_A8B8G8R8_USCALED_PACK32);
921 BIND_ENUM_CONSTANT(DATA_FORMAT_A8B8G8R8_SSCALED_PACK32);
922 BIND_ENUM_CONSTANT(DATA_FORMAT_A8B8G8R8_UINT_PACK32);
923 BIND_ENUM_CONSTANT(DATA_FORMAT_A8B8G8R8_SINT_PACK32);
924 BIND_ENUM_CONSTANT(DATA_FORMAT_A8B8G8R8_SRGB_PACK32);
925 BIND_ENUM_CONSTANT(DATA_FORMAT_A2R10G10B10_UNORM_PACK32);
926 BIND_ENUM_CONSTANT(DATA_FORMAT_A2R10G10B10_SNORM_PACK32);
927 BIND_ENUM_CONSTANT(DATA_FORMAT_A2R10G10B10_USCALED_PACK32);
928 BIND_ENUM_CONSTANT(DATA_FORMAT_A2R10G10B10_SSCALED_PACK32);
929 BIND_ENUM_CONSTANT(DATA_FORMAT_A2R10G10B10_UINT_PACK32);
930 BIND_ENUM_CONSTANT(DATA_FORMAT_A2R10G10B10_SINT_PACK32);
931 BIND_ENUM_CONSTANT(DATA_FORMAT_A2B10G10R10_UNORM_PACK32);
932 BIND_ENUM_CONSTANT(DATA_FORMAT_A2B10G10R10_SNORM_PACK32);
933 BIND_ENUM_CONSTANT(DATA_FORMAT_A2B10G10R10_USCALED_PACK32);
934 BIND_ENUM_CONSTANT(DATA_FORMAT_A2B10G10R10_SSCALED_PACK32);
935 BIND_ENUM_CONSTANT(DATA_FORMAT_A2B10G10R10_UINT_PACK32);
936 BIND_ENUM_CONSTANT(DATA_FORMAT_A2B10G10R10_SINT_PACK32);
937 BIND_ENUM_CONSTANT(DATA_FORMAT_R16_UNORM);
938 BIND_ENUM_CONSTANT(DATA_FORMAT_R16_SNORM);
939 BIND_ENUM_CONSTANT(DATA_FORMAT_R16_USCALED);
940 BIND_ENUM_CONSTANT(DATA_FORMAT_R16_SSCALED);
941 BIND_ENUM_CONSTANT(DATA_FORMAT_R16_UINT);
942 BIND_ENUM_CONSTANT(DATA_FORMAT_R16_SINT);
943 BIND_ENUM_CONSTANT(DATA_FORMAT_R16_SFLOAT);
944 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16_UNORM);
945 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16_SNORM);
946 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16_USCALED);
947 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16_SSCALED);
948 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16_UINT);
949 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16_SINT);
950 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16_SFLOAT);
951 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16B16_UNORM);
952 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16B16_SNORM);
953 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16B16_USCALED);
954 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16B16_SSCALED);
955 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16B16_UINT);
956 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16B16_SINT);
957 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16B16_SFLOAT);
958 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16B16A16_UNORM);
959 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16B16A16_SNORM);
960 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16B16A16_USCALED);
961 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16B16A16_SSCALED);
962 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16B16A16_UINT);
963 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16B16A16_SINT);
964 BIND_ENUM_CONSTANT(DATA_FORMAT_R16G16B16A16_SFLOAT);
965 BIND_ENUM_CONSTANT(DATA_FORMAT_R32_UINT);
966 BIND_ENUM_CONSTANT(DATA_FORMAT_R32_SINT);
967 BIND_ENUM_CONSTANT(DATA_FORMAT_R32_SFLOAT);
968 BIND_ENUM_CONSTANT(DATA_FORMAT_R32G32_UINT);
969 BIND_ENUM_CONSTANT(DATA_FORMAT_R32G32_SINT);
970 BIND_ENUM_CONSTANT(DATA_FORMAT_R32G32_SFLOAT);
971 BIND_ENUM_CONSTANT(DATA_FORMAT_R32G32B32_UINT);
972 BIND_ENUM_CONSTANT(DATA_FORMAT_R32G32B32_SINT);
973 BIND_ENUM_CONSTANT(DATA_FORMAT_R32G32B32_SFLOAT);
974 BIND_ENUM_CONSTANT(DATA_FORMAT_R32G32B32A32_UINT);
975 BIND_ENUM_CONSTANT(DATA_FORMAT_R32G32B32A32_SINT);
976 BIND_ENUM_CONSTANT(DATA_FORMAT_R32G32B32A32_SFLOAT);
977 BIND_ENUM_CONSTANT(DATA_FORMAT_R64_UINT);
978 BIND_ENUM_CONSTANT(DATA_FORMAT_R64_SINT);
979 BIND_ENUM_CONSTANT(DATA_FORMAT_R64_SFLOAT);
980 BIND_ENUM_CONSTANT(DATA_FORMAT_R64G64_UINT);
981 BIND_ENUM_CONSTANT(DATA_FORMAT_R64G64_SINT);
982 BIND_ENUM_CONSTANT(DATA_FORMAT_R64G64_SFLOAT);
983 BIND_ENUM_CONSTANT(DATA_FORMAT_R64G64B64_UINT);
984 BIND_ENUM_CONSTANT(DATA_FORMAT_R64G64B64_SINT);
985 BIND_ENUM_CONSTANT(DATA_FORMAT_R64G64B64_SFLOAT);
986 BIND_ENUM_CONSTANT(DATA_FORMAT_R64G64B64A64_UINT);
987 BIND_ENUM_CONSTANT(DATA_FORMAT_R64G64B64A64_SINT);
988 BIND_ENUM_CONSTANT(DATA_FORMAT_R64G64B64A64_SFLOAT);
989 BIND_ENUM_CONSTANT(DATA_FORMAT_B10G11R11_UFLOAT_PACK32);
990 BIND_ENUM_CONSTANT(DATA_FORMAT_E5B9G9R9_UFLOAT_PACK32);
991 BIND_ENUM_CONSTANT(DATA_FORMAT_D16_UNORM);
992 BIND_ENUM_CONSTANT(DATA_FORMAT_X8_D24_UNORM_PACK32);
993 BIND_ENUM_CONSTANT(DATA_FORMAT_D32_SFLOAT);
994 BIND_ENUM_CONSTANT(DATA_FORMAT_S8_UINT);
995 BIND_ENUM_CONSTANT(DATA_FORMAT_D16_UNORM_S8_UINT);
996 BIND_ENUM_CONSTANT(DATA_FORMAT_D24_UNORM_S8_UINT);
997 BIND_ENUM_CONSTANT(DATA_FORMAT_D32_SFLOAT_S8_UINT);
998 BIND_ENUM_CONSTANT(DATA_FORMAT_BC1_RGB_UNORM_BLOCK);
999 BIND_ENUM_CONSTANT(DATA_FORMAT_BC1_RGB_SRGB_BLOCK);
1000 BIND_ENUM_CONSTANT(DATA_FORMAT_BC1_RGBA_UNORM_BLOCK);
1001 BIND_ENUM_CONSTANT(DATA_FORMAT_BC1_RGBA_SRGB_BLOCK);
1002 BIND_ENUM_CONSTANT(DATA_FORMAT_BC2_UNORM_BLOCK);
1003 BIND_ENUM_CONSTANT(DATA_FORMAT_BC2_SRGB_BLOCK);
1004 BIND_ENUM_CONSTANT(DATA_FORMAT_BC3_UNORM_BLOCK);
1005 BIND_ENUM_CONSTANT(DATA_FORMAT_BC3_SRGB_BLOCK);
1006 BIND_ENUM_CONSTANT(DATA_FORMAT_BC4_UNORM_BLOCK);
1007 BIND_ENUM_CONSTANT(DATA_FORMAT_BC4_SNORM_BLOCK);
1008 BIND_ENUM_CONSTANT(DATA_FORMAT_BC5_UNORM_BLOCK);
1009 BIND_ENUM_CONSTANT(DATA_FORMAT_BC5_SNORM_BLOCK);
1010 BIND_ENUM_CONSTANT(DATA_FORMAT_BC6H_UFLOAT_BLOCK);
1011 BIND_ENUM_CONSTANT(DATA_FORMAT_BC6H_SFLOAT_BLOCK);
1012 BIND_ENUM_CONSTANT(DATA_FORMAT_BC7_UNORM_BLOCK);
1013 BIND_ENUM_CONSTANT(DATA_FORMAT_BC7_SRGB_BLOCK);
1014 BIND_ENUM_CONSTANT(DATA_FORMAT_ETC2_R8G8B8_UNORM_BLOCK);
1015 BIND_ENUM_CONSTANT(DATA_FORMAT_ETC2_R8G8B8_SRGB_BLOCK);
1016 BIND_ENUM_CONSTANT(DATA_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK);
1017 BIND_ENUM_CONSTANT(DATA_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK);
1018 BIND_ENUM_CONSTANT(DATA_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK);
1019 BIND_ENUM_CONSTANT(DATA_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK);
1020 BIND_ENUM_CONSTANT(DATA_FORMAT_EAC_R11_UNORM_BLOCK);
1021 BIND_ENUM_CONSTANT(DATA_FORMAT_EAC_R11_SNORM_BLOCK);
1022 BIND_ENUM_CONSTANT(DATA_FORMAT_EAC_R11G11_UNORM_BLOCK);
1023 BIND_ENUM_CONSTANT(DATA_FORMAT_EAC_R11G11_SNORM_BLOCK);
1024 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_4x4_UNORM_BLOCK);
1025 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_4x4_SRGB_BLOCK);
1026 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_5x4_UNORM_BLOCK);
1027 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_5x4_SRGB_BLOCK);
1028 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_5x5_UNORM_BLOCK);
1029 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_5x5_SRGB_BLOCK);
1030 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_6x5_UNORM_BLOCK);
1031 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_6x5_SRGB_BLOCK);
1032 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_6x6_UNORM_BLOCK);
1033 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_6x6_SRGB_BLOCK);
1034 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_8x5_UNORM_BLOCK);
1035 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_8x5_SRGB_BLOCK);
1036 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_8x6_UNORM_BLOCK);
1037 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_8x6_SRGB_BLOCK);
1038 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_8x8_UNORM_BLOCK);
1039 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_8x8_SRGB_BLOCK);
1040 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_10x5_UNORM_BLOCK);
1041 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_10x5_SRGB_BLOCK);
1042 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_10x6_UNORM_BLOCK);
1043 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_10x6_SRGB_BLOCK);
1044 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_10x8_UNORM_BLOCK);
1045 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_10x8_SRGB_BLOCK);
1046 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_10x10_UNORM_BLOCK);
1047 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_10x10_SRGB_BLOCK);
1048 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_12x10_UNORM_BLOCK);
1049 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_12x10_SRGB_BLOCK);
1050 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_12x12_UNORM_BLOCK);
1051 BIND_ENUM_CONSTANT(DATA_FORMAT_ASTC_12x12_SRGB_BLOCK);
1052 BIND_ENUM_CONSTANT(DATA_FORMAT_G8B8G8R8_422_UNORM);
1053 BIND_ENUM_CONSTANT(DATA_FORMAT_B8G8R8G8_422_UNORM);
1054 BIND_ENUM_CONSTANT(DATA_FORMAT_G8_B8_R8_3PLANE_420_UNORM);
1055 BIND_ENUM_CONSTANT(DATA_FORMAT_G8_B8R8_2PLANE_420_UNORM);
1056 BIND_ENUM_CONSTANT(DATA_FORMAT_G8_B8_R8_3PLANE_422_UNORM);
1057 BIND_ENUM_CONSTANT(DATA_FORMAT_G8_B8R8_2PLANE_422_UNORM);
1058 BIND_ENUM_CONSTANT(DATA_FORMAT_G8_B8_R8_3PLANE_444_UNORM);
1059 BIND_ENUM_CONSTANT(DATA_FORMAT_R10X6_UNORM_PACK16);
1060 BIND_ENUM_CONSTANT(DATA_FORMAT_R10X6G10X6_UNORM_2PACK16);
1061 BIND_ENUM_CONSTANT(DATA_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16);
1062 BIND_ENUM_CONSTANT(DATA_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16);
1063 BIND_ENUM_CONSTANT(DATA_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16);
1064 BIND_ENUM_CONSTANT(DATA_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16);
1065 BIND_ENUM_CONSTANT(DATA_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16);
1066 BIND_ENUM_CONSTANT(DATA_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16);
1067 BIND_ENUM_CONSTANT(DATA_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16);
1068 BIND_ENUM_CONSTANT(DATA_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16);
1069 BIND_ENUM_CONSTANT(DATA_FORMAT_R12X4_UNORM_PACK16);
1070 BIND_ENUM_CONSTANT(DATA_FORMAT_R12X4G12X4_UNORM_2PACK16);
1071 BIND_ENUM_CONSTANT(DATA_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16);
1072 BIND_ENUM_CONSTANT(DATA_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16);
1073 BIND_ENUM_CONSTANT(DATA_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16);
1074 BIND_ENUM_CONSTANT(DATA_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16);
1075 BIND_ENUM_CONSTANT(DATA_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16);
1076 BIND_ENUM_CONSTANT(DATA_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16);
1077 BIND_ENUM_CONSTANT(DATA_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16);
1078 BIND_ENUM_CONSTANT(DATA_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16);
1079 BIND_ENUM_CONSTANT(DATA_FORMAT_G16B16G16R16_422_UNORM);
1080 BIND_ENUM_CONSTANT(DATA_FORMAT_B16G16R16G16_422_UNORM);
1081 BIND_ENUM_CONSTANT(DATA_FORMAT_G16_B16_R16_3PLANE_420_UNORM);
1082 BIND_ENUM_CONSTANT(DATA_FORMAT_G16_B16R16_2PLANE_420_UNORM);
1083 BIND_ENUM_CONSTANT(DATA_FORMAT_G16_B16_R16_3PLANE_422_UNORM);
1084 BIND_ENUM_CONSTANT(DATA_FORMAT_G16_B16R16_2PLANE_422_UNORM);
1085 BIND_ENUM_CONSTANT(DATA_FORMAT_G16_B16_R16_3PLANE_444_UNORM);
1086 BIND_ENUM_CONSTANT(DATA_FORMAT_MAX);
1087
1088 BIND_BITFIELD_FLAG(BARRIER_MASK_VERTEX);
1089 BIND_BITFIELD_FLAG(BARRIER_MASK_FRAGMENT);
1090 BIND_BITFIELD_FLAG(BARRIER_MASK_COMPUTE);
1091 BIND_BITFIELD_FLAG(BARRIER_MASK_TRANSFER);
1092 BIND_BITFIELD_FLAG(BARRIER_MASK_RASTER);
1093 BIND_BITFIELD_FLAG(BARRIER_MASK_ALL_BARRIERS);
1094 BIND_BITFIELD_FLAG(BARRIER_MASK_NO_BARRIER);
1095
1096 BIND_ENUM_CONSTANT(TEXTURE_TYPE_1D);
1097 BIND_ENUM_CONSTANT(TEXTURE_TYPE_2D);
1098 BIND_ENUM_CONSTANT(TEXTURE_TYPE_3D);
1099 BIND_ENUM_CONSTANT(TEXTURE_TYPE_CUBE);
1100 BIND_ENUM_CONSTANT(TEXTURE_TYPE_1D_ARRAY);
1101 BIND_ENUM_CONSTANT(TEXTURE_TYPE_2D_ARRAY);
1102 BIND_ENUM_CONSTANT(TEXTURE_TYPE_CUBE_ARRAY);
1103 BIND_ENUM_CONSTANT(TEXTURE_TYPE_MAX);
1104
1105 BIND_ENUM_CONSTANT(TEXTURE_SAMPLES_1);
1106 BIND_ENUM_CONSTANT(TEXTURE_SAMPLES_2);
1107 BIND_ENUM_CONSTANT(TEXTURE_SAMPLES_4);
1108 BIND_ENUM_CONSTANT(TEXTURE_SAMPLES_8);
1109 BIND_ENUM_CONSTANT(TEXTURE_SAMPLES_16);
1110 BIND_ENUM_CONSTANT(TEXTURE_SAMPLES_32);
1111 BIND_ENUM_CONSTANT(TEXTURE_SAMPLES_64);
1112 BIND_ENUM_CONSTANT(TEXTURE_SAMPLES_MAX);
1113
1114 BIND_BITFIELD_FLAG(TEXTURE_USAGE_SAMPLING_BIT);
1115 BIND_BITFIELD_FLAG(TEXTURE_USAGE_COLOR_ATTACHMENT_BIT);
1116 BIND_BITFIELD_FLAG(TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
1117 BIND_BITFIELD_FLAG(TEXTURE_USAGE_STORAGE_BIT);
1118 BIND_BITFIELD_FLAG(TEXTURE_USAGE_STORAGE_ATOMIC_BIT);
1119 BIND_BITFIELD_FLAG(TEXTURE_USAGE_CPU_READ_BIT);
1120 BIND_BITFIELD_FLAG(TEXTURE_USAGE_CAN_UPDATE_BIT);
1121 BIND_BITFIELD_FLAG(TEXTURE_USAGE_CAN_COPY_FROM_BIT);
1122 BIND_BITFIELD_FLAG(TEXTURE_USAGE_CAN_COPY_TO_BIT);
1123 BIND_BITFIELD_FLAG(TEXTURE_USAGE_INPUT_ATTACHMENT_BIT);
1124
1125 BIND_ENUM_CONSTANT(TEXTURE_SWIZZLE_IDENTITY);
1126 BIND_ENUM_CONSTANT(TEXTURE_SWIZZLE_ZERO);
1127 BIND_ENUM_CONSTANT(TEXTURE_SWIZZLE_ONE);
1128 BIND_ENUM_CONSTANT(TEXTURE_SWIZZLE_R);
1129 BIND_ENUM_CONSTANT(TEXTURE_SWIZZLE_G);
1130 BIND_ENUM_CONSTANT(TEXTURE_SWIZZLE_B);
1131 BIND_ENUM_CONSTANT(TEXTURE_SWIZZLE_A);
1132 BIND_ENUM_CONSTANT(TEXTURE_SWIZZLE_MAX);
1133
1134 BIND_ENUM_CONSTANT(TEXTURE_SLICE_2D);
1135 BIND_ENUM_CONSTANT(TEXTURE_SLICE_CUBEMAP);
1136 BIND_ENUM_CONSTANT(TEXTURE_SLICE_3D);
1137
1138 BIND_ENUM_CONSTANT(SAMPLER_FILTER_NEAREST);
1139 BIND_ENUM_CONSTANT(SAMPLER_FILTER_LINEAR);
1140 BIND_ENUM_CONSTANT(SAMPLER_REPEAT_MODE_REPEAT);
1141 BIND_ENUM_CONSTANT(SAMPLER_REPEAT_MODE_MIRRORED_REPEAT);
1142 BIND_ENUM_CONSTANT(SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE);
1143 BIND_ENUM_CONSTANT(SAMPLER_REPEAT_MODE_CLAMP_TO_BORDER);
1144 BIND_ENUM_CONSTANT(SAMPLER_REPEAT_MODE_MIRROR_CLAMP_TO_EDGE);
1145 BIND_ENUM_CONSTANT(SAMPLER_REPEAT_MODE_MAX);
1146
1147 BIND_ENUM_CONSTANT(SAMPLER_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK);
1148 BIND_ENUM_CONSTANT(SAMPLER_BORDER_COLOR_INT_TRANSPARENT_BLACK);
1149 BIND_ENUM_CONSTANT(SAMPLER_BORDER_COLOR_FLOAT_OPAQUE_BLACK);
1150 BIND_ENUM_CONSTANT(SAMPLER_BORDER_COLOR_INT_OPAQUE_BLACK);
1151 BIND_ENUM_CONSTANT(SAMPLER_BORDER_COLOR_FLOAT_OPAQUE_WHITE);
1152 BIND_ENUM_CONSTANT(SAMPLER_BORDER_COLOR_INT_OPAQUE_WHITE);
1153 BIND_ENUM_CONSTANT(SAMPLER_BORDER_COLOR_MAX);
1154
1155 BIND_ENUM_CONSTANT(VERTEX_FREQUENCY_VERTEX);
1156 BIND_ENUM_CONSTANT(VERTEX_FREQUENCY_INSTANCE);
1157
1158 BIND_ENUM_CONSTANT(INDEX_BUFFER_FORMAT_UINT16);
1159 BIND_ENUM_CONSTANT(INDEX_BUFFER_FORMAT_UINT32);
1160
1161 BIND_BITFIELD_FLAG(STORAGE_BUFFER_USAGE_DISPATCH_INDIRECT);
1162
1163 BIND_ENUM_CONSTANT(UNIFORM_TYPE_SAMPLER); //for sampling only (sampler GLSL type)
1164 BIND_ENUM_CONSTANT(UNIFORM_TYPE_SAMPLER_WITH_TEXTURE); // for sampling only); but includes a texture); (samplerXX GLSL type)); first a sampler then a texture
1165 BIND_ENUM_CONSTANT(UNIFORM_TYPE_TEXTURE); //only texture); (textureXX GLSL type)
1166 BIND_ENUM_CONSTANT(UNIFORM_TYPE_IMAGE); // storage image (imageXX GLSL type)); for compute mostly
1167 BIND_ENUM_CONSTANT(UNIFORM_TYPE_TEXTURE_BUFFER); // buffer texture (or TBO); textureBuffer type)
1168 BIND_ENUM_CONSTANT(UNIFORM_TYPE_SAMPLER_WITH_TEXTURE_BUFFER); // buffer texture with a sampler(or TBO); samplerBuffer type)
1169 BIND_ENUM_CONSTANT(UNIFORM_TYPE_IMAGE_BUFFER); //texel buffer); (imageBuffer type)); for compute mostly
1170 BIND_ENUM_CONSTANT(UNIFORM_TYPE_UNIFORM_BUFFER); //regular uniform buffer (or UBO).
1171 BIND_ENUM_CONSTANT(UNIFORM_TYPE_STORAGE_BUFFER); //storage buffer ("buffer" qualifier) like UBO); but supports storage); for compute mostly
1172 BIND_ENUM_CONSTANT(UNIFORM_TYPE_INPUT_ATTACHMENT); //used for sub-pass read/write); for mobile mostly
1173 BIND_ENUM_CONSTANT(UNIFORM_TYPE_MAX);
1174
1175 BIND_ENUM_CONSTANT(RENDER_PRIMITIVE_POINTS);
1176 BIND_ENUM_CONSTANT(RENDER_PRIMITIVE_LINES);
1177 BIND_ENUM_CONSTANT(RENDER_PRIMITIVE_LINES_WITH_ADJACENCY);
1178 BIND_ENUM_CONSTANT(RENDER_PRIMITIVE_LINESTRIPS);
1179 BIND_ENUM_CONSTANT(RENDER_PRIMITIVE_LINESTRIPS_WITH_ADJACENCY);
1180 BIND_ENUM_CONSTANT(RENDER_PRIMITIVE_TRIANGLES);
1181 BIND_ENUM_CONSTANT(RENDER_PRIMITIVE_TRIANGLES_WITH_ADJACENCY);
1182 BIND_ENUM_CONSTANT(RENDER_PRIMITIVE_TRIANGLE_STRIPS);
1183 BIND_ENUM_CONSTANT(RENDER_PRIMITIVE_TRIANGLE_STRIPS_WITH_AJACENCY);
1184 BIND_ENUM_CONSTANT(RENDER_PRIMITIVE_TRIANGLE_STRIPS_WITH_RESTART_INDEX);
1185 BIND_ENUM_CONSTANT(RENDER_PRIMITIVE_TESSELATION_PATCH);
1186 BIND_ENUM_CONSTANT(RENDER_PRIMITIVE_MAX);
1187
1188 BIND_ENUM_CONSTANT(POLYGON_CULL_DISABLED);
1189 BIND_ENUM_CONSTANT(POLYGON_CULL_FRONT);
1190 BIND_ENUM_CONSTANT(POLYGON_CULL_BACK);
1191
1192 BIND_ENUM_CONSTANT(POLYGON_FRONT_FACE_CLOCKWISE);
1193 BIND_ENUM_CONSTANT(POLYGON_FRONT_FACE_COUNTER_CLOCKWISE);
1194
1195 BIND_ENUM_CONSTANT(STENCIL_OP_KEEP);
1196 BIND_ENUM_CONSTANT(STENCIL_OP_ZERO);
1197 BIND_ENUM_CONSTANT(STENCIL_OP_REPLACE);
1198 BIND_ENUM_CONSTANT(STENCIL_OP_INCREMENT_AND_CLAMP);
1199 BIND_ENUM_CONSTANT(STENCIL_OP_DECREMENT_AND_CLAMP);
1200 BIND_ENUM_CONSTANT(STENCIL_OP_INVERT);
1201 BIND_ENUM_CONSTANT(STENCIL_OP_INCREMENT_AND_WRAP);
1202 BIND_ENUM_CONSTANT(STENCIL_OP_DECREMENT_AND_WRAP);
1203 BIND_ENUM_CONSTANT(STENCIL_OP_MAX); //not an actual operator); just the amount of operators :D
1204
1205 BIND_ENUM_CONSTANT(COMPARE_OP_NEVER);
1206 BIND_ENUM_CONSTANT(COMPARE_OP_LESS);
1207 BIND_ENUM_CONSTANT(COMPARE_OP_EQUAL);
1208 BIND_ENUM_CONSTANT(COMPARE_OP_LESS_OR_EQUAL);
1209 BIND_ENUM_CONSTANT(COMPARE_OP_GREATER);
1210 BIND_ENUM_CONSTANT(COMPARE_OP_NOT_EQUAL);
1211 BIND_ENUM_CONSTANT(COMPARE_OP_GREATER_OR_EQUAL);
1212 BIND_ENUM_CONSTANT(COMPARE_OP_ALWAYS);
1213 BIND_ENUM_CONSTANT(COMPARE_OP_MAX);
1214
1215 BIND_ENUM_CONSTANT(LOGIC_OP_CLEAR);
1216 BIND_ENUM_CONSTANT(LOGIC_OP_AND);
1217 BIND_ENUM_CONSTANT(LOGIC_OP_AND_REVERSE);
1218 BIND_ENUM_CONSTANT(LOGIC_OP_COPY);
1219 BIND_ENUM_CONSTANT(LOGIC_OP_AND_INVERTED);
1220 BIND_ENUM_CONSTANT(LOGIC_OP_NO_OP);
1221 BIND_ENUM_CONSTANT(LOGIC_OP_XOR);
1222 BIND_ENUM_CONSTANT(LOGIC_OP_OR);
1223 BIND_ENUM_CONSTANT(LOGIC_OP_NOR);
1224 BIND_ENUM_CONSTANT(LOGIC_OP_EQUIVALENT);
1225 BIND_ENUM_CONSTANT(LOGIC_OP_INVERT);
1226 BIND_ENUM_CONSTANT(LOGIC_OP_OR_REVERSE);
1227 BIND_ENUM_CONSTANT(LOGIC_OP_COPY_INVERTED);
1228 BIND_ENUM_CONSTANT(LOGIC_OP_OR_INVERTED);
1229 BIND_ENUM_CONSTANT(LOGIC_OP_NAND);
1230 BIND_ENUM_CONSTANT(LOGIC_OP_SET);
1231 BIND_ENUM_CONSTANT(LOGIC_OP_MAX); //not an actual operator); just the amount of operators :D
1232
1233 BIND_ENUM_CONSTANT(BLEND_FACTOR_ZERO);
1234 BIND_ENUM_CONSTANT(BLEND_FACTOR_ONE);
1235 BIND_ENUM_CONSTANT(BLEND_FACTOR_SRC_COLOR);
1236 BIND_ENUM_CONSTANT(BLEND_FACTOR_ONE_MINUS_SRC_COLOR);
1237 BIND_ENUM_CONSTANT(BLEND_FACTOR_DST_COLOR);
1238 BIND_ENUM_CONSTANT(BLEND_FACTOR_ONE_MINUS_DST_COLOR);
1239 BIND_ENUM_CONSTANT(BLEND_FACTOR_SRC_ALPHA);
1240 BIND_ENUM_CONSTANT(BLEND_FACTOR_ONE_MINUS_SRC_ALPHA);
1241 BIND_ENUM_CONSTANT(BLEND_FACTOR_DST_ALPHA);
1242 BIND_ENUM_CONSTANT(BLEND_FACTOR_ONE_MINUS_DST_ALPHA);
1243 BIND_ENUM_CONSTANT(BLEND_FACTOR_CONSTANT_COLOR);
1244 BIND_ENUM_CONSTANT(BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR);
1245 BIND_ENUM_CONSTANT(BLEND_FACTOR_CONSTANT_ALPHA);
1246 BIND_ENUM_CONSTANT(BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA);
1247 BIND_ENUM_CONSTANT(BLEND_FACTOR_SRC_ALPHA_SATURATE);
1248 BIND_ENUM_CONSTANT(BLEND_FACTOR_SRC1_COLOR);
1249 BIND_ENUM_CONSTANT(BLEND_FACTOR_ONE_MINUS_SRC1_COLOR);
1250 BIND_ENUM_CONSTANT(BLEND_FACTOR_SRC1_ALPHA);
1251 BIND_ENUM_CONSTANT(BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA);
1252 BIND_ENUM_CONSTANT(BLEND_FACTOR_MAX);
1253
1254 BIND_ENUM_CONSTANT(BLEND_OP_ADD);
1255 BIND_ENUM_CONSTANT(BLEND_OP_SUBTRACT);
1256 BIND_ENUM_CONSTANT(BLEND_OP_REVERSE_SUBTRACT);
1257 BIND_ENUM_CONSTANT(BLEND_OP_MINIMUM);
1258 BIND_ENUM_CONSTANT(BLEND_OP_MAXIMUM);
1259 BIND_ENUM_CONSTANT(BLEND_OP_MAX);
1260
1261 BIND_BITFIELD_FLAG(DYNAMIC_STATE_LINE_WIDTH);
1262 BIND_BITFIELD_FLAG(DYNAMIC_STATE_DEPTH_BIAS);
1263 BIND_BITFIELD_FLAG(DYNAMIC_STATE_BLEND_CONSTANTS);
1264 BIND_BITFIELD_FLAG(DYNAMIC_STATE_DEPTH_BOUNDS);
1265 BIND_BITFIELD_FLAG(DYNAMIC_STATE_STENCIL_COMPARE_MASK);
1266 BIND_BITFIELD_FLAG(DYNAMIC_STATE_STENCIL_WRITE_MASK);
1267 BIND_BITFIELD_FLAG(DYNAMIC_STATE_STENCIL_REFERENCE);
1268
1269 BIND_ENUM_CONSTANT(INITIAL_ACTION_CLEAR); //start rendering and clear the framebuffer (supply params)
1270 BIND_ENUM_CONSTANT(INITIAL_ACTION_CLEAR_REGION); //start rendering and clear the framebuffer (supply params)
1271 BIND_ENUM_CONSTANT(INITIAL_ACTION_CLEAR_REGION_CONTINUE); //continue rendering and clear the framebuffer (supply params)
1272 BIND_ENUM_CONSTANT(INITIAL_ACTION_KEEP); //start rendering); but keep attached color texture contents (depth will be cleared)
1273 BIND_ENUM_CONSTANT(INITIAL_ACTION_DROP); //start rendering); ignore what is there); just write above it
1274 BIND_ENUM_CONSTANT(INITIAL_ACTION_CONTINUE); //continue rendering (framebuffer must have been left in "continue" state as final action previously)
1275 BIND_ENUM_CONSTANT(INITIAL_ACTION_MAX);
1276
1277 BIND_ENUM_CONSTANT(FINAL_ACTION_READ); //will no longer render to it); allows attached textures to be read again); but depth buffer contents will be dropped (Can't be read from)
1278 BIND_ENUM_CONSTANT(FINAL_ACTION_DISCARD); // discard contents after rendering
1279 BIND_ENUM_CONSTANT(FINAL_ACTION_CONTINUE); //will continue rendering later); attached textures can't be read until re-bound with "finish"
1280 BIND_ENUM_CONSTANT(FINAL_ACTION_MAX);
1281
1282 BIND_ENUM_CONSTANT(SHADER_STAGE_VERTEX);
1283 BIND_ENUM_CONSTANT(SHADER_STAGE_FRAGMENT);
1284 BIND_ENUM_CONSTANT(SHADER_STAGE_TESSELATION_CONTROL);
1285 BIND_ENUM_CONSTANT(SHADER_STAGE_TESSELATION_EVALUATION);
1286 BIND_ENUM_CONSTANT(SHADER_STAGE_COMPUTE);
1287 BIND_ENUM_CONSTANT(SHADER_STAGE_MAX);
1288 BIND_ENUM_CONSTANT(SHADER_STAGE_VERTEX_BIT);
1289 BIND_ENUM_CONSTANT(SHADER_STAGE_FRAGMENT_BIT);
1290 BIND_ENUM_CONSTANT(SHADER_STAGE_TESSELATION_CONTROL_BIT);
1291 BIND_ENUM_CONSTANT(SHADER_STAGE_TESSELATION_EVALUATION_BIT);
1292 BIND_ENUM_CONSTANT(SHADER_STAGE_COMPUTE_BIT);
1293
1294 BIND_ENUM_CONSTANT(SHADER_LANGUAGE_GLSL);
1295 BIND_ENUM_CONSTANT(SHADER_LANGUAGE_HLSL);
1296
1297 BIND_ENUM_CONSTANT(PIPELINE_SPECIALIZATION_CONSTANT_TYPE_BOOL);
1298 BIND_ENUM_CONSTANT(PIPELINE_SPECIALIZATION_CONSTANT_TYPE_INT);
1299 BIND_ENUM_CONSTANT(PIPELINE_SPECIALIZATION_CONSTANT_TYPE_FLOAT);
1300
1301 BIND_ENUM_CONSTANT(LIMIT_MAX_BOUND_UNIFORM_SETS);
1302 BIND_ENUM_CONSTANT(LIMIT_MAX_FRAMEBUFFER_COLOR_ATTACHMENTS);
1303 BIND_ENUM_CONSTANT(LIMIT_MAX_TEXTURES_PER_UNIFORM_SET);
1304 BIND_ENUM_CONSTANT(LIMIT_MAX_SAMPLERS_PER_UNIFORM_SET);
1305 BIND_ENUM_CONSTANT(LIMIT_MAX_STORAGE_BUFFERS_PER_UNIFORM_SET);
1306 BIND_ENUM_CONSTANT(LIMIT_MAX_STORAGE_IMAGES_PER_UNIFORM_SET);
1307 BIND_ENUM_CONSTANT(LIMIT_MAX_UNIFORM_BUFFERS_PER_UNIFORM_SET);
1308 BIND_ENUM_CONSTANT(LIMIT_MAX_DRAW_INDEXED_INDEX);
1309 BIND_ENUM_CONSTANT(LIMIT_MAX_FRAMEBUFFER_HEIGHT);
1310 BIND_ENUM_CONSTANT(LIMIT_MAX_FRAMEBUFFER_WIDTH);
1311 BIND_ENUM_CONSTANT(LIMIT_MAX_TEXTURE_ARRAY_LAYERS);
1312 BIND_ENUM_CONSTANT(LIMIT_MAX_TEXTURE_SIZE_1D);
1313 BIND_ENUM_CONSTANT(LIMIT_MAX_TEXTURE_SIZE_2D);
1314 BIND_ENUM_CONSTANT(LIMIT_MAX_TEXTURE_SIZE_3D);
1315 BIND_ENUM_CONSTANT(LIMIT_MAX_TEXTURE_SIZE_CUBE);
1316 BIND_ENUM_CONSTANT(LIMIT_MAX_TEXTURES_PER_SHADER_STAGE);
1317 BIND_ENUM_CONSTANT(LIMIT_MAX_SAMPLERS_PER_SHADER_STAGE);
1318 BIND_ENUM_CONSTANT(LIMIT_MAX_STORAGE_BUFFERS_PER_SHADER_STAGE);
1319 BIND_ENUM_CONSTANT(LIMIT_MAX_STORAGE_IMAGES_PER_SHADER_STAGE);
1320 BIND_ENUM_CONSTANT(LIMIT_MAX_UNIFORM_BUFFERS_PER_SHADER_STAGE);
1321 BIND_ENUM_CONSTANT(LIMIT_MAX_PUSH_CONSTANT_SIZE);
1322 BIND_ENUM_CONSTANT(LIMIT_MAX_UNIFORM_BUFFER_SIZE);
1323 BIND_ENUM_CONSTANT(LIMIT_MAX_VERTEX_INPUT_ATTRIBUTE_OFFSET);
1324 BIND_ENUM_CONSTANT(LIMIT_MAX_VERTEX_INPUT_ATTRIBUTES);
1325 BIND_ENUM_CONSTANT(LIMIT_MAX_VERTEX_INPUT_BINDINGS);
1326 BIND_ENUM_CONSTANT(LIMIT_MAX_VERTEX_INPUT_BINDING_STRIDE);
1327 BIND_ENUM_CONSTANT(LIMIT_MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT);
1328 BIND_ENUM_CONSTANT(LIMIT_MAX_COMPUTE_SHARED_MEMORY_SIZE);
1329 BIND_ENUM_CONSTANT(LIMIT_MAX_COMPUTE_WORKGROUP_COUNT_X);
1330 BIND_ENUM_CONSTANT(LIMIT_MAX_COMPUTE_WORKGROUP_COUNT_Y);
1331 BIND_ENUM_CONSTANT(LIMIT_MAX_COMPUTE_WORKGROUP_COUNT_Z);
1332 BIND_ENUM_CONSTANT(LIMIT_MAX_COMPUTE_WORKGROUP_INVOCATIONS);
1333 BIND_ENUM_CONSTANT(LIMIT_MAX_COMPUTE_WORKGROUP_SIZE_X);
1334 BIND_ENUM_CONSTANT(LIMIT_MAX_COMPUTE_WORKGROUP_SIZE_Y);
1335 BIND_ENUM_CONSTANT(LIMIT_MAX_COMPUTE_WORKGROUP_SIZE_Z);
1336 BIND_ENUM_CONSTANT(LIMIT_MAX_VIEWPORT_DIMENSIONS_X);
1337 BIND_ENUM_CONSTANT(LIMIT_MAX_VIEWPORT_DIMENSIONS_Y);
1338
1339 BIND_ENUM_CONSTANT(MEMORY_TEXTURES);
1340 BIND_ENUM_CONSTANT(MEMORY_BUFFERS);
1341 BIND_ENUM_CONSTANT(MEMORY_TOTAL);
1342
1343 BIND_CONSTANT(INVALID_ID);
1344 BIND_CONSTANT(INVALID_FORMAT_ID);
1345}
1346
1347RenderingDevice::RenderingDevice() {
1348 if (singleton == nullptr) { // there may be more rendering devices later
1349 singleton = this;
1350 }
1351}
1352