Path: blob/master/servers/rendering/renderer_rd/renderer_canvas_render_rd.h
21337 views
/**************************************************************************/1/* renderer_canvas_render_rd.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "core/templates/lru.h"33#include "servers/rendering/multi_uma_buffer.h"34#include "servers/rendering/renderer_canvas_render.h"35#include "servers/rendering/renderer_rd/pipeline_hash_map_rd.h"36#include "servers/rendering/renderer_rd/shaders/canvas.glsl.gen.h"37#include "servers/rendering/renderer_rd/shaders/canvas_occlusion.glsl.gen.h"38#include "servers/rendering/renderer_rd/storage_rd/material_storage.h"39#include "servers/rendering/rendering_device.h"40#include "servers/rendering/shader_compiler.h"4142class RendererCanvasRenderRD : public RendererCanvasRender {43enum {44BASE_UNIFORM_SET = 0,45MATERIAL_UNIFORM_SET = 1,46TRANSFORMS_UNIFORM_SET = 2,47BATCH_UNIFORM_SET = 3,48};4950const int SAMPLERS_BINDING_FIRST_INDEX = 10;51// The size of the ring buffer to store GPU buffers. Triple-buffering the max expected frames in flight.52static const uint32_t BATCH_DATA_BUFFER_COUNT = 3;5354enum ShaderVariant {55SHADER_VARIANT_QUAD,56SHADER_VARIANT_NINEPATCH,57SHADER_VARIANT_PRIMITIVE,58SHADER_VARIANT_PRIMITIVE_POINTS,59SHADER_VARIANT_ATTRIBUTES,60SHADER_VARIANT_ATTRIBUTES_POINTS,61SHADER_VARIANT_MAX62};6364enum {65INSTANCE_FLAGS_LIGHT_COUNT_SHIFT = 0, // 4 bits for light count.6667INSTANCE_FLAGS_CLIP_RECT_UV = (1 << 4),68INSTANCE_FLAGS_TRANSPOSE_RECT = (1 << 5),6970INSTANCE_FLAGS_NINEPACH_DRAW_CENTER = (1 << 8),71INSTANCE_FLAGS_NINEPATCH_H_MODE_SHIFT = 9,72INSTANCE_FLAGS_NINEPATCH_V_MODE_SHIFT = 11,7374INSTANCE_FLAGS_SHADOW_MASKED_SHIFT = 13, // 16 bits.75};7677enum {78BATCH_FLAGS_INSTANCING_MASK = 0x7F,79BATCH_FLAGS_INSTANCING_HAS_COLORS = (1 << 7),80BATCH_FLAGS_INSTANCING_HAS_CUSTOM_DATA = (1 << 8),8182BATCH_FLAGS_DEFAULT_NORMAL_MAP_USED = (1 << 9),83BATCH_FLAGS_DEFAULT_SPECULAR_MAP_USED = (1 << 10),84};8586enum {87CANVAS_FLAGS_CONVERT_ATTRIBUTES_TO_LINEAR = (1 << 0),88};8990enum {91LIGHT_FLAGS_TEXTURE_MASK = 0xFFFF,92LIGHT_FLAGS_BLEND_SHIFT = 16,93LIGHT_FLAGS_BLEND_MASK = (3 << 16),94LIGHT_FLAGS_BLEND_MODE_ADD = (0 << 16),95LIGHT_FLAGS_BLEND_MODE_SUB = (1 << 16),96LIGHT_FLAGS_BLEND_MODE_MIX = (2 << 16),97LIGHT_FLAGS_BLEND_MODE_MASK = (3 << 16),98LIGHT_FLAGS_HAS_SHADOW = (1 << 20),99LIGHT_FLAGS_FILTER_SHIFT = 22100101};102103enum {104MAX_RENDER_ITEMS = 256 * 1024,105MAX_LIGHT_TEXTURES = 1024,106MAX_LIGHTS_PER_ITEM = 16,107MAX_LIGHTS_PER_RENDER = 256,108};109110/****************/111/**** SHADER ****/112/****************/113114struct ShaderSpecialization {115union {116uint32_t packed_0;117118struct {119uint32_t use_lighting : 1;120uint32_t use_msdf : 1;121uint32_t use_lcd : 1;122};123};124};125126struct PipelineKey {127ShaderVariant variant = SHADER_VARIANT_MAX;128RD::FramebufferFormatID framebuffer_format_id = RD::INVALID_FORMAT_ID;129RD::VertexFormatID vertex_format_id = RD::INVALID_ID;130RD::RenderPrimitive render_primitive = RD::RENDER_PRIMITIVE_MAX;131ShaderSpecialization shader_specialization = {};132uint32_t lcd_blend = 0;133uint32_t ubershader = 0;134135uint32_t hash() const {136uint32_t h = hash_murmur3_one_32(variant);137h = hash_murmur3_one_32(framebuffer_format_id, h);138h = hash_murmur3_one_64((uint64_t)vertex_format_id, h);139h = hash_murmur3_one_32(render_primitive, h);140h = hash_murmur3_one_32(shader_specialization.packed_0, h);141h = hash_murmur3_one_32(lcd_blend, h);142h = hash_murmur3_one_32(ubershader, h);143return hash_fmix32(h);144}145};146147struct CanvasShaderData : public RendererRD::MaterialStorage::ShaderData {148Vector<ShaderCompiler::GeneratedCode::Texture> texture_uniforms;149int blend_mode = 0;150151Vector<uint32_t> ubo_offsets;152uint32_t ubo_size = 0;153154String code;155RID version;156PipelineHashMapRD<PipelineKey, CanvasShaderData, void (CanvasShaderData::*)(PipelineKey)> pipeline_hash_map;157158static const uint32_t VERTEX_INPUT_MASKS_SIZE = SHADER_VARIANT_MAX * 2;159std::atomic<uint64_t> vertex_input_masks[VERTEX_INPUT_MASKS_SIZE] = {};160161bool uses_screen_texture = false;162bool uses_screen_texture_mipmaps = false;163bool uses_sdf = false;164bool uses_time = false;165166void _clear_vertex_input_mask_cache();167void _create_pipeline(PipelineKey p_pipeline_key);168virtual void set_code(const String &p_Code);169virtual bool is_animated() const;170virtual bool casts_shadows() const;171virtual RS::ShaderNativeSourceCode get_native_source_code() const;172virtual Pair<ShaderRD *, RID> get_native_shader_and_version() const;173RID get_shader(ShaderVariant p_shader_variant, bool p_ubershader) const;174uint64_t get_vertex_input_mask(ShaderVariant p_shader_variant, bool p_ubershader);175bool is_valid() const;176177CanvasShaderData();178virtual ~CanvasShaderData();179};180181struct {182// Data must be guaranteed to be erased before the rest on the destructor.183CanvasShaderData *default_version_data = nullptr;184CanvasShaderRD canvas_shader;185RID default_version_rd_shader;186RID quad_index_buffer;187RID quad_index_array;188RD::VertexFormatID quad_vertex_format_id;189RD::VertexFormatID primitive_vertex_format_id;190ShaderCompiler compiler;191uint32_t pipeline_compilations[RS::PIPELINE_SOURCE_MAX] = {};192Mutex mutex;193} shader;194195RendererRD::MaterialStorage::ShaderData *_create_shader_func();196static RendererRD::MaterialStorage::ShaderData *_create_shader_funcs() {197return static_cast<RendererCanvasRenderRD *>(singleton)->_create_shader_func();198}199200struct CanvasMaterialData : public RendererRD::MaterialStorage::MaterialData {201CanvasShaderData *shader_data = nullptr;202RID uniform_set;203RID uniform_set_srgb;204205virtual void set_render_priority(int p_priority) {}206virtual void set_next_pass(RID p_pass) {}207virtual bool update_parameters(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty);208virtual ~CanvasMaterialData();209};210211RendererRD::MaterialStorage::MaterialData *_create_material_func(CanvasShaderData *p_shader);212static RendererRD::MaterialStorage::MaterialData *_create_material_funcs(RendererRD::MaterialStorage::ShaderData *p_shader) {213return static_cast<RendererCanvasRenderRD *>(singleton)->_create_material_func(static_cast<CanvasShaderData *>(p_shader));214}215216/**************************/217/**** CANVAS TEXTURES *****/218/**************************/219220struct {221RS::CanvasItemTextureFilter default_filter;222RS::CanvasItemTextureRepeat default_repeat;223} default_samplers;224225/******************/226/**** POLYGONS ****/227/******************/228229struct PolygonBuffers {230RD::VertexFormatID vertex_format_id;231RID vertex_buffer;232RID vertex_array;233RID index_buffer;234RID indices;235uint32_t primitive_count = 0;236};237238struct {239HashMap<PolygonID, PolygonBuffers> polygons;240PolygonID last_id;241} polygon_buffers;242243/********************/244/**** PRIMITIVES ****/245/********************/246247struct {248RID index_array[4];249} primitive_arrays;250251/*******************/252/**** MATERIALS ****/253/*******************/254255/******************/256/**** LIGHTING ****/257/******************/258259struct CanvasLight {260RID texture;261struct {262bool enabled = false;263float z_far;264float y_offset;265Transform2D directional_xform;266} shadow;267};268269RID_Owner<CanvasLight> canvas_light_owner;270271struct PositionalShadowRenderPushConstant {272float modelview[8];273float rotation[4];274float direction[2];275float z_far;276uint32_t pad;277float z_near;278uint32_t cull_mode;279float pad2[2];280};281282struct ShadowRenderPushConstant {283float projection[16];284float modelview[8];285float direction[2];286float z_far;287uint32_t cull_mode;288};289290struct OccluderPolygon {291RS::CanvasOccluderPolygonCullMode cull_mode;292int line_point_count;293RID vertex_buffer;294RID vertex_array;295RID index_buffer;296RID index_array;297298int sdf_point_count;299int sdf_index_count;300RID sdf_vertex_buffer;301RID sdf_vertex_array;302RID sdf_index_buffer;303RID sdf_index_array;304bool sdf_is_lines;305};306307struct LightUniform {308float matrix[8]; //light to texture coordinate matrix309float shadow_matrix[8]; //light to shadow coordinate matrix310float color[4];311312uint8_t shadow_color[4];313uint32_t flags; //index to light texture314float shadow_pixel_size;315float height;316317float position[2];318float shadow_z_far_inv;319float shadow_y_ofs;320321float atlas_rect[4];322};323324RID_Owner<OccluderPolygon> occluder_polygon_owner;325326enum ShadowRenderMode {327SHADOW_RENDER_MODE_DIRECTIONAL_SHADOW,328SHADOW_RENDER_MODE_POSITIONAL_SHADOW,329SHADOW_RENDER_MODE_SDF,330};331332enum {333SHADOW_RENDER_SDF_TRIANGLES,334SHADOW_RENDER_SDF_LINES,335};336337struct {338CanvasOcclusionShaderRD shader;339RID shader_version;340RID render_pipelines[2];341RID sdf_render_pipelines[2];342RD::VertexFormatID vertex_format;343RD::VertexFormatID sdf_vertex_format;344RD::FramebufferFormatID framebuffer_format;345RD::FramebufferFormatID sdf_framebuffer_format;346} shadow_render;347348/***************/349/**** STATE ****/350/***************/351352//state that does not vary across rendering all items353354struct InstanceData {355float world[6];356float ninepatch_pixel_size[2];357union {358//rect359struct {360float modulation[4];361float ninepatch_margins[4];362float dst_rect[4];363float src_rect[4];364float pad[2];365};366//primitive367struct {368float points[6]; // vec2 points[3]369float uvs[6]; // vec2 points[3]370uint32_t colors[6]; // colors encoded as half371};372};373uint32_t flags;374uint32_t instance_uniforms_ofs;375uint32_t lights[4];376};377378static_assert(sizeof(InstanceData) == 128, "2D instance data struct size must be 128 bytes");379380struct PushConstant {381ShaderSpecialization shader_specialization;382uint32_t specular_shininess;383uint32_t batch_flags;384uint32_t pad0;385386float msdf[2];387float color_texture_pixel_size[2];388};389390struct PushConstantAttributes {391PushConstant base;392393float world[6];394uint32_t flags;395uint32_t instance_uniforms_ofs;396float modulation[4];397uint32_t lights[4];398399operator PushConstant &() {400return base;401}402};403404// TextureState is used to determine when a new batch is required due to a change of texture state.405struct TextureState {406static const uint32_t FILTER_SHIFT = 0;407static const uint32_t FILTER_BITS = 3;408static const uint32_t FILTER_MASK = (1 << FILTER_BITS) - 1;409static const uint32_t REPEAT_SHIFT = FILTER_BITS;410static const uint32_t REPEAT_BITS = 2;411static const uint32_t REPEAT_MASK = (1 << REPEAT_BITS) - 1;412static const uint32_t TEXTURE_IS_DATA_SHIFT = REPEAT_SHIFT + REPEAT_BITS;413static const uint32_t TEXTURE_IS_DATA_BITS = 1;414static const uint32_t TEXTURE_IS_DATA_MASK = (1 << TEXTURE_IS_DATA_BITS) - 1;415static const uint32_t LINEAR_COLORS_SHIFT = TEXTURE_IS_DATA_SHIFT + TEXTURE_IS_DATA_BITS;416static const uint32_t LINEAR_COLORS_BITS = 1;417static const uint32_t LINEAR_COLORS_MASK = (1 << LINEAR_COLORS_BITS) - 1;418419RID texture;420uint32_t other = 0;421422TextureState() {}423424TextureState(RID p_texture, RS::CanvasItemTextureFilter p_base_filter, RS::CanvasItemTextureRepeat p_base_repeat, bool p_texture_is_data, bool p_use_linear_colors) {425texture = p_texture;426other = (((uint32_t)p_base_filter & FILTER_MASK) << FILTER_SHIFT) |427(((uint32_t)p_base_repeat & REPEAT_MASK) << REPEAT_SHIFT) |428(((uint32_t)p_texture_is_data & TEXTURE_IS_DATA_MASK) << TEXTURE_IS_DATA_SHIFT) |429(((uint32_t)p_use_linear_colors & LINEAR_COLORS_MASK) << LINEAR_COLORS_SHIFT);430}431432_ALWAYS_INLINE_ RS::CanvasItemTextureFilter texture_filter() const {433return (RS::CanvasItemTextureFilter)((other >> FILTER_SHIFT) & FILTER_MASK);434}435436_ALWAYS_INLINE_ RS::CanvasItemTextureRepeat texture_repeat() const {437return (RS::CanvasItemTextureRepeat)((other >> REPEAT_SHIFT) & REPEAT_MASK);438}439440_ALWAYS_INLINE_ bool linear_colors() const {441return (other >> LINEAR_COLORS_SHIFT) & LINEAR_COLORS_MASK;442}443444_ALWAYS_INLINE_ bool texture_is_data() const {445return (other >> TEXTURE_IS_DATA_SHIFT) & TEXTURE_IS_DATA_MASK;446}447448_ALWAYS_INLINE_ bool operator==(const TextureState &p_val) const {449return (texture == p_val.texture) && (other == p_val.other);450}451452_ALWAYS_INLINE_ bool operator!=(const TextureState &p_val) const {453return (texture != p_val.texture) || (other != p_val.other);454}455456_ALWAYS_INLINE_ bool is_valid() const { return texture.is_valid(); }457_ALWAYS_INLINE_ bool is_null() const { return texture.is_null(); }458459uint32_t hash() const {460uint32_t hash = hash_murmur3_one_64(texture.get_id());461return hash_murmur3_one_32(other, hash);462}463};464465struct TextureInfo {466TextureState state;467RID diffuse;468RID normal;469RID specular;470RID sampler;471Vector2 texpixel_size;472uint32_t specular_shininess = 0;473uint32_t flags = 0;474};475476/// A key used to uniquely identify a distinct BATCH_UNIFORM_SET477struct RIDSetKey {478TextureState state;479480RIDSetKey() {481}482483RIDSetKey(TextureState p_state) :484state(p_state) {485}486487_ALWAYS_INLINE_ bool operator==(const RIDSetKey &p_val) const {488return state == p_val.state;489}490491_ALWAYS_INLINE_ bool operator!=(const RIDSetKey &p_val) const {492return !(*this == p_val);493}494495_ALWAYS_INLINE_ uint32_t hash() const {496return state.hash();497}498};499500static void _before_evict(RendererCanvasRenderRD::RIDSetKey &p_key, RID &p_rid);501static void _uniform_set_invalidation_callback(void *p_userdata);502static void _canvas_texture_invalidation_callback(bool p_deleted, void *p_userdata);503504typedef LRUCache<RIDSetKey, RID, HashMapHasherDefault, HashMapComparatorDefault<RIDSetKey>, _before_evict> RIDCache;505RIDCache rid_set_to_uniform_set;506/// Maps a CanvasTexture to its associated uniform sets, which must507/// be invalidated when the CanvasTexture is updated, such as changing the508/// diffuse texture.509HashMap<RID, TightLocalVector<RID>> canvas_texture_to_uniform_set;510511static constexpr uint32_t PUSH_DATA_INSTANCE_COUNT = 0x8000'0000; // Use high bit to indicate instance data comes from push_data.512static constexpr uint32_t INSTANCE_COUNT_MASK = 0x7fff'ffff;513514struct Batch {515/// First instance index into the instance buffer for this batch.516uint32_t start = 0;517/// Number of instances in this batch.518uint32_t instance_count = 0;519/// Resource ID of the instance buffer for this batch.520RID instance_buffer; // UMA521/// Push-constant payload for non-VAO draws.522InstanceData push_data = {};523524TextureInfo *tex_info;525526Color modulate = Color(1.0, 1.0, 1.0, 1.0);527float msdf_pix_range = 0.0;528float msdf_outline = 0.0;529530Item *clip = nullptr;531532RID material;533CanvasMaterialData *material_data = nullptr;534535const Item::Command *command = nullptr;536Item::Command::Type command_type = Item::Command::TYPE_ANIMATION_SLICE; // Can default to any type that doesn't form a batch.537ShaderVariant shader_variant = SHADER_VARIANT_QUAD;538RD::RenderPrimitive render_primitive = RD::RENDER_PRIMITIVE_TRIANGLES;539bool use_lighting = false;540bool use_msdf = false;541bool use_lcd = false;542bool has_blend = false;543544// batch-specific data545union {546// TYPE_PRIMITIVE547uint32_t primitive_points = 0;548// TYPE_PARTICLES549uint32_t mesh_instance_count;550};551uint32_t flags = 0;552553_FORCE_INLINE_ PushConstant push_constant() const {554PushConstant pc;555pc.specular_shininess = tex_info->specular_shininess;556pc.batch_flags = tex_info->flags | flags;557pc.pad0 = 0;558559pc.msdf[0] = msdf_pix_range;560pc.msdf[1] = msdf_outline;561pc.color_texture_pixel_size[0] = tex_info->texpixel_size.x;562pc.color_texture_pixel_size[1] = tex_info->texpixel_size.y;563return pc;564}565566_FORCE_INLINE_ PushConstantAttributes push_constant_attributes() const {567PushConstantAttributes pc;568pc.base = push_constant();569memcpy(pc.world, push_data.world, sizeof(pc.world));570memcpy(pc.modulation, push_data.modulation, sizeof(pc.modulation));571memcpy(pc.lights, push_data.lights, sizeof(pc.lights));572pc.flags = push_data.flags;573pc.instance_uniforms_ofs = push_data.instance_uniforms_ofs;574return pc;575}576};577578HashMap<TextureState, TextureInfo, HashMapHasherDefault, HashMapComparatorDefault<TextureState>, PagedAllocator<HashMapElement<TextureState, TextureInfo>>> texture_info_map;579580struct State {581//state buffer582struct Buffer {583float canvas_transform[16];584float screen_transform[16];585float canvas_normal_transform[16];586float canvas_modulate[4];587588float screen_pixel_size[2];589float time;590uint32_t use_pixel_snap;591592float sdf_to_tex[4];593float sdf_to_screen[2];594float screen_to_sdf[2];595596uint32_t directional_light_count;597float tex_to_sdf;598float shadow_pixel_size;599uint32_t flags;600};601602LocalVector<Batch> canvas_instance_batches;603uint32_t current_batch_index = 0;604605static_assert(std::is_trivially_destructible_v<InstanceData>);606static_assert(std::is_trivially_constructible_v<InstanceData>);607608MultiUmaBuffer<1u> instance_buffers = MultiUmaBuffer<1u>("CANVAS_INSTANCE_DATA");609/// A pointer to the current instance buffer retrieved from <c>instance_buffers</c>.610InstanceData *instance_data = nullptr;611/// The index of the next instance to be added to <c>instance_data</c>.612uint32_t instance_data_index = 0;613/// Save the previous instance data to allow us to append .614InstanceData *prev_instance_data = nullptr;615uint32_t prev_instance_data_index = 0;616617InstanceData intermediary_instance_data;618619uint32_t max_instances_per_buffer = 16384;620uint32_t max_instance_buffer_size = 16384 * sizeof(InstanceData);621622Vector<RD::Uniform> batch_texture_uniforms;623RID current_batch_uniform_set;624625LightUniform *light_uniforms = nullptr;626627RID lights_storage_buffer;628RID canvas_state_buffer;629RID shadow_sampler;630RID shadow_texture;631RID shadow_depth_texture;632RID shadow_fb;633int shadow_texture_size = 2048;634635RID shadow_occluder_buffer;636uint32_t shadow_occluder_buffer_size;637RID shadow_ocluder_uniform_set;638639RID default_transforms_uniform_set;640641double time;642643} state;644645Item *items[MAX_RENDER_ITEMS];646647TextureInfo default_texture_info;648649bool using_directional_lights = false;650RID default_canvas_texture;651652RID default_canvas_group_shader;653RID default_canvas_group_material;654RID default_clip_children_material;655RID default_clip_children_shader;656657RS::CanvasItemTextureFilter default_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR;658RS::CanvasItemTextureRepeat default_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED;659660RID _create_base_uniform_set(RID p_to_render_target, bool p_backbuffer);661662bool debug_redraw = false;663Color debug_redraw_color;664double debug_redraw_time = 1.0;665666// A structure to store cached render target information667struct RenderTarget {668// Current render target for the canvas.669RID render_target;670bool use_linear_colors = false;671};672673inline RID _get_pipeline_specialization_or_ubershader(CanvasShaderData *p_shader_data, PipelineKey &r_pipeline_key, PushConstant &r_push_constant, RID p_mesh_instance = RID(), void *p_surface = nullptr, uint32_t p_surface_index = 0, RID *r_vertex_array = nullptr);674void _render_batch_items(RenderTarget p_to_render_target, int p_item_count, const Transform2D &p_canvas_transform_inverse, Light *p_lights, bool &r_sdf_used, bool p_to_backbuffer = false, RenderingMethod::RenderInfo *r_render_info = nullptr);675void _record_item_commands(const Item *p_item, RenderTarget p_render_target, const Transform2D &p_base_transform, Item *&r_current_clip, Light *p_lights, bool &r_batch_broken, bool &r_sdf_used, Batch *&r_current_batch);676void _render_batch(RD::DrawListID p_draw_list, CanvasShaderData *p_shader_data, RenderingDevice::FramebufferFormatID p_framebuffer_format, Light *p_lights, Batch const *p_batch, RenderingMethod::RenderInfo *r_render_info = nullptr);677void _prepare_batch_texture_info(RID p_texture, TextureState &p_state, TextureInfo *p_info);678679// non-UMA680InstanceData *new_instance_data(Batch &p_current_batch, const InstanceData &template_instance, bool p_use_push_data = false);681[[nodiscard]] Batch *_new_batch(bool &r_batch_broken);682void _add_to_batch(bool &r_batch_broken, Batch *&r_current_batch);683void _allocate_instance_buffer();684685_FORCE_INLINE_ void _update_transform_2d_to_mat2x4(const Transform2D &p_transform, float *p_mat2x4);686_FORCE_INLINE_ void _update_transform_2d_to_mat2x3(const Transform2D &p_transform, float *p_mat2x3);687688_FORCE_INLINE_ void _update_transform_2d_to_mat4(const Transform2D &p_transform, float *p_mat4);689_FORCE_INLINE_ void _update_transform_to_mat4(const Transform3D &p_transform, float *p_mat4);690691void _update_shadow_atlas();692void _update_occluder_buffer(uint32_t p_size);693694public:695PolygonID 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>(), int p_count = -1) override;696void free_polygon(PolygonID p_polygon) override;697698RID light_create() override;699void light_set_texture(RID p_rid, RID p_texture) override;700void light_set_use_shadow(RID p_rid, bool p_enable) override;701void light_update_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, const Rect2 &p_light_rect) override;702void light_update_directional_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_cull_distance, const Rect2 &p_clip_rect, LightOccluderInstance *p_occluders) override;703704virtual void render_sdf(RID p_render_target, LightOccluderInstance *p_occluders) override;705706RID occluder_polygon_create() override;707void occluder_polygon_set_shape(RID p_occluder, const Vector<Vector2> &p_points, bool p_closed) override;708void occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) override;709710void canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, Light *p_directional_light_list, const Transform2D &p_canvas_transform, RS::CanvasItemTextureFilter p_default_filter, RS::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, bool &r_sdf_used, RenderingMethod::RenderInfo *r_render_info = nullptr) override;711712virtual void set_shadow_texture_size(int p_size) override;713714void set_debug_redraw(bool p_enabled, double p_time, const Color &p_color) override;715uint32_t get_pipeline_compilations(RS::PipelineSource p_source) override;716717void set_time(double p_time);718void update() override;719bool free(RID p_rid) override;720RendererCanvasRenderRD();721~RendererCanvasRenderRD();722};723724725