summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-04-05 15:22:22 +0200
committerGitHub <noreply@github.com>2019-04-05 15:22:22 +0200
commitcffbb99327037b8356777964b2ba9f27b4f8fd47 (patch)
tree985a9dbfaa26e8c2f961d5219d15f8751f19bcaa
parentbf104e78ff6a82da0f885875def32316f61962c6 (diff)
parent4839b17f9357969e26a2730a977b5695ea75c6ac (diff)
Merge pull request #27411 from KidRigger/raster_store
Added GLES2 RenderStorage Info calculations.
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp14
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.cpp58
2 files changed, 70 insertions, 2 deletions
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index de31288838..3c8822175d 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -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;
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp
index 92a4c2a3b4..01d5e35e56 100644
--- a/drivers/gles2/rasterizer_storage_gles2.cpp
+++ b/drivers/gles2/rasterizer_storage_gles2.cpp
@@ -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) {
- return get_render_info(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() {