Items and draw calls added to IDE Monitor in '2d' section

This adds 2 new values (items and draw calls) to the performance monitor in a '2d' section, rather than reusing the 3d values in the 'raster' section.

This makes it far easier to optimize games to minimize drawcalls.
This commit is contained in:
lawnjelly 2020-04-16 11:46:52 +01:00
parent a4cd274ca7
commit b6d652367b
10 changed files with 56 additions and 1 deletions

View File

@ -620,6 +620,8 @@ void RasterizerCanvasGLES2::_batch_render_rects(const Batch &p_batch, Rasterizer
int num_elements = p_batch.num_commands * 6;
glDrawElements(GL_TRIANGLES, num_elements, GL_UNSIGNED_SHORT, (void *)offset);
storage->info.render._2d_draw_call_count++;
switch (tex.tile_mode) {
case BatchTex::TILE_FORCE_REPEAT: {
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_FORCE_REPEAT, false);
@ -718,6 +720,7 @@ void RasterizerCanvasGLES2::render_batches(Item::Command *const *p_commands, Ite
}
#endif
}
storage->info.render._2d_draw_call_count++;
} break;
case Item::Command::TYPE_RECT: {
@ -911,6 +914,7 @@ void RasterizerCanvasGLES2::render_batches(Item::Command *const *p_commands, Ite
}
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_FORCE_REPEAT, false);
storage->info.render._2d_draw_call_count++;
} break;
@ -1086,6 +1090,7 @@ void RasterizerCanvasGLES2::render_batches(Item::Command *const *p_commands, Ite
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
storage->info.render._2d_draw_call_count++;
} break;
@ -1117,6 +1122,7 @@ void RasterizerCanvasGLES2::render_batches(Item::Command *const *p_commands, Ite
_bind_canvas_texture(RID(), RID());
_draw_polygon(indices, num_points * 3, num_points + 1, points, NULL, &circle->color, true);
storage->info.render._2d_draw_call_count++;
} break;
case Item::Command::TYPE_POLYGON: {
@ -1149,6 +1155,7 @@ void RasterizerCanvasGLES2::render_batches(Item::Command *const *p_commands, Ite
glDisable(GL_LINE_SMOOTH);
}
#endif
storage->info.render._2d_draw_call_count++;
} break;
case Item::Command::TYPE_MESH: {
@ -1212,6 +1219,7 @@ void RasterizerCanvasGLES2::render_batches(Item::Command *const *p_commands, Ite
}
}
storage->info.render._2d_draw_call_count++;
} break;
case Item::Command::TYPE_MULTIMESH: {
Item::CommandMultiMesh *mmesh = static_cast<Item::CommandMultiMesh *>(command);
@ -1335,6 +1343,7 @@ void RasterizerCanvasGLES2::render_batches(Item::Command *const *p_commands, Ite
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_INSTANCE_CUSTOM, false);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_INSTANCING, false);
storage->info.render._2d_draw_call_count++;
} break;
case Item::Command::TYPE_POLYLINE: {
Item::CommandPolyLine *pline = static_cast<Item::CommandPolyLine *>(command);
@ -1386,6 +1395,7 @@ void RasterizerCanvasGLES2::render_batches(Item::Command *const *p_commands, Ite
glDisable(GL_LINE_SMOOTH);
#endif
}
storage->info.render._2d_draw_call_count++;
} break;
case Item::Command::TYPE_PRIMITIVE: {
@ -1415,6 +1425,7 @@ void RasterizerCanvasGLES2::render_batches(Item::Command *const *p_commands, Ite
}
_draw_gui_primitive(primitive->points.size(), primitive->points.ptr(), primitive->colors.ptr(), primitive->uvs.ptr());
storage->info.render._2d_draw_call_count++;
} break;
case Item::Command::TYPE_TRANSFORM: {
@ -1906,6 +1917,8 @@ bool RasterizerCanvasGLES2::_detect_batch_break(Item *p_ci) {
// Legacy non-batched implementation for regression testing.
// Should be removed after testing phase to avoid duplicate codepaths.
void RasterizerCanvasGLES2::_canvas_render_item(Item *p_ci, RenderItemState &r_ris) {
storage->info.render._2d_item_count++;
if (r_ris.current_clip != p_ci->final_clip_owner) {
r_ris.current_clip = p_ci->final_clip_owner;
@ -2269,6 +2282,8 @@ void RasterizerCanvasGLES2::_canvas_render_item(Item *p_ci, RenderItemState &r_r
void RasterizerCanvasGLES2::render_joined_item(const BItemJoined &p_bij, RenderItemState &r_ris) {
storage->info.render._2d_item_count++;
// all the joined items will share the same state with the first item
Item *ci = bdata.item_refs[p_bij.first_item_ref].item;

View File

@ -5760,6 +5760,8 @@ void RasterizerStorageGLES2::render_info_end_capture() {
info.snap.surface_switch_count = info.render.surface_switch_count - info.snap.surface_switch_count;
info.snap.shader_rebind_count = info.render.shader_rebind_count - info.snap.shader_rebind_count;
info.snap.vertices_count = info.render.vertices_count - info.snap.vertices_count;
info.snap._2d_item_count = info.render._2d_item_count - info.snap._2d_item_count;
info.snap._2d_draw_call_count = info.render._2d_draw_call_count - info.snap._2d_draw_call_count;
}
int RasterizerStorageGLES2::get_captured_render_info(VS::RenderInfo p_info) {
@ -5783,6 +5785,12 @@ int RasterizerStorageGLES2::get_captured_render_info(VS::RenderInfo p_info) {
case VS::INFO_DRAW_CALLS_IN_FRAME: {
return info.snap.draw_call_count;
} break;
case VS::INFO_2D_ITEMS_IN_FRAME: {
return info.snap._2d_item_count;
} break;
case VS::INFO_2D_DRAW_CALLS_IN_FRAME: {
return info.snap._2d_draw_call_count;
} break;
default: {
return get_render_info(p_info);
}
@ -5803,6 +5811,10 @@ int RasterizerStorageGLES2::get_render_info(VS::RenderInfo p_info) {
return info.render_final.surface_switch_count;
case VS::INFO_DRAW_CALLS_IN_FRAME:
return info.render_final.draw_call_count;
case VS::INFO_2D_ITEMS_IN_FRAME:
return info.render_final._2d_item_count;
case VS::INFO_2D_DRAW_CALLS_IN_FRAME:
return info.render_final._2d_draw_call_count;
case VS::INFO_USAGE_VIDEO_MEM_TOTAL:
return 0; //no idea
case VS::INFO_VIDEO_MEM_USED:

View File

@ -149,6 +149,8 @@ public:
uint32_t surface_switch_count;
uint32_t shader_rebind_count;
uint32_t vertices_count;
uint32_t _2d_item_count;
uint32_t _2d_draw_call_count;
void reset() {
object_count = 0;
@ -157,6 +159,8 @@ public:
surface_switch_count = 0;
shader_rebind_count = 0;
vertices_count = 0;
_2d_item_count = 0;
_2d_draw_call_count = 0;
}
} render, render_final, snap;

View File

@ -63,6 +63,8 @@ void Performance::_bind_methods() {
BIND_ENUM_CONSTANT(RENDER_SHADER_CHANGES_IN_FRAME);
BIND_ENUM_CONSTANT(RENDER_SURFACE_CHANGES_IN_FRAME);
BIND_ENUM_CONSTANT(RENDER_DRAW_CALLS_IN_FRAME);
BIND_ENUM_CONSTANT(RENDER_2D_ITEMS_IN_FRAME);
BIND_ENUM_CONSTANT(RENDER_2D_DRAW_CALLS_IN_FRAME);
BIND_ENUM_CONSTANT(RENDER_VIDEO_MEM_USED);
BIND_ENUM_CONSTANT(RENDER_TEXTURE_MEM_USED);
BIND_ENUM_CONSTANT(RENDER_VERTEX_MEM_USED);
@ -109,6 +111,8 @@ String Performance::get_monitor_name(Monitor p_monitor) const {
"raster/shader_changes",
"raster/surface_changes",
"raster/draw_calls",
"2d/items",
"2d/draw_calls",
"video/video_mem",
"video/texture_mem",
"video/vertex_mem",
@ -147,6 +151,8 @@ float Performance::get_monitor(Monitor p_monitor) const {
case RENDER_SHADER_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SHADER_CHANGES_IN_FRAME);
case RENDER_SURFACE_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SURFACE_CHANGES_IN_FRAME);
case RENDER_DRAW_CALLS_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_DRAW_CALLS_IN_FRAME);
case RENDER_2D_ITEMS_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_2D_ITEMS_IN_FRAME);
case RENDER_2D_DRAW_CALLS_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_2D_DRAW_CALLS_IN_FRAME);
case RENDER_VIDEO_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_VIDEO_MEM_USED);
case RENDER_TEXTURE_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_TEXTURE_MEM_USED);
case RENDER_VERTEX_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_VERTEX_MEM_USED);
@ -189,6 +195,8 @@ Performance::MonitorType Performance::get_monitor_type(Monitor p_monitor) const
MONITOR_TYPE_QUANTITY,
MONITOR_TYPE_QUANTITY,
MONITOR_TYPE_QUANTITY,
MONITOR_TYPE_QUANTITY,
MONITOR_TYPE_QUANTITY,
MONITOR_TYPE_MEMORY,
MONITOR_TYPE_MEMORY,
MONITOR_TYPE_MEMORY,

View File

@ -69,6 +69,8 @@ public:
RENDER_SHADER_CHANGES_IN_FRAME,
RENDER_SURFACE_CHANGES_IN_FRAME,
RENDER_DRAW_CALLS_IN_FRAME,
RENDER_2D_ITEMS_IN_FRAME,
RENDER_2D_DRAW_CALLS_IN_FRAME,
RENDER_VIDEO_MEM_USED,
RENDER_TEXTURE_MEM_USED,
RENDER_VERTEX_MEM_USED,

View File

@ -3287,6 +3287,8 @@ void Viewport::_bind_methods() {
BIND_ENUM_CONSTANT(RENDER_INFO_SHADER_CHANGES_IN_FRAME);
BIND_ENUM_CONSTANT(RENDER_INFO_SURFACE_CHANGES_IN_FRAME);
BIND_ENUM_CONSTANT(RENDER_INFO_DRAW_CALLS_IN_FRAME);
BIND_ENUM_CONSTANT(RENDER_INFO_2D_ITEMS_IN_FRAME);
BIND_ENUM_CONSTANT(RENDER_INFO_2D_DRAW_CALLS_IN_FRAME);
BIND_ENUM_CONSTANT(RENDER_INFO_MAX);
BIND_ENUM_CONSTANT(DEBUG_DRAW_DISABLED);

View File

@ -133,6 +133,8 @@ public:
RENDER_INFO_SHADER_CHANGES_IN_FRAME,
RENDER_INFO_SURFACE_CHANGES_IN_FRAME,
RENDER_INFO_DRAW_CALLS_IN_FRAME,
RENDER_INFO_2D_ITEMS_IN_FRAME,
RENDER_INFO_2D_DRAW_CALLS_IN_FRAME,
RENDER_INFO_MAX
};

View File

@ -349,6 +349,8 @@ void VisualServerViewport::draw_viewports() {
vp->render_info[VS::VIEWPORT_RENDER_INFO_SHADER_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_SHADER_CHANGES_IN_FRAME);
vp->render_info[VS::VIEWPORT_RENDER_INFO_SURFACE_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_SURFACE_CHANGES_IN_FRAME);
vp->render_info[VS::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_DRAW_CALLS_IN_FRAME);
vp->render_info[VS::VIEWPORT_RENDER_INFO_2D_ITEMS_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_2D_ITEMS_IN_FRAME);
vp->render_info[VS::VIEWPORT_RENDER_INFO_2D_DRAW_CALLS_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_2D_DRAW_CALLS_IN_FRAME);
if (vp->viewport_to_screen_rect != Rect2() && (!vp->viewport_render_direct_to_screen || !VSG::rasterizer->is_low_end())) {
//copy to screen if set as such

View File

@ -2188,6 +2188,8 @@ void VisualServer::_bind_methods() {
BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_SHADER_CHANGES_IN_FRAME);
BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_SURFACE_CHANGES_IN_FRAME);
BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME);
BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_2D_ITEMS_IN_FRAME);
BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_2D_DRAW_CALLS_IN_FRAME);
BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_MAX);
BIND_ENUM_CONSTANT(VIEWPORT_DEBUG_DRAW_DISABLED);
@ -2247,6 +2249,8 @@ void VisualServer::_bind_methods() {
BIND_ENUM_CONSTANT(INFO_SHADER_CHANGES_IN_FRAME);
BIND_ENUM_CONSTANT(INFO_SURFACE_CHANGES_IN_FRAME);
BIND_ENUM_CONSTANT(INFO_DRAW_CALLS_IN_FRAME);
BIND_ENUM_CONSTANT(INFO_2D_ITEMS_IN_FRAME);
BIND_ENUM_CONSTANT(INFO_2D_DRAW_CALLS_IN_FRAME);
BIND_ENUM_CONSTANT(INFO_USAGE_VIDEO_MEM_TOTAL);
BIND_ENUM_CONSTANT(INFO_VIDEO_MEM_USED);
BIND_ENUM_CONSTANT(INFO_TEXTURE_MEM_USED);
@ -2418,7 +2422,7 @@ VisualServer::VisualServer() {
GLOBAL_DEF("rendering/gles2/batching/light_scissor_area_threshold", 1.0f);
GLOBAL_DEF("rendering/gles2/batching/batch_buffer_size", 16384);
GLOBAL_DEF("rendering/gles2/debug/flash_batching", false);
GLOBAL_DEF_RST("rendering/gles2/debug/use_batching_in_editor", false);
GLOBAL_DEF_RST("rendering/gles2/debug/use_batching_in_editor", true);
ProjectSettings::get_singleton()->set_custom_property_info("rendering/gles2/batching/max_join_item_commands", PropertyInfo(Variant::INT, "rendering/gles2/batching/max_join_item_commands", PROPERTY_HINT_RANGE, "0,65535"));
ProjectSettings::get_singleton()->set_custom_property_info("rendering/gles2/batching/colored_vertex_format_threshold", PropertyInfo(Variant::REAL, "rendering/gles2/batching/colored_vertex_format_threshold", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"));

View File

@ -689,6 +689,8 @@ public:
VIEWPORT_RENDER_INFO_SHADER_CHANGES_IN_FRAME,
VIEWPORT_RENDER_INFO_SURFACE_CHANGES_IN_FRAME,
VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME,
VIEWPORT_RENDER_INFO_2D_ITEMS_IN_FRAME,
VIEWPORT_RENDER_INFO_2D_DRAW_CALLS_IN_FRAME,
VIEWPORT_RENDER_INFO_MAX
};
@ -1016,6 +1018,8 @@ public:
INFO_SHADER_CHANGES_IN_FRAME,
INFO_SURFACE_CHANGES_IN_FRAME,
INFO_DRAW_CALLS_IN_FRAME,
INFO_2D_ITEMS_IN_FRAME,
INFO_2D_DRAW_CALLS_IN_FRAME,
INFO_USAGE_VIDEO_MEM_TOTAL,
INFO_VIDEO_MEM_USED,
INFO_TEXTURE_MEM_USED,