@@ -2387,11 +2387,9 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
23872387 if (r_current_batch->tex_info != tex_info) {
23882388 r_current_batch = _new_batch (r_batch_broken);
23892389 r_current_batch->tex_info = tex_info;
2390- template_instance.color_texture_pixel_size [0 ] = tex_info->texpixel_size .width ;
2391- template_instance.color_texture_pixel_size [1 ] = tex_info->texpixel_size .height ;
23922390 }
23932391
2394- InstanceData *instance_data = new_instance_data (template_instance);
2392+ InstanceData *instance_data = new_instance_data (*r_current_batch, template_instance);
23952393 Rect2 src_rect;
23962394 Rect2 dst_rect;
23972395
@@ -2490,11 +2488,9 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
24902488 if (r_current_batch->tex_info != tex_info) {
24912489 r_current_batch = _new_batch (r_batch_broken);
24922490 r_current_batch->tex_info = tex_info;
2493- template_instance.color_texture_pixel_size [0 ] = tex_info->texpixel_size .width ;
2494- template_instance.color_texture_pixel_size [1 ] = tex_info->texpixel_size .height ;
24952491 }
24962492
2497- InstanceData *instance_data = new_instance_data (template_instance);
2493+ InstanceData *instance_data = new_instance_data (*r_current_batch, template_instance);
24982494
24992495 Rect2 src_rect;
25002496 Rect2 dst_rect (np->rect .position .x , np->rect .position .y , np->rect .size .x , np->rect .size .y );
@@ -2567,8 +2563,6 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
25672563 if (r_current_batch->tex_info != tex_info) {
25682564 r_current_batch = _new_batch (r_batch_broken);
25692565 r_current_batch->tex_info = tex_info;
2570- template_instance.color_texture_pixel_size [0 ] = tex_info->texpixel_size .width ;
2571- template_instance.color_texture_pixel_size [1 ] = tex_info->texpixel_size .height ;
25722566 }
25732567
25742568 // pipeline variant
@@ -2578,7 +2572,7 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
25782572 r_current_batch->render_primitive = _primitive_type_to_render_primitive (polygon->primitive );
25792573 }
25802574
2581- InstanceData *instance_data = new_instance_data (template_instance);
2575+ InstanceData *instance_data = new_instance_data (*r_current_batch, template_instance);
25822576
25832577 Color color = base_color;
25842578 if (use_linear_colors) {
@@ -2636,11 +2630,9 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
26362630 if (r_current_batch->tex_info != tex_info) {
26372631 r_current_batch = _new_batch (r_batch_broken);
26382632 r_current_batch->tex_info = tex_info;
2639- template_instance.color_texture_pixel_size [0 ] = tex_info->texpixel_size .width ;
2640- template_instance.color_texture_pixel_size [1 ] = tex_info->texpixel_size .height ;
26412633 }
26422634
2643- InstanceData *instance_data = new_instance_data (template_instance);
2635+ InstanceData *instance_data = new_instance_data (*r_current_batch, template_instance);
26442636
26452637 for (uint32_t j = 0 ; j < MIN (3u , primitive->point_count ); j++) {
26462638 instance_data->points [j * 2 + 0 ] = primitive->points [j].x ;
@@ -2658,7 +2650,7 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
26582650 _add_to_batch (r_batch_broken, r_current_batch);
26592651
26602652 if (primitive->point_count == 4 ) {
2661- instance_data = new_instance_data (template_instance);
2653+ instance_data = new_instance_data (*r_current_batch, template_instance);
26622654
26632655 for (uint32_t j = 0 ; j < 3 ; j++) {
26642656 int offset = j == 0 ? 0 : 1 ;
@@ -2701,9 +2693,7 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
27012693 _prepare_batch_texture_info (m->texture , tex_state, tex_info);
27022694 }
27032695 r_current_batch->tex_info = tex_info;
2704- template_instance.color_texture_pixel_size [0 ] = tex_info->texpixel_size .width ;
2705- template_instance.color_texture_pixel_size [1 ] = tex_info->texpixel_size .height ;
2706- instance_data = new_instance_data (template_instance);
2696+ instance_data = new_instance_data (*r_current_batch, template_instance);
27072697
27082698 r_current_batch->mesh_instance_count = 1 ;
27092699 _update_transform_2d_to_mat2x3 (base_transform * draw_transform * m->transform , instance_data->world );
@@ -2730,9 +2720,7 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
27302720 _prepare_batch_texture_info (mm->texture , tex_state, tex_info);
27312721 }
27322722 r_current_batch->tex_info = tex_info;
2733- template_instance.color_texture_pixel_size [0 ] = tex_info->texpixel_size .width ;
2734- template_instance.color_texture_pixel_size [1 ] = tex_info->texpixel_size .height ;
2735- instance_data = new_instance_data (template_instance);
2723+ instance_data = new_instance_data (*r_current_batch, template_instance);
27362724
27372725 r_current_batch->flags |= 1 ; // multimesh, trails disabled
27382726
@@ -2754,9 +2742,7 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
27542742 _prepare_batch_texture_info (pt->texture , tex_state, tex_info);
27552743 }
27562744 r_current_batch->tex_info = tex_info;
2757- template_instance.color_texture_pixel_size [0 ] = tex_info->texpixel_size .width ;
2758- template_instance.color_texture_pixel_size [1 ] = tex_info->texpixel_size .height ;
2759- instance_data = new_instance_data (template_instance);
2745+ instance_data = new_instance_data (*r_current_batch, template_instance);
27602746
27612747 uint32_t divisor = 1 ;
27622748 r_current_batch->mesh_instance_count = particles_storage->particles_get_amount (pt->particles , divisor);
@@ -2877,12 +2863,10 @@ void RendererCanvasRenderRD::_record_item_commands(const Item *p_item, RenderTar
28772863 if (r_current_batch->tex_info != tex_info) {
28782864 r_current_batch = _new_batch (r_batch_broken);
28792865 r_current_batch->tex_info = tex_info;
2880- template_instance.color_texture_pixel_size [0 ] = tex_info->texpixel_size .width ;
2881- template_instance.color_texture_pixel_size [1 ] = tex_info->texpixel_size .height ;
28822866 }
28832867
28842868 _update_transform_2d_to_mat2x3 (base_transform, template_instance.world );
2885- InstanceData *instance_data = new_instance_data (template_instance);
2869+ InstanceData *instance_data = new_instance_data (*r_current_batch, template_instance);
28862870
28872871 Rect2 src_rect;
28882872 Rect2 dst_rect;
@@ -3165,11 +3149,13 @@ void RendererCanvasRenderRD::_render_batch(RD::DrawListID p_draw_list, CanvasSha
31653149 }
31663150}
31673151
3168- RendererCanvasRenderRD::InstanceData *RendererCanvasRenderRD::new_instance_data (const InstanceData &template_instance) {
3152+ RendererCanvasRenderRD::InstanceData *RendererCanvasRenderRD::new_instance_data (Batch &p_current_batch, const InstanceData &template_instance) {
31693153 DEV_ASSERT (state.instance_data != nullptr );
31703154
31713155 InstanceData *instance_data = &state.instance_data [state.instance_data_index ];
31723156 memcpy (instance_data, &template_instance, sizeof (InstanceData));
3157+ instance_data->color_texture_pixel_size [0 ] = p_current_batch.tex_info ->texpixel_size .width ;
3158+ instance_data->color_texture_pixel_size [1 ] = p_current_batch.tex_info ->texpixel_size .height ;
31733159 return instance_data;
31743160}
31753161
0 commit comments