texture_storage.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. /*************************************************************************/
  2. /* texture_storage.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 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 TEXTURE_STORAGE_RD_H
  31. #define TEXTURE_STORAGE_RD_H
  32. #include "core/templates/rid_owner.h"
  33. #include "servers/rendering/renderer_rd/shaders/canvas_sdf.glsl.gen.h"
  34. #include "servers/rendering/renderer_storage.h"
  35. #include "servers/rendering/storage/texture_storage.h"
  36. namespace RendererRD {
  37. enum DefaultRDTexture {
  38. DEFAULT_RD_TEXTURE_WHITE,
  39. DEFAULT_RD_TEXTURE_BLACK,
  40. DEFAULT_RD_TEXTURE_NORMAL,
  41. DEFAULT_RD_TEXTURE_ANISO,
  42. DEFAULT_RD_TEXTURE_DEPTH,
  43. DEFAULT_RD_TEXTURE_MULTIMESH_BUFFER,
  44. DEFAULT_RD_TEXTURE_CUBEMAP_BLACK,
  45. DEFAULT_RD_TEXTURE_CUBEMAP_ARRAY_BLACK,
  46. DEFAULT_RD_TEXTURE_CUBEMAP_WHITE,
  47. DEFAULT_RD_TEXTURE_3D_WHITE,
  48. DEFAULT_RD_TEXTURE_3D_BLACK,
  49. DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE,
  50. DEFAULT_RD_TEXTURE_2D_UINT,
  51. DEFAULT_RD_TEXTURE_MAX
  52. };
  53. class CanvasTexture {
  54. public:
  55. RID diffuse;
  56. RID normal_map;
  57. RID specular;
  58. Color specular_color = Color(1, 1, 1, 1);
  59. float shininess = 1.0;
  60. RS::CanvasItemTextureFilter texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT;
  61. RS::CanvasItemTextureRepeat texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT;
  62. RID uniform_sets[RS::CANVAS_ITEM_TEXTURE_FILTER_MAX][RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX];
  63. Size2i size_cache = Size2i(1, 1);
  64. bool use_normal_cache = false;
  65. bool use_specular_cache = false;
  66. bool cleared_cache = true;
  67. void clear_sets();
  68. ~CanvasTexture();
  69. };
  70. class Texture {
  71. public:
  72. enum Type {
  73. TYPE_2D,
  74. TYPE_LAYERED,
  75. TYPE_3D
  76. };
  77. Type type;
  78. RS::TextureLayeredType layered_type = RS::TEXTURE_LAYERED_2D_ARRAY;
  79. RenderingDevice::TextureType rd_type;
  80. RID rd_texture;
  81. RID rd_texture_srgb;
  82. RenderingDevice::DataFormat rd_format;
  83. RenderingDevice::DataFormat rd_format_srgb;
  84. RD::TextureView rd_view;
  85. Image::Format format;
  86. Image::Format validated_format;
  87. int width;
  88. int height;
  89. int depth;
  90. int layers;
  91. int mipmaps;
  92. int height_2d;
  93. int width_2d;
  94. struct BufferSlice3D {
  95. Size2i size;
  96. uint32_t offset = 0;
  97. uint32_t buffer_size = 0;
  98. };
  99. Vector<BufferSlice3D> buffer_slices_3d;
  100. uint32_t buffer_size_3d = 0;
  101. bool is_render_target;
  102. bool is_proxy;
  103. Ref<Image> image_cache_2d;
  104. String path;
  105. RID proxy_to;
  106. Vector<RID> proxies;
  107. Set<RID> lightmap_users;
  108. RS::TextureDetectCallback detect_3d_callback = nullptr;
  109. void *detect_3d_callback_ud = nullptr;
  110. RS::TextureDetectCallback detect_normal_callback = nullptr;
  111. void *detect_normal_callback_ud = nullptr;
  112. RS::TextureDetectRoughnessCallback detect_roughness_callback = nullptr;
  113. void *detect_roughness_callback_ud = nullptr;
  114. CanvasTexture *canvas_texture = nullptr;
  115. void cleanup();
  116. };
  117. struct DecalAtlas {
  118. struct Texture {
  119. int panorama_to_dp_users;
  120. int users;
  121. Rect2 uv_rect;
  122. };
  123. struct SortItem {
  124. RID texture;
  125. Size2i pixel_size;
  126. Size2i size;
  127. Point2i pos;
  128. bool operator<(const SortItem &p_item) const {
  129. //sort larger to smaller
  130. if (size.height == p_item.size.height) {
  131. return size.width > p_item.size.width;
  132. } else {
  133. return size.height > p_item.size.height;
  134. }
  135. }
  136. };
  137. HashMap<RID, Texture> textures;
  138. bool dirty = true;
  139. int mipmaps = 5;
  140. RID texture;
  141. RID texture_srgb;
  142. struct MipMap {
  143. RID fb;
  144. RID texture;
  145. Size2i size;
  146. };
  147. Vector<MipMap> texture_mipmaps;
  148. Size2i size;
  149. };
  150. struct Decal {
  151. Vector3 extents = Vector3(1, 1, 1);
  152. RID textures[RS::DECAL_TEXTURE_MAX];
  153. float emission_energy = 1.0;
  154. float albedo_mix = 1.0;
  155. Color modulate = Color(1, 1, 1, 1);
  156. uint32_t cull_mask = (1 << 20) - 1;
  157. float upper_fade = 0.3;
  158. float lower_fade = 0.3;
  159. bool distance_fade = false;
  160. float distance_fade_begin = 10;
  161. float distance_fade_length = 1;
  162. float normal_fade = 0.0;
  163. RendererStorage::Dependency dependency;
  164. };
  165. struct RenderTarget {
  166. Size2i size;
  167. uint32_t view_count;
  168. RID framebuffer;
  169. RID color;
  170. //used for retrieving from CPU
  171. RD::DataFormat color_format = RD::DATA_FORMAT_R4G4_UNORM_PACK8;
  172. RD::DataFormat color_format_srgb = RD::DATA_FORMAT_R4G4_UNORM_PACK8;
  173. Image::Format image_format = Image::FORMAT_L8;
  174. bool flags[RendererTextureStorage::RENDER_TARGET_FLAG_MAX];
  175. bool sdf_enabled = false;
  176. RID backbuffer; //used for effects
  177. RID backbuffer_fb;
  178. RID backbuffer_mipmap0;
  179. Vector<RID> backbuffer_mipmaps;
  180. RID framebuffer_uniform_set;
  181. RID backbuffer_uniform_set;
  182. RID sdf_buffer_write;
  183. RID sdf_buffer_write_fb;
  184. RID sdf_buffer_process[2];
  185. RID sdf_buffer_read;
  186. RID sdf_buffer_process_uniform_sets[2];
  187. RS::ViewportSDFOversize sdf_oversize = RS::VIEWPORT_SDF_OVERSIZE_120_PERCENT;
  188. RS::ViewportSDFScale sdf_scale = RS::VIEWPORT_SDF_SCALE_50_PERCENT;
  189. Size2i process_size;
  190. //texture generated for this owner (nor RD).
  191. RID texture;
  192. bool was_used;
  193. //clear request
  194. bool clear_requested;
  195. Color clear_color;
  196. };
  197. struct RenderTargetSDF {
  198. enum {
  199. SHADER_LOAD,
  200. SHADER_LOAD_SHRINK,
  201. SHADER_PROCESS,
  202. SHADER_PROCESS_OPTIMIZED,
  203. SHADER_STORE,
  204. SHADER_STORE_SHRINK,
  205. SHADER_MAX
  206. };
  207. struct PushConstant {
  208. int32_t size[2];
  209. int32_t stride;
  210. int32_t shift;
  211. int32_t base_size[2];
  212. int32_t pad[2];
  213. };
  214. CanvasSdfShaderRD shader;
  215. RID shader_version;
  216. RID pipelines[SHADER_MAX];
  217. };
  218. class TextureStorage : public RendererTextureStorage {
  219. private:
  220. static TextureStorage *singleton;
  221. /* Canvas Texture API */
  222. RID_Owner<RendererRD::CanvasTexture, true> canvas_texture_owner;
  223. /* Texture API */
  224. //textures can be created from threads, so this RID_Owner is thread safe
  225. mutable RID_Owner<Texture, true> texture_owner;
  226. struct TextureToRDFormat {
  227. RD::DataFormat format;
  228. RD::DataFormat format_srgb;
  229. RD::TextureSwizzle swizzle_r;
  230. RD::TextureSwizzle swizzle_g;
  231. RD::TextureSwizzle swizzle_b;
  232. RD::TextureSwizzle swizzle_a;
  233. TextureToRDFormat() {
  234. format = RD::DATA_FORMAT_MAX;
  235. format_srgb = RD::DATA_FORMAT_MAX;
  236. swizzle_r = RD::TEXTURE_SWIZZLE_R;
  237. swizzle_g = RD::TEXTURE_SWIZZLE_G;
  238. swizzle_b = RD::TEXTURE_SWIZZLE_B;
  239. swizzle_a = RD::TEXTURE_SWIZZLE_A;
  240. }
  241. };
  242. Ref<Image> _validate_texture_format(const Ref<Image> &p_image, TextureToRDFormat &r_format);
  243. void _texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0, bool p_immediate = false);
  244. /* DECAL API */
  245. DecalAtlas decal_atlas;
  246. mutable RID_Owner<Decal, true> decal_owner;
  247. /* RENDER TARGET API */
  248. mutable RID_Owner<RenderTarget> render_target_owner;
  249. void _clear_render_target(RenderTarget *rt);
  250. void _update_render_target(RenderTarget *rt);
  251. void _create_render_target_backbuffer(RenderTarget *rt);
  252. void _render_target_allocate_sdf(RenderTarget *rt);
  253. void _render_target_clear_sdf(RenderTarget *rt);
  254. Rect2i _render_target_get_sdf_rect(const RenderTarget *rt) const;
  255. RenderTargetSDF rt_sdf;
  256. public:
  257. static TextureStorage *get_singleton();
  258. RID default_rd_textures[DEFAULT_RD_TEXTURE_MAX];
  259. _FORCE_INLINE_ RID texture_rd_get_default(DefaultRDTexture p_texture) {
  260. return default_rd_textures[p_texture];
  261. }
  262. TextureStorage();
  263. virtual ~TextureStorage();
  264. /* Canvas Texture API */
  265. CanvasTexture *get_canvas_texture(RID p_rid) { return canvas_texture_owner.get_or_null(p_rid); };
  266. bool owns_canvas_texture(RID p_rid) { return canvas_texture_owner.owns(p_rid); };
  267. virtual RID canvas_texture_allocate() override;
  268. virtual void canvas_texture_initialize(RID p_rid) override;
  269. virtual void canvas_texture_free(RID p_rid) override;
  270. virtual void canvas_texture_set_channel(RID p_canvas_texture, RS::CanvasTextureChannel p_channel, RID p_texture) override;
  271. virtual void canvas_texture_set_shading_parameters(RID p_canvas_texture, const Color &p_base_color, float p_shininess) override;
  272. virtual void canvas_texture_set_texture_filter(RID p_item, RS::CanvasItemTextureFilter p_filter) override;
  273. virtual void canvas_texture_set_texture_repeat(RID p_item, RS::CanvasItemTextureRepeat p_repeat) override;
  274. bool canvas_texture_get_uniform_set(RID p_texture, RS::CanvasItemTextureFilter p_base_filter, RS::CanvasItemTextureRepeat p_base_repeat, RID p_base_shader, int p_base_set, RID &r_uniform_set, Size2i &r_size, Color &r_specular_shininess, bool &r_use_normal, bool &r_use_specular);
  275. /* Texture API */
  276. Texture *get_texture(RID p_rid) { return texture_owner.get_or_null(p_rid); };
  277. bool owns_texture(RID p_rid) { return texture_owner.owns(p_rid); };
  278. virtual bool can_create_resources_async() const override;
  279. virtual RID texture_allocate() override;
  280. virtual void texture_free(RID p_rid) override;
  281. virtual void texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) override;
  282. virtual void texture_2d_layered_initialize(RID p_texture, const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) override;
  283. virtual void texture_3d_initialize(RID p_texture, Image::Format, int p_width, int p_height, int p_depth, bool p_mipmaps, const Vector<Ref<Image>> &p_data) override;
  284. virtual void texture_proxy_initialize(RID p_texture, RID p_base) override; //all slices, then all the mipmaps, must be coherent
  285. virtual void texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) override;
  286. virtual void texture_3d_update(RID p_texture, const Vector<Ref<Image>> &p_data) override;
  287. virtual void texture_proxy_update(RID p_proxy, RID p_base) override;
  288. //these two APIs can be used together or in combination with the others.
  289. virtual void texture_2d_placeholder_initialize(RID p_texture) override;
  290. virtual void texture_2d_layered_placeholder_initialize(RID p_texture, RenderingServer::TextureLayeredType p_layered_type) override;
  291. virtual void texture_3d_placeholder_initialize(RID p_texture) override;
  292. virtual Ref<Image> texture_2d_get(RID p_texture) const override;
  293. virtual Ref<Image> texture_2d_layer_get(RID p_texture, int p_layer) const override;
  294. virtual Vector<Ref<Image>> texture_3d_get(RID p_texture) const override;
  295. virtual void texture_replace(RID p_texture, RID p_by_texture) override;
  296. virtual void texture_set_size_override(RID p_texture, int p_width, int p_height) override;
  297. virtual void texture_set_path(RID p_texture, const String &p_path) override;
  298. virtual String texture_get_path(RID p_texture) const override;
  299. virtual void texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) override;
  300. virtual void texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) override;
  301. virtual void texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata) override;
  302. virtual void texture_debug_usage(List<RS::TextureInfo> *r_info) override;
  303. virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) override;
  304. virtual Size2 texture_size_with_proxy(RID p_proxy) override;
  305. //internal usage
  306. _FORCE_INLINE_ RID texture_get_rd_texture(RID p_texture, bool p_srgb = false) {
  307. if (p_texture.is_null()) {
  308. return RID();
  309. }
  310. RendererRD::Texture *tex = texture_owner.get_or_null(p_texture);
  311. if (!tex) {
  312. return RID();
  313. }
  314. return (p_srgb && tex->rd_texture_srgb.is_valid()) ? tex->rd_texture_srgb : tex->rd_texture;
  315. }
  316. _FORCE_INLINE_ Size2i texture_2d_get_size(RID p_texture) {
  317. if (p_texture.is_null()) {
  318. return Size2i();
  319. }
  320. RendererRD::Texture *tex = texture_owner.get_or_null(p_texture);
  321. if (!tex) {
  322. return Size2i();
  323. }
  324. return Size2i(tex->width_2d, tex->height_2d);
  325. }
  326. /* DECAL API */
  327. void update_decal_atlas();
  328. Decal *get_decal(RID p_rid) { return decal_owner.get_or_null(p_rid); };
  329. bool owns_decal(RID p_rid) { return decal_owner.owns(p_rid); };
  330. RID decal_atlas_get_texture() const;
  331. RID decal_atlas_get_texture_srgb() const;
  332. _FORCE_INLINE_ Rect2 decal_atlas_get_texture_rect(RID p_texture) {
  333. DecalAtlas::Texture *t = decal_atlas.textures.getptr(p_texture);
  334. if (!t) {
  335. return Rect2();
  336. }
  337. return t->uv_rect;
  338. }
  339. virtual RID decal_allocate() override;
  340. virtual void decal_initialize(RID p_decal) override;
  341. virtual void decal_free(RID p_rid) override;
  342. virtual void decal_set_extents(RID p_decal, const Vector3 &p_extents) override;
  343. virtual void decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) override;
  344. virtual void decal_set_emission_energy(RID p_decal, float p_energy) override;
  345. virtual void decal_set_albedo_mix(RID p_decal, float p_mix) override;
  346. virtual void decal_set_modulate(RID p_decal, const Color &p_modulate) override;
  347. virtual void decal_set_cull_mask(RID p_decal, uint32_t p_layers) override;
  348. virtual void decal_set_distance_fade(RID p_decal, bool p_enabled, float p_begin, float p_length) override;
  349. virtual void decal_set_fade(RID p_decal, float p_above, float p_below) override;
  350. virtual void decal_set_normal_fade(RID p_decal, float p_fade) override;
  351. void decal_atlas_mark_dirty_on_texture(RID p_texture);
  352. void decal_atlas_remove_texture(RID p_texture);
  353. virtual void texture_add_to_decal_atlas(RID p_texture, bool p_panorama_to_dp = false) override;
  354. virtual void texture_remove_from_decal_atlas(RID p_texture, bool p_panorama_to_dp = false) override;
  355. _FORCE_INLINE_ Vector3 decal_get_extents(RID p_decal) {
  356. const Decal *decal = decal_owner.get_or_null(p_decal);
  357. return decal->extents;
  358. }
  359. _FORCE_INLINE_ RID decal_get_texture(RID p_decal, RS::DecalTexture p_texture) {
  360. const Decal *decal = decal_owner.get_or_null(p_decal);
  361. return decal->textures[p_texture];
  362. }
  363. _FORCE_INLINE_ Color decal_get_modulate(RID p_decal) {
  364. const Decal *decal = decal_owner.get_or_null(p_decal);
  365. return decal->modulate;
  366. }
  367. _FORCE_INLINE_ float decal_get_emission_energy(RID p_decal) {
  368. const Decal *decal = decal_owner.get_or_null(p_decal);
  369. return decal->emission_energy;
  370. }
  371. _FORCE_INLINE_ float decal_get_albedo_mix(RID p_decal) {
  372. const Decal *decal = decal_owner.get_or_null(p_decal);
  373. return decal->albedo_mix;
  374. }
  375. _FORCE_INLINE_ uint32_t decal_get_cull_mask(RID p_decal) {
  376. const Decal *decal = decal_owner.get_or_null(p_decal);
  377. return decal->cull_mask;
  378. }
  379. _FORCE_INLINE_ float decal_get_upper_fade(RID p_decal) {
  380. const Decal *decal = decal_owner.get_or_null(p_decal);
  381. return decal->upper_fade;
  382. }
  383. _FORCE_INLINE_ float decal_get_lower_fade(RID p_decal) {
  384. const Decal *decal = decal_owner.get_or_null(p_decal);
  385. return decal->lower_fade;
  386. }
  387. _FORCE_INLINE_ float decal_get_normal_fade(RID p_decal) {
  388. const Decal *decal = decal_owner.get_or_null(p_decal);
  389. return decal->normal_fade;
  390. }
  391. _FORCE_INLINE_ bool decal_is_distance_fade_enabled(RID p_decal) {
  392. const Decal *decal = decal_owner.get_or_null(p_decal);
  393. return decal->distance_fade;
  394. }
  395. _FORCE_INLINE_ float decal_get_distance_fade_begin(RID p_decal) {
  396. const Decal *decal = decal_owner.get_or_null(p_decal);
  397. return decal->distance_fade_begin;
  398. }
  399. _FORCE_INLINE_ float decal_get_distance_fade_length(RID p_decal) {
  400. const Decal *decal = decal_owner.get_or_null(p_decal);
  401. return decal->distance_fade_length;
  402. }
  403. virtual AABB decal_get_aabb(RID p_decal) const override;
  404. /* RENDER TARGET API */
  405. RenderTarget *get_render_target(RID p_rid) { return render_target_owner.get_or_null(p_rid); };
  406. bool owns_render_target(RID p_rid) { return render_target_owner.owns(p_rid); };
  407. virtual RID render_target_create() override;
  408. virtual void render_target_free(RID p_rid) override;
  409. virtual void render_target_set_position(RID p_render_target, int p_x, int p_y) override;
  410. virtual void render_target_set_size(RID p_render_target, int p_width, int p_height, uint32_t p_view_count) override;
  411. virtual RID render_target_get_texture(RID p_render_target) override;
  412. virtual void render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id) override;
  413. virtual void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) override;
  414. virtual bool render_target_was_used(RID p_render_target) override;
  415. virtual void render_target_set_as_unused(RID p_render_target) override;
  416. void render_target_copy_to_back_buffer(RID p_render_target, const Rect2i &p_region, bool p_gen_mipmaps);
  417. void render_target_clear_back_buffer(RID p_render_target, const Rect2i &p_region, const Color &p_color);
  418. void render_target_gen_back_buffer_mipmaps(RID p_render_target, const Rect2i &p_region);
  419. RID render_target_get_back_buffer_uniform_set(RID p_render_target, RID p_base_shader);
  420. virtual void render_target_request_clear(RID p_render_target, const Color &p_clear_color) override;
  421. virtual bool render_target_is_clear_requested(RID p_render_target) override;
  422. virtual Color render_target_get_clear_request_color(RID p_render_target) override;
  423. virtual void render_target_disable_clear_request(RID p_render_target) override;
  424. virtual void render_target_do_clear_request(RID p_render_target) override;
  425. virtual void render_target_set_sdf_size_and_scale(RID p_render_target, RS::ViewportSDFOversize p_size, RS::ViewportSDFScale p_scale) override;
  426. RID render_target_get_sdf_texture(RID p_render_target);
  427. RID render_target_get_sdf_framebuffer(RID p_render_target);
  428. void render_target_sdf_process(RID p_render_target);
  429. virtual Rect2i render_target_get_sdf_rect(RID p_render_target) const override;
  430. virtual void render_target_mark_sdf_enabled(RID p_render_target, bool p_enabled) override;
  431. bool render_target_is_sdf_enabled(RID p_render_target) const;
  432. Size2 render_target_get_size(RID p_render_target);
  433. RID render_target_get_rd_framebuffer(RID p_render_target);
  434. RID render_target_get_rd_texture(RID p_render_target);
  435. RID render_target_get_rd_backbuffer(RID p_render_target);
  436. RID render_target_get_rd_backbuffer_framebuffer(RID p_render_target);
  437. RID render_target_get_framebuffer_uniform_set(RID p_render_target);
  438. RID render_target_get_backbuffer_uniform_set(RID p_render_target);
  439. void render_target_set_framebuffer_uniform_set(RID p_render_target, RID p_uniform_set);
  440. void render_target_set_backbuffer_uniform_set(RID p_render_target, RID p_uniform_set);
  441. };
  442. } // namespace RendererRD
  443. #endif // !_TEXTURE_STORAGE_RD_H