diff options
Diffstat (limited to 'servers/visual')
-rw-r--r-- | servers/visual/rasterizer.h | 6 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.cpp | 2 | ||||
-rw-r--r-- | servers/visual/visual_server_viewport.cpp | 13 | ||||
-rw-r--r-- | servers/visual/visual_server_wrap_mt.h | 11 |
4 files changed, 28 insertions, 4 deletions
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 87cf6eed8c..eb06c64c40 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -501,6 +501,12 @@ public: virtual void set_debug_generate_wireframes(bool p_generate) = 0; + virtual void render_info_begin_capture() = 0; + virtual void render_info_end_capture() = 0; + virtual int get_captured_render_info(VS::RenderInfo p_info) = 0; + + virtual int get_render_info(VS::RenderInfo p_info) = 0; + static RasterizerStorage *base_singleton; RasterizerStorage(); virtual ~RasterizerStorage() {} diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 93c3793819..8d332b3e6c 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -145,7 +145,7 @@ void VisualServerRaster::finish() { int VisualServerRaster::get_render_info(RenderInfo p_info) { - return 0; + return VSG::storage->get_render_info(p_info); } /* TESTING */ diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp index 9ab56894e9..a99b890601 100644 --- a/servers/visual/visual_server_viewport.cpp +++ b/servers/visual/visual_server_viewport.cpp @@ -274,9 +274,18 @@ void VisualServerViewport::draw_viewports() { VSG::rasterizer->set_current_render_target(vp->render_target); VSG::scene_render->set_debug_draw_mode(vp->debug_draw); + VSG::storage->render_info_begin_capture(); _draw_viewport(vp); + VSG::storage->render_info_end_capture(); + vp->render_info[VS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_OBJECTS_IN_FRAME); + vp->render_info[VS::VIEWPORT_RENDER_INFO_VERTICES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_VERTICES_IN_FRAME); + vp->render_info[VS::VIEWPORT_RENDER_INFO_MATERIAL_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_MATERIAL_CHANGES_IN_FRAME); + 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); + if (vp->viewport_to_screen_rect != Rect2()) { //copy to screen if set as such VSG::rasterizer->set_current_render_target(RID()); @@ -564,8 +573,10 @@ void VisualServerViewport::viewport_set_usage(RID p_viewport, VS::ViewportUsage int VisualServerViewport::viewport_get_render_info(RID p_viewport, VS::ViewportRenderInfo p_info) { ERR_FAIL_INDEX_V(p_info, VS::VIEWPORT_RENDER_INFO_MAX, -1); + Viewport *viewport = viewport_owner.getornull(p_viewport); - ERR_FAIL_COND_V(!viewport, -1); + if (!viewport) + return 0; //there should be a lock here.. return viewport->render_info[p_info]; } diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index d4f43ac396..407a4fd32b 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -372,7 +372,11 @@ public: FUNC2(viewport_set_hdr, RID, bool) FUNC2(viewport_set_usage, RID, ViewportUsage) - FUNC2R(int, viewport_get_render_info, RID, ViewportRenderInfo) + //this passes directly to avoid stalling, but it's pretty dangerous, so dont call after freeing a viewport + virtual int viewport_get_render_info(RID p_viewport, ViewportRenderInfo p_info) { + visual_server->viewport_get_render_info(p_viewport, p_info); + } + FUNC2(viewport_set_debug_draw, RID, ViewportDebugDraw) /* ENVIRONMENT API */ @@ -548,7 +552,10 @@ public: /* RENDER INFO */ - FUNC1R(int, get_render_info, RenderInfo) + //this passes directly to avoid stalling + virtual int get_render_info(RenderInfo p_info) { + visual_server->get_render_info(p_info); + } FUNC3(set_boot_image, const Ref<Image> &, const Color &, bool) FUNC1(set_default_clear_color, const Color &) |