| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "servers/rendering/rendering_server.h" |
| 34 |
|
| 35 |
class RendererTextureStorage { |
| 36 |
private: |
| 37 |
Color default_clear_color; |
| 38 |
|
| 39 |
public: |
| 40 |
void set_default_clear_color(const Color &p_color) { |
| 41 |
default_clear_color = p_color; |
| 42 |
} |
| 43 |
|
| 44 |
Color get_default_clear_color() const { |
| 45 |
return default_clear_color; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
virtual RID canvas_texture_allocate() = 0; |
| 51 |
virtual void canvas_texture_initialize(RID p_rid) = 0; |
| 52 |
virtual void canvas_texture_free(RID p_rid) = 0; |
| 53 |
|
| 54 |
virtual void canvas_texture_set_channel(RID p_canvas_texture, RS::CanvasTextureChannel p_channel, RID p_texture) = 0; |
| 55 |
virtual void canvas_texture_set_shading_parameters(RID p_canvas_texture, const Color &p_base_color, float p_shininess) = 0; |
| 56 |
|
| 57 |
virtual void canvas_texture_set_texture_filter(RID p_item, RS::CanvasItemTextureFilter p_filter) = 0; |
| 58 |
virtual void canvas_texture_set_texture_repeat(RID p_item, RS::CanvasItemTextureRepeat p_repeat) = 0; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
virtual ~RendererTextureStorage() {} |
| 63 |
|
| 64 |
virtual RID texture_allocate() = 0; |
| 65 |
virtual void texture_free(RID p_rid) = 0; |
| 66 |
|
| 67 |
virtual void texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) = 0; |
| 68 |
virtual void texture_2d_layered_initialize(RID p_texture, const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) = 0; |
| 69 |
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) = 0; |
| 70 |
virtual void texture_external_initialize(RID p_texture, int p_width, int p_height, uint64_t p_external_buffer) = 0; |
| 71 |
virtual void texture_proxy_initialize(RID p_texture, RID p_base) = 0; |
| 72 |
|
| 73 |
virtual RID texture_create_from_native_handle(RS::TextureType p_type, Image::Format p_format, uint64_t p_native_handle, int p_width, int p_height, int p_depth, int p_layers = 1, RS::TextureLayeredType p_layered_type = RS::TEXTURE_LAYERED_2D_ARRAY) = 0; |
| 74 |
|
| 75 |
virtual void texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) = 0; |
| 76 |
virtual void texture_3d_update(RID p_texture, const Vector<Ref<Image>> &p_data) = 0; |
| 77 |
virtual void texture_external_update(RID p_proxy, int p_width, int p_height, uint64_t p_external_buffer) = 0; |
| 78 |
virtual void texture_proxy_update(RID p_proxy, RID p_base) = 0; |
| 79 |
|
| 80 |
|
| 81 |
virtual void texture_2d_placeholder_initialize(RID p_texture) = 0; |
| 82 |
virtual void texture_2d_layered_placeholder_initialize(RID p_texture, RenderingServer::TextureLayeredType p_layered_type) = 0; |
| 83 |
virtual void texture_3d_placeholder_initialize(RID p_texture) = 0; |
| 84 |
|
| 85 |
virtual Ref<Image> texture_2d_get(RID p_texture) const = 0; |
| 86 |
virtual Ref<Image> texture_2d_layer_get(RID p_texture, int p_layer) const = 0; |
| 87 |
virtual Vector<Ref<Image>> texture_3d_get(RID p_texture) const = 0; |
| 88 |
|
| 89 |
virtual void texture_replace(RID p_texture, RID p_by_texture) = 0; |
| 90 |
virtual void texture_set_size_override(RID p_texture, int p_width, int p_height) = 0; |
| 91 |
|
| 92 |
virtual void texture_set_path(RID p_texture, const String &p_path) = 0; |
| 93 |
virtual String texture_get_path(RID p_texture) const = 0; |
| 94 |
|
| 95 |
virtual Image::Format texture_get_format(RID p_texture) const = 0; |
| 96 |
|
| 97 |
virtual void texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) = 0; |
| 98 |
virtual void texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) = 0; |
| 99 |
virtual void texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata) = 0; |
| 100 |
|
| 101 |
virtual void texture_debug_usage(List<RS::TextureInfo> *r_info) = 0; |
| 102 |
|
| 103 |
virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) = 0; |
| 104 |
|
| 105 |
virtual Size2 texture_size_with_proxy(RID p_proxy) = 0; |
| 106 |
|
| 107 |
virtual void texture_rd_initialize(RID p_texture, const RID &p_rd_texture, const RS::TextureLayeredType p_layer_type = RS::TEXTURE_LAYERED_2D_ARRAY) = 0; |
| 108 |
virtual RID texture_get_rd_texture(RID p_texture, bool p_srgb = false) const = 0; |
| 109 |
virtual uint64_t texture_get_native_handle(RID p_texture, bool p_srgb = false) const = 0; |
| 110 |
|
| 111 |
|
| 112 |
virtual RID decal_allocate() = 0; |
| 113 |
virtual void decal_initialize(RID p_rid) = 0; |
| 114 |
virtual void decal_free(RID p_rid) = 0; |
| 115 |
|
| 116 |
virtual void decal_set_size(RID p_decal, const Vector3 &p_size) = 0; |
| 117 |
virtual void decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) = 0; |
| 118 |
virtual void decal_set_emission_energy(RID p_decal, float p_energy) = 0; |
| 119 |
virtual void decal_set_albedo_mix(RID p_decal, float p_mix) = 0; |
| 120 |
virtual void decal_set_modulate(RID p_decal, const Color &p_modulate) = 0; |
| 121 |
virtual void decal_set_cull_mask(RID p_decal, uint32_t p_layers) = 0; |
| 122 |
virtual void decal_set_distance_fade(RID p_decal, bool p_enabled, float p_begin, float p_length) = 0; |
| 123 |
virtual void decal_set_fade(RID p_decal, float p_above, float p_below) = 0; |
| 124 |
virtual void decal_set_normal_fade(RID p_decal, float p_fade) = 0; |
| 125 |
|
| 126 |
virtual AABB decal_get_aabb(RID p_decal) const = 0; |
| 127 |
virtual uint32_t decal_get_cull_mask(RID p_decal) const = 0; |
| 128 |
|
| 129 |
virtual void texture_add_to_decal_atlas(RID p_texture, bool p_panorama_to_dp = false) = 0; |
| 130 |
virtual void texture_remove_from_decal_atlas(RID p_texture, bool p_panorama_to_dp = false) = 0; |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
virtual RID decal_instance_create(RID p_decal) = 0; |
| 135 |
virtual void decal_instance_free(RID p_decal_instance) = 0; |
| 136 |
virtual void decal_instance_set_transform(RID p_decal_instance, const Transform3D &p_transform) = 0; |
| 137 |
virtual void decal_instance_set_sorting_offset(RID p_decal_instance, float p_sorting_offset) = 0; |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
virtual RID render_target_create() = 0; |
| 142 |
virtual void render_target_free(RID p_rid) = 0; |
| 143 |
|
| 144 |
virtual void render_target_set_position(RID p_render_target, int p_x, int p_y) = 0; |
| 145 |
virtual Point2i render_target_get_position(RID p_render_target) const = 0; |
| 146 |
virtual void render_target_set_size(RID p_render_target, int p_width, int p_height, uint32_t p_view_count) = 0; |
| 147 |
virtual Size2i render_target_get_size(RID p_render_target) const = 0; |
| 148 |
virtual void render_target_set_transparent(RID p_render_target, bool p_is_transparent) = 0; |
| 149 |
virtual bool render_target_get_transparent(RID p_render_target) const = 0; |
| 150 |
virtual void render_target_set_direct_to_screen(RID p_render_target, bool p_direct_to_screen) = 0; |
| 151 |
virtual bool render_target_get_direct_to_screen(RID p_render_target) const = 0; |
| 152 |
virtual bool render_target_was_used(RID p_render_target) const = 0; |
| 153 |
virtual void render_target_set_as_unused(RID p_render_target) = 0; |
| 154 |
virtual void render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) = 0; |
| 155 |
virtual RS::ViewportMSAA render_target_get_msaa(RID p_render_target) const = 0; |
| 156 |
virtual void render_target_set_msaa_needs_resolve(RID p_render_target, bool p_needs_resolve) = 0; |
| 157 |
virtual bool render_target_get_msaa_needs_resolve(RID p_render_target) const = 0; |
| 158 |
virtual void render_target_do_msaa_resolve(RID p_render_target) = 0; |
| 159 |
virtual void render_target_set_use_hdr(RID p_render_target, bool p_use_hdr) = 0; |
| 160 |
virtual bool render_target_is_using_hdr(RID p_render_target) const = 0; |
| 161 |
virtual void render_target_set_use_debanding(RID p_render_target, bool p_use_debanding) = 0; |
| 162 |
virtual bool render_target_is_using_debanding(RID p_render_target) const = 0; |
| 163 |
|
| 164 |
virtual void render_target_request_clear(RID p_render_target, const Color &p_clear_color) = 0; |
| 165 |
virtual bool render_target_is_clear_requested(RID p_render_target) = 0; |
| 166 |
virtual Color render_target_get_clear_request_color(RID p_render_target) = 0; |
| 167 |
virtual void render_target_disable_clear_request(RID p_render_target) = 0; |
| 168 |
virtual void render_target_do_clear_request(RID p_render_target) = 0; |
| 169 |
|
| 170 |
virtual void render_target_set_sdf_size_and_scale(RID p_render_target, RS::ViewportSDFOversize p_size, RS::ViewportSDFScale p_scale) = 0; |
| 171 |
virtual Rect2i render_target_get_sdf_rect(RID p_render_target) const = 0; |
| 172 |
virtual void render_target_mark_sdf_enabled(RID p_render_target, bool p_enabled) = 0; |
| 173 |
|
| 174 |
virtual void render_target_set_vrs_mode(RID p_render_target, RS::ViewportVRSMode p_mode) = 0; |
| 175 |
virtual RS::ViewportVRSMode render_target_get_vrs_mode(RID p_render_target) const = 0; |
| 176 |
virtual void render_target_set_vrs_update_mode(RID p_render_target, RS::ViewportVRSUpdateMode p_mode) = 0; |
| 177 |
virtual RS::ViewportVRSUpdateMode render_target_get_vrs_update_mode(RID p_render_target) const = 0; |
| 178 |
virtual void render_target_set_vrs_texture(RID p_render_target, RID p_texture) = 0; |
| 179 |
virtual RID render_target_get_vrs_texture(RID p_render_target) const = 0; |
| 180 |
|
| 181 |
|
| 182 |
virtual void render_target_set_override(RID p_render_target, RID p_color_texture, RID p_depth_texture, RID p_velocity_texture, RID p_velocity_depth_texture) = 0; |
| 183 |
virtual RID render_target_get_override_color(RID p_render_target) const = 0; |
| 184 |
virtual RID render_target_get_override_depth(RID p_render_target) const = 0; |
| 185 |
virtual RID render_target_get_override_velocity(RID p_render_target) const = 0; |
| 186 |
virtual RID render_target_get_override_velocity_depth(RID p_render_target) const = 0; |
| 187 |
|
| 188 |
virtual void render_target_set_render_region(RID p_render_target, const Rect2i &p_render_region) = 0; |
| 189 |
virtual Rect2i render_target_get_render_region(RID p_render_target) const = 0; |
| 190 |
|
| 191 |
|
| 192 |
virtual RID render_target_get_texture(RID p_render_target) = 0; |
| 193 |
|
| 194 |
|
| 195 |
virtual void render_target_set_velocity_target_size(RID p_render_target, const Size2i &p_target_size) = 0; |
| 196 |
virtual Size2i render_target_get_velocity_target_size(RID p_render_target) const = 0; |
| 197 |
}; |