@@ -761,6 +761,10 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
761
761
762
762
_update_vrs (rb);
763
763
764
+ if (rb->has_texture (RB_SCOPE_VRS, RB_TEXTURE)) {
765
+ global_pipeline_data_required.use_vrs = true ;
766
+ }
767
+
764
768
RENDER_TIMESTAMP (" Setup 3D Scene" );
765
769
766
770
/* TODO
@@ -793,6 +797,7 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
793
797
bool merge_transparent_pass = true ; // If true: we can do our transparent pass in the same pass as our opaque pass.
794
798
bool using_subpass_post_process = true ; // If true: we can do our post processing in a subpass
795
799
RendererRD::MaterialStorage::Samplers samplers;
800
+ bool hdr_render_target = false ;
796
801
797
802
RS::ViewportMSAA msaa = rb->get_msaa_3d ();
798
803
bool use_msaa = msaa != RS::VIEWPORT_MSAA_DISABLED;
@@ -892,11 +897,20 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
892
897
if (using_subpass_post_process) {
893
898
// We can do all in one go.
894
899
framebuffer = rb_data->get_color_fbs (RenderBufferDataForwardMobile::FB_CONFIG_RENDER_AND_POST_PASS);
900
+ global_pipeline_data_required.use_subpass_post_pass = true ;
895
901
} else {
896
902
// We separate things out.
897
903
framebuffer = rb_data->get_color_fbs (RenderBufferDataForwardMobile::FB_CONFIG_RENDER_PASS);
904
+ global_pipeline_data_required.use_separate_post_pass = true ;
898
905
}
899
906
samplers = rb->get_samplers ();
907
+
908
+ hdr_render_target = RendererRD::TextureStorage::get_singleton ()->render_target_is_using_hdr (rb->get_render_target ());
909
+ if (hdr_render_target) {
910
+ global_pipeline_data_required.use_hdr_render_target = true ;
911
+ } else {
912
+ global_pipeline_data_required.use_ldr_render_target = true ;
913
+ }
900
914
} else {
901
915
ERR_FAIL (); // bug?
902
916
}
@@ -1107,7 +1121,7 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
1107
1121
WARN_PRINT_ONCE (" Canvas background is not supported in multiview!" );
1108
1122
} else {
1109
1123
RID texture = RendererRD::TextureStorage::get_singleton ()->render_target_get_rd_texture (rb->get_render_target ());
1110
- bool convert_to_linear = !RendererRD::TextureStorage::get_singleton ()-> render_target_is_using_hdr (rb-> get_render_target ()) ;
1124
+ bool convert_to_linear = !hdr_render_target ;
1111
1125
1112
1126
copy_effects->copy_to_drawlist (draw_list, fb_format, texture, convert_to_linear);
1113
1127
}
@@ -2893,6 +2907,7 @@ static RD::FramebufferFormatID _get_color_framebuffer_format_for_pipeline(RD::Da
2893
2907
attachment.samples = RD::TEXTURE_SAMPLES_1;
2894
2908
attachment.format = RenderSceneBuffersRD::get_vrs_format ();
2895
2909
attachment.usage_flags = RenderSceneBuffersRD::get_vrs_usage_bits ();
2910
+ attachments.push_back (attachment);
2896
2911
}
2897
2912
2898
2913
if (multisampling) {
@@ -3006,11 +3021,18 @@ void RenderForwardMobile::_mesh_compile_pipelines_for_surface(const SurfacePipel
3006
3021
const bool multiview_enabled = p_global.use_multiview && scene_shader.is_multiview_enabled ();
3007
3022
const RD::DataFormat buffers_color_format = _render_buffers_get_color_format ();
3008
3023
const bool buffers_can_be_storage = _render_buffers_can_be_storage ();
3009
- const uint32_t vrs_iterations = is_vrs_supported () ? 2 : 1 ;
3024
+ const uint32_t vrs_iterations = p_global.use_vrs ? 2 : 1 ;
3025
+
3026
+ const uint32_t post_pass_start = p_global.use_separate_post_pass ? 0 : 1 ;
3027
+ const uint32_t post_pass_iterations = p_global.use_subpass_post_pass ? 2 : (post_pass_start + 1 );
3028
+
3029
+ const uint32_t hdr_start = p_global.use_ldr_render_target ? 0 : 1 ;
3030
+ const uint32_t hdr_target_iterations = p_global.use_hdr_render_target ? 2 : 1 ;
3031
+
3010
3032
for (uint32_t use_vrs = 0 ; use_vrs < vrs_iterations; use_vrs++) {
3011
- for (uint32_t use_post_pass = 0 ; use_post_pass < 2 ; use_post_pass++) {
3012
- const uint32_t hdr_iterations = use_post_pass ? 2 : 1 ;
3013
- for (uint32_t use_hdr = 0 ; use_hdr < hdr_iterations; use_hdr++) {
3033
+ for (uint32_t use_post_pass = post_pass_start ; use_post_pass < post_pass_iterations ; use_post_pass++) {
3034
+ const uint32_t hdr_iterations = use_post_pass ? hdr_target_iterations : (hdr_start + 1 ) ;
3035
+ for (uint32_t use_hdr = hdr_start ; use_hdr < hdr_iterations; use_hdr++) {
3014
3036
pipeline_key.version = SceneShaderForwardMobile::SHADER_VERSION_COLOR_PASS;
3015
3037
pipeline_key.framebuffer_format_id = _get_color_framebuffer_format_for_pipeline (buffers_color_format, buffers_can_be_storage, RD::TextureSamples (p_global.texture_samples ), RD::TextureSamples (p_global.target_samples ), use_vrs, use_post_pass, use_hdr, 1 );
3016
3038
_mesh_compile_pipeline_for_surface (p_surface.shader , p_surface.mesh_surface , p_surface.instanced , p_source, pipeline_key, r_pipeline_pairs);
@@ -3237,6 +3259,12 @@ RenderForwardMobile::RenderForwardMobile() {
3237
3259
scene_shader.init (defines);
3238
3260
3239
3261
_update_shader_quality_settings ();
3262
+ _update_global_pipeline_data_requirements_from_project ();
3263
+
3264
+ // Only update these from the project setting at init time.
3265
+ const bool root_hdr_render_target = GLOBAL_GET (" rendering/viewport/hdr_2d" );
3266
+ global_pipeline_data_required.use_hdr_render_target = root_hdr_render_target;
3267
+ global_pipeline_data_required.use_ldr_render_target = !root_hdr_render_target;
3240
3268
}
3241
3269
3242
3270
RenderForwardMobile::~RenderForwardMobile () {
0 commit comments