Skip to content

Commit 54006f6

Browse files
committed
Merge pull request godotengine#102217 from clayjohn/mobile-pipelines
Reduce mobile pipeline compilations
2 parents 1a0bf54 + 7444839 commit 54006f6

File tree

6 files changed

+53
-11
lines changed

6 files changed

+53
-11
lines changed

scene/main/scene_tree.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1888,16 +1888,16 @@ SceneTree::SceneTree() {
18881888
root->set_as_audio_listener_2d(true);
18891889
current_scene = nullptr;
18901890

1891-
const int msaa_mode_2d = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "rendering/anti_aliasing/quality/msaa_2d", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Average),4× (Slow),8× (Slowest)")), 0);
1891+
const int msaa_mode_2d = GLOBAL_GET("rendering/anti_aliasing/quality/msaa_2d");
18921892
root->set_msaa_2d(Viewport::MSAA(msaa_mode_2d));
18931893

1894-
const int msaa_mode_3d = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "rendering/anti_aliasing/quality/msaa_3d", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Average),4× (Slow),8× (Slowest)")), 0);
1894+
const int msaa_mode_3d = GLOBAL_GET("rendering/anti_aliasing/quality/msaa_3d");
18951895
root->set_msaa_3d(Viewport::MSAA(msaa_mode_3d));
18961896

18971897
const bool transparent_background = GLOBAL_DEF("rendering/viewport/transparent_background", false);
18981898
root->set_transparent_background(transparent_background);
18991899

1900-
const bool use_hdr_2d = GLOBAL_DEF_BASIC("rendering/viewport/hdr_2d", false);
1900+
const bool use_hdr_2d = GLOBAL_GET("rendering/viewport/hdr_2d");
19011901
root->set_use_hdr_2d(use_hdr_2d);
19021902

19031903
const int ssaa_mode = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "rendering/anti_aliasing/quality/screen_space_aa", PROPERTY_HINT_ENUM, "Disabled (Fastest),FXAA (Fast)"), 0);
@@ -1941,7 +1941,7 @@ SceneTree::SceneTree() {
19411941

19421942
int shadowmap_size = GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/lights_and_shadows/positional_shadow/atlas_size", PROPERTY_HINT_RANGE, "256,16384"), 4096);
19431943
GLOBAL_DEF("rendering/lights_and_shadows/positional_shadow/atlas_size.mobile", 2048);
1944-
bool shadowmap_16_bits = GLOBAL_DEF("rendering/lights_and_shadows/positional_shadow/atlas_16_bits", true);
1944+
bool shadowmap_16_bits = GLOBAL_GET("rendering/lights_and_shadows/positional_shadow/atlas_16_bits");
19451945
int atlas_q0 = GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/lights_and_shadows/positional_shadow/atlas_quadrant_0_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), 2);
19461946
int atlas_q1 = GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/lights_and_shadows/positional_shadow/atlas_quadrant_1_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), 2);
19471947
int atlas_q2 = GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/lights_and_shadows/positional_shadow/atlas_quadrant_2_subdiv", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), 3);

servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -4940,6 +4940,7 @@ RenderForwardClustered::RenderForwardClustered() {
49404940
}
49414941

49424942
_update_shader_quality_settings();
4943+
_update_global_pipeline_data_requirements_from_project();
49434944

49444945
resolve_effects = memnew(RendererRD::Resolve());
49454946
taa = memnew(RendererRD::TAA);

servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp

+33-5
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,10 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
761761

762762
_update_vrs(rb);
763763

764+
if (rb->has_texture(RB_SCOPE_VRS, RB_TEXTURE)) {
765+
global_pipeline_data_required.use_vrs = true;
766+
}
767+
764768
RENDER_TIMESTAMP("Setup 3D Scene");
765769

