rasterizer_storage_gles2.h 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321
  1. /*************************************************************************/
  2. /* rasterizer_storage_gles2.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 RASTERIZERSTORAGEGLES2_H
  31. #define RASTERIZERSTORAGEGLES2_H
  32. #include "core/self_list.h"
  33. #include "servers/rendering/rasterizer.h"
  34. #include "servers/rendering/shader_language.h"
  35. #include "shader_compiler_gles2.h"
  36. #include "shader_gles2.h"
  37. #include "core/rid_owner.h"
  38. #include "shaders/copy.glsl.gen.h"
  39. #include "shaders/cubemap_filter.glsl.gen.h"
  40. /*
  41. #include "shaders/blend_shape.glsl.gen.h"
  42. #include "shaders/canvas.glsl.gen.h"
  43. #include "shaders/particles.glsl.gen.h"
  44. */
  45. class RasterizerCanvasGLES2;
  46. class RasterizerSceneGLES2;
  47. class RasterizerStorageGLES2 : public RasterizerStorage {
  48. public:
  49. RasterizerCanvasGLES2 *canvas;
  50. RasterizerSceneGLES2 *scene;
  51. static GLuint system_fbo;
  52. struct Config {
  53. bool shrink_textures_x2;
  54. bool use_fast_texture_filter;
  55. bool use_skeleton_software;
  56. int max_vertex_texture_image_units;
  57. int max_texture_image_units;
  58. int max_texture_size;
  59. // TODO implement wireframe in GLES2
  60. // bool generate_wireframes;
  61. Set<String> extensions;
  62. bool texture_3d_supported;
  63. bool texture_array_supported;
  64. bool float_texture_supported;
  65. bool s3tc_supported;
  66. bool etc1_supported;
  67. bool pvrtc_supported;
  68. bool rgtc_supported;
  69. bool bptc_supported;
  70. bool keep_original_textures;
  71. bool force_vertex_shading;
  72. bool use_rgba_2d_shadows;
  73. bool use_rgba_3d_shadows;
  74. bool support_32_bits_indices;
  75. bool support_write_depth;
  76. bool support_half_float_vertices;
  77. bool support_npot_repeat_mipmap;
  78. bool support_depth_texture;
  79. bool support_depth_cubemaps;
  80. bool support_shadow_cubemaps;
  81. bool multisample_supported;
  82. bool render_to_mipmap_supported;
  83. GLuint depth_internalformat;
  84. GLuint depth_type;
  85. GLuint depth_buffer_internalformat;
  86. } config;
  87. struct Resources {
  88. GLuint white_tex;
  89. GLuint black_tex;
  90. GLuint normal_tex;
  91. GLuint aniso_tex;
  92. GLuint white_tex_3d;
  93. GLuint white_tex_array;
  94. GLuint mipmap_blur_fbo;
  95. GLuint mipmap_blur_color;
  96. GLuint radical_inverse_vdc_cache_tex;
  97. bool use_rgba_2d_shadows;
  98. GLuint quadie;
  99. size_t skeleton_transform_buffer_size;
  100. GLuint skeleton_transform_buffer;
  101. Vector<float> skeleton_transform_cpu_buffer;
  102. } resources;
  103. mutable struct Shaders {
  104. ShaderCompilerGLES2 compiler;
  105. CopyShaderGLES2 copy;
  106. CubemapFilterShaderGLES2 cubemap_filter;
  107. ShaderCompilerGLES2::IdentifierActions actions_canvas;
  108. ShaderCompilerGLES2::IdentifierActions actions_scene;
  109. ShaderCompilerGLES2::IdentifierActions actions_particles;
  110. } shaders;
  111. struct Info {
  112. uint64_t texture_mem;
  113. uint64_t vertex_mem;
  114. struct Render {
  115. uint32_t object_count;
  116. uint32_t draw_call_count;
  117. uint32_t material_switch_count;
  118. uint32_t surface_switch_count;
  119. uint32_t shader_rebind_count;
  120. uint32_t vertices_count;
  121. void reset() {
  122. object_count = 0;
  123. draw_call_count = 0;
  124. material_switch_count = 0;
  125. surface_switch_count = 0;
  126. shader_rebind_count = 0;
  127. vertices_count = 0;
  128. }
  129. } render, render_final, snap;
  130. Info() :
  131. texture_mem(0),
  132. vertex_mem(0) {
  133. render.reset();
  134. render_final.reset();
  135. }
  136. } info;
  137. void bind_quad_array() const;
  138. /////////////////////////////////////////////////////////////////////////////////////////
  139. //////////////////////////////////DATA///////////////////////////////////////////////////
  140. /////////////////////////////////////////////////////////////////////////////////////////
  141. struct Instantiable {
  142. SelfList<RasterizerScene::InstanceBase>::List instance_list;
  143. _FORCE_INLINE_ void instance_change_notify(bool p_aabb, bool p_materials) {
  144. SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
  145. while (instances) {
  146. instances->self()->base_changed(p_aabb, p_materials);
  147. instances = instances->next();
  148. }
  149. }
  150. _FORCE_INLINE_ void instance_remove_deps() {
  151. SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
  152. while (instances) {
  153. instances->self()->base_removed();
  154. instances = instances->next();
  155. }
  156. }
  157. Instantiable() {}
  158. virtual ~Instantiable() {}
  159. };
  160. struct GeometryOwner : public Instantiable {
  161. };
  162. struct Geometry : public Instantiable {
  163. enum Type {
  164. GEOMETRY_INVALID,
  165. GEOMETRY_SURFACE,
  166. GEOMETRY_IMMEDIATE,
  167. GEOMETRY_MULTISURFACE
  168. };
  169. Type type;
  170. RID material;
  171. uint64_t last_pass;
  172. uint32_t index;
  173. virtual void material_changed_notify() {}
  174. Geometry() {
  175. last_pass = 0;
  176. index = 0;
  177. }
  178. };
  179. /////////////////////////////////////////////////////////////////////////////////////////
  180. //////////////////////////////////API////////////////////////////////////////////////////
  181. /////////////////////////////////////////////////////////////////////////////////////////
  182. /* TEXTURE API */
  183. struct RenderTarget;
  184. struct Texture {
  185. Texture *proxy;
  186. Set<Texture *> proxy_owners;
  187. String path;
  188. uint32_t flags;
  189. int width, height, depth;
  190. int alloc_width, alloc_height;
  191. Image::Format format;
  192. RS::TextureType type;
  193. GLenum target;
  194. GLenum gl_format_cache;
  195. GLenum gl_internal_format_cache;
  196. GLenum gl_type_cache;
  197. int data_size;
  198. int total_data_size;
  199. bool ignore_mipmaps;
  200. bool compressed;
  201. bool srgb;
  202. int mipmaps;
  203. bool resize_to_po2;
  204. bool active;
  205. GLenum tex_id;
  206. uint16_t stored_cube_sides;
  207. RenderTarget *render_target;
  208. Vector<Ref<Image>> images;
  209. bool redraw_if_visible;
  210. RenderingServer::TextureDetectCallback detect_3d;
  211. void *detect_3d_ud;
  212. RenderingServer::TextureDetectCallback detect_srgb;
  213. void *detect_srgb_ud;
  214. RenderingServer::TextureDetectCallback detect_normal;
  215. void *detect_normal_ud;
  216. Texture() :
  217. proxy(NULL),
  218. flags(0),
  219. width(0),
  220. height(0),
  221. alloc_width(0),
  222. alloc_height(0),
  223. format(Image::FORMAT_L8),
  224. type(RS::TEXTURE_TYPE_2D),
  225. target(0),
  226. data_size(0),
  227. total_data_size(0),
  228. ignore_mipmaps(false),
  229. compressed(false),
  230. mipmaps(0),
  231. resize_to_po2(false),
  232. active(false),
  233. tex_id(0),
  234. stored_cube_sides(0),
  235. render_target(NULL),
  236. redraw_if_visible(false),
  237. detect_3d(NULL),
  238. detect_3d_ud(NULL),
  239. detect_srgb(NULL),
  240. detect_srgb_ud(NULL),
  241. detect_normal(NULL),
  242. detect_normal_ud(NULL) {
  243. }
  244. _ALWAYS_INLINE_ Texture *get_ptr() {
  245. if (proxy) {
  246. return proxy; //->get_ptr(); only one level of indirection, else not inlining possible.
  247. } else {
  248. return this;
  249. }
  250. }
  251. ~Texture() {
  252. if (tex_id != 0) {
  253. glDeleteTextures(1, &tex_id);
  254. }
  255. for (Set<Texture *>::Element *E = proxy_owners.front(); E; E = E->next()) {
  256. E->get()->proxy = NULL;
  257. }
  258. if (proxy) {
  259. proxy->proxy_owners.erase(this);
  260. }
  261. }
  262. };
  263. mutable RID_PtrOwner<Texture2D> texture_owner;
  264. Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool p_force_decompress) const;
  265. virtual RID texture_create();
  266. virtual void texture_allocate(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, RS::TextureType p_type, uint32_t p_flags = RS::TEXTURE_FLAGS_DEFAULT);
  267. virtual void texture_set_data(RID p_texture, const Ref<Image> &p_image, int p_layer = 0);
  268. virtual 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_layer = 0);
  269. virtual Ref<Image> texture_get_data(RID p_texture, int p_layer = 0) const;
  270. virtual void texture_set_flags(RID p_texture, uint32_t p_flags);
  271. virtual uint32_t texture_get_flags(RID p_texture) const;
  272. virtual Image::Format texture_get_format(RID p_texture) const;
  273. virtual RS::TextureType texture_get_type(RID p_texture) const;
  274. virtual uint32_t texture_get_texid(RID p_texture) const;
  275. virtual uint32_t texture_get_width(RID p_texture) const;
  276. virtual uint32_t texture_get_height(RID p_texture) const;
  277. virtual uint32_t texture_get_depth(RID p_texture) const;
  278. virtual void texture_set_size_override(RID p_texture, int p_width, int p_height, int p_depth);
  279. virtual void texture_bind(RID p_texture, uint32_t p_texture_no);
  280. virtual void texture_set_path(RID p_texture, const String &p_path);
  281. virtual String texture_get_path(RID p_texture) const;
  282. virtual void texture_set_shrink_all_x2_on_set_data(bool p_enable);
  283. virtual void texture_debug_usage(List<RS::TextureInfo> *r_info);
  284. virtual RID texture_create_radiance_cubemap(RID p_source, int p_resolution = -1) const;
  285. virtual void textures_keep_original(bool p_enable);
  286. virtual void texture_set_proxy(RID p_texture, RID p_proxy);
  287. virtual Size2 texture_size_with_proxy(RID p_texture) const;
  288. virtual void texture_set_detect_3d_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata);
  289. virtual void texture_set_detect_srgb_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata);
  290. virtual void texture_set_detect_normal_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata);
  291. virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable);
  292. /* SKY API */
  293. struct Sky {
  294. RID panorama;
  295. GLuint radiance;
  296. int radiance_size;
  297. };
  298. mutable RID_PtrOwner<Sky> sky_owner;
  299. virtual RID sky_create();
  300. virtual void sky_set_texture(RID p_sky, RID p_panorama, int p_radiance_size);
  301. /* SHADER API */
  302. struct Material;
  303. struct Shader {
  304. RID self;
  305. RS::ShaderMode mode;
  306. ShaderGLES2 *shader;
  307. String code;
  308. SelfList<Material>::List materials;
  309. Map<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms;
  310. uint32_t texture_count;
  311. uint32_t custom_code_id;
  312. uint32_t version;
  313. SelfList<Shader> dirty_list;
  314. Map<StringName, RID> default_textures;
  315. Vector<ShaderLanguage::DataType> texture_types;
  316. Vector<ShaderLanguage::ShaderNode::Uniform::Hint> texture_hints;
  317. bool valid;
  318. String path;
  319. uint32_t index;
  320. uint64_t last_pass;
  321. struct CanvasItem {
  322. enum BlendMode {
  323. BLEND_MODE_MIX,
  324. BLEND_MODE_ADD,
  325. BLEND_MODE_SUB,
  326. BLEND_MODE_MUL,
  327. BLEND_MODE_PMALPHA,
  328. };
  329. int blend_mode;
  330. enum LightMode {
  331. LIGHT_MODE_NORMAL,
  332. LIGHT_MODE_UNSHADED,
  333. LIGHT_MODE_LIGHT_ONLY
  334. };
  335. int light_mode;
  336. bool uses_screen_texture;
  337. bool uses_screen_uv;
  338. bool uses_time;
  339. } canvas_item;
  340. struct Spatial {
  341. enum BlendMode {
  342. BLEND_MODE_MIX,
  343. BLEND_MODE_ADD,
  344. BLEND_MODE_SUB,
  345. BLEND_MODE_MUL,
  346. };
  347. int blend_mode;
  348. enum DepthDrawMode {
  349. DEPTH_DRAW_OPAQUE,
  350. DEPTH_DRAW_ALWAYS,
  351. DEPTH_DRAW_NEVER,
  352. DEPTH_DRAW_ALPHA_PREPASS,
  353. };
  354. int depth_draw_mode;
  355. enum CullMode {
  356. CULL_MODE_FRONT,
  357. CULL_MODE_BACK,
  358. CULL_MODE_DISABLED,
  359. };
  360. int cull_mode;
  361. bool uses_alpha;
  362. bool uses_alpha_scissor;
  363. bool unshaded;
  364. bool no_depth_test;
  365. bool uses_vertex;
  366. bool uses_discard;
  367. bool uses_sss;
  368. bool uses_screen_texture;
  369. bool uses_depth_texture;
  370. bool uses_time;
  371. bool writes_modelview_or_projection;
  372. bool uses_vertex_lighting;
  373. bool uses_world_coordinates;
  374. } spatial;
  375. struct Particles {
  376. } particles;
  377. bool uses_vertex_time;
  378. bool uses_fragment_time;
  379. Shader() :
  380. dirty_list(this) {
  381. shader = NULL;
  382. valid = false;
  383. custom_code_id = 0;
  384. version = 1;
  385. last_pass = 0;
  386. }
  387. };
  388. mutable RID_PtrOwner<Shader> shader_owner;
  389. mutable SelfList<Shader>::List _shader_dirty_list;
  390. void _shader_make_dirty(Shader *p_shader);
  391. virtual RID shader_create();
  392. virtual void shader_set_code(RID p_shader, const String &p_code);
  393. virtual String shader_get_code(RID p_shader) const;
  394. virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const;
  395. virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture);
  396. virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name) const;
  397. void _update_shader(Shader *p_shader) const;
  398. void update_dirty_shaders();
  399. /* COMMON MATERIAL API */
  400. struct Material {
  401. Shader *shader;
  402. Map<StringName, Variant> params;
  403. SelfList<Material> list;
  404. SelfList<Material> dirty_list;
  405. Vector<Pair<StringName, RID>> textures;
  406. float line_width;
  407. int render_priority;
  408. RID next_pass;
  409. uint32_t index;
  410. uint64_t last_pass;
  411. Map<Geometry *, int> geometry_owners;
  412. Map<RasterizerScene::InstanceBase *, int> instance_owners;
  413. bool can_cast_shadow_cache;
  414. bool is_animated_cache;
  415. Material() :
  416. list(this),
  417. dirty_list(this) {
  418. can_cast_shadow_cache = false;
  419. is_animated_cache = false;
  420. shader = NULL;
  421. line_width = 1.0;
  422. last_pass = 0;
  423. render_priority = 0;
  424. }
  425. };
  426. mutable SelfList<Material>::List _material_dirty_list;
  427. void _material_make_dirty(Material *p_material) const;
  428. void _material_add_geometry(RID p_material, Geometry *p_geometry);
  429. void _material_remove_geometry(RID p_material, Geometry *p_geometry);
  430. void _update_material(Material *p_material);
  431. mutable RID_PtrOwner<Material> material_owner;
  432. virtual RID material_create();
  433. virtual void material_set_shader(RID p_material, RID p_shader);
  434. virtual RID material_get_shader(RID p_material) const;
  435. virtual void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value);
  436. virtual Variant material_get_param(RID p_material, const StringName &p_param) const;
  437. virtual Variant material_get_param_default(RID p_material, const StringName &p_param) const;
  438. virtual void material_set_line_width(RID p_material, float p_width);
  439. virtual void material_set_next_pass(RID p_material, RID p_next_material);
  440. virtual bool material_is_animated(RID p_material);
  441. virtual bool material_casts_shadows(RID p_material);
  442. virtual void material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance);
  443. virtual void material_remove_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance);
  444. virtual void material_set_render_priority(RID p_material, int priority);
  445. void update_dirty_materials();
  446. /* MESH API */
  447. struct Mesh;
  448. struct Surface : public Geometry {
  449. struct Attrib {
  450. bool enabled;
  451. bool integer;
  452. GLuint index;
  453. GLint size;
  454. GLenum type;
  455. GLboolean normalized;
  456. GLsizei stride;
  457. uint32_t offset;
  458. };
  459. Attrib attribs[RS::ARRAY_MAX];
  460. Mesh *mesh;
  461. uint32_t format;
  462. GLuint vertex_id;
  463. GLuint index_id;
  464. struct BlendShape {
  465. GLuint vertex_id;
  466. GLuint array_id;
  467. };
  468. Vector<BlendShape> blend_shapes;
  469. AABB aabb;
  470. int array_len;
  471. int index_array_len;
  472. int max_bone;
  473. int array_byte_size;
  474. int index_array_byte_size;
  475. RS::PrimitiveType primitive;
  476. Vector<AABB> skeleton_bone_aabb;
  477. Vector<bool> skeleton_bone_used;
  478. bool active;
  479. Vector<uint8_t> data;
  480. Vector<uint8_t> index_data;
  481. Vector<Vector<uint8_t>> blend_shape_data;
  482. int total_data_size;
  483. Surface() :
  484. mesh(NULL),
  485. array_len(0),
  486. index_array_len(0),
  487. array_byte_size(0),
  488. index_array_byte_size(0),
  489. primitive(RS::PRIMITIVE_POINTS),
  490. active(false),
  491. total_data_size(0) {
  492. }
  493. };
  494. struct MultiMesh;
  495. struct Mesh : public GeometryOwner {
  496. bool active;
  497. Vector<Surface *> surfaces;
  498. int blend_shape_count;
  499. RS::BlendShapeMode blend_shape_mode;
  500. AABB custom_aabb;
  501. mutable uint64_t last_pass;
  502. SelfList<MultiMesh>::List multimeshes;
  503. _FORCE_INLINE_ void update_multimeshes() {
  504. SelfList<MultiMesh> *mm = multimeshes.first();
  505. while (mm) {
  506. mm->self()->instance_change_notify(false, true);
  507. mm = mm->next();
  508. }
  509. }
  510. Mesh() :
  511. blend_shape_count(0),
  512. blend_shape_mode(RS::BLEND_SHAPE_MODE_NORMALIZED) {
  513. }
  514. };
  515. mutable RID_PtrOwner<Mesh> mesh_owner;
  516. virtual RID mesh_create();
  517. virtual 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>());
  518. virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount);
  519. virtual int mesh_get_blend_shape_count(RID p_mesh) const;
  520. virtual void mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode);
  521. virtual RS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const;
  522. virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data);
  523. virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material);
  524. virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const;
  525. virtual int mesh_surface_get_array_len(RID p_mesh, int p_surface) const;
  526. virtual int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const;
  527. virtual Vector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const;
  528. virtual Vector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const;
  529. virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const;
  530. virtual RS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const;
  531. virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const;
  532. virtual Vector<Vector<uint8_t>> mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const;
  533. virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const;
  534. virtual void mesh_remove_surface(RID p_mesh, int p_surface);
  535. virtual int mesh_get_surface_count(RID p_mesh) const;
  536. virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb);
  537. virtual AABB mesh_get_custom_aabb(RID p_mesh) const;
  538. virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const;
  539. virtual void mesh_clear(RID p_mesh);
  540. /* MULTIMESH API */
  541. struct MultiMesh : public GeometryOwner {
  542. RID mesh;
  543. int size;
  544. RS::MultimeshTransformFormat transform_format;
  545. RS::MultimeshColorFormat color_format;
  546. RS::MultimeshCustomDataFormat custom_data_format;
  547. Vector<float> data;
  548. AABB aabb;
  549. SelfList<MultiMesh> update_list;
  550. SelfList<MultiMesh> mesh_list;
  551. int visible_instances;
  552. int xform_floats;
  553. int color_floats;
  554. int custom_data_floats;
  555. bool dirty_aabb;
  556. bool dirty_data;
  557. MultiMesh() :
  558. size(0),
  559. transform_format(RS::MULTIMESH_TRANSFORM_2D),
  560. color_format(RS::MULTIMESH_COLOR_NONE),
  561. custom_data_format(RS::MULTIMESH_CUSTOM_DATA_NONE),
  562. update_list(this),
  563. mesh_list(this),
  564. visible_instances(-1),
  565. xform_floats(0),
  566. color_floats(0),
  567. custom_data_floats(0),
  568. dirty_aabb(true),
  569. dirty_data(true) {
  570. }
  571. };
  572. mutable RID_PtrOwner<MultiMesh> multimesh_owner;
  573. SelfList<MultiMesh>::List multimesh_update_list;
  574. virtual RID multimesh_create();
  575. virtual void multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, RS::MultimeshColorFormat p_color_format, RS::MultimeshCustomDataFormat p_data = RS::MULTIMESH_CUSTOM_DATA_NONE);
  576. virtual int multimesh_get_instance_count(RID p_multimesh) const;
  577. virtual void multimesh_set_mesh(RID p_multimesh, RID p_mesh);
  578. virtual void multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform &p_transform);
  579. virtual void multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform);
  580. virtual void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color);
  581. virtual void multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_custom_data);
  582. virtual RID multimesh_get_mesh(RID p_multimesh) const;
  583. virtual Transform multimesh_instance_get_transform(RID p_multimesh, int p_index) const;
  584. virtual Transform2D multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const;
  585. virtual Color multimesh_instance_get_color(RID p_multimesh, int p_index) const;
  586. virtual Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const;
  587. virtual void multimesh_set_as_bulk_array(RID p_multimesh, const Vector<float> &p_array);
  588. virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible);
  589. virtual int multimesh_get_visible_instances(RID p_multimesh) const;
  590. virtual AABB multimesh_get_aabb(RID p_multimesh) const;
  591. void update_dirty_multimeshes();
  592. /* IMMEDIATE API */
  593. struct Immediate : public Geometry {
  594. struct Chunk {
  595. RID texture;
  596. RS::PrimitiveType primitive;
  597. Vector<Vector3> vertices;
  598. Vector<Vector3> normals;
  599. Vector<Plane> tangents;
  600. Vector<Color> colors;
  601. Vector<Vector2> uvs;
  602. Vector<Vector2> uv2s;
  603. };
  604. List<Chunk> chunks;
  605. bool building;
  606. int mask;
  607. AABB aabb;
  608. Immediate() {
  609. type = GEOMETRY_IMMEDIATE;
  610. building = false;
  611. }
  612. };
  613. Vector3 chunk_normal;
  614. Plane chunk_tangent;
  615. Color chunk_color;
  616. Vector2 chunk_uv;
  617. Vector2 chunk_uv2;
  618. mutable RID_PtrOwner<Immediate> immediate_owner;
  619. virtual RID immediate_create();
  620. virtual void immediate_begin(RID p_immediate, RS::PrimitiveType p_primitive, RID p_texture = RID());
  621. virtual void immediate_vertex(RID p_immediate, const Vector3 &p_vertex);
  622. virtual void immediate_normal(RID p_immediate, const Vector3 &p_normal);
  623. virtual void immediate_tangent(RID p_immediate, const Plane &p_tangent);
  624. virtual void immediate_color(RID p_immediate, const Color &p_color);
  625. virtual void immediate_uv(RID p_immediate, const Vector2 &tex_uv);
  626. virtual void immediate_uv2(RID p_immediate, const Vector2 &tex_uv);
  627. virtual void immediate_end(RID p_immediate);
  628. virtual void immediate_clear(RID p_immediate);
  629. virtual void immediate_set_material(RID p_immediate, RID p_material);
  630. virtual RID immediate_get_material(RID p_immediate) const;
  631. virtual AABB immediate_get_aabb(RID p_immediate) const;
  632. /* SKELETON API */
  633. struct Skeleton {
  634. bool use_2d;
  635. int size;
  636. // TODO use float textures for storage
  637. Vector<float> bone_data;
  638. GLuint tex_id;
  639. SelfList<Skeleton> update_list;
  640. Set<RasterizerScene::InstanceBase *> instances;
  641. Transform2D base_transform_2d;
  642. Skeleton() :
  643. use_2d(false),
  644. size(0),
  645. tex_id(0),
  646. update_list(this) {
  647. }
  648. };
  649. mutable RID_PtrOwner<Skeleton> skeleton_owner;
  650. SelfList<Skeleton>::List skeleton_update_list;
  651. void update_dirty_skeletons();
  652. virtual RID skeleton_create();
  653. virtual void skeleton_allocate(RID p_skeleton, int p_bones, bool p_2d_skeleton = false);
  654. virtual int skeleton_get_bone_count(RID p_skeleton) const;
  655. virtual void skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform &p_transform);
  656. virtual Transform skeleton_bone_get_transform(RID p_skeleton, int p_bone) const;
  657. virtual void skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform);
  658. virtual Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const;
  659. virtual void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform);
  660. void _update_skeleton_transform_buffer(const Vector<float> &p_data, size_t p_size);
  661. /* Light API */
  662. struct Light : Instantiable {
  663. RS::LightType type;
  664. float param[RS::LIGHT_PARAM_MAX];
  665. Color color;
  666. Color shadow_color;
  667. RID projector;
  668. bool shadow;
  669. bool negative;
  670. bool reverse_cull;
  671. bool use_gi;
  672. uint32_t cull_mask;
  673. RS::LightOmniShadowMode omni_shadow_mode;
  674. RS::LightOmniShadowDetail omni_shadow_detail;
  675. RS::LightDirectionalShadowMode directional_shadow_mode;
  676. RS::LightDirectionalShadowDepthRangeMode directional_range_mode;
  677. bool directional_blend_splits;
  678. uint64_t version;
  679. };
  680. mutable RID_PtrOwner<Light> light_owner;
  681. virtual RID light_create(RS::LightType p_type);
  682. virtual void light_set_color(RID p_light, const Color &p_color);
  683. virtual void light_set_param(RID p_light, RS::LightParam p_param, float p_value);
  684. virtual void light_set_shadow(RID p_light, bool p_enabled);
  685. virtual void light_set_shadow_color(RID p_light, const Color &p_color);
  686. virtual void light_set_projector(RID p_light, RID p_texture);
  687. virtual void light_set_negative(RID p_light, bool p_enable);
  688. virtual void light_set_cull_mask(RID p_light, uint32_t p_mask);
  689. virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled);
  690. virtual void light_set_use_gi(RID p_light, bool p_enabled);
  691. virtual void light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode);
  692. virtual void light_omni_set_shadow_detail(RID p_light, RS::LightOmniShadowDetail p_detail);
  693. virtual void light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode);
  694. virtual void light_directional_set_blend_splits(RID p_light, bool p_enable);
  695. virtual bool light_directional_get_blend_splits(RID p_light) const;
  696. virtual RS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light);
  697. virtual RS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light);
  698. virtual void light_directional_set_shadow_depth_range_mode(RID p_light, RS::LightDirectionalShadowDepthRangeMode p_range_mode);
  699. virtual RS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const;
  700. virtual bool light_has_shadow(RID p_light) const;
  701. virtual RS::LightType light_get_type(RID p_light) const;
  702. virtual float light_get_param(RID p_light, RS::LightParam p_param);
  703. virtual Color light_get_color(RID p_light);
  704. virtual bool light_get_use_gi(RID p_light);
  705. virtual AABB light_get_aabb(RID p_light) const;
  706. virtual uint64_t light_get_version(RID p_light) const;
  707. /* PROBE API */
  708. struct ReflectionProbe : Instantiable {
  709. RS::ReflectionProbeUpdateMode update_mode;
  710. float intensity;
  711. Color interior_ambient;
  712. float interior_ambient_energy;
  713. float interior_ambient_probe_contrib;
  714. float max_distance;
  715. Vector3 extents;
  716. Vector3 origin_offset;
  717. bool interior;
  718. bool box_projection;
  719. bool enable_shadows;
  720. uint32_t cull_mask;
  721. int resolution;
  722. };
  723. mutable RID_PtrOwner<ReflectionProbe> reflection_probe_owner;
  724. virtual RID reflection_probe_create();
  725. virtual void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode);
  726. virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity);
  727. virtual void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient);
  728. virtual void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy);
  729. virtual void reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib);
  730. virtual void reflection_probe_set_max_distance(RID p_probe, float p_distance);
  731. virtual void reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents);
  732. virtual void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset);
  733. virtual void reflection_probe_set_as_interior(RID p_probe, bool p_enable);
  734. virtual void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable);
  735. virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable);
  736. virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers);
  737. virtual void reflection_probe_set_resolution(RID p_probe, int p_resolution);
  738. virtual AABB reflection_probe_get_aabb(RID p_probe) const;
  739. virtual RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const;
  740. virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const;
  741. virtual int reflection_probe_get_resolution(RID p_probe) const;
  742. virtual Vector3 reflection_probe_get_extents(RID p_probe) const;
  743. virtual Vector3 reflection_probe_get_origin_offset(RID p_probe) const;
  744. virtual float reflection_probe_get_origin_max_distance(RID p_probe) const;
  745. virtual bool reflection_probe_renders_shadows(RID p_probe) const;
  746. /* GI PROBE API */
  747. virtual RID gi_probe_create();
  748. virtual void gi_probe_set_bounds(RID p_probe, const AABB &p_bounds);
  749. virtual AABB gi_probe_get_bounds(RID p_probe) const;
  750. virtual void gi_probe_set_cell_size(RID p_probe, float p_size);
  751. virtual float gi_probe_get_cell_size(RID p_probe) const;
  752. virtual void gi_probe_set_to_cell_xform(RID p_probe, const Transform &p_xform);
  753. virtual Transform gi_probe_get_to_cell_xform(RID p_probe) const;
  754. virtual void gi_probe_set_dynamic_data(RID p_probe, const Vector<int> &p_data);
  755. virtual Vector<int> gi_probe_get_dynamic_data(RID p_probe) const;
  756. virtual void gi_probe_set_dynamic_range(RID p_probe, int p_range);
  757. virtual int gi_probe_get_dynamic_range(RID p_probe) const;
  758. virtual void gi_probe_set_energy(RID p_probe, float p_range);
  759. virtual float gi_probe_get_energy(RID p_probe) const;
  760. virtual void gi_probe_set_bias(RID p_probe, float p_range);
  761. virtual float gi_probe_get_bias(RID p_probe) const;
  762. virtual void gi_probe_set_normal_bias(RID p_probe, float p_range);
  763. virtual float gi_probe_get_normal_bias(RID p_probe) const;
  764. virtual void gi_probe_set_propagation(RID p_probe, float p_range);
  765. virtual float gi_probe_get_propagation(RID p_probe) const;
  766. virtual void gi_probe_set_interior(RID p_probe, bool p_enable);
  767. virtual bool gi_probe_is_interior(RID p_probe) const;
  768. virtual void gi_probe_set_compress(RID p_probe, bool p_enable);
  769. virtual bool gi_probe_is_compressed(RID p_probe) const;
  770. virtual uint32_t gi_probe_get_version(RID p_probe);
  771. virtual GIProbeCompression gi_probe_get_dynamic_data_get_preferred_compression() const;
  772. virtual RID gi_probe_dynamic_data_create(int p_width, int p_height, int p_depth, GIProbeCompression p_compression);
  773. virtual void gi_probe_dynamic_data_update(RID p_gi_probe_data, int p_depth_slice, int p_slice_count, int p_mipmap, const void *p_data);
  774. /* LIGHTMAP */
  775. struct LightmapCapture : public Instantiable {
  776. Vector<LightmapCaptureOctree> octree;
  777. AABB bounds;
  778. Transform cell_xform;
  779. int cell_subdiv;
  780. float energy;
  781. LightmapCapture() {
  782. energy = 1.0;
  783. cell_subdiv = 1;
  784. }
  785. };
  786. mutable RID_PtrOwner<LightmapCapture> lightmap_capture_data_owner;
  787. virtual RID lightmap_capture_create();
  788. virtual void lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds);
  789. virtual AABB lightmap_capture_get_bounds(RID p_capture) const;
  790. virtual void lightmap_capture_set_octree(RID p_capture, const Vector<uint8_t> &p_octree);
  791. virtual Vector<uint8_t> lightmap_capture_get_octree(RID p_capture) const;
  792. virtual void lightmap_capture_set_octree_cell_transform(RID p_capture, const Transform &p_xform);
  793. virtual Transform lightmap_capture_get_octree_cell_transform(RID p_capture) const;
  794. virtual void lightmap_capture_set_octree_cell_subdiv(RID p_capture, int p_subdiv);
  795. virtual int lightmap_capture_get_octree_cell_subdiv(RID p_capture) const;
  796. virtual void lightmap_capture_set_energy(RID p_capture, float p_energy);
  797. virtual float lightmap_capture_get_energy(RID p_capture) const;
  798. virtual const Vector<LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const;
  799. /* PARTICLES */
  800. void update_particles();
  801. virtual RID particles_create();
  802. virtual void particles_set_emitting(RID p_particles, bool p_emitting);
  803. virtual bool particles_get_emitting(RID p_particles);
  804. virtual void particles_set_amount(RID p_particles, int p_amount);
  805. virtual void particles_set_lifetime(RID p_particles, float p_lifetime);
  806. virtual void particles_set_one_shot(RID p_particles, bool p_one_shot);
  807. virtual void particles_set_pre_process_time(RID p_particles, float p_time);
  808. virtual void particles_set_explosiveness_ratio(RID p_particles, float p_ratio);
  809. virtual void particles_set_randomness_ratio(RID p_particles, float p_ratio);
  810. virtual void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb);
  811. virtual void particles_set_speed_scale(RID p_particles, float p_scale);
  812. virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable);
  813. virtual void particles_set_process_material(RID p_particles, RID p_material);
  814. virtual void particles_set_fixed_fps(RID p_particles, int p_fps);
  815. virtual void particles_set_fractional_delta(RID p_particles, bool p_enable);
  816. virtual void particles_restart(RID p_particles);
  817. virtual void particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order);
  818. virtual void particles_set_draw_passes(RID p_particles, int p_passes);
  819. virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh);
  820. virtual void particles_request_process(RID p_particles);
  821. virtual AABB particles_get_current_aabb(RID p_particles);
  822. virtual AABB particles_get_aabb(RID p_particles) const;
  823. virtual void particles_set_emission_transform(RID p_particles, const Transform &p_transform);
  824. virtual int particles_get_draw_passes(RID p_particles) const;
  825. virtual RID particles_get_draw_pass_mesh(RID p_particles, int p_pass) const;
  826. virtual bool particles_is_inactive(RID p_particles) const;
  827. /* INSTANCE */
  828. virtual void instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance);
  829. virtual void instance_remove_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance);
  830. virtual void instance_add_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance);
  831. virtual void instance_remove_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance);
  832. /* RENDER TARGET */
  833. struct RenderTarget {
  834. GLuint fbo;
  835. GLuint color;
  836. GLuint depth;
  837. GLuint multisample_fbo;
  838. GLuint multisample_color;
  839. GLuint multisample_depth;
  840. bool multisample_active;
  841. struct Effect {
  842. GLuint fbo;
  843. int width;
  844. int height;
  845. GLuint color;
  846. Effect() :
  847. fbo(0),
  848. width(0),
  849. height(0),
  850. color(0) {
  851. }
  852. };
  853. Effect copy_screen_effect;
  854. struct MipMaps {
  855. struct Size {
  856. GLuint fbo;
  857. GLuint color;
  858. int width;
  859. int height;
  860. };
  861. Vector<Size> sizes;
  862. GLuint color;
  863. int levels;
  864. MipMaps() :
  865. color(0),
  866. levels(0) {
  867. }
  868. };
  869. MipMaps mip_maps[2];
  870. struct External {
  871. GLuint fbo;
  872. GLuint color;
  873. GLuint depth;
  874. RID texture;
  875. External() :
  876. fbo(0),
  877. color(0),
  878. depth(0) {
  879. }
  880. } external;
  881. int x, y, width, height;
  882. bool flags[RENDER_TARGET_FLAG_MAX];
  883. bool used_in_frame;
  884. RS::ViewportMSAA msaa;
  885. RID texture;
  886. bool used_dof_blur_near;
  887. bool mip_maps_allocated;
  888. RenderTarget() :
  889. fbo(0),
  890. color(0),
  891. depth(0),
  892. multisample_fbo(0),
  893. multisample_color(0),
  894. multisample_depth(0),
  895. multisample_active(false),
  896. x(0),
  897. y(0),
  898. width(0),
  899. height(0),
  900. used_in_frame(false),
  901. msaa(RS::VIEWPORT_MSAA_DISABLED),
  902. used_dof_blur_near(false),
  903. mip_maps_allocated(false) {
  904. for (int i = 0; i < RENDER_TARGET_FLAG_MAX; ++i) {
  905. flags[i] = false;
  906. }
  907. external.fbo = 0;
  908. }
  909. };
  910. mutable RID_PtrOwner<RenderTarget> render_target_owner;
  911. void _render_target_clear(RenderTarget *rt);
  912. void _render_target_allocate(RenderTarget *rt);
  913. virtual RID render_target_create();
  914. virtual void render_target_set_position(RID p_render_target, int p_x, int p_y);
  915. virtual void render_target_set_size(RID p_render_target, int p_width, int p_height);
  916. virtual RID render_target_get_texture(RID p_render_target) const;
  917. virtual void render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id);
  918. virtual void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value);
  919. virtual bool render_target_was_used(RID p_render_target);
  920. virtual void render_target_set_as_unused(RID p_render_target);
  921. virtual void render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa);
  922. /* CANVAS SHADOW */
  923. struct CanvasLightShadow {
  924. int size;
  925. int height;
  926. GLuint fbo;
  927. GLuint depth;
  928. GLuint distance; //for older devices
  929. };
  930. RID_PtrOwner<CanvasLightShadow> canvas_light_shadow_owner;
  931. virtual RID canvas_light_shadow_buffer_create(int p_width);
  932. /* LIGHT SHADOW MAPPING */
  933. struct CanvasOccluder {
  934. GLuint vertex_id; // 0 means, unconfigured
  935. GLuint index_id; // 0 means, unconfigured
  936. Vector<Vector2> lines;
  937. int len;
  938. };
  939. RID_PtrOwner<CanvasOccluder> canvas_occluder_owner;
  940. virtual RID canvas_light_occluder_create();
  941. virtual void canvas_light_occluder_set_polylines(RID p_occluder, const Vector<Vector2> &p_lines);
  942. virtual RS::InstanceType get_base_type(RID p_rid) const;
  943. virtual bool free(RID p_rid);
  944. struct Frame {
  945. RenderTarget *current_rt;
  946. bool clear_request;
  947. Color clear_request_color;
  948. int canvas_draw_commands;
  949. float time[4];
  950. float delta;
  951. uint64_t count;
  952. } frame;
  953. void initialize();
  954. void finalize();
  955. void _copy_screen();
  956. virtual bool has_os_feature(const String &p_feature) const;
  957. virtual void update_dirty_resources();
  958. virtual void set_debug_generate_wireframes(bool p_generate);
  959. virtual void render_info_begin_capture();
  960. virtual void render_info_end_capture();
  961. virtual int get_captured_render_info(RS::RenderInfo p_info);
  962. virtual int get_render_info(RS::RenderInfo p_info);
  963. virtual String get_video_adapter_name() const;
  964. virtual String get_video_adapter_vendor() const;
  965. RasterizerStorageGLES2();
  966. };
  967. #endif // RASTERIZERSTORAGEGLES2_H