rendering_server_default.h 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  1. /**************************************************************************/
  2. /* rendering_server_default.h */
  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. #ifndef RENDERING_SERVER_DEFAULT_H
  31. #define RENDERING_SERVER_DEFAULT_H
  32. #include "core/object/worker_thread_pool.h"
  33. #include "core/os/thread.h"
  34. #include "core/templates/command_queue_mt.h"
  35. #include "core/templates/hash_map.h"
  36. #include "renderer_canvas_cull.h"
  37. #include "renderer_scene_cull.h"
  38. #include "renderer_viewport.h"
  39. #include "rendering_server_globals.h"
  40. #include "servers/rendering/renderer_compositor.h"
  41. #include "servers/rendering_server.h"
  42. #include "servers/server_wrap_mt_common.h"
  43. class RenderingServerDefault : public RenderingServer {
  44. enum {
  45. MAX_INSTANCE_CULL = 8192,
  46. MAX_INSTANCE_LIGHTS = 4,
  47. LIGHT_CACHE_DIRTY = -1,
  48. MAX_LIGHTS_CULLED = 256,
  49. MAX_ROOM_CULL = 32,
  50. MAX_EXTERIOR_PORTALS = 128,
  51. MAX_LIGHT_SAMPLERS = 256,
  52. INSTANCE_ROOMLESS_MASK = (1 << 20)
  53. };
  54. static int changes;
  55. RID test_cube;
  56. List<Callable> frame_drawn_callbacks;
  57. static void _changes_changed() {}
  58. uint64_t frame_profile_frame = 0;
  59. Vector<FrameProfileArea> frame_profile;
  60. double frame_setup_time = 0;
  61. //for printing
  62. bool print_gpu_profile = false;
  63. HashMap<String, float> print_gpu_profile_task_time;
  64. uint64_t print_frame_profile_ticks_from = 0;
  65. uint32_t print_frame_profile_frame_count = 0;
  66. mutable CommandQueueMT command_queue;
  67. Thread::ID server_thread = Thread::MAIN_ID;
  68. WorkerThreadPool::TaskID server_task_id = WorkerThreadPool::INVALID_TASK_ID;
  69. bool exit = false;
  70. bool create_thread = false;
  71. void _assign_mt_ids(WorkerThreadPool::TaskID p_pump_task_id);
  72. void _thread_exit();
  73. void _thread_loop();
  74. void _draw(bool p_swap_buffers, double frame_step);
  75. void _run_post_draw_steps();
  76. void _init();
  77. void _finish();
  78. void _free(RID p_rid);
  79. void _call_on_render_thread(const Callable &p_callable);
  80. public:
  81. //if editor is redrawing when it shouldn't, enable this and put a breakpoint in _changes_changed()
  82. //#define DEBUG_CHANGES
  83. #ifdef DEBUG_CHANGES
  84. _FORCE_INLINE_ static void redraw_request() {
  85. changes++;
  86. _changes_changed();
  87. }
  88. #else
  89. _FORCE_INLINE_ static void redraw_request() {
  90. changes++;
  91. }
  92. #endif
  93. #define WRITE_ACTION redraw_request();
  94. #ifdef DEBUG_SYNC
  95. #define SYNC_DEBUG print_line("sync on: " + String(__FUNCTION__));
  96. #else
  97. #define SYNC_DEBUG
  98. #endif
  99. #ifdef DEBUG_ENABLED
  100. #define MAIN_THREAD_SYNC_WARN WARN_PRINT("Call to " + String(__FUNCTION__) + " causing RenderingServer synchronizations on every frame. This significantly affects performance.");
  101. #endif
  102. #include "servers/server_wrap_mt_common.h"
  103. /* TEXTURE API */
  104. #define ServerName RendererTextureStorage
  105. #define server_name RSG::texture_storage
  106. #define FUNCRIDTEX0(m_type) \
  107. virtual RID m_type##_create() override { \
  108. RID ret = RSG::texture_storage->texture_allocate(); \
  109. if (Thread::get_caller_id() == server_thread || RSG::rasterizer->can_create_resources_async()) { \
  110. RSG::texture_storage->m_type##_initialize(ret); \
  111. } else { \
  112. command_queue.push(RSG::texture_storage, &RendererTextureStorage::m_type##_initialize, ret); \
  113. } \
  114. return ret; \
  115. }
  116. #define FUNCRIDTEX1(m_type, m_type1) \
  117. virtual RID m_type##_create(m_type1 p1) override { \
  118. RID ret = RSG::texture_storage->texture_allocate(); \
  119. if (Thread::get_caller_id() == server_thread || RSG::rasterizer->can_create_resources_async()) { \
  120. RSG::texture_storage->m_type##_initialize(ret, p1); \
  121. } else { \
  122. command_queue.push(RSG::texture_storage, &RendererTextureStorage::m_type##_initialize, ret, p1); \
  123. } \
  124. return ret; \
  125. }
  126. #define FUNCRIDTEX2(m_type, m_type1, m_type2) \
  127. virtual RID m_type##_create(m_type1 p1, m_type2 p2) override { \
  128. RID ret = RSG::texture_storage->texture_allocate(); \
  129. if (Thread::get_caller_id() == server_thread || RSG::rasterizer->can_create_resources_async()) { \
  130. RSG::texture_storage->m_type##_initialize(ret, p1, p2); \
  131. } else { \
  132. command_queue.push(RSG::texture_storage, &RendererTextureStorage::m_type##_initialize, ret, p1, p2); \
  133. } \
  134. return ret; \
  135. }
  136. #define FUNCRIDTEX3(m_type, m_type1, m_type2, m_type3) \
  137. virtual RID m_type##_create(m_type1 p1, m_type2 p2, m_type3 p3) override { \
  138. RID ret = RSG::texture_storage->texture_allocate(); \
  139. if (Thread::get_caller_id() == server_thread || RSG::rasterizer->can_create_resources_async()) { \
  140. RSG::texture_storage->m_type##_initialize(ret, p1, p2, p3); \
  141. } else { \
  142. command_queue.push(RSG::texture_storage, &RendererTextureStorage::m_type##_initialize, ret, p1, p2, p3); \
  143. } \
  144. return ret; \
  145. }
  146. #define FUNCRIDTEX6(m_type, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6) \
  147. virtual RID m_type##_create(m_type1 p1, m_type2 p2, m_type3 p3, m_type4 p4, m_type5 p5, m_type6 p6) override { \
  148. RID ret = RSG::texture_storage->texture_allocate(); \
  149. if (Thread::get_caller_id() == server_thread || RSG::rasterizer->can_create_resources_async()) { \
  150. RSG::texture_storage->m_type##_initialize(ret, p1, p2, p3, p4, p5, p6); \
  151. } else { \
  152. command_queue.push(RSG::texture_storage, &RendererTextureStorage::m_type##_initialize, ret, p1, p2, p3, p4, p5, p6); \
  153. } \
  154. return ret; \
  155. }
  156. //these go pass-through, as they can be called from any thread
  157. FUNCRIDTEX1(texture_2d, const Ref<Image> &)
  158. FUNCRIDTEX2(texture_2d_layered, const Vector<Ref<Image>> &, TextureLayeredType)
  159. FUNCRIDTEX6(texture_3d, Image::Format, int, int, int, bool, const Vector<Ref<Image>> &)
  160. FUNCRIDTEX3(texture_external, int, int, uint64_t)
  161. FUNCRIDTEX1(texture_proxy, RID)
  162. // Called directly, not through the command queue.
  163. virtual RID texture_create_from_native_handle(TextureType p_type, Image::Format p_format, uint64_t p_native_handle, int p_width, int p_height, int p_depth, int p_layers = 1, TextureLayeredType p_layered_type = TEXTURE_LAYERED_2D_ARRAY) override {
  164. return RSG::texture_storage->texture_create_from_native_handle(p_type, p_format, p_native_handle, p_width, p_height, p_depth, p_layers, p_layered_type);
  165. }
  166. //these go through command queue if they are in another thread
  167. FUNC3(texture_2d_update, RID, const Ref<Image> &, int)
  168. FUNC2(texture_3d_update, RID, const Vector<Ref<Image>> &)
  169. FUNC4(texture_external_update, RID, int, int, uint64_t)
  170. FUNC2(texture_proxy_update, RID, RID)
  171. //these also go pass-through
  172. FUNCRIDTEX0(texture_2d_placeholder)
  173. FUNCRIDTEX1(texture_2d_layered_placeholder, TextureLayeredType)
  174. FUNCRIDTEX0(texture_3d_placeholder)
  175. FUNC1RC(Ref<Image>, texture_2d_get, RID)
  176. FUNC2RC(Ref<Image>, texture_2d_layer_get, RID, int)
  177. FUNC1RC(Vector<Ref<Image>>, texture_3d_get, RID)
  178. FUNC2(texture_replace, RID, RID)
  179. FUNC3(texture_set_size_override, RID, int, int)
  180. // FIXME: Disabled during Vulkan refactoring, should be ported.
  181. #if 0
  182. FUNC2(texture_bind, RID, uint32_t)
  183. #endif
  184. FUNC3(texture_set_detect_3d_callback, RID, TextureDetectCallback, void *)
  185. FUNC3(texture_set_detect_normal_callback, RID, TextureDetectCallback, void *)
  186. FUNC3(texture_set_detect_roughness_callback, RID, TextureDetectRoughnessCallback, void *)
  187. FUNC2(texture_set_path, RID, const String &)
  188. FUNC1RC(String, texture_get_path, RID)
  189. FUNC1RC(Image::Format, texture_get_format, RID)
  190. FUNC1(texture_debug_usage, List<TextureInfo> *)
  191. FUNC2(texture_set_force_redraw_if_visible, RID, bool)
  192. FUNCRIDTEX2(texture_rd, const RID &, const RS::TextureLayeredType)
  193. FUNC2RC(RID, texture_get_rd_texture, RID, bool)
  194. FUNC2RC(uint64_t, texture_get_native_handle, RID, bool)
  195. /* SHADER API */
  196. #undef ServerName
  197. #undef server_name
  198. #define ServerName RendererMaterialStorage
  199. #define server_name RSG::material_storage
  200. FUNCRIDSPLIT(shader)
  201. virtual RID shader_create_from_code(const String &p_code, const String &p_path_hint = String()) override {
  202. RID shader = RSG::material_storage->shader_allocate();
  203. bool using_server_thread = Thread::get_caller_id() == server_thread;
  204. if (using_server_thread || RSG::rasterizer->can_create_resources_async()) {
  205. if (using_server_thread) {
  206. command_queue.flush_if_pending();
  207. }
  208. RSG::material_storage->shader_initialize(shader);
  209. RSG::material_storage->shader_set_code(shader, p_code);
  210. RSG::material_storage->shader_set_path_hint(shader, p_path_hint);
  211. } else {
  212. command_queue.push(RSG::material_storage, &RendererMaterialStorage::shader_initialize, shader);
  213. command_queue.push(RSG::material_storage, &RendererMaterialStorage::shader_set_code, shader, p_code);
  214. command_queue.push(RSG::material_storage, &RendererMaterialStorage::shader_set_path_hint, shader, p_path_hint);
  215. }
  216. return shader;
  217. }
  218. FUNC2(shader_set_code, RID, const String &)
  219. FUNC2(shader_set_path_hint, RID, const String &)
  220. FUNC1RC(String, shader_get_code, RID)
  221. FUNC2SC(get_shader_parameter_list, RID, List<PropertyInfo> *)
  222. FUNC4(shader_set_default_texture_parameter, RID, const StringName &, RID, int)
  223. FUNC3RC(RID, shader_get_default_texture_parameter, RID, const StringName &, int)
  224. FUNC2RC(Variant, shader_get_parameter_default, RID, const StringName &)
  225. FUNC1RC(ShaderNativeSourceCode, shader_get_native_source_code, RID)
  226. /* COMMON MATERIAL API */
  227. FUNCRIDSPLIT(material)
  228. virtual RID material_create_from_shader(RID p_next_pass, int p_render_priority, RID p_shader) override {
  229. RID material = RSG::material_storage->material_allocate();
  230. bool using_server_thread = Thread::get_caller_id() == server_thread;
  231. if (using_server_thread || RSG::rasterizer->can_create_resources_async()) {
  232. if (using_server_thread) {
  233. command_queue.flush_if_pending();
  234. }
  235. RSG::material_storage->material_initialize(material);
  236. RSG::material_storage->material_set_next_pass(material, p_next_pass);
  237. RSG::material_storage->material_set_render_priority(material, p_render_priority);
  238. RSG::material_storage->material_set_shader(material, p_shader);
  239. } else {
  240. command_queue.push(RSG::material_storage, &RendererMaterialStorage::material_initialize, material);
  241. command_queue.push(RSG::material_storage, &RendererMaterialStorage::material_set_next_pass, material, p_next_pass);
  242. command_queue.push(RSG::material_storage, &RendererMaterialStorage::material_set_render_priority, material, p_render_priority);
  243. command_queue.push(RSG::material_storage, &RendererMaterialStorage::material_set_shader, material, p_shader);
  244. }
  245. return material;
  246. }
  247. FUNC2(material_set_shader, RID, RID)
  248. FUNC3(material_set_param, RID, const StringName &, const Variant &)
  249. FUNC2RC(Variant, material_get_param, RID, const StringName &)
  250. FUNC2(material_set_render_priority, RID, int)
  251. FUNC2(material_set_next_pass, RID, RID)
  252. /* MESH API */
  253. //from now on, calls forwarded to this singleton
  254. #undef ServerName
  255. #undef server_name
  256. #define ServerName RendererMeshStorage
  257. #define server_name RSG::mesh_storage
  258. virtual RID mesh_create_from_surfaces(const Vector<SurfaceData> &p_surfaces, int p_blend_shape_count = 0) override {
  259. RID mesh = RSG::mesh_storage->mesh_allocate();
  260. bool using_server_thread = Thread::get_caller_id() == server_thread;
  261. if (using_server_thread || RSG::rasterizer->can_create_resources_async()) {
  262. if (using_server_thread) {
  263. command_queue.flush_if_pending();
  264. }
  265. RSG::mesh_storage->mesh_initialize(mesh);
  266. RSG::mesh_storage->mesh_set_blend_shape_count(mesh, p_blend_shape_count);
  267. for (int i = 0; i < p_surfaces.size(); i++) {
  268. RSG::mesh_storage->mesh_add_surface(mesh, p_surfaces[i]);
  269. }
  270. RSG::scene->mesh_generate_pipelines(mesh, using_server_thread);
  271. } else {
  272. command_queue.push(RSG::mesh_storage, &RendererMeshStorage::mesh_initialize, mesh);
  273. command_queue.push(RSG::mesh_storage, &RendererMeshStorage::mesh_set_blend_shape_count, mesh, p_blend_shape_count);
  274. for (int i = 0; i < p_surfaces.size(); i++) {
  275. command_queue.push(RSG::mesh_storage, &RendererMeshStorage::mesh_add_surface, mesh, p_surfaces[i]);
  276. }
  277. command_queue.push(RSG::scene, &RenderingMethod::mesh_generate_pipelines, mesh, true);
  278. }
  279. return mesh;
  280. }
  281. FUNC2(mesh_set_blend_shape_count, RID, int)
  282. FUNCRIDSPLIT(mesh)
  283. FUNC2(mesh_add_surface, RID, const SurfaceData &)
  284. FUNC1RC(int, mesh_get_blend_shape_count, RID)
  285. FUNC2(mesh_set_blend_shape_mode, RID, BlendShapeMode)
  286. FUNC1RC(BlendShapeMode, mesh_get_blend_shape_mode, RID)
  287. FUNC4(mesh_surface_update_vertex_region, RID, int, int, const Vector<uint8_t> &)
  288. FUNC4(mesh_surface_update_attribute_region, RID, int, int, const Vector<uint8_t> &)
  289. FUNC4(mesh_surface_update_skin_region, RID, int, int, const Vector<uint8_t> &)
  290. FUNC3(mesh_surface_set_material, RID, int, RID)
  291. FUNC2RC(RID, mesh_surface_get_material, RID, int)
  292. FUNC2RC(SurfaceData, mesh_get_surface, RID, int)
  293. FUNC1RC(int, mesh_get_surface_count, RID)
  294. FUNC2(mesh_set_custom_aabb, RID, const AABB &)
  295. FUNC1RC(AABB, mesh_get_custom_aabb, RID)
  296. FUNC2(mesh_set_path, RID, const String &)
  297. FUNC1RC(String, mesh_get_path, RID)
  298. FUNC2(mesh_set_shadow_mesh, RID, RID)
  299. FUNC1(mesh_clear, RID)
  300. /* MULTIMESH API */
  301. FUNCRIDSPLIT(multimesh)
  302. FUNC5(multimesh_allocate_data, RID, int, MultimeshTransformFormat, bool, bool)
  303. FUNC1RC(int, multimesh_get_instance_count, RID)
  304. FUNC2(multimesh_set_mesh, RID, RID)
  305. FUNC3(multimesh_instance_set_transform, RID, int, const Transform3D &)
  306. FUNC3(multimesh_instance_set_transform_2d, RID, int, const Transform2D &)
  307. FUNC3(multimesh_instance_set_color, RID, int, const Color &)
  308. FUNC3(multimesh_instance_set_custom_data, RID, int, const Color &)
  309. FUNC2(multimesh_set_custom_aabb, RID, const AABB &)
  310. FUNC1RC(AABB, multimesh_get_custom_aabb, RID)
  311. FUNC1RC(RID, multimesh_get_mesh, RID)
  312. FUNC1RC(AABB, multimesh_get_aabb, RID)
  313. FUNC2RC(Transform3D, multimesh_instance_get_transform, RID, int)
  314. FUNC2RC(Transform2D, multimesh_instance_get_transform_2d, RID, int)
  315. FUNC2RC(Color, multimesh_instance_get_color, RID, int)
  316. FUNC2RC(Color, multimesh_instance_get_custom_data, RID, int)
  317. FUNC2(multimesh_set_buffer, RID, const Vector<float> &)
  318. FUNC1RC(RID, multimesh_get_buffer_rd_rid, RID)
  319. FUNC1RC(Vector<float>, multimesh_get_buffer, RID)
  320. FUNC3(multimesh_set_buffer_interpolated, RID, const Vector<float> &, const Vector<float> &)
  321. FUNC2(multimesh_set_physics_interpolated, RID, bool)
  322. FUNC2(multimesh_set_physics_interpolation_quality, RID, MultimeshPhysicsInterpolationQuality)
  323. FUNC2(multimesh_instance_reset_physics_interpolation, RID, int)
  324. FUNC2(multimesh_set_visible_instances, RID, int)
  325. FUNC1RC(int, multimesh_get_visible_instances, RID)
  326. /* SKELETON API */
  327. FUNCRIDSPLIT(skeleton)
  328. FUNC3(skeleton_allocate_data, RID, int, bool)
  329. FUNC1RC(int, skeleton_get_bone_count, RID)
  330. FUNC3(skeleton_bone_set_transform, RID, int, const Transform3D &)
  331. FUNC2RC(Transform3D, skeleton_bone_get_transform, RID, int)
  332. FUNC3(skeleton_bone_set_transform_2d, RID, int, const Transform2D &)
  333. FUNC2RC(Transform2D, skeleton_bone_get_transform_2d, RID, int)
  334. FUNC2(skeleton_set_base_transform_2d, RID, const Transform2D &)
  335. /* Light API */
  336. #undef ServerName
  337. #undef server_name
  338. #define ServerName RendererLightStorage
  339. #define server_name RSG::light_storage
  340. FUNCRIDSPLIT(directional_light)
  341. FUNCRIDSPLIT(omni_light)
  342. FUNCRIDSPLIT(spot_light)
  343. FUNC2(light_set_color, RID, const Color &)
  344. FUNC3(light_set_param, RID, LightParam, float)
  345. FUNC2(light_set_shadow, RID, bool)
  346. FUNC2(light_set_projector, RID, RID)
  347. FUNC2(light_set_negative, RID, bool)
  348. FUNC2(light_set_cull_mask, RID, uint32_t)
  349. FUNC5(light_set_distance_fade, RID, bool, float, float, float)
  350. FUNC2(light_set_reverse_cull_face_mode, RID, bool)
  351. FUNC2(light_set_shadow_caster_mask, RID, uint32_t)
  352. FUNC2(light_set_bake_mode, RID, LightBakeMode)
  353. FUNC2(light_set_max_sdfgi_cascade, RID, uint32_t)
  354. FUNC2(light_omni_set_shadow_mode, RID, LightOmniShadowMode)
  355. FUNC2(light_directional_set_shadow_mode, RID, LightDirectionalShadowMode)
  356. FUNC2(light_directional_set_blend_splits, RID, bool)
  357. FUNC2(light_directional_set_sky_mode, RID, LightDirectionalSkyMode)
  358. /* PROBE API */
  359. FUNCRIDSPLIT(reflection_probe)
  360. FUNC2(reflection_probe_set_update_mode, RID, ReflectionProbeUpdateMode)
  361. FUNC2(reflection_probe_set_intensity, RID, float)
  362. FUNC2(reflection_probe_set_ambient_color, RID, const Color &)
  363. FUNC2(reflection_probe_set_ambient_energy, RID, float)
  364. FUNC2(reflection_probe_set_ambient_mode, RID, ReflectionProbeAmbientMode)
  365. FUNC2(reflection_probe_set_max_distance, RID, float)
  366. FUNC2(reflection_probe_set_size, RID, const Vector3 &)
  367. FUNC2(reflection_probe_set_origin_offset, RID, const Vector3 &)
  368. FUNC2(reflection_probe_set_as_interior, RID, bool)
  369. FUNC2(reflection_probe_set_enable_box_projection, RID, bool)
  370. FUNC2(reflection_probe_set_enable_shadows, RID, bool)
  371. FUNC2(reflection_probe_set_cull_mask, RID, uint32_t)
  372. FUNC2(reflection_probe_set_reflection_mask, RID, uint32_t)
  373. FUNC2(reflection_probe_set_resolution, RID, int)
  374. FUNC2(reflection_probe_set_mesh_lod_threshold, RID, float)
  375. /* LIGHTMAP */
  376. FUNCRIDSPLIT(lightmap)
  377. FUNC3(lightmap_set_textures, RID, RID, bool)
  378. FUNC2(lightmap_set_probe_bounds, RID, const AABB &)
  379. FUNC2(lightmap_set_probe_interior, RID, bool)
  380. FUNC5(lightmap_set_probe_capture_data, RID, const PackedVector3Array &, const PackedColorArray &, const PackedInt32Array &, const PackedInt32Array &)
  381. FUNC2(lightmap_set_baked_exposure_normalization, RID, float)
  382. FUNC1RC(PackedVector3Array, lightmap_get_probe_capture_points, RID)
  383. FUNC1RC(PackedColorArray, lightmap_get_probe_capture_sh, RID)
  384. FUNC1RC(PackedInt32Array, lightmap_get_probe_capture_tetrahedra, RID)
  385. FUNC1RC(PackedInt32Array, lightmap_get_probe_capture_bsp_tree, RID)
  386. FUNC1(lightmap_set_probe_capture_update_speed, float)
  387. /* Shadow Atlas */
  388. FUNC0R(RID, shadow_atlas_create)
  389. FUNC3(shadow_atlas_set_size, RID, int, bool)
  390. FUNC3(shadow_atlas_set_quadrant_subdivision, RID, int, int)
  391. FUNC2(directional_shadow_atlas_set_size, int, bool)
  392. /* DECAL API */
  393. #undef ServerName
  394. #undef server_name
  395. #define ServerName RendererTextureStorage
  396. #define server_name RSG::texture_storage
  397. FUNCRIDSPLIT(decal)
  398. FUNC2(decal_set_size, RID, const Vector3 &)
  399. FUNC3(decal_set_texture, RID, DecalTexture, RID)
  400. FUNC2(decal_set_emission_energy, RID, float)
  401. FUNC2(decal_set_albedo_mix, RID, float)
  402. FUNC2(decal_set_modulate, RID, const Color &)
  403. FUNC2(decal_set_cull_mask, RID, uint32_t)
  404. FUNC4(decal_set_distance_fade, RID, bool, float, float)
  405. FUNC3(decal_set_fade, RID, float, float)
  406. FUNC2(decal_set_normal_fade, RID, float)
  407. /* BAKED LIGHT API */
  408. //from now on, calls forwarded to this singleton
  409. #undef ServerName
  410. #undef server_name
  411. #define ServerName RendererGI
  412. #define server_name RSG::gi
  413. FUNCRIDSPLIT(voxel_gi)
  414. FUNC8(voxel_gi_allocate_data, RID, const Transform3D &, const AABB &, const Vector3i &, const Vector<uint8_t> &, const Vector<uint8_t> &, const Vector<uint8_t> &, const Vector<int> &)
  415. FUNC1RC(AABB, voxel_gi_get_bounds, RID)
  416. FUNC1RC(Vector3i, voxel_gi_get_octree_size, RID)
  417. FUNC1RC(Vector<uint8_t>, voxel_gi_get_octree_cells, RID)
  418. FUNC1RC(Vector<uint8_t>, voxel_gi_get_data_cells, RID)
  419. FUNC1RC(Vector<uint8_t>, voxel_gi_get_distance_field, RID)
  420. FUNC1RC(Vector<int>, voxel_gi_get_level_counts, RID)
  421. FUNC1RC(Transform3D, voxel_gi_get_to_cell_xform, RID)
  422. FUNC2(voxel_gi_set_dynamic_range, RID, float)
  423. FUNC2(voxel_gi_set_propagation, RID, float)
  424. FUNC2(voxel_gi_set_energy, RID, float)
  425. FUNC2(voxel_gi_set_baked_exposure_normalization, RID, float)
  426. FUNC2(voxel_gi_set_bias, RID, float)
  427. FUNC2(voxel_gi_set_normal_bias, RID, float)
  428. FUNC2(voxel_gi_set_interior, RID, bool)
  429. FUNC2(voxel_gi_set_use_two_bounces, RID, bool)
  430. FUNC0(sdfgi_reset)
  431. /* PARTICLES */
  432. #undef ServerName
  433. #undef server_name
  434. #define ServerName RendererParticlesStorage
  435. #define server_name RSG::particles_storage
  436. FUNCRIDSPLIT(particles)
  437. FUNC2(particles_set_mode, RID, ParticlesMode)
  438. FUNC2(particles_set_emitting, RID, bool)
  439. FUNC1R(bool, particles_get_emitting, RID)
  440. FUNC2(particles_set_amount, RID, int)
  441. FUNC2(particles_set_amount_ratio, RID, float)
  442. FUNC2(particles_set_lifetime, RID, double)
  443. FUNC2(particles_set_one_shot, RID, bool)
  444. FUNC2(particles_set_pre_process_time, RID, double)
  445. FUNC2(particles_set_explosiveness_ratio, RID, float)
  446. FUNC2(particles_set_randomness_ratio, RID, float)
  447. FUNC2(particles_set_custom_aabb, RID, const AABB &)
  448. FUNC2(particles_set_speed_scale, RID, double)
  449. FUNC2(particles_set_use_local_coordinates, RID, bool)
  450. FUNC2(particles_set_process_material, RID, RID)
  451. FUNC2(particles_set_fixed_fps, RID, int)
  452. FUNC2(particles_set_interpolate, RID, bool)
  453. FUNC2(particles_set_fractional_delta, RID, bool)
  454. FUNC1R(bool, particles_is_inactive, RID)
  455. FUNC3(particles_set_trails, RID, bool, float)
  456. FUNC2(particles_set_trail_bind_poses, RID, const Vector<Transform3D> &)
  457. FUNC1(particles_request_process, RID)
  458. FUNC1(particles_restart, RID)
  459. FUNC6(particles_emit, RID, const Transform3D &, const Vector3 &, const Color &, const Color &, uint32_t)
  460. FUNC2(particles_set_subemitter, RID, RID)
  461. FUNC2(particles_set_collision_base_size, RID, float)
  462. FUNC2(particles_set_transform_align, RID, RS::ParticlesTransformAlign)
  463. FUNC2(particles_set_draw_order, RID, RS::ParticlesDrawOrder)
  464. FUNC2(particles_set_draw_passes, RID, int)
  465. FUNC3(particles_set_draw_pass_mesh, RID, int, RID)
  466. FUNC1R(AABB, particles_get_current_aabb, RID)
  467. FUNC2(particles_set_emission_transform, RID, const Transform3D &)
  468. FUNC2(particles_set_emitter_velocity, RID, const Vector3 &)
  469. FUNC2(particles_set_interp_to_end, RID, float)
  470. /* PARTICLES COLLISION */
  471. FUNCRIDSPLIT(particles_collision)
  472. FUNC2(particles_collision_set_collision_type, RID, ParticlesCollisionType)
  473. FUNC2(particles_collision_set_cull_mask, RID, uint32_t)
  474. FUNC2(particles_collision_set_sphere_radius, RID, real_t)
  475. FUNC2(particles_collision_set_box_extents, RID, const Vector3 &)
  476. FUNC2(particles_collision_set_attractor_strength, RID, real_t)
  477. FUNC2(particles_collision_set_attractor_directionality, RID, real_t)
  478. FUNC2(particles_collision_set_attractor_attenuation, RID, real_t)
  479. FUNC2(particles_collision_set_field_texture, RID, RID)
  480. FUNC1(particles_collision_height_field_update, RID)
  481. FUNC2(particles_collision_set_height_field_resolution, RID, ParticlesCollisionHeightfieldResolution)
  482. /* FOG VOLUME */
  483. #undef ServerName
  484. #undef server_name
  485. #define ServerName RendererFog
  486. #define server_name RSG::fog
  487. FUNCRIDSPLIT(fog_volume)
  488. FUNC2(fog_volume_set_shape, RID, FogVolumeShape)
  489. FUNC2(fog_volume_set_size, RID, const Vector3 &)
  490. FUNC2(fog_volume_set_material, RID, RID)
  491. /* VISIBILITY_NOTIFIER */
  492. #undef ServerName
  493. #undef server_name
  494. #define ServerName RendererUtilities
  495. #define server_name RSG::utilities
  496. FUNCRIDSPLIT(visibility_notifier)
  497. FUNC2(visibility_notifier_set_aabb, RID, const AABB &)
  498. FUNC3(visibility_notifier_set_callbacks, RID, const Callable &, const Callable &)
  499. #undef server_name
  500. #undef ServerName
  501. //from now on, calls forwarded to this singleton
  502. #define ServerName RenderingMethod
  503. #define server_name RSG::scene
  504. /* CAMERA API */
  505. FUNCRIDSPLIT(camera)
  506. FUNC4(camera_set_perspective, RID, float, float, float)
  507. FUNC4(camera_set_orthogonal, RID, float, float, float)
  508. FUNC5(camera_set_frustum, RID, float, Vector2, float, float)
  509. FUNC2(camera_set_transform, RID, const Transform3D &)
  510. FUNC2(camera_set_cull_mask, RID, uint32_t)
  511. FUNC2(camera_set_environment, RID, RID)
  512. FUNC2(camera_set_camera_attributes, RID, RID)
  513. FUNC2(camera_set_compositor, RID, RID)
  514. FUNC2(camera_set_use_vertical_aspect, RID, bool)
  515. /* OCCLUDER */
  516. FUNCRIDSPLIT(occluder)
  517. FUNC3(occluder_set_mesh, RID, const PackedVector3Array &, const PackedInt32Array &)
  518. #undef server_name
  519. #undef ServerName
  520. //from now on, calls forwarded to this singleton
  521. #define ServerName RendererViewport
  522. #define server_name RSG::viewport
  523. /* VIEWPORT TARGET API */
  524. FUNCRIDSPLIT(viewport)
  525. FUNC2(viewport_set_use_xr, RID, bool)
  526. FUNC3(viewport_set_size, RID, int, int)
  527. FUNC2(viewport_set_active, RID, bool)
  528. FUNC2(viewport_set_parent_viewport, RID, RID)
  529. FUNC2(viewport_set_clear_mode, RID, ViewportClearMode)
  530. FUNC3(viewport_attach_to_screen, RID, const Rect2 &, int)
  531. FUNC2(viewport_set_render_direct_to_screen, RID, bool)
  532. FUNC2(viewport_set_scaling_3d_mode, RID, ViewportScaling3DMode)
  533. FUNC2(viewport_set_scaling_3d_scale, RID, float)
  534. FUNC2(viewport_set_fsr_sharpness, RID, float)
  535. FUNC2(viewport_set_texture_mipmap_bias, RID, float)
  536. FUNC2(viewport_set_update_mode, RID, ViewportUpdateMode)
  537. FUNC1RC(ViewportUpdateMode, viewport_get_update_mode, RID)
  538. FUNC1RC(RID, viewport_get_render_target, RID)
  539. FUNC1RC(RID, viewport_get_texture, RID)
  540. FUNC2(viewport_set_disable_2d, RID, bool)
  541. FUNC2(viewport_set_environment_mode, RID, ViewportEnvironmentMode)
  542. FUNC2(viewport_set_disable_3d, RID, bool)
  543. FUNC2(viewport_set_canvas_cull_mask, RID, uint32_t)
  544. FUNC2(viewport_attach_camera, RID, RID)
  545. FUNC2(viewport_set_scenario, RID, RID)
  546. FUNC2(viewport_attach_canvas, RID, RID)
  547. FUNC2(viewport_remove_canvas, RID, RID)
  548. FUNC3(viewport_set_canvas_transform, RID, RID, const Transform2D &)
  549. FUNC2(viewport_set_transparent_background, RID, bool)
  550. FUNC2(viewport_set_use_hdr_2d, RID, bool)
  551. FUNC1RC(bool, viewport_is_using_hdr_2d, RID)
  552. FUNC2(viewport_set_snap_2d_transforms_to_pixel, RID, bool)
  553. FUNC2(viewport_set_snap_2d_vertices_to_pixel, RID, bool)
  554. FUNC2(viewport_set_default_canvas_item_texture_filter, RID, CanvasItemTextureFilter)
  555. FUNC2(viewport_set_default_canvas_item_texture_repeat, RID, CanvasItemTextureRepeat)
  556. FUNC2(viewport_set_global_canvas_transform, RID, const Transform2D &)
  557. FUNC4(viewport_set_canvas_stacking, RID, RID, int, int)
  558. FUNC3(viewport_set_positional_shadow_atlas_size, RID, int, bool)
  559. FUNC3(viewport_set_sdf_oversize_and_scale, RID, ViewportSDFOversize, ViewportSDFScale)
  560. FUNC3(viewport_set_positional_shadow_atlas_quadrant_subdivision, RID, int, int)
  561. FUNC2(viewport_set_msaa_2d, RID, ViewportMSAA)
  562. FUNC2(viewport_set_msaa_3d, RID, ViewportMSAA)
  563. FUNC2(viewport_set_screen_space_aa, RID, ViewportScreenSpaceAA)
  564. FUNC2(viewport_set_use_taa, RID, bool)
  565. FUNC2(viewport_set_use_debanding, RID, bool)
  566. FUNC2(viewport_set_use_occlusion_culling, RID, bool)
  567. FUNC1(viewport_set_occlusion_rays_per_thread, int)
  568. FUNC1(viewport_set_occlusion_culling_build_quality, ViewportOcclusionCullingBuildQuality)
  569. FUNC2(viewport_set_mesh_lod_threshold, RID, float)
  570. FUNC3R(int, viewport_get_render_info, RID, ViewportRenderInfoType, ViewportRenderInfo)
  571. FUNC2(viewport_set_debug_draw, RID, ViewportDebugDraw)
  572. FUNC2(viewport_set_measure_render_time, RID, bool)
  573. FUNC1RC(double, viewport_get_measured_render_time_cpu, RID)
  574. FUNC1RC(double, viewport_get_measured_render_time_gpu, RID)
  575. FUNC1RC(RID, viewport_find_from_screen_attachment, DisplayServer::WindowID)
  576. FUNC2(call_set_vsync_mode, DisplayServer::VSyncMode, DisplayServer::WindowID)
  577. FUNC2(viewport_set_vrs_mode, RID, ViewportVRSMode)
  578. FUNC2(viewport_set_vrs_update_mode, RID, ViewportVRSUpdateMode)
  579. FUNC2(viewport_set_vrs_texture, RID, RID)
  580. /* COMPOSITOR EFFECT */
  581. #undef server_name
  582. #undef ServerName
  583. //from now on, calls forwarded to this singleton
  584. #define ServerName RenderingMethod
  585. #define server_name RSG::scene
  586. FUNCRIDSPLIT(compositor_effect)
  587. FUNC2(compositor_effect_set_enabled, RID, bool)
  588. FUNC3(compositor_effect_set_callback, RID, CompositorEffectCallbackType, const Callable &)
  589. FUNC3(compositor_effect_set_flag, RID, CompositorEffectFlags, bool)
  590. /* COMPOSITOR */
  591. FUNC2(compositor_set_compositor_effects, RID, const TypedArray<RID> &)
  592. FUNCRIDSPLIT(compositor)
  593. /* ENVIRONMENT API */
  594. FUNC1(voxel_gi_set_quality, VoxelGIQuality)
  595. /* SKY API */
  596. FUNCRIDSPLIT(sky)
  597. FUNC2(sky_set_radiance_size, RID, int)
  598. FUNC2(sky_set_mode, RID, SkyMode)
  599. FUNC2(sky_set_material, RID, RID)
  600. FUNC4R(Ref<Image>, sky_bake_panorama, RID, float, bool, const Size2i &)
  601. /* ENVIRONMENT */
  602. FUNCRIDSPLIT(environment)
  603. FUNC2(environment_set_background, RID, EnvironmentBG)
  604. FUNC2(environment_set_sky, RID, RID)
  605. FUNC2(environment_set_sky_custom_fov, RID, float)
  606. FUNC2(environment_set_sky_orientation, RID, const Basis &)
  607. FUNC2(environment_set_bg_color, RID, const Color &)
  608. FUNC3(environment_set_bg_energy, RID, float, float)
  609. FUNC2(environment_set_canvas_max_layer, RID, int)
  610. FUNC6(environment_set_ambient_light, RID, const Color &, EnvironmentAmbientSource, float, float, EnvironmentReflectionSource)
  611. FUNC2(environment_set_camera_feed_id, RID, int)
  612. FUNC6(environment_set_ssr, RID, bool, int, float, float, float)
  613. FUNC1(environment_set_ssr_roughness_quality, EnvironmentSSRRoughnessQuality)
  614. FUNC10(environment_set_ssao, RID, bool, float, float, float, float, float, float, float, float)
  615. FUNC6(environment_set_ssao_quality, EnvironmentSSAOQuality, bool, float, int, float, float)
  616. FUNC6(environment_set_ssil, RID, bool, float, float, float, float)
  617. FUNC6(environment_set_ssil_quality, EnvironmentSSILQuality, bool, float, int, float, float)
  618. FUNC13(environment_set_glow, RID, bool, Vector<float>, float, float, float, float, EnvironmentGlowBlendMode, float, float, float, float, RID)
  619. FUNC1(environment_glow_set_use_bicubic_upscale, bool)
  620. FUNC4(environment_set_tonemap, RID, EnvironmentToneMapper, float, float)
  621. FUNC7(environment_set_adjustment, RID, bool, float, float, float, bool, RID)
  622. FUNC11(environment_set_fog, RID, bool, const Color &, float, float, float, float, float, float, float, EnvironmentFogMode)
  623. FUNC4(environment_set_fog_depth, RID, float, float, float)
  624. FUNC14(environment_set_volumetric_fog, RID, bool, float, const Color &, const Color &, float, float, float, float, float, bool, float, float, float)
  625. FUNC2(environment_set_volumetric_fog_volume_size, int, int)
  626. FUNC1(environment_set_volumetric_fog_filter_active, bool)
  627. FUNC11(environment_set_sdfgi, RID, bool, int, float, EnvironmentSDFGIYScale, bool, float, bool, float, float, float)
  628. FUNC1(environment_set_sdfgi_ray_count, EnvironmentSDFGIRayCount)
  629. FUNC1(environment_set_sdfgi_frames_to_converge, EnvironmentSDFGIFramesToConverge)
  630. FUNC1(environment_set_sdfgi_frames_to_update_light, EnvironmentSDFGIFramesToUpdateLight)
  631. FUNC3R(Ref<Image>, environment_bake_panorama, RID, bool, const Size2i &)
  632. FUNC3(screen_space_roughness_limiter_set_active, bool, float, float)
  633. FUNC1(sub_surface_scattering_set_quality, SubSurfaceScatteringQuality)
  634. FUNC2(sub_surface_scattering_set_scale, float, float)
  635. FUNC1(positional_soft_shadow_filter_set_quality, ShadowQuality);
  636. FUNC1(directional_soft_shadow_filter_set_quality, ShadowQuality);
  637. FUNC1(decals_set_filter, RS::DecalFilter);
  638. FUNC1(light_projectors_set_filter, RS::LightProjectorFilter);
  639. FUNC1(lightmaps_set_bicubic_filter, bool);
  640. /* CAMERA ATTRIBUTES */
  641. #undef server_name
  642. #undef ServerName
  643. //from now on, calls forwarded to this singleton
  644. #define ServerName RendererCameraAttributes
  645. #define server_name RSG::camera_attributes
  646. FUNCRIDSPLIT(camera_attributes)
  647. FUNC2(camera_attributes_set_dof_blur_quality, DOFBlurQuality, bool)
  648. FUNC1(camera_attributes_set_dof_blur_bokeh_shape, DOFBokehShape)
  649. FUNC8(camera_attributes_set_dof_blur, RID, bool, float, float, bool, float, float, float)
  650. FUNC3(camera_attributes_set_exposure, RID, float, float)
  651. FUNC6(camera_attributes_set_auto_exposure, RID, bool, float, float, float, float)
  652. /* SCENARIO API */
  653. #undef server_name
  654. #undef ServerName
  655. #define ServerName RenderingMethod
  656. #define server_name RSG::scene
  657. FUNCRIDSPLIT(scenario)
  658. FUNC2(scenario_set_environment, RID, RID)
  659. FUNC2(scenario_set_camera_attributes, RID, RID)
  660. FUNC2(scenario_set_fallback_environment, RID, RID)
  661. FUNC2(scenario_set_compositor, RID, RID)
  662. /* INSTANCING API */
  663. FUNCRIDSPLIT(instance)
  664. FUNC2(instance_set_base, RID, RID)
  665. FUNC2(instance_set_scenario, RID, RID)
  666. FUNC2(instance_set_layer_mask, RID, uint32_t)
  667. FUNC3(instance_set_pivot_data, RID, float, bool)
  668. FUNC2(instance_set_transform, RID, const Transform3D &)
  669. FUNC2(instance_set_interpolated, RID, bool)
  670. FUNC1(instance_reset_physics_interpolation, RID)
  671. FUNC2(instance_attach_object_instance_id, RID, ObjectID)
  672. FUNC3(instance_set_blend_shape_weight, RID, int, float)
  673. FUNC3(instance_set_surface_override_material, RID, int, RID)
  674. FUNC2(instance_set_visible, RID, bool)
  675. FUNC2(instance_set_custom_aabb, RID, AABB)
  676. FUNC2(instance_attach_skeleton, RID, RID)
  677. FUNC2(instance_set_extra_visibility_margin, RID, real_t)
  678. FUNC2(instance_set_visibility_parent, RID, RID)
  679. FUNC2(instance_set_ignore_culling, RID, bool)
  680. // don't use these in a game!
  681. FUNC2RC(Vector<ObjectID>, instances_cull_aabb, const AABB &, RID)
  682. FUNC3RC(Vector<ObjectID>, instances_cull_ray, const Vector3 &, const Vector3 &, RID)
  683. FUNC2RC(Vector<ObjectID>, instances_cull_convex, const Vector<Plane> &, RID)
  684. FUNC3(instance_geometry_set_flag, RID, InstanceFlags, bool)
  685. FUNC2(instance_geometry_set_cast_shadows_setting, RID, ShadowCastingSetting)
  686. FUNC2(instance_geometry_set_material_override, RID, RID)
  687. FUNC2(instance_geometry_set_material_overlay, RID, RID)
  688. FUNC6(instance_geometry_set_visibility_range, RID, float, float, float, float, VisibilityRangeFadeMode)
  689. FUNC4(instance_geometry_set_lightmap, RID, RID, const Rect2 &, int)
  690. FUNC2(instance_geometry_set_lod_bias, RID, float)
  691. FUNC2(instance_geometry_set_transparency, RID, float)
  692. FUNC3(instance_geometry_set_shader_parameter, RID, const StringName &, const Variant &)
  693. FUNC2RC(Variant, instance_geometry_get_shader_parameter, RID, const StringName &)
  694. FUNC2RC(Variant, instance_geometry_get_shader_parameter_default_value, RID, const StringName &)
  695. FUNC2C(instance_geometry_get_shader_parameter_list, RID, List<PropertyInfo> *)
  696. FUNC3R(TypedArray<Image>, bake_render_uv2, RID, const TypedArray<RID> &, const Size2i &)
  697. FUNC1(gi_set_use_half_resolution, bool)
  698. #undef server_name
  699. #undef ServerName
  700. //from now on, calls forwarded to this singleton
  701. #define ServerName RendererCanvasCull
  702. #define server_name RSG::canvas
  703. /* CANVAS (2D) */
  704. FUNCRIDSPLIT(canvas)
  705. FUNC3(canvas_set_item_mirroring, RID, RID, const Point2 &)
  706. FUNC3(canvas_set_item_repeat, RID, const Point2 &, int)
  707. FUNC2(canvas_set_modulate, RID, const Color &)
  708. FUNC3(canvas_set_parent, RID, RID, float)
  709. FUNC1(canvas_set_disable_scale, bool)
  710. FUNCRIDSPLIT(canvas_texture)
  711. FUNC3(canvas_texture_set_channel, RID, CanvasTextureChannel, RID)
  712. FUNC3(canvas_texture_set_shading_parameters, RID, const Color &, float)
  713. FUNC2(canvas_texture_set_texture_filter, RID, CanvasItemTextureFilter)
  714. FUNC2(canvas_texture_set_texture_repeat, RID, CanvasItemTextureRepeat)
  715. FUNCRIDSPLIT(canvas_item)
  716. FUNC2(canvas_item_set_parent, RID, RID)
  717. FUNC2(canvas_item_set_default_texture_filter, RID, CanvasItemTextureFilter)
  718. FUNC2(canvas_item_set_default_texture_repeat, RID, CanvasItemTextureRepeat)
  719. FUNC2(canvas_item_set_visible, RID, bool)
  720. FUNC2(canvas_item_set_light_mask, RID, int)
  721. FUNC2(canvas_item_set_visibility_layer, RID, uint32_t)
  722. FUNC2(canvas_item_set_update_when_visible, RID, bool)
  723. FUNC2(canvas_item_set_transform, RID, const Transform2D &)
  724. FUNC2(canvas_item_set_clip, RID, bool)
  725. FUNC2(canvas_item_set_distance_field_mode, RID, bool)
  726. FUNC3(canvas_item_set_custom_rect, RID, bool, const Rect2 &)
  727. FUNC2(canvas_item_set_modulate, RID, const Color &)
  728. FUNC2(canvas_item_set_self_modulate, RID, const Color &)
  729. FUNC2(canvas_item_set_draw_behind_parent, RID, bool)
  730. FUNC6(canvas_item_add_line, RID, const Point2 &, const Point2 &, const Color &, float, bool)
  731. FUNC5(canvas_item_add_polyline, RID, const Vector<Point2> &, const Vector<Color> &, float, bool)
  732. FUNC5(canvas_item_add_multiline, RID, const Vector<Point2> &, const Vector<Color> &, float, bool)
  733. FUNC4(canvas_item_add_rect, RID, const Rect2 &, const Color &, bool)
  734. FUNC5(canvas_item_add_circle, RID, const Point2 &, float, const Color &, bool)
  735. FUNC6(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool)
  736. FUNC7(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, bool)
  737. FUNC8(canvas_item_add_msdf_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, int, float, float)
  738. FUNC5(canvas_item_add_lcd_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &)
  739. FUNC10(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &)
  740. FUNC5(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID)
  741. FUNC5(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID)
  742. FUNC9(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, const Vector<int> &, const Vector<float> &, RID, int)
  743. FUNC5(canvas_item_add_mesh, RID, const RID &, const Transform2D &, const Color &, RID)
  744. FUNC3(canvas_item_add_multimesh, RID, RID, RID)
  745. FUNC3(canvas_item_add_particles, RID, RID, RID)
  746. FUNC2(canvas_item_add_set_transform, RID, const Transform2D &)
  747. FUNC2(canvas_item_add_clip_ignore, RID, bool)
  748. FUNC5(canvas_item_add_animation_slice, RID, double, double, double, double)
  749. FUNC2(canvas_item_set_sort_children_by_y, RID, bool)
  750. FUNC2(canvas_item_set_z_index, RID, int)
  751. FUNC2(canvas_item_set_z_as_relative_to_parent, RID, bool)
  752. FUNC3(canvas_item_set_copy_to_backbuffer, RID, bool, const Rect2 &)
  753. FUNC2(canvas_item_attach_skeleton, RID, RID)
  754. FUNC1(canvas_item_clear, RID)
  755. FUNC2(canvas_item_set_draw_index, RID, int)
  756. FUNC2(canvas_item_set_material, RID, RID)
  757. FUNC2(canvas_item_set_use_parent_material, RID, bool)
  758. FUNC5(canvas_item_set_visibility_notifier, RID, bool, const Rect2 &, const Callable &, const Callable &)
  759. FUNC6(canvas_item_set_canvas_group_mode, RID, CanvasGroupMode, float, bool, float, bool)
  760. FUNC1(canvas_item_set_debug_redraw, bool)
  761. FUNC0RC(bool, canvas_item_get_debug_redraw)
  762. FUNC2(canvas_item_set_interpolated, RID, bool)
  763. FUNC1(canvas_item_reset_physics_interpolation, RID)
  764. FUNC2(canvas_item_transform_physics_interpolation, RID, const Transform2D &)
  765. FUNCRIDSPLIT(canvas_light)
  766. FUNC2(canvas_light_set_mode, RID, CanvasLightMode)
  767. FUNC2(canvas_light_attach_to_canvas, RID, RID)
  768. FUNC2(canvas_light_set_enabled, RID, bool)
  769. FUNC2(canvas_light_set_texture_scale, RID, float)
  770. FUNC2(canvas_light_set_transform, RID, const Transform2D &)
  771. FUNC2(canvas_light_set_texture, RID, RID)
  772. FUNC2(canvas_light_set_texture_offset, RID, const Vector2 &)
  773. FUNC2(canvas_light_set_color, RID, const Color &)
  774. FUNC2(canvas_light_set_height, RID, float)
  775. FUNC2(canvas_light_set_energy, RID, float)
  776. FUNC3(canvas_light_set_z_range, RID, int, int)
  777. FUNC3(canvas_light_set_layer_range, RID, int, int)
  778. FUNC2(canvas_light_set_item_cull_mask, RID, int)
  779. FUNC2(canvas_light_set_item_shadow_cull_mask, RID, int)
  780. FUNC2(canvas_light_set_directional_distance, RID, float)
  781. FUNC2(canvas_light_set_blend_mode, RID, CanvasLightBlendMode)
  782. FUNC2(canvas_light_set_shadow_enabled, RID, bool)
  783. FUNC2(canvas_light_set_shadow_filter, RID, CanvasLightShadowFilter)
  784. FUNC2(canvas_light_set_shadow_color, RID, const Color &)
  785. FUNC2(canvas_light_set_shadow_smooth, RID, float)
  786. FUNC2(canvas_light_set_interpolated, RID, bool)
  787. FUNC1(canvas_light_reset_physics_interpolation, RID)
  788. FUNC2(canvas_light_transform_physics_interpolation, RID, const Transform2D &)
  789. FUNCRIDSPLIT(canvas_light_occluder)
  790. FUNC2(canvas_light_occluder_attach_to_canvas, RID, RID)
  791. FUNC2(canvas_light_occluder_set_enabled, RID, bool)
  792. FUNC2(canvas_light_occluder_set_polygon, RID, RID)
  793. FUNC2(canvas_light_occluder_set_as_sdf_collision, RID, bool)
  794. FUNC2(canvas_light_occluder_set_transform, RID, const Transform2D &)
  795. FUNC2(canvas_light_occluder_set_light_mask, RID, int)
  796. FUNC2(canvas_light_occluder_set_interpolated, RID, bool)
  797. FUNC1(canvas_light_occluder_reset_physics_interpolation, RID)
  798. FUNC2(canvas_light_occluder_transform_physics_interpolation, RID, const Transform2D &)
  799. FUNCRIDSPLIT(canvas_occluder_polygon)
  800. FUNC3(canvas_occluder_polygon_set_shape, RID, const Vector<Vector2> &, bool)
  801. FUNC2(canvas_occluder_polygon_set_cull_mode, RID, CanvasOccluderPolygonCullMode)
  802. FUNC1(canvas_set_shadow_texture_size, int)
  803. FUNC1R(Rect2, _debug_canvas_item_get_rect, RID)
  804. /* GLOBAL SHADER UNIFORMS */
  805. #undef server_name
  806. #undef ServerName
  807. //from now on, calls forwarded to this singleton
  808. #define ServerName RendererMaterialStorage
  809. #define server_name RSG::material_storage
  810. FUNC3(global_shader_parameter_add, const StringName &, GlobalShaderParameterType, const Variant &)
  811. FUNC1(global_shader_parameter_remove, const StringName &)
  812. FUNC0RC(Vector<StringName>, global_shader_parameter_get_list)
  813. FUNC2(global_shader_parameter_set, const StringName &, const Variant &)
  814. FUNC2(global_shader_parameter_set_override, const StringName &, const Variant &)
  815. FUNC1RC(GlobalShaderParameterType, global_shader_parameter_get_type, const StringName &)
  816. FUNC1RC(Variant, global_shader_parameter_get, const StringName &)
  817. FUNC1(global_shader_parameters_load_settings, bool)
  818. FUNC0(global_shader_parameters_clear)
  819. /* COMPOSITOR */
  820. #undef server_name
  821. #undef ServerName
  822. #define ServerName RendererCompositor
  823. #define server_name RSG::rasterizer
  824. FUNC4S(set_boot_image, const Ref<Image> &, const Color &, bool, bool)
  825. /* STATUS INFORMATION */
  826. #undef server_name
  827. #undef ServerName
  828. /* UTILITIES */
  829. #define ServerName RendererUtilities
  830. #define server_name RSG::utilities
  831. FUNC0RC(String, get_video_adapter_name)
  832. FUNC0RC(String, get_video_adapter_vendor)
  833. FUNC0RC(String, get_video_adapter_api_version)
  834. #undef server_name
  835. #undef ServerName
  836. #undef WRITE_ACTION
  837. #undef SYNC_DEBUG
  838. #ifdef DEBUG_ENABLED
  839. #undef MAIN_THREAD_SYNC_WARN
  840. #endif
  841. virtual uint64_t get_rendering_info(RenderingInfo p_info) override;
  842. virtual RenderingDevice::DeviceType get_video_adapter_type() const override;
  843. virtual void set_frame_profiling_enabled(bool p_enable) override;
  844. virtual Vector<FrameProfileArea> get_frame_profile() override;
  845. virtual uint64_t get_frame_profile_frame() override;
  846. virtual RID get_test_cube() override;
  847. /* FREE */
  848. virtual void free(RID p_rid) override {
  849. if (Thread::get_caller_id() == server_thread) {
  850. command_queue.flush_if_pending();
  851. _free(p_rid);
  852. } else {
  853. command_queue.push(this, &RenderingServerDefault::_free, p_rid);
  854. }
  855. }
  856. /* INTERPOLATION */
  857. virtual void set_physics_interpolation_enabled(bool p_enabled) override;
  858. /* EVENT QUEUING */
  859. virtual void request_frame_drawn_callback(const Callable &p_callable) override;
  860. virtual void draw(bool p_swap_buffers, double frame_step) override;
  861. virtual void sync() override;
  862. virtual bool has_changed() const override;
  863. virtual void init() override;
  864. virtual void finish() override;
  865. virtual void tick() override;
  866. virtual void pre_draw(bool p_will_draw) override;
  867. virtual bool is_on_render_thread() override {
  868. return Thread::get_caller_id() == server_thread;
  869. }
  870. virtual void call_on_render_thread(const Callable &p_callable) override {
  871. if (Thread::get_caller_id() == server_thread) {
  872. command_queue.flush_if_pending();
  873. p_callable.call();
  874. } else {
  875. command_queue.push(this, &RenderingServerDefault::_call_on_render_thread, p_callable);
  876. }
  877. }
  878. /* TESTING */
  879. virtual double get_frame_setup_time_cpu() const override;
  880. virtual Color get_default_clear_color() override;
  881. virtual void set_default_clear_color(const Color &p_color) override;
  882. #ifndef DISABLE_DEPRECATED
  883. virtual bool has_feature(Features p_feature) const override;
  884. #endif
  885. virtual bool has_os_feature(const String &p_feature) const override;
  886. virtual void set_debug_generate_wireframes(bool p_generate) override;
  887. virtual bool is_low_end() const override;
  888. virtual void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) override;
  889. virtual void set_print_gpu_profile(bool p_enable) override;
  890. virtual Size2i get_maximum_viewport_size() const override;
  891. RenderingServerDefault(bool p_create_thread = false);
  892. ~RenderingServerDefault();
  893. };
  894. #endif // RENDERING_SERVER_DEFAULT_H