rasterizer_dummy.h 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. /*************************************************************************/
  2. /* rasterizer_dummy.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
  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 RASTERIZER_DUMMY_H
  31. #define RASTERIZER_DUMMY_H
  32. #include "core/math/camera_matrix.h"
  33. #include "core/rid_owner.h"
  34. #include "core/self_list.h"
  35. #include "scene/resources/mesh.h"
  36. #include "servers/rendering/rasterizer.h"
  37. #include "servers/rendering_server.h"
  38. class RasterizerSceneDummy : public RasterizerScene {
  39. public:
  40. /* SHADOW ATLAS API */
  41. RID shadow_atlas_create() { return RID(); }
  42. void shadow_atlas_set_size(RID p_atlas, int p_size) {}
  43. void shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) {}
  44. bool shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) { return false; }
  45. void directional_shadow_atlas_set_size(int p_size) {}
  46. int get_directional_light_shadow_size(RID p_light_intance) { return 0; }
  47. void set_directional_shadow_count(int p_count) {}
  48. /* SKY API */
  49. RID sky_create() { return RID(); }
  50. void sky_set_radiance_size(RID p_sky, int p_radiance_size) {}
  51. void sky_set_mode(RID p_sky, RS::SkyMode p_samples) {}
  52. void sky_set_texture(RID p_sky, RID p_panorama) {}
  53. void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) {}
  54. void sky_set_material(RID p_sky, RID p_material) {}
  55. /* ENVIRONMENT API */
  56. RID environment_create() { return RID(); }
  57. void environment_set_background(RID p_env, RS::EnvironmentBG p_bg) {}
  58. void environment_set_sky(RID p_env, RID p_sky) {}
  59. void environment_set_sky_custom_fov(RID p_env, float p_scale) {}
  60. void environment_set_sky_orientation(RID p_env, const Basis &p_orientation) {}
  61. void environment_set_bg_color(RID p_env, const Color &p_color) {}
  62. void environment_set_bg_energy(RID p_env, float p_energy) {}
  63. void environment_set_canvas_max_layer(RID p_env, int p_max_layer) {}
  64. void environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient = RS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, RS::EnvironmentReflectionSource p_reflection_source = RS::ENV_REFLECTION_SOURCE_BG, const Color &p_ao_color = Color()) {}
  65. // FIXME: Disabled during Vulkan refactoring, should be ported.
  66. #if 0
  67. void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id) {}
  68. #endif
  69. void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {}
  70. void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) {}
  71. void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance, bool p_roughness) {}
  72. virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, RS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) {}
  73. virtual void environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size) {}
  74. void environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {}
  75. void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) {}
  76. void environment_set_fog(RID p_env, bool p_enable, const Color &p_color, const Color &p_sun_color, float p_sun_amount) {}
  77. void environment_set_fog_depth(RID p_env, bool p_enable, float p_depth_begin, float p_depth_end, float p_depth_curve, bool p_transmit, float p_transmit_curve) {}
  78. void environment_set_fog_height(RID p_env, bool p_enable, float p_min_height, float p_max_height, float p_height_curve) {}
  79. bool is_environment(RID p_env) const { return false; }
  80. RS::EnvironmentBG environment_get_background(RID p_env) const { return RS::ENV_BG_KEEP; }
  81. int environment_get_canvas_max_layer(RID p_env) const { return 0; }
  82. virtual RID camera_effects_create() { return RID(); }
  83. virtual void camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) {}
  84. virtual void camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) {}
  85. virtual void camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) {}
  86. virtual void camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) {}
  87. RID light_instance_create(RID p_light) { return RID(); }
  88. void light_instance_set_transform(RID p_light_instance, const Transform &p_transform) {}
  89. void light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform &p_transform, float p_far, float p_split, int p_pass, float p_bias_scale = 1.0) {}
  90. void light_instance_mark_visible(RID p_light_instance) {}
  91. RID reflection_atlas_create() { return RID(); }
  92. virtual void reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) {}
  93. RID reflection_probe_instance_create(RID p_probe) { return RID(); }
  94. void reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform) {}
  95. void reflection_probe_release_atlas_index(RID p_instance) {}
  96. bool reflection_probe_instance_needs_redraw(RID p_instance) { return false; }
  97. bool reflection_probe_instance_has_reflection(RID p_instance) { return false; }
  98. bool reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) { return false; }
  99. bool reflection_probe_instance_postprocess_step(RID p_instance) { return true; }
  100. virtual RID gi_probe_instance_create(RID p_gi_probe) { return RID(); }
  101. void gi_probe_instance_set_light_data(RID p_probe, RID p_base, RID p_data) {}
  102. void gi_probe_instance_set_transform_to_data(RID p_probe, const Transform &p_xform) {}
  103. virtual bool gi_probe_needs_update(RID p_probe) const { return false; }
  104. virtual void gi_probe_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, int p_dynamic_object_count, InstanceBase **p_dynamic_objects) {}
  105. virtual void render_scene(RID p_render_buffers, const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID *p_gi_probe_cull_result, int p_gi_probe_cull_count, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {}
  106. void render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count) {}
  107. virtual void render_material(const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID p_framebuffer, const Rect2i &p_region) {}
  108. void set_scene_pass(uint64_t p_pass) {}
  109. virtual void set_time(double p_time, double p_step) {}
  110. void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) {}
  111. virtual RID render_buffers_create() { return RID(); }
  112. virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa) {}
  113. virtual void screen_space_roughness_limiter_set_active(bool p_enable, float p_curve) {}
  114. virtual bool screen_space_roughness_limiter_is_active() const { return false; }
  115. bool free(RID p_rid) { return true; }
  116. virtual void update() {}
  117. RasterizerSceneDummy() {}
  118. ~RasterizerSceneDummy() {}
  119. };
  120. class RasterizerStorageDummy : public RasterizerStorage {
  121. public:
  122. /* TEXTURE API */
  123. struct DummyTexture {
  124. int width;
  125. int height;
  126. uint32_t flags;
  127. Image::Format format;
  128. Ref<Image> image;
  129. String path;
  130. };
  131. struct DummySurface {
  132. uint32_t format;
  133. RS::PrimitiveType primitive;
  134. Vector<uint8_t> array;
  135. int vertex_count;
  136. Vector<uint8_t> index_array;
  137. int index_count;
  138. AABB aabb;
  139. Vector<Vector<uint8_t>> blend_shapes;
  140. Vector<AABB> bone_aabbs;
  141. };
  142. struct DummyMesh {
  143. Vector<DummySurface> surfaces;
  144. int blend_shape_count;
  145. RS::BlendShapeMode blend_shape_mode;
  146. };
  147. mutable RID_PtrOwner<DummyTexture> texture_owner;
  148. mutable RID_PtrOwner<DummyMesh> mesh_owner;
  149. virtual RID texture_2d_create(const Ref<Image> &p_image) { return RID(); }
  150. virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) { return RID(); }
  151. virtual RID texture_3d_create(const Vector<Ref<Image>> &p_slices) { return RID(); }
  152. virtual RID texture_proxy_create(RID p_base) { return RID(); }
  153. virtual void texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) {}
  154. virtual void texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) {}
  155. virtual void texture_3d_update(RID p_texture, const Ref<Image> &p_image, int p_depth, int p_mipmap) {}
  156. virtual void texture_proxy_update(RID p_proxy, RID p_base) {}
  157. virtual RID texture_2d_placeholder_create() { return RID(); }
  158. virtual RID texture_2d_layered_placeholder_create() { return RID(); }
  159. virtual RID texture_3d_placeholder_create() { return RID(); }
  160. virtual Ref<Image> texture_2d_get(RID p_texture) const { return Ref<Image>(); }
  161. virtual Ref<Image> texture_2d_layer_get(RID p_texture, int p_layer) const { return Ref<Image>(); }
  162. virtual Ref<Image> texture_3d_slice_get(RID p_texture, int p_depth, int p_mipmap) const { return Ref<Image>(); }
  163. virtual void texture_replace(RID p_texture, RID p_by_texture) {}
  164. virtual void texture_set_size_override(RID p_texture, int p_width, int p_height) {}
  165. // FIXME: Disabled during Vulkan refactoring, should be ported.
  166. #if 0
  167. virtual void texture_bind(RID p_texture, uint32_t p_texture_no) = 0;
  168. #endif
  169. virtual void texture_set_path(RID p_texture, const String &p_path) {}
  170. virtual String texture_get_path(RID p_texture) const { return String(); }
  171. virtual void texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {}
  172. virtual void texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {}
  173. virtual void texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata) {}
  174. virtual void texture_debug_usage(List<RS::TextureInfo> *r_info) {}
  175. virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {}
  176. virtual Size2 texture_size_with_proxy(RID p_proxy) { return Size2(); }
  177. #if 0
  178. RID texture_create() {
  179. DummyTexture *texture = memnew(DummyTexture);
  180. ERR_FAIL_COND_V(!texture, RID());
  181. return texture_owner.make_rid(texture);
  182. }
  183. void texture_allocate(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, RenderingServer::TextureType p_type = RS::TEXTURE_TYPE_2D, uint32_t p_flags = RS::TEXTURE_FLAGS_DEFAULT) {
  184. DummyTexture *t = texture_owner.getornull(p_texture);
  185. ERR_FAIL_COND(!t);
  186. t->width = p_width;
  187. t->height = p_height;
  188. t->flags = p_flags;
  189. t->format = p_format;
  190. t->image = Ref<Image>(memnew(Image));
  191. t->image->create(p_width, p_height, false, p_format);
  192. }
  193. void texture_set_data(RID p_texture, const Ref<Image> &p_image, int p_level) {
  194. DummyTexture *t = texture_owner.getornull(p_texture);
  195. ERR_FAIL_COND(!t);
  196. t->width = p_image->get_width();
  197. t->height = p_image->get_height();
  198. t->format = p_image->get_format();
  199. t->image->create(t->width, t->height, false, t->format, p_image->get_data());
  200. }
  201. void texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, int p_level) {
  202. DummyTexture *t = texture_owner.getornull(p_texture);
  203. ERR_FAIL_COND(!t);
  204. ERR_FAIL_COND_MSG(p_image.is_null(), "It's not a reference to a valid Image object.");
  205. ERR_FAIL_COND(t->format != p_image->get_format());
  206. ERR_FAIL_COND(src_w <= 0 || src_h <= 0);
  207. ERR_FAIL_COND(src_x < 0 || src_y < 0 || src_x + src_w > p_image->get_width() || src_y + src_h > p_image->get_height());
  208. ERR_FAIL_COND(dst_x < 0 || dst_y < 0 || dst_x + src_w > t->width || dst_y + src_h > t->height);
  209. t->image->blit_rect(p_image, Rect2(src_x, src_y, src_w, src_h), Vector2(dst_x, dst_y));
  210. }
  211. Ref<Image> texture_get_data(RID p_texture, int p_level) const {
  212. DummyTexture *t = texture_owner.getornull(p_texture);
  213. ERR_FAIL_COND_V(!t, Ref<Image>());
  214. return t->image;
  215. }
  216. void texture_set_flags(RID p_texture, uint32_t p_flags) {
  217. DummyTexture *t = texture_owner.getornull(p_texture);
  218. ERR_FAIL_COND(!t);
  219. t->flags = p_flags;
  220. }
  221. uint32_t texture_get_flags(RID p_texture) const {
  222. DummyTexture *t = texture_owner.getornull(p_texture);
  223. ERR_FAIL_COND_V(!t, 0);
  224. return t->flags;
  225. }
  226. Image::Format texture_get_format(RID p_texture) const {
  227. DummyTexture *t = texture_owner.getornull(p_texture);
  228. ERR_FAIL_COND_V(!t, Image::FORMAT_RGB8);
  229. return t->format;
  230. }
  231. RenderingServer::TextureType texture_get_type(RID p_texture) const { return RS::TEXTURE_TYPE_2D; }
  232. uint32_t texture_get_texid(RID p_texture) const { return 0; }
  233. uint32_t texture_get_width(RID p_texture) const { return 0; }
  234. uint32_t texture_get_height(RID p_texture) const { return 0; }
  235. uint32_t texture_get_depth(RID p_texture) const { return 0; }
  236. void texture_set_size_override(RID p_texture, int p_width, int p_height, int p_depth_3d) {}
  237. void texture_bind(RID p_texture, uint32_t p_texture_no) {}
  238. void texture_set_path(RID p_texture, const String &p_path) {
  239. DummyTexture *t = texture_owner.getornull(p_texture);
  240. ERR_FAIL_COND(!t);
  241. t->path = p_path;
  242. }
  243. String texture_get_path(RID p_texture) const {
  244. DummyTexture *t = texture_owner.getornull(p_texture);
  245. ERR_FAIL_COND_V(!t, String());
  246. return t->path;
  247. }
  248. void texture_set_shrink_all_x2_on_set_data(bool p_enable) {}
  249. void texture_debug_usage(List<RS::TextureInfo> *r_info) {}
  250. RID texture_create_radiance_cubemap(RID p_source, int p_resolution = -1) const { return RID(); }
  251. void texture_set_detect_3d_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata) {}
  252. void texture_set_detect_srgb_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata) {}
  253. void texture_set_detect_normal_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata) {}
  254. void textures_keep_original(bool p_enable) {}
  255. void texture_set_proxy(RID p_proxy, RID p_base) {}
  256. virtual Size2 texture_size_with_proxy(RID p_texture) const { return Size2(); }
  257. void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {}
  258. #endif
  259. /* SKY API */
  260. RID sky_create() { return RID(); }
  261. void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) {}
  262. /* SHADER API */
  263. RID shader_create() { return RID(); }
  264. void shader_set_code(RID p_shader, const String &p_code) {}
  265. String shader_get_code(RID p_shader) const { return ""; }
  266. void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {}
  267. void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) {}
  268. RID shader_get_default_texture_param(RID p_shader, const StringName &p_name) const { return RID(); }
  269. virtual Variant shader_get_param_default(RID p_material, const StringName &p_param) const { return Variant(); }
  270. /* COMMON MATERIAL API */
  271. RID material_create() { return RID(); }
  272. void material_set_render_priority(RID p_material, int priority) {}
  273. void material_set_shader(RID p_shader_material, RID p_shader) {}
  274. void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {}
  275. Variant material_get_param(RID p_material, const StringName &p_param) const { return Variant(); }
  276. void material_set_next_pass(RID p_material, RID p_next_material) {}
  277. bool material_is_animated(RID p_material) { return false; }
  278. bool material_casts_shadows(RID p_material) { return false; }
  279. void material_update_dependency(RID p_material, RasterizerScene::InstanceBase *p_instance) {}
  280. /* MESH API */
  281. RID mesh_create() {
  282. DummyMesh *mesh = memnew(DummyMesh);
  283. ERR_FAIL_COND_V(!mesh, RID());
  284. mesh->blend_shape_count = 0;
  285. mesh->blend_shape_mode = RS::BLEND_SHAPE_MODE_NORMALIZED;
  286. return mesh_owner.make_rid(mesh);
  287. }
  288. void mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) {}
  289. #if 0
  290. void mesh_add_surface(RID p_mesh, uint32_t p_format, RS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes = Vector<Vector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) {
  291. DummyMesh *m = mesh_owner.getornull(p_mesh);
  292. ERR_FAIL_COND(!m);
  293. m->surfaces.push_back(DummySurface());
  294. DummySurface *s = &m->surfaces.write[m->surfaces.size() - 1];
  295. s->format = p_format;
  296. s->primitive = p_primitive;
  297. s->array = p_array;
  298. s->vertex_count = p_vertex_count;
  299. s->index_array = p_index_array;
  300. s->index_count = p_index_count;
  301. s->aabb = p_aabb;
  302. s->blend_shapes = p_blend_shapes;
  303. s->bone_aabbs = p_bone_aabbs;
  304. }
  305. void mesh_set_blend_shape_count(RID p_mesh, int p_amount) {
  306. DummyMesh *m = mesh_owner.getornull(p_mesh);
  307. ERR_FAIL_COND(!m);
  308. m->blend_shape_count = p_amount;
  309. }
  310. #endif
  311. int mesh_get_blend_shape_count(RID p_mesh) const {
  312. DummyMesh *m = mesh_owner.getornull(p_mesh);
  313. ERR_FAIL_COND_V(!m, 0);
  314. return m->blend_shape_count;
  315. }
  316. void mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) {
  317. DummyMesh *m = mesh_owner.getornull(p_mesh);
  318. ERR_FAIL_COND(!m);
  319. m->blend_shape_mode = p_mode;
  320. }
  321. RS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const {
  322. DummyMesh *m = mesh_owner.getornull(p_mesh);
  323. ERR_FAIL_COND_V(!m, RS::BLEND_SHAPE_MODE_NORMALIZED);
  324. return m->blend_shape_mode;
  325. }
  326. void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) {}
  327. void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) {}
  328. RID mesh_surface_get_material(RID p_mesh, int p_surface) const { return RID(); }
  329. #if 0
  330. int mesh_surface_get_array_len(RID p_mesh, int p_surface) const {
  331. DummyMesh *m = mesh_owner.getornull(p_mesh);
  332. ERR_FAIL_COND_V(!m, 0);
  333. return m->surfaces[p_surface].vertex_count;
  334. }
  335. int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const {
  336. DummyMesh *m = mesh_owner.getornull(p_mesh);
  337. ERR_FAIL_COND_V(!m, 0);
  338. return m->surfaces[p_surface].index_count;
  339. }
  340. Vector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const {
  341. DummyMesh *m = mesh_owner.getornull(p_mesh);
  342. ERR_FAIL_COND_V(!m, Vector<uint8_t>());
  343. return m->surfaces[p_surface].array;
  344. }
  345. Vector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const {
  346. DummyMesh *m = mesh_owner.getornull(p_mesh);
  347. ERR_FAIL_COND_V(!m, Vector<uint8_t>());
  348. return m->surfaces[p_surface].index_array;
  349. }
  350. uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const {
  351. DummyMesh *m = mesh_owner.getornull(p_mesh);
  352. ERR_FAIL_COND_V(!m, 0);
  353. return m->surfaces[p_surface].format;
  354. }
  355. RS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const {
  356. DummyMesh *m = mesh_owner.getornull(p_mesh);
  357. ERR_FAIL_COND_V(!m, RS::PRIMITIVE_POINTS);
  358. return m->surfaces[p_surface].primitive;
  359. }
  360. AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const {
  361. DummyMesh *m = mesh_owner.getornull(p_mesh);
  362. ERR_FAIL_COND_V(!m, AABB());
  363. return m->surfaces[p_surface].aabb;
  364. }
  365. Vector<Vector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const {
  366. DummyMesh *m = mesh_owner.getornull(p_mesh);
  367. ERR_FAIL_COND_V(!m, Vector<Vector<uint8_t> >());
  368. return m->surfaces[p_surface].blend_shapes;
  369. }
  370. Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const {
  371. DummyMesh *m = mesh_owner.getornull(p_mesh);
  372. ERR_FAIL_COND_V(!m, Vector<AABB>());
  373. return m->surfaces[p_surface].bone_aabbs;
  374. }
  375. void mesh_remove_surface(RID p_mesh, int p_index) {
  376. DummyMesh *m = mesh_owner.getornull(p_mesh);
  377. ERR_FAIL_COND(!m);
  378. ERR_FAIL_COND(p_index >= m->surfaces.size());
  379. m->surfaces.remove(p_index);
  380. }
  381. #endif
  382. RS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const { return RS::SurfaceData(); }
  383. int mesh_get_surface_count(RID p_mesh) const {
  384. DummyMesh *m = mesh_owner.getornull(p_mesh);
  385. ERR_FAIL_COND_V(!m, 0);
  386. return m->surfaces.size();
  387. }
  388. void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) {}
  389. AABB mesh_get_custom_aabb(RID p_mesh) const { return AABB(); }
  390. AABB mesh_get_aabb(RID p_mesh, RID p_skeleton = RID()) { return AABB(); }
  391. void mesh_clear(RID p_mesh) {}
  392. /* MULTIMESH API */
  393. virtual RID multimesh_create() { return RID(); }
  394. virtual void multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false) {}
  395. int multimesh_get_instance_count(RID p_multimesh) const { return 0; }
  396. void multimesh_set_mesh(RID p_multimesh, RID p_mesh) {}
  397. void multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform &p_transform) {}
  398. void multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) {}
  399. void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) {}
  400. void multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) {}
  401. RID multimesh_get_mesh(RID p_multimesh) const { return RID(); }
  402. AABB multimesh_get_aabb(RID p_multimesh) const { return AABB(); }
  403. Transform multimesh_instance_get_transform(RID p_multimesh, int p_index) const { return Transform(); }
  404. Transform2D multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const { return Transform2D(); }
  405. Color multimesh_instance_get_color(RID p_multimesh, int p_index) const { return Color(); }
  406. Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const { return Color(); }
  407. virtual void multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) {}
  408. virtual Vector<float> multimesh_get_buffer(RID p_multimesh) const { return Vector<float>(); }
  409. void multimesh_set_visible_instances(RID p_multimesh, int p_visible) {}
  410. int multimesh_get_visible_instances(RID p_multimesh) const { return 0; }
  411. /* IMMEDIATE API */
  412. RID immediate_create() { return RID(); }
  413. void immediate_begin(RID p_immediate, RS::PrimitiveType p_rimitive, RID p_texture = RID()) {}
  414. void immediate_vertex(RID p_immediate, const Vector3 &p_vertex) {}
  415. void immediate_normal(RID p_immediate, const Vector3 &p_normal) {}
  416. void immediate_tangent(RID p_immediate, const Plane &p_tangent) {}
  417. void immediate_color(RID p_immediate, const Color &p_color) {}
  418. void immediate_uv(RID p_immediate, const Vector2 &tex_uv) {}
  419. void immediate_uv2(RID p_immediate, const Vector2 &tex_uv) {}
  420. void immediate_end(RID p_immediate) {}
  421. void immediate_clear(RID p_immediate) {}
  422. void immediate_set_material(RID p_immediate, RID p_material) {}
  423. RID immediate_get_material(RID p_immediate) const { return RID(); }
  424. AABB immediate_get_aabb(RID p_immediate) const { return AABB(); }
  425. /* SKELETON API */
  426. RID skeleton_create() { return RID(); }
  427. void skeleton_allocate(RID p_skeleton, int p_bones, bool p_2d_skeleton = false) {}
  428. void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) {}
  429. void skeleton_set_world_transform(RID p_skeleton, bool p_enable, const Transform &p_world_transform) {}
  430. int skeleton_get_bone_count(RID p_skeleton) const { return 0; }
  431. void skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform &p_transform) {}
  432. Transform skeleton_bone_get_transform(RID p_skeleton, int p_bone) const { return Transform(); }
  433. void skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) {}
  434. Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const { return Transform2D(); }
  435. /* Light API */
  436. RID light_create(RS::LightType p_type) { return RID(); }
  437. RID directional_light_create() { return light_create(RS::LIGHT_DIRECTIONAL); }
  438. RID omni_light_create() { return light_create(RS::LIGHT_OMNI); }
  439. RID spot_light_create() { return light_create(RS::LIGHT_SPOT); }
  440. void light_set_color(RID p_light, const Color &p_color) {}
  441. void light_set_param(RID p_light, RS::LightParam p_param, float p_value) {}
  442. void light_set_shadow(RID p_light, bool p_enabled) {}
  443. void light_set_shadow_color(RID p_light, const Color &p_color) {}
  444. void light_set_projector(RID p_light, RID p_texture) {}
  445. void light_set_negative(RID p_light, bool p_enable) {}
  446. void light_set_cull_mask(RID p_light, uint32_t p_mask) {}
  447. void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) {}
  448. void light_set_use_gi(RID p_light, bool p_enabled) {}
  449. void light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) {}
  450. void light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) {}
  451. void light_directional_set_blend_splits(RID p_light, bool p_enable) {}
  452. bool light_directional_get_blend_splits(RID p_light) const { return false; }
  453. void light_directional_set_shadow_depth_range_mode(RID p_light, RS::LightDirectionalShadowDepthRangeMode p_range_mode) {}
  454. RS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const { return RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE; }
  455. RS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) { return RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL; }
  456. RS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) { return RS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID; }
  457. bool light_has_shadow(RID p_light) const { return false; }
  458. RS::LightType light_get_type(RID p_light) const { return RS::LIGHT_OMNI; }
  459. AABB light_get_aabb(RID p_light) const { return AABB(); }
  460. float light_get_param(RID p_light, RS::LightParam p_param) { return 0.0; }
  461. Color light_get_color(RID p_light) { return Color(); }
  462. bool light_get_use_gi(RID p_light) { return false; }
  463. uint64_t light_get_version(RID p_light) const { return 0; }
  464. /* PROBE API */
  465. RID reflection_probe_create() { return RID(); }
  466. void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {}
  467. void reflection_probe_set_intensity(RID p_probe, float p_intensity) {}
  468. void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) {}
  469. void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) {}
  470. void reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib) {}
  471. void reflection_probe_set_max_distance(RID p_probe, float p_distance) {}
  472. void reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {}
  473. void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {}
  474. void reflection_probe_set_as_interior(RID p_probe, bool p_enable) {}
  475. void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {}
  476. void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) {}
  477. void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {}
  478. void reflection_probe_set_resolution(RID p_probe, int p_resolution) {}
  479. AABB reflection_probe_get_aabb(RID p_probe) const { return AABB(); }
  480. RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const { return RenderingServer::REFLECTION_PROBE_UPDATE_ONCE; }
  481. uint32_t reflection_probe_get_cull_mask(RID p_probe) const { return 0; }
  482. Vector3 reflection_probe_get_extents(RID p_probe) const { return Vector3(); }
  483. Vector3 reflection_probe_get_origin_offset(RID p_probe) const { return Vector3(); }
  484. float reflection_probe_get_origin_max_distance(RID p_probe) const { return 0.0; }
  485. bool reflection_probe_renders_shadows(RID p_probe) const { return false; }
  486. virtual void base_update_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {}
  487. virtual void skeleton_update_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {}
  488. /* GI PROBE API */
  489. RID gi_probe_create() { return RID(); }
  490. virtual void gi_probe_allocate(RID p_gi_probe, const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) {}
  491. virtual AABB gi_probe_get_bounds(RID p_gi_probe) const { return AABB(); }
  492. virtual Vector3i gi_probe_get_octree_size(RID p_gi_probe) const { return Vector3i(); }
  493. virtual Vector<uint8_t> gi_probe_get_octree_cells(RID p_gi_probe) const { return Vector<uint8_t>(); }
  494. virtual Vector<uint8_t> gi_probe_get_data_cells(RID p_gi_probe) const { return Vector<uint8_t>(); }
  495. virtual Vector<uint8_t> gi_probe_get_distance_field(RID p_gi_probe) const { return Vector<uint8_t>(); }
  496. virtual Vector<int> gi_probe_get_level_counts(RID p_gi_probe) const { return Vector<int>(); }
  497. virtual Transform gi_probe_get_to_cell_xform(RID p_gi_probe) const { return Transform(); }
  498. virtual void gi_probe_set_dynamic_range(RID p_gi_probe, float p_range) {}
  499. virtual float gi_probe_get_dynamic_range(RID p_gi_probe) const { return 0; }
  500. virtual void gi_probe_set_propagation(RID p_gi_probe, float p_range) {}
  501. virtual float gi_probe_get_propagation(RID p_gi_probe) const { return 0; }
  502. void gi_probe_set_energy(RID p_gi_probe, float p_range) {}
  503. float gi_probe_get_energy(RID p_gi_probe) const { return 0.0; }
  504. virtual void gi_probe_set_ao(RID p_gi_probe, float p_ao) {}
  505. virtual float gi_probe_get_ao(RID p_gi_probe) const { return 0; }
  506. virtual void gi_probe_set_ao_size(RID p_gi_probe, float p_strength) {}
  507. virtual float gi_probe_get_ao_size(RID p_gi_probe) const { return 0; }
  508. void gi_probe_set_bias(RID p_gi_probe, float p_range) {}
  509. float gi_probe_get_bias(RID p_gi_probe) const { return 0.0; }
  510. void gi_probe_set_normal_bias(RID p_gi_probe, float p_range) {}
  511. float gi_probe_get_normal_bias(RID p_gi_probe) const { return 0.0; }
  512. void gi_probe_set_interior(RID p_gi_probe, bool p_enable) {}
  513. bool gi_probe_is_interior(RID p_gi_probe) const { return false; }
  514. virtual void gi_probe_set_use_two_bounces(RID p_gi_probe, bool p_enable) {}
  515. virtual bool gi_probe_is_using_two_bounces(RID p_gi_probe) const { return false; }
  516. virtual void gi_probe_set_anisotropy_strength(RID p_gi_probe, float p_strength) {}
  517. virtual float gi_probe_get_anisotropy_strength(RID p_gi_probe) const { return 0; }
  518. uint32_t gi_probe_get_version(RID p_gi_probe) { return 0; }
  519. /* LIGHTMAP CAPTURE */
  520. struct Instantiable {
  521. SelfList<RasterizerScene::InstanceBase>::List instance_list;
  522. _FORCE_INLINE_ void instance_change_notify(bool p_aabb = true, bool p_materials = true) {
  523. SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
  524. while (instances) {
  525. //instances->self()->base_changed(p_aabb, p_materials);
  526. instances = instances->next();
  527. }
  528. }
  529. _FORCE_INLINE_ void instance_remove_deps() {
  530. SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
  531. while (instances) {
  532. SelfList<RasterizerScene::InstanceBase> *next = instances->next();
  533. //instances->self()->base_removed();
  534. instances = next;
  535. }
  536. }
  537. Instantiable() {}
  538. virtual ~Instantiable() {
  539. }
  540. };
  541. struct LightmapCapture : public Instantiable {
  542. Vector<LightmapCaptureOctree> octree;
  543. AABB bounds;
  544. Transform cell_xform;
  545. int cell_subdiv;
  546. float energy;
  547. LightmapCapture() {
  548. energy = 1.0;
  549. cell_subdiv = 1;
  550. }
  551. };
  552. mutable RID_PtrOwner<LightmapCapture> lightmap_capture_data_owner;
  553. void lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds) {}
  554. AABB lightmap_capture_get_bounds(RID p_capture) const { return AABB(); }
  555. void lightmap_capture_set_octree(RID p_capture, const Vector<uint8_t> &p_octree) {}
  556. RID lightmap_capture_create() {
  557. LightmapCapture *capture = memnew(LightmapCapture);
  558. return lightmap_capture_data_owner.make_rid(capture);
  559. }
  560. Vector<uint8_t> lightmap_capture_get_octree(RID p_capture) const {
  561. const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
  562. ERR_FAIL_COND_V(!capture, Vector<uint8_t>());
  563. return Vector<uint8_t>();
  564. }
  565. void lightmap_capture_set_octree_cell_transform(RID p_capture, const Transform &p_xform) {}
  566. Transform lightmap_capture_get_octree_cell_transform(RID p_capture) const { return Transform(); }
  567. void lightmap_capture_set_octree_cell_subdiv(RID p_capture, int p_subdiv) {}
  568. int lightmap_capture_get_octree_cell_subdiv(RID p_capture) const { return 0; }
  569. void lightmap_capture_set_energy(RID p_capture, float p_energy) {}
  570. float lightmap_capture_get_energy(RID p_capture) const { return 0.0; }
  571. const Vector<LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const {
  572. const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
  573. ERR_FAIL_COND_V(!capture, NULL);
  574. return &capture->octree;
  575. }
  576. /* PARTICLES */
  577. RID particles_create() { return RID(); }
  578. void particles_set_emitting(RID p_particles, bool p_emitting) {}
  579. void particles_set_amount(RID p_particles, int p_amount) {}
  580. void particles_set_lifetime(RID p_particles, float p_lifetime) {}
  581. void particles_set_one_shot(RID p_particles, bool p_one_shot) {}
  582. void particles_set_pre_process_time(RID p_particles, float p_time) {}
  583. void particles_set_explosiveness_ratio(RID p_particles, float p_ratio) {}
  584. void particles_set_randomness_ratio(RID p_particles, float p_ratio) {}
  585. void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) {}
  586. void particles_set_speed_scale(RID p_particles, float p_scale) {}
  587. void particles_set_use_local_coordinates(RID p_particles, bool p_enable) {}
  588. void particles_set_process_material(RID p_particles, RID p_material) {}
  589. void particles_set_fixed_fps(RID p_particles, int p_fps) {}
  590. void particles_set_fractional_delta(RID p_particles, bool p_enable) {}
  591. void particles_restart(RID p_particles) {}
  592. void particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) {}
  593. void particles_set_draw_passes(RID p_particles, int p_count) {}
  594. void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) {}
  595. void particles_request_process(RID p_particles) {}
  596. AABB particles_get_current_aabb(RID p_particles) { return AABB(); }
  597. AABB particles_get_aabb(RID p_particles) const { return AABB(); }
  598. void particles_set_emission_transform(RID p_particles, const Transform &p_transform) {}
  599. bool particles_get_emitting(RID p_particles) { return false; }
  600. int particles_get_draw_passes(RID p_particles) const { return 0; }
  601. RID particles_get_draw_pass_mesh(RID p_particles, int p_pass) const { return RID(); }
  602. virtual bool particles_is_inactive(RID p_particles) const { return false; }
  603. /* RENDER TARGET */
  604. RID render_target_create() { return RID(); }
  605. void render_target_set_position(RID p_render_target, int p_x, int p_y) {}
  606. void render_target_set_size(RID p_render_target, int p_width, int p_height) {}
  607. RID render_target_get_texture(RID p_render_target) { return RID(); }
  608. void render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id) {}
  609. void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) {}
  610. bool render_target_was_used(RID p_render_target) { return false; }
  611. void render_target_set_as_unused(RID p_render_target) {}
  612. virtual void render_target_request_clear(RID p_render_target, const Color &p_clear_color) {}
  613. virtual bool render_target_is_clear_requested(RID p_render_target) { return false; }
  614. virtual Color render_target_get_clear_request_color(RID p_render_target) { return Color(); }
  615. virtual void render_target_disable_clear_request(RID p_render_target) {}
  616. virtual void render_target_do_clear_request(RID p_render_target) {}
  617. RS::InstanceType get_base_type(RID p_rid) const {
  618. if (mesh_owner.owns(p_rid)) {
  619. return RS::INSTANCE_MESH;
  620. }
  621. return RS::INSTANCE_NONE;
  622. }
  623. bool free(RID p_rid) {
  624. if (texture_owner.owns(p_rid)) {
  625. // delete the texture
  626. DummyTexture *texture = texture_owner.getornull(p_rid);
  627. texture_owner.free(p_rid);
  628. memdelete(texture);
  629. }
  630. return true;
  631. }
  632. bool has_os_feature(const String &p_feature) const { return false; }
  633. void update_dirty_resources() {}
  634. void set_debug_generate_wireframes(bool p_generate) {}
  635. void render_info_begin_capture() {}
  636. void render_info_end_capture() {}
  637. int get_captured_render_info(RS::RenderInfo p_info) { return 0; }
  638. int get_render_info(RS::RenderInfo p_info) { return 0; }
  639. String get_video_adapter_name() const { return String(); }
  640. String get_video_adapter_vendor() const { return String(); }
  641. static RasterizerStorage *base_singleton;
  642. virtual void capture_timestamps_begin() {}
  643. virtual void capture_timestamp(const String &p_name) {}
  644. virtual uint32_t get_captured_timestamps_count() const { return 0; }
  645. virtual uint64_t get_captured_timestamps_frame() const { return 0; }
  646. virtual uint64_t get_captured_timestamp_gpu_time(uint32_t p_index) const { return 0; }
  647. virtual uint64_t get_captured_timestamp_cpu_time(uint32_t p_index) const { return 0; }
  648. virtual String get_captured_timestamp_name(uint32_t p_index) const { return String(); }
  649. RasterizerStorageDummy() {}
  650. ~RasterizerStorageDummy() {}
  651. };
  652. class RasterizerCanvasDummy : public RasterizerCanvas {
  653. public:
  654. virtual TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) { return 0; }
  655. virtual void free_texture_binding(TextureBindingID p_binding) {}
  656. virtual PolygonID request_polygon(const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>()) { return 0; }
  657. virtual void free_polygon(PolygonID p_polygon) {}
  658. virtual void canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, const Transform2D &p_canvas_transform) {}
  659. virtual void canvas_debug_viewport_shadows(Light *p_lights_with_shadow) {}
  660. virtual RID light_create() { return RID(); }
  661. virtual void light_set_texture(RID p_rid, RID p_texture) {}
  662. virtual void light_set_use_shadow(RID p_rid, bool p_enable, int p_resolution) {}
  663. virtual void light_update_shadow(RID p_rid, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders) {}
  664. virtual RID occluder_polygon_create() { return RID(); }
  665. virtual void occluder_polygon_set_shape_as_lines(RID p_occluder, const Vector<Vector2> &p_lines) {}
  666. virtual void occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) {}
  667. void draw_window_margins(int *p_margins, RID *p_margin_textures) {}
  668. virtual bool free(RID p_rid) { return true; }
  669. virtual void update() {}
  670. RasterizerCanvasDummy() {}
  671. ~RasterizerCanvasDummy() {}
  672. };
  673. class RasterizerDummy : public Rasterizer {
  674. protected:
  675. RasterizerCanvasDummy canvas;
  676. RasterizerStorageDummy storage;
  677. RasterizerSceneDummy scene;
  678. public:
  679. RasterizerStorage *get_storage() { return &storage; }
  680. RasterizerCanvas *get_canvas() { return &canvas; }
  681. RasterizerScene *get_scene() { return &scene; }
  682. void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) {}
  683. void initialize() {}
  684. void begin_frame(double frame_step) {}
  685. virtual void prepare_for_blitting_render_targets() {}
  686. virtual void blit_render_targets_to_screen(int p_screen, const BlitToScreen *p_render_targets, int p_amount) {}
  687. void end_frame(bool p_swap_buffers) { OS::get_singleton()->swap_buffers(); }
  688. void finalize() {}
  689. static Error is_viable() {
  690. return OK;
  691. }
  692. static Rasterizer *_create_current() {
  693. return memnew(RasterizerDummy);
  694. }
  695. static void make_current() {
  696. _create_func = _create_current;
  697. }
  698. virtual bool is_low_end() const { return true; }
  699. RasterizerDummy() {}
  700. ~RasterizerDummy() {}
  701. };
  702. #endif // RASTERIZER_DUMMY_H