Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce mobile pipeline compilations #102217

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions scene/main/scene_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1883,16 +1883,16 @@ SceneTree::SceneTree() {
root->set_as_audio_listener_2d(true);
current_scene = nullptr;

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);
const int msaa_mode_2d = GLOBAL_GET("rendering/anti_aliasing/quality/msaa_2d");
root->set_msaa_2d(Viewport::MSAA(msaa_mode_2d));

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);
const int msaa_mode_3d = GLOBAL_GET("rendering/anti_aliasing/quality/msaa_3d");
root->set_msaa_3d(Viewport::MSAA(msaa_mode_3d));

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

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

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);
Expand Down Expand Up @@ -1936,7 +1936,7 @@ SceneTree::SceneTree() {

int shadowmap_size = GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/lights_and_shadows/positional_shadow/atlas_size", PROPERTY_HINT_RANGE, "256,16384"), 4096);
GLOBAL_DEF("rendering/lights_and_shadows/positional_shadow/atlas_size.mobile", 2048);
bool shadowmap_16_bits = GLOBAL_DEF("rendering/lights_and_shadows/positional_shadow/atlas_16_bits", true);
bool shadowmap_16_bits = GLOBAL_GET("rendering/lights_and_shadows/positional_shadow/atlas_16_bits");
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);
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);
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4940,6 +4940,7 @@ RenderForwardClustered::RenderForwardClustered() {
}

_update_shader_quality_settings();
_update_global_pipeline_data_requirements_from_project();

resolve_effects = memnew(RendererRD::Resolve());
taa = memnew(RendererRD::TAA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,10 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color

_update_vrs(rb);

if (rb->has_texture(RB_SCOPE_VRS, RB_TEXTURE)) {
global_pipeline_data_required.use_vrs = true;
}

RENDER_TIMESTAMP("Setup 3D Scene");

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

RS::ViewportMSAA msaa = rb->get_msaa_3d();
bool use_msaa = msaa != RS::VIEWPORT_MSAA_DISABLED;
Expand Down Expand Up @@ -892,11 +897,20 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
if (using_subpass_post_process) {
// We can do all in one go.
framebuffer = rb_data->get_color_fbs(RenderBufferDataForwardMobile::FB_CONFIG_RENDER_AND_POST_PASS);
global_pipeline_data_required.use_subpass_post_pass = true;
} else {
// We separate things out.
framebuffer = rb_data->get_color_fbs(RenderBufferDataForwardMobile::FB_CONFIG_RENDER_PASS);
global_pipeline_data_required.use_separate_post_pass = true;
}
samplers = rb->get_samplers();

hdr_render_target = RendererRD::TextureStorage::get_singleton()->render_target_is_using_hdr(rb->get_render_target());
if (hdr_render_target) {
global_pipeline_data_required.use_hdr_render_target = true;
} else {
global_pipeline_data_required.use_ldr_render_target = true;
}
} else {
ERR_FAIL(); //bug?
}
Expand Down Expand Up @@ -1107,7 +1121,7 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
WARN_PRINT_ONCE("Canvas background is not supported in multiview!");
} else {
RID texture = RendererRD::TextureStorage::get_singleton()->render_target_get_rd_texture(rb->get_render_target());
bool convert_to_linear = !RendererRD::TextureStorage::get_singleton()->render_target_is_using_hdr(rb->get_render_target());
bool convert_to_linear = !hdr_render_target;

copy_effects->copy_to_drawlist(draw_list, fb_format, texture, convert_to_linear);
}
Expand Down Expand Up @@ -2893,6 +2907,7 @@ static RD::FramebufferFormatID _get_color_framebuffer_format_for_pipeline(RD::Da
attachment.samples = RD::TEXTURE_SAMPLES_1;
attachment.format = RenderSceneBuffersRD::get_vrs_format();
attachment.usage_flags = RenderSceneBuffersRD::get_vrs_usage_bits();
attachments.push_back(attachment);
}

