FIX:Less than 5 GB of free memory will not apply for lod

and ban lod in mac 15
jira: STUDIO-12063

Change-Id: Ibbf2960d8b61f07710fcd96aef175e067f02778f
This commit is contained in:
zhou.xu 2025-05-21 15:22:11 +08:00 committed by lane.wei
parent 0a0e76ec95
commit 852816f8d0
2 changed files with 18 additions and 3 deletions

View File

@ -42,7 +42,9 @@
#if ENABLE_RETINA_GL
#include "slic3r/Utils/RetinaHelper.hpp"
#endif
#ifdef __APPLE__
#include "libslic3r/MacUtils.hpp"
#endif
#include <GL/glew.h>
#include <wx/glcanvas.h>
@ -2997,7 +2999,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
}
}
m_volumes.volumes = std::move(glvolumes_new);
bool enable_lod = GUI::wxGetApp().app_config->get_bool("enable_lod") && CpuMemory::cur_free_memory_less_than_specify_size_gb(LOD_FREE_MEMORY_SIZE);
bool enable_lod = GUI::wxGetApp().app_config->get_bool("enable_lod") ;
for (unsigned int obj_idx = 0; obj_idx < (unsigned int)m_model->objects.size(); ++ obj_idx) {
const ModelObject &model_object = *m_model->objects[obj_idx];
for (int volume_idx = 0; volume_idx < (int)model_object.volumes.size(); ++ volume_idx) {
@ -3018,6 +3020,14 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
// Note the index of the loaded volume, so that we can reload the main model GLVolume with the hollowed mesh
// later in this function.
it->volume_idx = m_volumes.volumes.size();
if (enable_lod && CpuMemory::cur_free_memory_less_than_specify_size_gb(LOD_FREE_MEMORY_SIZE)) {
enable_lod = false;
}
#ifdef __APPLE__
if (Slic3r::is_mac_version_15()) {
enable_lod = false;
}
#endif
m_volumes.load_object_volume(&model_object, obj_idx, volume_idx, instance_idx, m_color_by, m_initialized, m_canvas_type == ECanvasType::CanvasAssembleView, false, enable_lod);
m_volumes.volumes.back()->geometry_id = key.geometry_id;
update_object_list = true;

View File

@ -63,11 +63,16 @@ bool CpuMemory::cur_free_memory_less_than_specify_size_gb(int size)
unsigned long long free_mem = get_free_memory();
auto cur_size = free_mem / (1024.0 * 1024.0 * 1024.0);
static bool first_debug_free_memory = true;
static bool first_meet_size_gb = true;
if (first_debug_free_memory) {
first_debug_free_memory = false;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " cur_size = " << cur_size << "GB";
}
if (cur_size > size) {
if (cur_size < size) {
if (first_meet_size_gb) {
first_meet_size_gb = false;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " cur_size = " << cur_size << "GB" << "first_meet_size_gb ";
}
return true;
}
return false;