Added GLES2 RenderStorage Info calculations.

Proper counting code has been added to update info struct.

Extra: Added the render_info_capture calculations.
Fixes: #27273
This commit is contained in:
Anish Bhobe 2019-03-25 23:08:23 +05:30
parent 81292665d5
commit 4839b17f93
2 changed files with 70 additions and 2 deletions

View File

@ -1566,8 +1566,10 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
if (s->index_array_len > 0) {
glDrawElements(gl_primitive[s->primitive], s->index_array_len, (s->array_len >= (1 << 16)) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, 0);
storage->info.render.vertices_count += s->index_array_len;
} else {
glDrawArrays(gl_primitive[s->primitive], 0, s->array_len);
storage->info.render.vertices_count += s->array_len;
}
/*
if (p_element->instance->skeleton.is_valid() && s->attribs[VS::ARRAY_BONES].enabled && s->attribs[VS::ARRAY_WEIGHTS].enabled) {
@ -1637,8 +1639,10 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
if (s->index_array_len > 0) {
glDrawElements(gl_primitive[s->primitive], s->index_array_len, (s->array_len >= (1 << 16)) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, 0);
storage->info.render.vertices_count += s->index_array_len;
} else {
glDrawArrays(gl_primitive[s->primitive], 0, s->array_len);
storage->info.render.vertices_count += s->array_len;
}
}
@ -2182,6 +2186,8 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
float lightmap_energy = 1.0;
bool prev_use_lightmap_capture = false;
storage->info.render.draw_call_count += p_element_count;
for (int i = 0; i < p_element_count; i++) {
RenderList::Element *e = p_elements[i];
@ -2389,11 +2395,17 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
if (e->owner != prev_owner || e->geometry != prev_geometry || skeleton != prev_skeleton) {
_setup_geometry(e, skeleton);
storage->info.render.surface_switch_count++;
}
bool shader_rebind = false;
if (rebind || material != prev_material) {
storage->info.render.material_switch_count++;
shader_rebind = _setup_material(material, p_reverse_cull, p_alpha_pass, Size2i(skeleton ? skeleton->size * 3 : 0, 0));
if (shader_rebind) {
storage->info.render.shader_rebind_count++;
}
}
if (i == 0 || shader_rebind) { //first time must rebind
@ -2637,6 +2649,8 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
Transform cam_transform = p_cam_transform;
storage->info.render.object_count += p_cull_count;
GLuint current_fb = 0;
Environment *env = NULL;

View File

@ -5208,18 +5208,72 @@ void RasterizerStorageGLES2::set_debug_generate_wireframes(bool p_generate) {
}
void RasterizerStorageGLES2::render_info_begin_capture() {
info.snap = info.render;
}
void RasterizerStorageGLES2::render_info_end_capture() {
info.snap.object_count = info.render.object_count - info.snap.object_count;
info.snap.draw_call_count = info.render.draw_call_count - info.snap.draw_call_count;
info.snap.material_switch_count = info.render.material_switch_count - info.snap.material_switch_count;
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;
}
int RasterizerStorageGLES2::get_captured_render_info(VS::RenderInfo p_info) {
switch (p_info) {
case VS::INFO_OBJECTS_IN_FRAME: {
return info.snap.object_count;
} break;
case VS::INFO_VERTICES_IN_FRAME: {
return info.snap.vertices_count;
} break;
case VS::INFO_MATERIAL_CHANGES_IN_FRAME: {
return info.snap.material_switch_count;
} break;
case VS::INFO_SHADER_CHANGES_IN_FRAME: {
return info.snap.shader_rebind_count;
} break;
case VS::INFO_SURFACE_CHANGES_IN_FRAME: {
return info.snap.surface_switch_count;
} break;
case VS::INFO_DRAW_CALLS_IN_FRAME: {
return info.snap.draw_call_count;
} break;
default: {
return get_render_info(p_info);
}
}
}
int RasterizerStorageGLES2::get_render_info(VS::RenderInfo p_info) {
return 0;
switch (p_info) {
case VS::INFO_OBJECTS_IN_FRAME:
return info.render_final.object_count;
case VS::INFO_VERTICES_IN_FRAME:
return info.render_final.vertices_count;
case VS::INFO_MATERIAL_CHANGES_IN_FRAME:
return info.render_final.material_switch_count;
case VS::INFO_SHADER_CHANGES_IN_FRAME:
return info.render_final.shader_rebind_count;
case VS::INFO_SURFACE_CHANGES_IN_FRAME:
return info.render_final.surface_switch_count;
case VS::INFO_DRAW_CALLS_IN_FRAME:
return info.render_final.draw_call_count;
case VS::INFO_USAGE_VIDEO_MEM_TOTAL:
return 0; //no idea
case VS::INFO_VIDEO_MEM_USED:
return info.vertex_mem + info.texture_mem;
case VS::INFO_TEXTURE_MEM_USED:
return info.texture_mem;
case VS::INFO_VERTEX_MEM_USED:
return info.vertex_mem;
default:
return 0; //no idea either
}
}
void RasterizerStorageGLES2::initialize() {