if (multisampling) {
Expand Down Expand Up @@ -3006,11 +3021,18 @@ void RenderForwardMobile::_mesh_compile_pipelines_for_surface(const SurfacePipel
const bool multiview_enabled = p_global.use_multiview && scene_shader.is_multiview_enabled();
const RD::DataFormat buffers_color_format = _render_buffers_get_color_format();
const bool buffers_can_be_storage = _render_buffers_can_be_storage();
const uint32_t vrs_iterations = is_vrs_supported() ? 2 : 1;
const uint32_t vrs_iterations = p_global.use_vrs ? 2 : 1;

const uint32_t post_pass_start = p_global.use_separate_post_pass ? 0 : 1;
const uint32_t post_pass_iterations = p_global.use_subpass_post_pass ? 2 : (post_pass_start + 1);

const uint32_t hdr_start = p_global.use_ldr_render_target ? 0 : 1;
const uint32_t hdr_target_iterations = p_global.use_hdr_render_target ? 2 : 1;

for (uint32_t use_vrs = 0; use_vrs < vrs_iterations; use_vrs++) {
for (uint32_t use_post_pass = 0; use_post_pass < 2; use_post_pass++) {
const uint32_t hdr_iterations = use_post_pass ? 2 : 1;
for (uint32_t use_hdr = 0; use_hdr < hdr_iterations; use_hdr++) {
for (uint32_t use_post_pass = post_pass_start; use_post_pass < post_pass_iterations; use_post_pass++) {
const uint32_t hdr_iterations = use_post_pass ? hdr_target_iterations : (hdr_start + 1);
for (uint32_t use_hdr = hdr_start; use_hdr < hdr_iterations; use_hdr++) {
pipeline_key.version = SceneShaderForwardMobile::SHADER_VERSION_COLOR_PASS;
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);
_mesh_compile_pipeline_for_surface(p_surface.shader, p_surface.mesh_surface, p_surface.instanced, p_source, pipeline_key, r_pipeline_pairs);
Expand Down Expand Up @@ -3237,6 +3259,12 @@ RenderForwardMobile::RenderForwardMobile() {
scene_shader.init(defines);

_update_shader_quality_settings();
_update_global_pipeline_data_requirements_from_project();

// Only update these from the project setting at init time.
const bool root_hdr_render_target = GLOBAL_GET("rendering/viewport/hdr_2d");
global_pipeline_data_required.use_hdr_render_target = root_hdr_render_target;
global_pipeline_data_required.use_ldr_render_target = !root_hdr_render_target;
}

RenderForwardMobile::~RenderForwardMobile() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,11 @@ class RenderForwardMobile : public RendererSceneRenderRD {
uint32_t use_32_bit_shadows : 1;
uint32_t use_shadow_cubemaps : 1;
uint32_t use_shadow_dual_paraboloid : 1;
uint32_t use_vrs : 1;
uint32_t use_subpass_post_pass : 1;
uint32_t use_separate_post_pass : 1;
uint32_t use_hdr_render_target : 1;
uint32_t use_ldr_render_target : 1;
};
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ class SceneShaderForwardMobile {
h = hash_murmur3_one_32(cull_mode, h);
h = hash_murmur3_one_32(primitive_type, h);
h = hash_murmur3_one_32(shader_specialization.packed_0, h);
h = hash_murmur3_one_float(shader_specialization.packed_1, h);
h = hash_murmur3_one_32(shader_specialization.packed_1, h);
h = hash_murmur3_one_32(shader_specialization.packed_2, h);
h = hash_murmur3_one_float(shader_specialization.packed_3, h);
h = hash_murmur3_one_32(version, h);
h = hash_murmur3_one_32(render_pass, h);
h = hash_murmur3_one_32(wireframe, h);
Expand Down
9 changes: 8 additions & 1 deletion servers/rendering_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3608,6 +3608,7 @@ void RenderingServer::init() {

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);
GLOBAL_DEF("rendering/lights_and_shadows/positional_shadow/soft_shadow_filter_quality.mobile", 0);
GLOBAL_DEF("rendering/lights_and_shadows/positional_shadow/atlas_16_bits", true);

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

// Move the project setting definitions here so they are available when we init the rendering internals.
GLOBAL_DEF_BASIC("rendering/viewport/hdr_2d", false);

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);
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);

GLOBAL_DEF("rendering/anti_aliasing/screen_space_roughness_limiter/enabled", true);
GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/amount", PROPERTY_HINT_RANGE, "0.01,4.0,0.01"), 0.25);
GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/limit", PROPERTY_HINT_RANGE, "0.01,1.0,0.01"), 0.18);
Expand All @@ -3686,8 +3693,8 @@ void RenderingServer::init() {
}
GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/scaling_3d/scale", PROPERTY_HINT_RANGE, "0.25,2.0,0.01"), 1.0);
GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/scaling_3d/fsr_sharpness", PROPERTY_HINT_RANGE, "0,2,0.1"), 0.2f);
GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/textures/default_filters/texture_mipmap_bias", PROPERTY_HINT_RANGE, "-2,2,0.001"), 0.0f);

GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/textures/default_filters/texture_mipmap_bias", PROPERTY_HINT_RANGE, "-2,2,0.001"), 0.0f);
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);
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);

Expand Down