diff options
Diffstat (limited to 'servers/rendering')
-rw-r--r-- | servers/rendering/renderer_viewport.cpp | 17 | ||||
-rw-r--r-- | servers/rendering/rendering_device.cpp | 2 | ||||
-rw-r--r-- | servers/rendering/rendering_device.h | 2 | ||||
-rw-r--r-- | servers/rendering/shader_compiler.cpp | 9 |
4 files changed, 22 insertions, 8 deletions
diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index aecd0593bc..c725d93a82 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -229,6 +229,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { bool scenario_draw_canvas_bg = false; //draw canvas, or some layer of it, as BG for 3D instead of in front int scenario_canvas_max_layer = 0; + bool force_clear_render_target = false; for (int i = 0; i < RS::VIEWPORT_RENDER_INFO_TYPE_MAX; i++) { for (int j = 0; j < RS::VIEWPORT_RENDER_INFO_MAX; j++) { @@ -236,11 +237,16 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { } } - if (!p_viewport->disable_2d && !viewport_is_environment_disabled(p_viewport) && RSG::scene->is_scenario(p_viewport->scenario)) { + if (RSG::scene->is_scenario(p_viewport->scenario)) { RID environment = RSG::scene->scenario_get_environment(p_viewport->scenario); if (RSG::scene->is_environment(environment)) { - scenario_draw_canvas_bg = RSG::scene->environment_get_background(environment) == RS::ENV_BG_CANVAS; - scenario_canvas_max_layer = RSG::scene->environment_get_canvas_max_layer(environment); + if (!p_viewport->disable_2d && !viewport_is_environment_disabled(p_viewport)) { + scenario_draw_canvas_bg = RSG::scene->environment_get_background(environment) == RS::ENV_BG_CANVAS; + scenario_canvas_max_layer = RSG::scene->environment_get_canvas_max_layer(environment); + } else if (RSG::scene->environment_get_background(environment) == RS::ENV_BG_CANVAS) { + // The scene renderer will still copy over the last frame, so we need to clear the render target. + force_clear_render_target = true; + } } } @@ -263,6 +269,9 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { } if (!scenario_draw_canvas_bg && can_draw_3d) { + if (force_clear_render_target) { + RSG::texture_storage->render_target_do_clear_request(p_viewport->render_target); + } _draw_3d(p_viewport); } @@ -844,7 +853,7 @@ void RendererViewport::viewport_set_scaling_3d_scale(RID p_viewport, float p_sca } void RendererViewport::viewport_set_size(RID p_viewport, int p_width, int p_height) { - ERR_FAIL_COND(p_width < 0 && p_height < 0); + ERR_FAIL_COND(p_width < 0 || p_height < 0); Viewport *viewport = viewport_owner.get_or_null(p_viewport); ERR_FAIL_COND(!viewport); diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index 28f872761a..286d1b683f 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -746,7 +746,7 @@ void RenderingDevice::_bind_methods() { ClassDB::bind_method(D_METHOD("buffer_update", "buffer", "offset", "size_bytes", "data", "post_barrier"), &RenderingDevice::_buffer_update, DEFVAL(BARRIER_MASK_ALL_BARRIERS)); ClassDB::bind_method(D_METHOD("buffer_clear", "buffer", "offset", "size_bytes", "post_barrier"), &RenderingDevice::buffer_clear, DEFVAL(BARRIER_MASK_ALL_BARRIERS)); - ClassDB::bind_method(D_METHOD("buffer_get_data", "buffer"), &RenderingDevice::buffer_get_data); + ClassDB::bind_method(D_METHOD("buffer_get_data", "buffer", "offset_bytes", "size_bytes"), &RenderingDevice::buffer_get_data, DEFVAL(0), DEFVAL(0)); ClassDB::bind_method(D_METHOD("render_pipeline_create", "shader", "framebuffer_format", "vertex_format", "primitive", "rasterization_state", "multisample_state", "stencil_state", "color_blend_state", "dynamic_state_flags", "for_render_pass", "specialization_constants"), &RenderingDevice::_render_pipeline_create, DEFVAL(0), DEFVAL(0), DEFVAL(TypedArray<RDPipelineSpecializationConstant>())); ClassDB::bind_method(D_METHOD("render_pipeline_is_valid", "render_pipeline"), &RenderingDevice::render_pipeline_is_valid); diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h index 9117669124..447627b08e 100644 --- a/servers/rendering/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -828,7 +828,7 @@ public: virtual Error buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const void *p_data, BitField<BarrierMask> p_post_barrier = BARRIER_MASK_ALL_BARRIERS) = 0; virtual Error buffer_clear(RID p_buffer, uint32_t p_offset, uint32_t p_size, BitField<BarrierMask> p_post_barrier = BARRIER_MASK_ALL_BARRIERS) = 0; - virtual Vector<uint8_t> buffer_get_data(RID p_buffer) = 0; //this causes stall, only use to retrieve large buffers for saving + virtual Vector<uint8_t> buffer_get_data(RID p_buffer, uint32_t p_offset = 0, uint32_t p_size = 0) = 0; // This causes stall, only use to retrieve large buffers for saving. /******************************************/ /**** PIPELINE SPECIALIZATION CONSTANT ****/ diff --git a/servers/rendering/shader_compiler.cpp b/servers/rendering/shader_compiler.cpp index 2710724066..8737d3b217 100644 --- a/servers/rendering/shader_compiler.cpp +++ b/servers/rendering/shader_compiler.cpp @@ -1151,6 +1151,9 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene bool is_texture_func = false; bool is_screen_texture = false; + bool texture_func_no_uv = false; + bool texture_func_returns_data = false; + if (onode->op == SL::OP_STRUCT) { code += _mkid(vnode->name); } else if (onode->op == SL::OP_CONSTRUCT) { @@ -1164,6 +1167,8 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene if (is_internal_func) { code += vnode->name; is_texture_func = texture_functions.has(vnode->name); + texture_func_no_uv = (vnode->name == "textureSize" || vnode->name == "textureQueryLevels"); + texture_func_returns_data = texture_func_no_uv || vnode->name == "textureQueryLod"; } else if (p_default_actions.renames.has(vnode->name)) { code += p_default_actions.renames[vnode->name]; } else { @@ -1313,7 +1318,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene } else { code += node_code; } - } else if (multiview_uv_needed && i == 2) { + } else if (multiview_uv_needed && !texture_func_no_uv && i == 2) { // UV coordinate after using color, depth or normal roughness texture. node_code = "multiview_uv(" + node_code + ".xy)"; @@ -1323,7 +1328,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene } } code += ")"; - if (is_screen_texture && actions.apply_luminance_multiplier) { + if (is_screen_texture && !texture_func_returns_data && actions.apply_luminance_multiplier) { code = "(" + code + " * vec4(vec3(sc_luminance_multiplier), 1.0))"; } } break; |