diff options
Diffstat (limited to 'servers/rendering/rendering_server_viewport.cpp')
-rw-r--r-- | servers/rendering/rendering_server_viewport.cpp | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/servers/rendering/rendering_server_viewport.cpp b/servers/rendering/rendering_server_viewport.cpp index 6fb8f6ca63..660c96e441 100644 --- a/servers/rendering/rendering_server_viewport.cpp +++ b/servers/rendering/rendering_server_viewport.cpp @@ -36,7 +36,6 @@ #include "rendering_server_scene.h" static Transform2D _canvas_get_transform(RenderingServerViewport::Viewport *p_viewport, RenderingServerCanvas::Canvas *p_canvas, RenderingServerViewport::Viewport::CanvasData *p_canvas_data, const Vector2 &p_vp_size) { - Transform2D xf = p_viewport->global_transform; float scale = 1.0; @@ -63,7 +62,6 @@ static Transform2D _canvas_get_transform(RenderingServerViewport::Viewport *p_vi } void RenderingServerViewport::_draw_3d(Viewport *p_viewport, XRInterface::Eyes p_eye) { - RENDER_TIMESTAMP(">Begin Rendering 3D Scene"); Ref<XRInterface> xr_interface; @@ -80,7 +78,6 @@ void RenderingServerViewport::_draw_3d(Viewport *p_viewport, XRInterface::Eyes p } void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface::Eyes p_eye) { - if (p_viewport->measure_render_time) { String rt_id = "vp_begin_" + itos(p_viewport->self.get_id()); RSG::storage->capture_timestamp(rt_id); @@ -95,7 +92,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface:: Color bgcolor = RSG::storage->get_default_clear_color(); if (!p_viewport->hide_canvas && !p_viewport->disable_environment && RSG::scene->scenario_owner.owns(p_viewport->scenario)) { - RenderingServerScene::Scenario *scenario = RSG::scene->scenario_owner.getornull(p_viewport->scenario); ERR_FAIL_COND(!scenario); if (RSG::scene_render->is_environment(scenario->environment)) { @@ -143,7 +139,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface:: RENDER_TIMESTAMP("Cull Canvas Lights"); for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) { - RenderingServerCanvas::Canvas *canvas = static_cast<RenderingServerCanvas::Canvas *>(E->get().canvas); Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size); @@ -151,7 +146,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface:: //find lights in canvas for (Set<RasterizerCanvas::Light *>::Element *F = canvas->lights.front(); F; F = F->next()) { - RasterizerCanvas::Light *cl = F->get(); if (cl->enabled && cl->texture.is_valid()) { //not super efficient.. @@ -163,7 +157,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface:: cl->xform_cache = xf * cl->xform; if (clip_rect.intersects_transformed(cl->xform_cache, cl->rect_cache)) { - cl->filter_next_ptr = lights; lights = cl; // cl->texture_cache = nullptr; @@ -173,7 +166,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface:: cl->light_shader_xform = cl->xform * scale; //cl->light_shader_pos = cl->xform_cache[2]; if (cl->use_shadow) { - cl->shadows_next_ptr = lights_with_shadow; if (lights_with_shadow == nullptr) { shadow_rect = cl->xform_cache.xform(cl->rect_cache); @@ -209,17 +201,14 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface:: //make list of occluders for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) { - RenderingServerCanvas::Canvas *canvas = static_cast<RenderingServerCanvas::Canvas *>(E->get().canvas); Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size); for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) { - if (!F->get()->enabled) continue; F->get()->xform_cache = xf * F->get()->xform; if (shadow_rect.intersects_transformed(F->get()->xform_cache, F->get()->aabb_cache)) { - F->get()->next = occluders; occluders = F->get(); } @@ -229,7 +218,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface:: RasterizerCanvas::Light *light = lights_with_shadow; while (light) { - RENDER_TIMESTAMP("Render Shadow"); RSG::canvas_render->light_update_shadow(light->light_internal, light->xform_cache.affine_inverse(), light->item_shadow_mask, light->radius_cache / 1000.0, light->radius_cache * 1.1, occluders); @@ -250,7 +238,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface:: } for (Map<Viewport::CanvasKey, Viewport::CanvasData *>::Element *E = canvas_map.front(); E; E = E->next()) { - RenderingServerCanvas::Canvas *canvas = static_cast<RenderingServerCanvas::Canvas *>(E->get()->canvas); Transform2D xform = _canvas_get_transform(p_viewport, canvas, E->get(), clip_rect.size); @@ -304,7 +291,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface:: } void RenderingServerViewport::draw_viewports() { - timestamp_vp_map.clear(); // get our xr interface in case we need it @@ -368,7 +354,6 @@ void RenderingServerViewport::draw_viewports() { } for (int i = 0; i < active_viewports.size(); i++) { - Viewport *vp = active_viewports[i]; if (vp->last_pass != draw_viewports_pass) { @@ -470,7 +455,6 @@ void RenderingServerViewport::draw_viewports() { } RID RenderingServerViewport::viewport_create() { - Viewport *viewport = memnew(Viewport); RID rid = viewport_owner.make_rid(viewport); @@ -493,7 +477,6 @@ void RenderingServerViewport::viewport_set_use_xr(RID p_viewport, bool p_use_xr) } void RenderingServerViewport::viewport_set_size(RID p_viewport, int p_width, int p_height) { - ERR_FAIL_COND(p_width < 0 && p_height < 0); Viewport *viewport = viewport_owner.getornull(p_viewport); @@ -512,7 +495,6 @@ void RenderingServerViewport::viewport_set_size(RID p_viewport, int p_width, int } void RenderingServerViewport::viewport_set_active(RID p_viewport, bool p_active) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -525,7 +507,6 @@ void RenderingServerViewport::viewport_set_active(RID p_viewport, bool p_active) } void RenderingServerViewport::viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -533,7 +514,6 @@ void RenderingServerViewport::viewport_set_parent_viewport(RID p_viewport, RID p } void RenderingServerViewport::viewport_set_clear_mode(RID p_viewport, RS::ViewportClearMode p_clear_mode) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -541,7 +521,6 @@ void RenderingServerViewport::viewport_set_clear_mode(RID p_viewport, RS::Viewpo } void RenderingServerViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect, DisplayServer::WindowID p_screen) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -549,7 +528,6 @@ void RenderingServerViewport::viewport_attach_to_screen(RID p_viewport, const Re // If using GLES2 we can optimize this operation by rendering directly to system_fbo // instead of rendering to fbo and copying to system_fbo after if (RSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) { - RSG::storage->render_target_set_size(viewport->render_target, p_rect.size.x, p_rect.size.y); RSG::storage->render_target_set_position(viewport->render_target, p_rect.position.x, p_rect.position.y); } @@ -557,10 +535,8 @@ void RenderingServerViewport::viewport_attach_to_screen(RID p_viewport, const Re viewport->viewport_to_screen_rect = p_rect; viewport->viewport_to_screen = p_screen; } else { - // if render_direct_to_screen was used, reset size and position if (RSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) { - RSG::storage->render_target_set_position(viewport->render_target, 0, 0); RSG::storage->render_target_set_size(viewport->render_target, viewport->size.x, viewport->size.y); } @@ -579,7 +555,6 @@ void RenderingServerViewport::viewport_set_render_direct_to_screen(RID p_viewpor // if disabled, reset render_target size and position if (!p_enable) { - RSG::storage->render_target_set_position(viewport->render_target, 0, 0); RSG::storage->render_target_set_size(viewport->render_target, viewport->size.x, viewport->size.y); } @@ -589,14 +564,12 @@ void RenderingServerViewport::viewport_set_render_direct_to_screen(RID p_viewpor // if attached to screen already, setup screen size and position, this needs to happen after setting flag to avoid an unnecessary buffer allocation if (RSG::rasterizer->is_low_end() && viewport->viewport_to_screen_rect != Rect2() && p_enable) { - RSG::storage->render_target_set_size(viewport->render_target, viewport->viewport_to_screen_rect.size.x, viewport->viewport_to_screen_rect.size.y); RSG::storage->render_target_set_position(viewport->render_target, viewport->viewport_to_screen_rect.position.x, viewport->viewport_to_screen_rect.position.y); } } void RenderingServerViewport::viewport_set_update_mode(RID p_viewport, RS::ViewportUpdateMode p_mode) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -604,7 +577,6 @@ void RenderingServerViewport::viewport_set_update_mode(RID p_viewport, RS::Viewp } RID RenderingServerViewport::viewport_get_texture(RID p_viewport) const { - const Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND_V(!viewport, RID()); @@ -612,21 +584,18 @@ RID RenderingServerViewport::viewport_get_texture(RID p_viewport) const { } void RenderingServerViewport::viewport_set_hide_scenario(RID p_viewport, bool p_hide) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); viewport->hide_scenario = p_hide; } void RenderingServerViewport::viewport_set_hide_canvas(RID p_viewport, bool p_hide) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); viewport->hide_canvas = p_hide; } void RenderingServerViewport::viewport_set_disable_environment(RID p_viewport, bool p_disable) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -634,21 +603,18 @@ void RenderingServerViewport::viewport_set_disable_environment(RID p_viewport, b } void RenderingServerViewport::viewport_attach_camera(RID p_viewport, RID p_camera) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); viewport->camera = p_camera; } void RenderingServerViewport::viewport_set_scenario(RID p_viewport, RID p_scenario) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); viewport->scenario = p_scenario; } void RenderingServerViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -664,7 +630,6 @@ void RenderingServerViewport::viewport_attach_canvas(RID p_viewport, RID p_canva } void RenderingServerViewport::viewport_remove_canvas(RID p_viewport, RID p_canvas) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -675,7 +640,6 @@ void RenderingServerViewport::viewport_remove_canvas(RID p_viewport, RID p_canva canvas->viewports.erase(p_viewport); } void RenderingServerViewport::viewport_set_canvas_transform(RID p_viewport, RID p_canvas, const Transform2D &p_offset) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -683,7 +647,6 @@ void RenderingServerViewport::viewport_set_canvas_transform(RID p_viewport, RID viewport->canvas_map[p_canvas].transform = p_offset; } void RenderingServerViewport::viewport_set_transparent_background(RID p_viewport, bool p_enabled) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -692,14 +655,12 @@ void RenderingServerViewport::viewport_set_transparent_background(RID p_viewport } void RenderingServerViewport::viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); viewport->global_transform = p_transform; } void RenderingServerViewport::viewport_set_canvas_stacking(RID p_viewport, RID p_canvas, int p_layer, int p_sublayer) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -709,7 +670,6 @@ void RenderingServerViewport::viewport_set_canvas_stacking(RID p_viewport, RID p } void RenderingServerViewport::viewport_set_shadow_atlas_size(RID p_viewport, int p_size) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -719,7 +679,6 @@ void RenderingServerViewport::viewport_set_shadow_atlas_size(RID p_viewport, int } void RenderingServerViewport::viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -727,7 +686,6 @@ void RenderingServerViewport::viewport_set_shadow_atlas_quadrant_subdivision(RID } void RenderingServerViewport::viewport_set_msaa(RID p_viewport, RS::ViewportMSAA p_msaa) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -754,7 +712,6 @@ void RenderingServerViewport::viewport_set_screen_space_aa(RID p_viewport, RS::V } int RenderingServerViewport::viewport_get_render_info(RID p_viewport, RS::ViewportRenderInfo p_info) { - ERR_FAIL_INDEX_V(p_info, RS::VIEWPORT_RENDER_INFO_MAX, -1); Viewport *viewport = viewport_owner.getornull(p_viewport); @@ -765,7 +722,6 @@ int RenderingServerViewport::viewport_get_render_info(RID p_viewport, RS::Viewpo } void RenderingServerViewport::viewport_set_debug_draw(RID p_viewport, RS::ViewportDebugDraw p_draw) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -773,7 +729,6 @@ void RenderingServerViewport::viewport_set_debug_draw(RID p_viewport, RS::Viewpo } void RenderingServerViewport::viewport_set_measure_render_time(RID p_viewport, bool p_enable) { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -781,7 +736,6 @@ void RenderingServerViewport::viewport_set_measure_render_time(RID p_viewport, b } float RenderingServerViewport::viewport_get_measured_render_time_cpu(RID p_viewport) const { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND_V(!viewport, 0); @@ -789,7 +743,6 @@ float RenderingServerViewport::viewport_get_measured_render_time_cpu(RID p_viewp } float RenderingServerViewport::viewport_get_measured_render_time_gpu(RID p_viewport) const { - Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND_V(!viewport, 0); @@ -797,9 +750,7 @@ float RenderingServerViewport::viewport_get_measured_render_time_gpu(RID p_viewp } bool RenderingServerViewport::free(RID p_rid) { - if (viewport_owner.owns(p_rid)) { - Viewport *viewport = viewport_owner.getornull(p_rid); RSG::storage->free(viewport->render_target); @@ -825,7 +776,6 @@ bool RenderingServerViewport::free(RID p_rid) { } void RenderingServerViewport::handle_timestamp(String p_timestamp, uint64_t p_cpu_time, uint64_t p_gpu_time) { - RID *vp = timestamp_vp_map.getptr(p_timestamp); if (!vp) { return; |