rendering_device.cpp 68 KB

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