From 2d08e166017f8f157ca78b08a54e095d91c6f2a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 14 Feb 2024 15:09:24 +0100 Subject: [PATCH] Cleanup: EEVEE-Next: Split display sync function --- .../eevee_next/eevee_reflection_probes.cc | 45 +++++++++++-------- .../eevee_next/eevee_reflection_probes.hh | 2 + 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/source/blender/draw/engines/eevee_next/eevee_reflection_probes.cc b/source/blender/draw/engines/eevee_next/eevee_reflection_probes.cc index 085b813fe91..89a3245384f 100644 --- a/source/blender/draw/engines/eevee_next/eevee_reflection_probes.cc +++ b/source/blender/draw/engines/eevee_next/eevee_reflection_probes.cc @@ -254,27 +254,36 @@ void SphereProbeModule::set_view(View & /*view*/) } data_buf_.push_update(); - do_display_draw_ = DRW_state_draw_support() && probe_active.size() > 0; - if (do_display_draw_) { - int display_index = 0; - for (int i : probe_active.index_range()) { - if (probe_active[i]->viewport_display) { - display_data_buf_.get_or_resize(display_index++) = { - i, probe_active[i]->viewport_display_size}; - } - } - do_display_draw_ = display_index > 0; - if (do_display_draw_) { - display_data_buf_.resize(display_index); - display_data_buf_.push_update(); - } - } - - /* Add one for world probe. */ - reflection_probe_count_ = probe_active.size() + 1; + reflection_probe_count_ = probe_id; dispatch_probe_select_.x = divide_ceil_u(reflection_probe_count_, SPHERE_PROBE_SELECT_GROUP_SIZE); instance_.manager->submit(select_ps_); + + sync_display(probe_active); +} + +void SphereProbeModule::sync_display(Vector &probe_active) +{ + do_display_draw_ = false; + if (!DRW_state_draw_support()) { + return; + } + + int display_index = 0; + for (int i : probe_active.index_range()) { + if (probe_active[i]->viewport_display) { + SphereProbeDisplayData &sph_data = display_data_buf_.get_or_resize(display_index++); + sph_data.probe_index = i; + sph_data.display_size = probe_active[i]->viewport_display_size; + } + } + + if (display_index == 0) { + return; + } + do_display_draw_ = true; + display_data_buf_.resize(display_index); + display_data_buf_.push_update(); } void SphereProbeModule::viewport_draw(View &view, GPUFrameBuffer *view_fb) diff --git a/source/blender/draw/engines/eevee_next/eevee_reflection_probes.hh b/source/blender/draw/engines/eevee_next/eevee_reflection_probes.hh index 910d4f42919..924e5071c44 100644 --- a/source/blender/draw/engines/eevee_next/eevee_reflection_probes.hh +++ b/source/blender/draw/engines/eevee_next/eevee_reflection_probes.hh @@ -169,6 +169,8 @@ class SphereProbeModule { void remap_to_octahedral_projection(const SphereProbeAtlasCoord &atlas_coord); void update_probes_texture_mipmaps(); void update_world_irradiance(); + + void sync_display(Vector &probe_active); }; /** \} */