Skip to content

Commit 724879c

Browse files
committed
Merge pull request godotengine#97554 from clayjohn/batching-uniform-sets
Combine texture and instance data into one uniform set in the 2D renderer
2 parents 91eb067 + 5ac2b4f commit 724879c

5 files changed

Lines changed: 146 additions & 195 deletions

File tree

servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp

Lines changed: 71 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,12 @@ RendererCanvasRenderRD::RendererCanvasRenderRD() {
19741974
default_canvas_texture = texture_storage->canvas_texture_allocate();
19751975
texture_storage->canvas_texture_initialize(default_canvas_texture);
19761976

1977+
RendererRD::TextureStorage::CanvasTextureInfo info = RendererRD::TextureStorage::get_singleton()->canvas_texture_get_info(default_canvas_texture, default_filter, default_repeat, false, false);
1978+
default_texture_info.diffuse = info.diffuse;
1979+
default_texture_info.normal = info.normal;
1980+
default_texture_info.specular = info.specular;
1981+
default_texture_info.sampler = info.sampler;
1982+
19771983
state.shadow_texture_size = GLOBAL_GET("rendering/2d/shadow_atlas/size");
19781984

19791985
//create functions for shader and material
@@ -2219,7 +2225,7 @@ void RendererCanvasRenderRD::_render_batch_items(RenderTarget p_to_render_target
22192225
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, state.default_transforms_uniform_set, TRANSFORMS_UNIFORM_SET);
22202226

22212227
Item *current_clip = nullptr;
2222-
state.current_tex_uniform_set = RID();
2228+
state.current_batch_uniform_set = RID();
22232229

22242230
for (uint32_t i = 0; i <= state.current_batch_index; i++) {
22252231
Batch *current_batch = &state.canvas_instance_batches[i];
@@ -2337,11 +2343,11 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
23372343
instance_data->world[i] = world[i];
23382344
}
23392345

2340-
instance_data->flags = base_flags | r_current_batch->tex_flags; // Reset on each command for safety, keep canvas texture binding config.
2346+
instance_data->flags = base_flags | r_current_batch->tex_info.flags; // Reset on each command for safety, keep canvas texture binding config.
23412347

2342-
instance_data->color_texture_pixel_size[0] = r_current_batch->tex_texpixel_size.width;
2343-
instance_data->color_texture_pixel_size[1] = r_current_batch->tex_texpixel_size.height;
2344-
instance_data->specular_shininess = r_current_batch->tex_specular_shininess;
2348+
instance_data->color_texture_pixel_size[0] = r_current_batch->tex_info.texpixel_size.width;
2349+
instance_data->color_texture_pixel_size[1] = r_current_batch->tex_info.texpixel_size.height;
2350+
instance_data->specular_shininess = r_current_batch->tex_info.specular_shininess;
23452351

23462352
return instance_data;
23472353
};
@@ -2373,10 +2379,10 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
23732379
bool has_msdf = bool(rect->flags & CANVAS_RECT_MSDF);
23742380
TextureState tex_state(rect->texture, texture_filter, texture_repeat, has_msdf, use_linear_colors);
23752381

