Merge pull request #105175 from clayjohn/RD-pipeline-sss-roughness

Detect more pipeline settings at load time to avoid pipeline stutters
This commit is contained in:
Thaddeus Crews 2025-04-10 11:10:22 -05:00
commit 06c71fbf40
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
6 changed files with 106 additions and 37 deletions

View file

@ -1174,14 +1174,22 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
_process_compositor_effects(RS::COMPOSITOR_EFFECT_CALLBACK_TYPE_PRE_TRANSPARENT, p_render_data);
}
if (scene_state.used_screen_texture) {
// Copy screen texture to backbuffer so we can read from it
_render_buffers_copy_screen_texture(p_render_data);
if (scene_state.used_screen_texture || global_surface_data.screen_texture_used) {
_render_buffers_ensure_screen_texture(p_render_data);
if (scene_state.used_screen_texture) {
// Copy screen texture to backbuffer so we can read from it
_render_buffers_copy_screen_texture(p_render_data);
}
}
if (scene_state.used_depth_texture) {
// Copy depth texture to backbuffer so we can read from it
_render_buffers_copy_depth_texture(p_render_data);
if (scene_state.used_depth_texture || global_surface_data.depth_texture_used) {
_render_buffers_ensure_depth_texture(p_render_data);
if (scene_state.used_depth_texture) {
// Copy depth texture to backbuffer so we can read from it
_render_buffers_copy_depth_texture(p_render_data);
}
}
if (render_list[RENDER_LIST_ALPHA].element_info.size() > 0) {
@ -1887,9 +1895,7 @@ void RenderForwardMobile::_fill_render_list(RenderListType p_render_list, const
RendererRD::MeshStorage *mesh_storage = RendererRD::MeshStorage::get_singleton();
if (p_render_list == RENDER_LIST_OPAQUE) {
scene_state.used_sss = false;
scene_state.used_screen_texture = false;
scene_state.used_normal_texture = false;
scene_state.used_depth_texture = false;
scene_state.used_lightmap = false;
}
@ -2043,15 +2049,9 @@ void RenderForwardMobile::_fill_render_list(RenderListType p_render_list, const
scene_state.used_lightmap = true;
}
if (surf->flags & GeometryInstanceSurfaceDataCache::FLAG_USES_SUBSURFACE_SCATTERING) {
scene_state.used_sss = true;
}
if (surf->flags & GeometryInstanceSurfaceDataCache::FLAG_USES_SCREEN_TEXTURE) {
scene_state.used_screen_texture = true;
}
if (surf->flags & GeometryInstanceSurfaceDataCache::FLAG_USES_NORMAL_TEXTURE) {
scene_state.used_normal_texture = true;
}
if (surf->flags & GeometryInstanceSurfaceDataCache::FLAG_USES_DEPTH_TEXTURE) {
scene_state.used_depth_texture = true;
}
@ -2536,10 +2536,12 @@ void RenderForwardMobile::_geometry_instance_add_surface_with_material(GeometryI
if (p_material->shader_data->uses_screen_texture) {
flags |= GeometryInstanceSurfaceDataCache::FLAG_USES_SCREEN_TEXTURE;
global_surface_data.screen_texture_used = true;
}
if (p_material->shader_data->uses_depth_texture) {
flags |= GeometryInstanceSurfaceDataCache::FLAG_USES_DEPTH_TEXTURE;
global_surface_data.depth_texture_used = true;
}
if (p_material->shader_data->uses_normal_texture) {

View file

@ -282,9 +282,7 @@ private:
RID lightmap_capture_buffer;
bool used_screen_texture = false;
bool used_normal_texture = false;
bool used_depth_texture = false;
bool used_sss = false;
bool used_lightmap = false;
struct ShadowPass {
@ -659,6 +657,12 @@ public:
void _update_dirty_geometry_instances();
void _update_dirty_geometry_pipelines();
// Global data about the scene that can be used to pre-allocate resources without relying on culling.
struct GlobalSurfaceData {
bool screen_texture_used = false;
bool depth_texture_used = false;
} global_surface_data;
virtual RenderGeometryInstance *geometry_instance_create(RID p_base) override;
virtual void geometry_instance_free(RenderGeometryInstance *p_geometry_instance) override;