766770
/* TODO
@@ -793,6 +797,7 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
793797
bool merge_transparent_pass = true; // If true: we can do our transparent pass in the same pass as our opaque pass.
794798
bool using_subpass_post_process = true; // If true: we can do our post processing in a subpass
795799
RendererRD::MaterialStorage::Samplers samplers;
800+
bool hdr_render_target = false;
796801

797802
RS::ViewportMSAA msaa = rb->get_msaa_3d();
798803
bool use_msaa = msaa != RS::VIEWPORT_MSAA_DISABLED;
@@ -892,11 +897,20 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
892897
if (using_subpass_post_process) {
893898
// We can do all in one go.
894899
framebuffer = rb_data->get_color_fbs(RenderBufferDataForwardMobile::FB_CONFIG_RENDER_AND_POST_PASS);
900+
global_pipeline_data_required.use_subpass_post_pass = true;
895901
} else {
896902
// We separate things out.
897903
framebuffer = rb_data->get_color_fbs(RenderBufferDataForwardMobile::FB_CONFIG_RENDER_PASS);
904+
global_pipeline_data_required.use_separate_post_pass = true;
898905
}
899906
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+
}
900914
} else {
901915
ERR_FAIL(); //bug?
902916
}
@@ -1107,7 +1121,7 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
11071121
WARN_PRINT_ONCE("Canvas background is not supported in multiview!");
11081122
} else {
11091123
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;
11111125

11121126
copy_effects->copy_to_drawlist(draw_list, fb_format, texture, convert_to_linear);
11131127
}
@@ -2893,6 +2907,7 @@ static RD::FramebufferFormatID _get_color_framebuffer_format_for_pipeline(RD::Da
28932907
attachment.samples = RD::TEXTURE_SAMPLES_1;
28942908
attachment.format = RenderSceneBuffersRD::get_vrs_format();
28952909
attachment.usage_flags = RenderSceneBuffersRD::get_vrs_usage_bits();
2910+
attachments.push_back(attachment);
28962911
}
28972912

28982913
if (multisampling) {
@@ -3006,11 +3021,18 @@ void RenderForwardMobile::_mesh_compile_pipelines_for_surface(const SurfacePipel
30063021
const bool multiview_enabled = p_global.use_multiview && scene_shader.is_multiview_enabled();
30073022
const RD::DataFormat buffers_color_format = _render_buffers_get_color_format();
30083023
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+
30103032
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++) {
30143036
pipeline_key.version = SceneShaderForwardMobile::SHADER_VERSION_COLOR_PASS;
30153037
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);
30163038
_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() {
32373259
scene_shader.init(defines);
32383260

32393261
_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;
32403268
}
32413269

32423270
RenderForwardMobile::~RenderForwardMobile() {

servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h

+5
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,11 @@ class RenderForwardMobile : public RendererSceneRenderRD {
587587
uint32_t use_32_bit_shadows : 1;
588588
uint32_t use_shadow_cubemaps : 1;
589589
uint32_t use_shadow_dual_paraboloid : 1;
590+
uint32_t use_vrs : 1;
591+
uint32_t use_subpass_post_pass : 1;
592+
uint32_t use_separate_post_pass : 1;
593+
uint32_t use_hdr_render_target : 1;
594+
uint32_t use_ldr_render_target : 1;
590595
};
591596
};
592597
};

servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ class SceneShaderForwardMobile {
172172
h = hash_murmur3_one_32(cull_mode, h);
173173
h = hash_murmur3_one_32(primitive_type, h);
174174
h = hash_murmur3_one_32(shader_specialization.packed_0, h);
175-
h = hash_murmur3_one_float(shader_specialization.packed_1, h);
175+
h = hash_murmur3_one_32(shader_specialization.packed_1, h);
176176
h = hash_murmur3_one_32(shader_specialization.packed_2, h);
177+
h = hash_murmur3_one_float(shader_specialization.packed_3, h);
177178
h = hash_murmur3_one_32(version, h);
178179
h = hash_murmur3_one_32(render_pass, h);
179180
h = hash_murmur3_one_32(wireframe, h);

servers/rendering_server.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -3608,6 +3608,7 @@ void RenderingServer::init() {
36083608

36093609
GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/lights_and_shadows/positional_shadow/soft_shadow_filter_quality", PROPERTY_HINT_ENUM, "Hard (Fastest),Soft Very Low (Faster),Soft Low (Fast),Soft Medium (Average),Soft High (Slow),Soft Ultra (Slowest)"), 2);
36103610
GLOBAL_DEF("rendering/lights_and_shadows/positional_shadow/soft_shadow_filter_quality.mobile", 0);
3611+
GLOBAL_DEF("rendering/lights_and_shadows/positional_shadow/atlas_16_bits", true);
36113612

36123613
GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/2d/shadow_atlas/size", PROPERTY_HINT_RANGE, "128,16384"), 2048);
36133614
GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/2d/batching/item_buffer_size", PROPERTY_HINT_RANGE, "128,1048576,1"), 16384);
@@ -3664,6 +3665,12 @@ void RenderingServer::init() {
36643665
GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssil/fadeout_from", PROPERTY_HINT_RANGE, "0.0,512,0.1,or_greater"), 50.0);
36653666
GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/environment/ssil/fadeout_to", PROPERTY_HINT_RANGE, "64,65536,0.1,or_greater"), 300.0);
36663667

3668+
// Move the project setting definitions here so they are available when we init the rendering internals.
3669+
GLOBAL_DEF_BASIC("rendering/viewport/hdr_2d", false);
3670+
3671+
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "rendering/anti_aliasing/quality/msaa_2d", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Average),4× (Slow),8× (Slowest)")), 0);
3672+
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "rendering/anti_aliasing/quality/msaa_3d", PROPERTY_HINT_ENUM, String::utf8("Disabled (Fastest),2× (Average),4× (Slow),8× (Slowest)")), 0);
3673+
36673674
GLOBAL_DEF("rendering/anti_aliasing/screen_space_roughness_limiter/enabled", true);
36683675
GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/amount", PROPERTY_HINT_RANGE, "0.01,4.0,0.01"), 0.25);
36693676
GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/limit", PROPERTY_HINT_RANGE, "0.01,1.0,0.01"), 0.18);
@@ -3686,8 +3693,8 @@ void RenderingServer::init() {
36863693
}
36873694
GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/scaling_3d/scale", PROPERTY_HINT_RANGE, "0.25,2.0,0.01"), 1.0);
36883695
GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/scaling_3d/fsr_sharpness", PROPERTY_HINT_RANGE, "0,2,0.1"), 0.2f);
3689-
GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/textures/default_filters/texture_mipmap_bias", PROPERTY_HINT_RANGE, "-2,2,0.001"), 0.0f);
36903696

3697+
GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/textures/default_filters/texture_mipmap_bias", PROPERTY_HINT_RANGE, "-2,2,0.001"), 0.0f);
36913698
GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/textures/decals/filter", PROPERTY_HINT_ENUM, "Nearest (Fast),Linear (Fast),Nearest Mipmap (Fast),Linear Mipmap (Fast),Nearest Mipmap Anisotropic (Average),Linear Mipmap Anisotropic (Average)"), DECAL_FILTER_LINEAR_MIPMAPS);
36923699
GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/textures/light_projectors/filter", PROPERTY_HINT_ENUM, "Nearest (Fast),Linear (Fast),Nearest Mipmap (Fast),Linear Mipmap (Fast),Nearest Mipmap Anisotropic (Average),Linear Mipmap Anisotropic (Average)"), LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS);
36933700

0 commit comments

Comments
 (0)