2376-
if (tex_state != r_current_batch->tex_state) {
2382+
if (tex_state != r_current_batch->tex_info.state) {
23772383
r_current_batch = _new_batch(r_batch_broken);
2378-
r_current_batch->set_tex_state(tex_state);
2379-
_prepare_batch_texture(r_current_batch, rect->texture);
2384+
r_current_batch->tex_info.state = tex_state;
2385+
_prepare_batch_texture_info(r_current_batch, rect->texture);
23802386
}
23812387

23822388
Color modulated = rect->modulate * base_color;
@@ -2399,7 +2405,7 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
23992405
Rect2 dst_rect;
24002406

24012407
if (rect->texture.is_valid()) {
2402-
src_rect = (rect->flags & CANVAS_RECT_REGION) ? Rect2(rect->source.position * r_current_batch->tex_texpixel_size, rect->source.size * r_current_batch->tex_texpixel_size) : Rect2(0, 0, 1, 1);
2408+
src_rect = (rect->flags & CANVAS_RECT_REGION) ? Rect2(rect->source.position * r_current_batch->tex_info.texpixel_size, rect->source.size * r_current_batch->tex_info.texpixel_size) : Rect2(0, 0, 1, 1);
24032409
dst_rect = Rect2(rect->rect.position, rect->rect.size);
24042410

24052411
if (dst_rect.size.width < 0) {
@@ -2484,10 +2490,10 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
24842490
}
24852491

24862492
TextureState tex_state(np->texture, texture_filter, texture_repeat, false, use_linear_colors);
2487-
if (tex_state != r_current_batch->tex_state) {
2493+
if (tex_state != r_current_batch->tex_info.state) {
24882494
r_current_batch = _new_batch(r_batch_broken);
2489-
r_current_batch->set_tex_state(tex_state);
2490-
_prepare_batch_texture(r_current_batch, np->texture);
2495+
r_current_batch->tex_info.state = tex_state;
2496+
_prepare_batch_texture_info(r_current_batch, np->texture);
24912497
}
24922498

24932499
InstanceData *instance_data = new_instance_data();
@@ -2499,7 +2505,7 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
24992505
src_rect = Rect2(0, 0, 1, 1);
25002506
} else {
25012507
if (np->source != Rect2()) {
2502-
src_rect = Rect2(np->source.position.x * r_current_batch->tex_texpixel_size.width, np->source.position.y * r_current_batch->tex_texpixel_size.height, np->source.size.x * r_current_batch->tex_texpixel_size.width, np->source.size.y * r_current_batch->tex_texpixel_size.height);
2508+
src_rect = Rect2(np->source.position.x * r_current_batch->tex_info.texpixel_size.width, np->source.position.y * r_current_batch->tex_info.texpixel_size.height, np->source.size.x * r_current_batch->tex_info.texpixel_size.width, np->source.size.y * r_current_batch->tex_info.texpixel_size.height);
25032509
instance_data->color_texture_pixel_size[0] = 1.0 / np->source.size.width;
25042510
instance_data->color_texture_pixel_size[1] = 1.0 / np->source.size.height;
25052511
} else {
@@ -2553,10 +2559,10 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
25532559
r_current_batch->command = c;
25542560

25552561
TextureState tex_state(polygon->texture, texture_filter, texture_repeat, false, use_linear_colors);
2556-
if (tex_state != r_current_batch->tex_state) {
2562+
if (tex_state != r_current_batch->tex_info.state) {
25572563
r_current_batch = _new_batch(r_batch_broken);
2558-
r_current_batch->set_tex_state(tex_state);
2559-
_prepare_batch_texture(r_current_batch, polygon->texture);
2564+
r_current_batch->tex_info.state = tex_state;
2565+
_prepare_batch_texture_info(r_current_batch, polygon->texture);
25602566
}
25612567

25622568
// pipeline variant
@@ -2596,10 +2602,10 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
25962602
r_current_batch->pipeline_variant = variant[primitive->point_count - 1];
25972603

25982604
TextureState tex_state(primitive->texture, texture_filter, texture_repeat, false, use_linear_colors);
2599-
if (tex_state != r_current_batch->tex_state) {
2605+
if (tex_state != r_current_batch->tex_info.state) {
26002606
r_current_batch = _new_batch(r_batch_broken);
2601-
r_current_batch->set_tex_state(tex_state);
2602-
_prepare_batch_texture(r_current_batch, primitive->texture);
2607+
r_current_batch->tex_info.state = tex_state;
2608+
_prepare_batch_texture_info(r_current_batch, primitive->texture);
26032609
}
26042610
}
26052611

@@ -2657,8 +2663,8 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
26572663
if (c->type == Item::Command::TYPE_MESH) {
26582664
const Item::CommandMesh *m = static_cast<const Item::CommandMesh *>(c);
26592665
TextureState tex_state(m->texture, texture_filter, texture_repeat, false, use_linear_colors);
2660-
r_current_batch->set_tex_state(tex_state);
2661-
_prepare_batch_texture(r_current_batch, m->texture);
2666+
r_current_batch->tex_info.state = tex_state;
2667+
_prepare_batch_texture_info(r_current_batch, m->texture);
26622668
instance_data = new_instance_data();
26632669

26642670
r_current_batch->mesh_instance_count = 1;
@@ -2680,8 +2686,8 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
26802686
}
26812687

26822688
TextureState tex_state(mm->texture, texture_filter, texture_repeat, false, use_linear_colors);
2683-
r_current_batch->set_tex_state(tex_state);
2684-
_prepare_batch_texture(r_current_batch, mm->texture);
2689+
r_current_batch->tex_info.state = tex_state;
2690+
_prepare_batch_texture_info(r_current_batch, mm->texture);
26852691
instance_data = new_instance_data();
26862692

26872693
instance_data->flags |= 1; // multimesh, trails disabled
@@ -2698,8 +2704,8 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
26982704

26992705
const Item::CommandParticles *pt = static_cast<const Item::CommandParticles *>(c);
27002706
TextureState tex_state(pt->texture, texture_filter, texture_repeat, false, use_linear_colors);
2701-
r_current_batch->set_tex_state(tex_state);
2702-
_prepare_batch_texture(r_current_batch, pt->texture);
2707+
r_current_batch->tex_info.state = tex_state;
2708+
_prepare_batch_texture_info(r_current_batch, pt->texture);
27032709

27042710
instance_data = new_instance_data();
27052711

@@ -2795,7 +2801,20 @@ void RendererCanvasRenderRD::_render_batch(RD::DrawListID p_draw_list, PipelineV
27952801

27962802
ERR_FAIL_NULL(p_batch->command);
27972803

2798-
_bind_canvas_texture(p_draw_list, p_batch->tex_uniform_set);
2804+
{
2805+
RD::Uniform u_diffuse(RD::UNIFORM_TYPE_TEXTURE, 0, p_batch->tex_info.diffuse);
2806+
RD::Uniform u_normal(RD::UNIFORM_TYPE_TEXTURE, 1, p_batch->tex_info.normal);
2807+
RD::Uniform u_specular(RD::UNIFORM_TYPE_TEXTURE, 2, p_batch->tex_info.specular);
2808+
RD::Uniform u_sampler(RD::UNIFORM_TYPE_SAMPLER, 3, p_batch->tex_info.sampler);
2809+
RD::Uniform u_instance_data(RD::UNIFORM_TYPE_STORAGE_BUFFER, 4, state.canvas_instance_data_buffers[state.current_data_buffer_index].instance_buffers[p_batch->instance_buffer_index]);
2810+
2811+
RID uniform_set = uniform_set_cache->get_cache(shader.default_version_rd_shader, BATCH_UNIFORM_SET, u_diffuse, u_normal, u_specular, u_sampler, u_instance_data);
2812+
2813+
if (state.current_batch_uniform_set != uniform_set) {
2814+
state.current_batch_uniform_set = uniform_set;
2815+
RD::get_singleton()->draw_list_bind_uniform_set(p_draw_list, uniform_set, BATCH_UNIFORM_SET);
2816+
}
2817+
}
27992818

28002819
switch (p_batch->command_type) {
28012820
case Item::Command::TYPE_RECT:
@@ -2810,13 +2829,6 @@ void RendererCanvasRenderRD::_render_batch(RD::DrawListID p_draw_list, PipelineV
28102829
PushConstant push_constant;
28112830
push_constant.base_instance_index = p_batch->start;
28122831
RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(PushConstant));
2813-
2814-
RD::Uniform u_instance_data(RD::UNIFORM_TYPE_STORAGE_BUFFER, 0, state.canvas_instance_data_buffers[state.current_data_buffer_index].instance_buffers[p_batch->instance_buffer_index]);
2815-
RD::get_singleton()->draw_list_bind_uniform_set(
2816-
p_draw_list,
2817-
uniform_set_cache->get_cache(shader.default_version_rd_shader, INSTANCE_DATA_UNIFORM_SET, u_instance_data),
2818-
INSTANCE_DATA_UNIFORM_SET);
2819-
28202832
RD::get_singleton()->draw_list_bind_index_array(p_draw_list, shader.quad_index_array);
28212833
RD::get_singleton()->draw_list_draw(p_draw_list, true, p_batch->instance_count);
28222834

@@ -2839,13 +2851,6 @@ void RendererCanvasRenderRD::_render_batch(RD::DrawListID p_draw_list, PipelineV
28392851
PushConstant push_constant;
28402852
push_constant.base_instance_index = p_batch->start;
28412853
RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(PushConstant));
2842-
2843-
RD::Uniform u_instance_data(RD::UNIFORM_TYPE_STORAGE_BUFFER, 0, state.canvas_instance_data_buffers[state.current_data_buffer_index].instance_buffers[p_batch->instance_buffer_index]);
2844-
RD::get_singleton()->draw_list_bind_uniform_set(
2845-
p_draw_list,
2846-
uniform_set_cache->get_cache(shader.default_version_rd_shader, INSTANCE_DATA_UNIFORM_SET, u_instance_data),
2847-
INSTANCE_DATA_UNIFORM_SET);
2848-
28492854
RD::get_singleton()->draw_list_bind_vertex_array(p_draw_list, pb->vertex_array);
28502855
if (pb->indices.is_valid()) {
28512856
RD::get_singleton()->draw_list_bind_index_array(p_draw_list, pb->indices);
@@ -2868,13 +2873,6 @@ void RendererCanvasRenderRD::_render_batch(RD::DrawListID p_draw_list, PipelineV
28682873
PushConstant push_constant;
28692874
push_constant.base_instance_index = p_batch->start;
28702875
RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(PushConstant));
2871-
2872-
RD::Uniform u_instance_data(RD::UNIFORM_TYPE_STORAGE_BUFFER, 0, state.canvas_instance_data_buffers[state.current_data_buffer_index].instance_buffers[p_batch->instance_buffer_index]);
2873-
RD::get_singleton()->draw_list_bind_uniform_set(
2874-
p_draw_list,
2875-
uniform_set_cache->get_cache(shader.default_version_rd_shader, INSTANCE_DATA_UNIFORM_SET, u_instance_data),
2876-
INSTANCE_DATA_UNIFORM_SET);
2877-
28782876
RD::get_singleton()->draw_list_bind_index_array(p_draw_list, primitive_arrays.index_array[MIN(3u, primitive->point_count) - 1]);
28792877
uint32_t instance_count = p_batch->instance_count;
28802878
RD::get_singleton()->draw_list_draw(p_draw_list, true, instance_count);
@@ -2934,12 +2932,6 @@ void RendererCanvasRenderRD::_render_batch(RD::DrawListID p_draw_list, PipelineV
29342932
break;
29352933
}
29362934

2937-
RD::Uniform u_instance_data(RD::UNIFORM_TYPE_STORAGE_BUFFER, 0, state.canvas_instance_data_buffers[state.current_data_buffer_index].instance_buffers[p_batch->instance_buffer_index]);
2938-
RD::get_singleton()->draw_list_bind_uniform_set(
2939-
p_draw_list,
2940-
uniform_set_cache->get_cache(shader.default_version_rd_shader, INSTANCE_DATA_UNIFORM_SET, u_instance_data),
2941-
INSTANCE_DATA_UNIFORM_SET);
2942-
29432935
uint32_t surf_count = mesh_storage->mesh_get_surface_count(mesh);
29442936
static const PipelineVariant variant[RS::PRIMITIVE_MAX] = { PIPELINE_VARIANT_ATTRIBUTE_POINTS, PIPELINE_VARIANT_ATTRIBUTE_LINES, PIPELINE_VARIANT_ATTRIBUTE_LINES_STRIP, PIPELINE_VARIANT_ATTRIBUTE_TRIANGLES, PIPELINE_VARIANT_ATTRIBUTE_TRIANGLE_STRIP };
29452937

@@ -3046,60 +3038,46 @@ void RendererCanvasRenderRD::_allocate_instance_buffer() {
30463038
state.canvas_instance_data_buffers[state.current_data_buffer_index].instance_buffers.push_back(buf);
30473039
}
30483040

3049-
void RendererCanvasRenderRD::_prepare_batch_texture(Batch *p_current_batch, RID p_texture) const {
3041+
void RendererCanvasRenderRD::_prepare_batch_texture_info(Batch *p_current_batch, RID p_texture) const {
30503042
if (p_texture.is_null()) {
30513043
p_texture = default_canvas_texture;
30523044
}
30533045

3054-
Color specular_shininess;
3055-
bool use_normal;
3056-
bool use_specular;
3057-
Size2i size;
3058-
bool success = RendererRD::TextureStorage::get_singleton()->canvas_texture_get_uniform_set(
3059-
p_texture,
3060-
p_current_batch->tex_state.texture_filter(),
3061-
p_current_batch->tex_state.texture_repeat(),
3062-
shader.default_version_rd_shader,
3063-
CANVAS_TEXTURE_UNIFORM_SET,
3064-
p_current_batch->tex_state.linear_colors(),
3065-
p_current_batch->tex_uniform_set,
3066-
size,
3067-
specular_shininess,
3068-
use_normal,
3069-
use_specular,
3070-
p_current_batch->tex_state.texture_is_data());
3046+
RendererRD::TextureStorage::CanvasTextureInfo info =
3047+
RendererRD::TextureStorage::get_singleton()->canvas_texture_get_info(
3048+
p_texture,
3049+
p_current_batch->tex_info.state.texture_filter(),
3050+
p_current_batch->tex_info.state.texture_repeat(),
3051+
p_current_batch->tex_info.state.linear_colors(),
3052+
p_current_batch->tex_info.state.texture_is_data());
3053+
30713054
// something odd happened
3072-
if (!success) {
3073-
_prepare_batch_texture(p_current_batch, default_canvas_texture);
3055+
if (info.is_null()) {
3056+
_prepare_batch_texture_info(p_current_batch, default_canvas_texture);
30743057
return;
30753058
}
30763059

3077-
// cache values to be copied to instance data
3078-
if (specular_shininess.a < 0.999) {
3079-
p_current_batch->tex_flags |= FLAGS_DEFAULT_SPECULAR_MAP_USED;
3080-
}
3060+
p_current_batch->tex_info.diffuse = info.diffuse;
3061+
p_current_batch->tex_info.normal = info.normal;
3062+
p_current_batch->tex_info.specular = info.specular;
3063+
p_current_batch->tex_info.sampler = info.sampler;
30813064

3082-
if (use_normal) {
3083-
p_current_batch->tex_flags |= FLAGS_DEFAULT_NORMAL_MAP_USED;
3065+
// cache values to be copied to instance data
3066+
if (info.specular_color.a < 0.999) {
3067+
p_current_batch->tex_info.flags |= FLAGS_DEFAULT_SPECULAR_MAP_USED;
30843068
}
30853069

3086-
uint8_t a = uint8_t(CLAMP(specular_shininess.a * 255.0, 0.0, 255.0));
3087-
uint8_t b = uint8_t(CLAMP(specular_shininess.b * 255.0, 0.0, 255.0));
3088-
uint8_t g = uint8_t(CLAMP(specular_shininess.g * 255.0, 0.0, 255.0));
3089-
uint8_t r = uint8_t(CLAMP(specular_shininess.r * 255.0, 0.0, 255.0));
3090-
p_current_batch->tex_specular_shininess = uint32_t(a) << 24 | uint32_t(b) << 16 | uint32_t(g) << 8 | uint32_t(r);
3091-
3092-
p_current_batch->tex_texpixel_size = Vector2(1.0 / float(size.width), 1.0 / float(size.height));
3093-
}
3094-
3095-
void RendererCanvasRenderRD::_bind_canvas_texture(RD::DrawListID p_draw_list, RID p_uniform_set) {
3096-
if (state.current_tex_uniform_set == p_uniform_set) {
3097-
return;
3070+
if (info.use_normal) {
3071+
p_current_batch->tex_info.flags |= FLAGS_DEFAULT_NORMAL_MAP_USED;
30983072
}
30993073

3100-
state.current_tex_uniform_set = p_uniform_set;
3074+
uint8_t a = uint8_t(CLAMP(info.specular_color.a * 255.0, 0.0, 255.0));
3075+
uint8_t b = uint8_t(CLAMP(info.specular_color.b * 255.0, 0.0, 255.0));
3076+
uint8_t g = uint8_t(CLAMP(info.specular_color.g * 255.0, 0.0, 255.0));
3077+
uint8_t r = uint8_t(CLAMP(info.specular_color.r * 255.0, 0.0, 255.0));
3078+
p_current_batch->tex_info.specular_shininess = uint32_t(a) << 24 | uint32_t(b) << 16 | uint32_t(g) << 8 | uint32_t(r);
31013079

3102-
RD::get_singleton()->draw_list_bind_uniform_set(p_draw_list, p_uniform_set, CANVAS_TEXTURE_UNIFORM_SET);
3080+
p_current_batch->tex_info.texpixel_size = Vector2(1.0 / float(info.size.width), 1.0 / float(info.size.height));
31033081
}
31043082

31053083
RendererCanvasRenderRD::~RendererCanvasRenderRD() {

servers/rendering/renderer_rd/renderer_canvas_render_rd.h

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ class RendererCanvasRenderRD : public RendererCanvasRender {
4545
BASE_UNIFORM_SET = 0,
4646
MATERIAL_UNIFORM_SET = 1,
4747
TRANSFORMS_UNIFORM_SET = 2,
48-
CANVAS_TEXTURE_UNIFORM_SET = 3,
49-
INSTANCE_DATA_UNIFORM_SET = 4,
48+
BATCH_UNIFORM_SET = 3,
5049
};
5150

5251
const int SAMPLERS_BINDING_FIRST_INDEX = 10;
@@ -423,24 +422,25 @@ class RendererCanvasRenderRD : public RendererCanvasRender {
423422
}
424423
};
425424

425+
struct TextureInfo {
426+
TextureState state;
427+
uint32_t specular_shininess = 0;
428+
uint32_t flags = 0;
429+
Vector2 texpixel_size;
430+
431+
RID diffuse;
432+
RID normal;
433+
RID specular;
434+
RID sampler;
435+
};
436+
426437
struct Batch {
427438
// Position in the UBO measured in bytes
428439
uint32_t start = 0;
429440
uint32_t instance_count = 0;
430441
uint32_t instance_buffer_index = 0;
431442

432-
TextureState tex_state;
433-
RID tex_uniform_set;
434-
435-
// The following tex_ prefixed fields are used to cache the texture data for the current batch.
436-
// These values are applied to new InstanceData for the batch
437-
438-
// The cached specular shininess derived from the current texture.
439-
uint32_t tex_specular_shininess = 0;
440-
// The cached texture flags, such as FLAGS_DEFAULT_SPECULAR_MAP_USED and FLAGS_DEFAULT_NORMAL_MAP_USED
441-
uint32_t tex_flags = 0;
442-
// The cached texture pixel size.
443-
Vector2 tex_texpixel_size;
443+
TextureInfo tex_info;
444444

445445
Color modulate = Color(1.0, 1.0, 1.0, 1.0);
446446

@@ -462,14 +462,6 @@ class RendererCanvasRenderRD : public RendererCanvasRender {
462462
uint32_t mesh_instance_count;
463463
};
464464
bool has_blend = false;
465-
466-
void set_tex_state(TextureState &p_tex_state) {
467-
tex_state = p_tex_state;
468-
tex_uniform_set = RID();
469-
tex_texpixel_size = Size2();
470-
tex_specular_shininess = 0;
471-
tex_flags = 0;
472-
}
473465
};
474466

475467
struct DataBuffer {
@@ -509,7 +501,7 @@ class RendererCanvasRenderRD : public RendererCanvasRender {
509501
uint32_t max_instances_per_buffer = 16384;
510502
uint32_t max_instance_buffer_size = 16384 * sizeof(InstanceData);
511503

512-
RID current_tex_uniform_set;
504+
RID current_batch_uniform_set;
513505

514506
LightUniform *light_uniforms = nullptr;
515507

@@ -532,6 +524,8 @@ class RendererCanvasRenderRD : public RendererCanvasRender {
532524

533525
Item *items[MAX_RENDER_ITEMS];
534526

527+
TextureInfo default_texture_info;
528+
535529
bool using_directional_lights = false;
536530
RID default_canvas_texture;
537531

@@ -561,8 +555,7 @@ class RendererCanvasRenderRD : public RendererCanvasRender {
561555
void _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);
562556
void _record_item_commands(const Item *p_item, RenderTarget p_render_target, const Transform2D &p_base_transform, Item *&r_current_clip, Light *p_lights, uint32_t &r_index, bool &r_batch_broken, bool &r_sdf_used, Batch *&r_current_batch);
563557
void _render_batch(RD::DrawListID p_draw_list, PipelineVariants *p_pipeline_variants, RenderingDevice::FramebufferFormatID p_framebuffer_format, Light *p_lights, Batch const *p_batch, RenderingMethod::RenderInfo *r_render_info = nullptr);
564-
void _prepare_batch_texture(Batch *p_current_batch, RID p_texture) const;
565-
void _bind_canvas_texture(RD::DrawListID p_draw_list, RID p_uniform_set);
558+
void _prepare_batch_texture_info(Batch *p_current_batch, RID p_texture) const;
566559
[[nodiscard]] Batch *_new_batch(bool &r_batch_broken);
567560
void _add_to_batch(uint32_t &r_index, bool &r_batch_broken, Batch *&r_current_batch);
568561
void _allocate_instance_buffer();

0 commit comments

Comments
 (0)