rendering_server_default.h 48 KB

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