@@ -1281,6 +1281,76 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
1281
1281
r_batch_broken = false ;
1282
1282
}
1283
1283
1284
+ #ifdef DEBUG_ENABLED
1285
+ if (debug_redraw && p_item->debug_redraw_time > 0.0 ) {
1286
+ Color dc = debug_redraw_color;
1287
+ dc.a *= p_item->debug_redraw_time / debug_redraw_time;
1288
+
1289
+ if (state.canvas_instance_batches [state.current_batch_index ].tex != RID () || state.canvas_instance_batches [state.current_batch_index ].command_type != Item::Command::TYPE_RECT) {
1290
+ _new_batch (r_batch_broken);
1291
+ state.canvas_instance_batches [state.current_batch_index ].tex = RID ();
1292
+ state.canvas_instance_batches [state.current_batch_index ].command_type = Item::Command::TYPE_RECT;
1293
+ state.canvas_instance_batches [state.current_batch_index ].command = nullptr ;
1294
+ state.canvas_instance_batches [state.current_batch_index ].specialization &= specialization_command_mask;
1295
+ state.canvas_instance_batches [state.current_batch_index ].flags = 0 ;
1296
+ }
1297
+
1298
+ if (state.canvas_instance_batches [state.current_batch_index ].blend_mode != GLES3::CanvasShaderData::BLEND_MODE_MIX || state.canvas_instance_batches [state.current_batch_index ].blend_color != Color (1.0 , 1.0 , 1.0 , 1.0 )) {
1299
+ _new_batch (r_batch_broken);
1300
+ state.canvas_instance_batches [state.current_batch_index ].blend_mode = GLES3::CanvasShaderData::BLEND_MODE_MIX;
1301
+ state.canvas_instance_batches [state.current_batch_index ].blend_color = Color (1.0 , 1.0 , 1.0 , 1.0 );
1302
+ }
1303
+
1304
+ _prepare_canvas_texture (RID (), state.canvas_instance_batches [state.current_batch_index ].filter , state.canvas_instance_batches [state.current_batch_index ].repeat , r_index, texpixel_size);
1305
+
1306
+ _update_transform_2d_to_mat2x3 (base_transform, state.instance_data_array [r_index].world );
1307
+ for (int i = 0 ; i < 4 ; i++) {
1308
+ state.instance_data_array [r_index].ninepatch_margins [i] = 0.0 ;
1309
+ state.instance_data_array [r_index].lights [i] = uint32_t (0 );
1310
+ }
1311
+ state.instance_data_array [r_index].color_texture_pixel_size [0 ] = 0.0 ;
1312
+ state.instance_data_array [r_index].color_texture_pixel_size [1 ] = 0.0 ;
1313
+
1314
+ Rect2 src_rect;
1315
+ Rect2 dst_rect;
1316
+
1317
+ dst_rect = p_item->rect ;
1318
+ if (dst_rect.size .width < 0 ) {
1319
+ dst_rect.position .x += dst_rect.size .width ;
1320
+ dst_rect.size .width *= -1 ;
1321
+ }
1322
+ if (dst_rect.size .height < 0 ) {
1323
+ dst_rect.position .y += dst_rect.size .height ;
1324
+ dst_rect.size .height *= -1 ;
1325
+ }
1326
+
1327
+ src_rect = Rect2 (0 , 0 , 1 , 1 );
1328
+
1329
+ state.instance_data_array [r_index].modulation [0 ] = dc.r ;
1330
+ state.instance_data_array [r_index].modulation [1 ] = dc.g ;
1331
+ state.instance_data_array [r_index].modulation [2 ] = dc.b ;
1332
+ state.instance_data_array [r_index].modulation [3 ] = dc.a ;
1333
+
1334
+ state.instance_data_array [r_index].src_rect [0 ] = src_rect.position .x ;
1335
+ state.instance_data_array [r_index].src_rect [1 ] = src_rect.position .y ;
1336
+ state.instance_data_array [r_index].src_rect [2 ] = src_rect.size .width ;
1337
+ state.instance_data_array [r_index].src_rect [3 ] = src_rect.size .height ;
1338
+
1339
+ state.instance_data_array [r_index].dst_rect [0 ] = dst_rect.position .x ;
1340
+ state.instance_data_array [r_index].dst_rect [1 ] = dst_rect.position .y ;
1341
+ state.instance_data_array [r_index].dst_rect [2 ] = dst_rect.size .width ;
1342
+ state.instance_data_array [r_index].dst_rect [3 ] = dst_rect.size .height ;
1343
+
1344
+ _add_to_batch (r_index, r_batch_broken);
1345
+
1346
+ p_item->debug_redraw_time -= RSG::rasterizer->get_frame_delta_time ();
1347
+
1348
+ RenderingServerDefault::redraw_request ();
1349
+
1350
+ r_batch_broken = false ;
1351
+ }
1352
+ #endif
1353
+
1284
1354
if (current_clip && reclip) {
1285
1355
// will make it re-enable clipping if needed afterwards
1286
1356
current_clip = nullptr ;
@@ -1294,8 +1364,6 @@ _FORCE_INLINE_ static uint32_t _indices_to_primitives(RS::PrimitiveType p_primit
1294
1364
}
1295
1365
1296
1366
void RasterizerCanvasGLES3::_render_batch (Light *p_lights, uint32_t p_index, RenderingMethod::RenderInfo *r_render_info) {
1297
- ERR_FAIL_NULL (state.canvas_instance_batches [state.current_batch_index ].command );
1298
-
1299
1367
// Used by Polygon and Mesh.
1300
1368
static const GLenum prim[5 ] = { GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_TRIANGLES, GL_TRIANGLE_STRIP };
1301
1369
@@ -1321,6 +1389,7 @@ void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index, Ren
1321
1389
} break ;
1322
1390
1323
1391
case Item::Command::TYPE_POLYGON: {
1392
+ ERR_FAIL_NULL (state.canvas_instance_batches [state.current_batch_index ].command );
1324
1393
const Item::CommandPolygon *polygon = static_cast <const Item::CommandPolygon *>(state.canvas_instance_batches [p_index].command );
1325
1394
1326
1395
PolygonBuffers *pb = polygon_buffers.polygons .getptr (polygon->polygon .polygon_id );
@@ -1379,6 +1448,7 @@ void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index, Ren
1379
1448
case Item::Command::TYPE_MESH:
1380
1449
case Item::Command::TYPE_MULTIMESH:
1381
1450
case Item::Command::TYPE_PARTICLES: {
1451
+ ERR_FAIL_NULL (state.canvas_instance_batches [state.current_batch_index ].command );
1382
1452
GLES3::MeshStorage *mesh_storage = GLES3::MeshStorage::get_singleton ();
1383
1453
GLES3::ParticlesStorage *particles_storage = GLES3::ParticlesStorage::get_singleton ();
1384
1454
RID mesh;
@@ -2888,6 +2958,12 @@ void fragment() {
2888
2958
state.time = 0.0 ;
2889
2959
}
2890
2960
2961
+ void RasterizerCanvasGLES3::set_debug_redraw (bool p_enabled, double p_time, const Color &p_color) {
2962
+ debug_redraw = p_enabled;
2963
+ debug_redraw_time = p_time;
2964
+ debug_redraw_color = p_color;
2965
+ }
2966
+
2891
2967
RasterizerCanvasGLES3::~RasterizerCanvasGLES3 () {
2892
2968
singleton = nullptr ;
2893
2969
0 commit comments