mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 03:43:52 +00:00
Compare commits
2 Commits
nightly-bu
...
fix/linux-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5a1f708b2 | ||
|
|
d2c24fdabb |
@@ -1206,14 +1206,51 @@ int CLI::run(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// WebKit2GTK compositing can fail under XWayland. Only disable it when
|
// Orca: WebKit2GTK has two distinct workarounds, depending on display server and GPU:
|
||||||
// both DISPLAY and WAYLAND_DISPLAY are set (i.e., XWayland is in use).
|
// - XWayland (any GPU): WebKit's compositing mode fails silently, leaving
|
||||||
// On pure X11 or native Wayland, compositing is left enabled.
|
// WebViews blank. Fix: WEBKIT_DISABLE_COMPOSITING_MODE=1.
|
||||||
|
// - Native Wayland + NVIDIA proprietary driver: WebKit's DMABUF renderer
|
||||||
|
// is broken (WebKit bug 262607, RESOLVED WONTFIX). Fix: WEBKIT_DISABLE_DMABUF_RENDERER=1.
|
||||||
|
// - Native Wayland + AMD/Intel: leave WebKit defaults; hardware accel works fine.
|
||||||
|
// We detect GPU vendor via the PCI vendor ID exposed in /sys/class/drm.
|
||||||
|
// setenv() uses replace=false so user-set values win.
|
||||||
{
|
{
|
||||||
const char* display_env_wk = ::getenv("DISPLAY");
|
const char* wayland_env = ::getenv("WAYLAND_DISPLAY");
|
||||||
const char* wayland_env_wk = ::getenv("WAYLAND_DISPLAY");
|
const char* gdk_backend = ::getenv("GDK_BACKEND");
|
||||||
if (display_env_wk && *display_env_wk && wayland_env_wk && *wayland_env_wk) {
|
const bool has_wayland = wayland_env && *wayland_env;
|
||||||
|
// GTK uses X11 when GDK_BACKEND forces it, or when WAYLAND_DISPLAY is unset.
|
||||||
|
// Otherwise it prefers native Wayland (this matches the wxHAS_EGL fallback
|
||||||
|
// above, which sets GDK_BACKEND=x11 explicitly when EGL is unavailable).
|
||||||
|
const bool gdk_forces_x11 = gdk_backend && boost::starts_with(gdk_backend, "x11");
|
||||||
|
const bool xwayland = gdk_forces_x11 && has_wayland;
|
||||||
|
const bool native_wayland = !gdk_forces_x11 && has_wayland;
|
||||||
|
|
||||||
|
auto has_nvidia_gpu = []() -> bool {
|
||||||
|
#ifdef __linux__
|
||||||
|
namespace fs = boost::filesystem;
|
||||||
|
try {
|
||||||
|
for (const auto& entry : fs::directory_iterator("/sys/class/drm")) {
|
||||||
|
const std::string name = entry.path().filename().string();
|
||||||
|
// Match the card itself (e.g. "card0"), not connector subdirs ("card0-DP-1").
|
||||||
|
if (!boost::starts_with(name, "card") || name.find('-') != std::string::npos)
|
||||||
|
continue;
|
||||||
|
boost::nowide::ifstream f((entry.path() / "device" / "vendor").string());
|
||||||
|
std::string vendor_id;
|
||||||
|
// 0x10de = NVIDIA. (0x1002 = AMD, 0x8086 = Intel.)
|
||||||
|
if (std::getline(f, vendor_id) && vendor_id == "0x10de")
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (...) {}
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (xwayland) {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "XWayland detected; disabling WebKit compositing mode.";
|
||||||
::setenv("WEBKIT_DISABLE_COMPOSITING_MODE", "1", /* replace */ false);
|
::setenv("WEBKIT_DISABLE_COMPOSITING_MODE", "1", /* replace */ false);
|
||||||
|
} else if (native_wayland && has_nvidia_gpu()) {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Native Wayland with NVIDIA GPU detected; disabling WebKit DMABUF renderer.";
|
||||||
|
::setenv("WEBKIT_DISABLE_DMABUF_RENDERER", "1", /* replace */ false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -787,9 +787,20 @@ void GUI_App::post_init()
|
|||||||
mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||||
plater_->select_view_3D("3D");
|
plater_->select_view_3D("3D");
|
||||||
//BBS init the opengl resource here
|
//BBS init the opengl resource here
|
||||||
//#ifdef __linux__
|
if (!plater_->canvas3D()->get_wxglcanvas()->IsShownOnScreen() ||
|
||||||
if (plater_->canvas3D()->get_wxglcanvas()->IsShownOnScreen()&&plater_->canvas3D()->make_current_for_postinit()) {
|
!plater_->canvas3D()->make_current_for_postinit()) {
|
||||||
//#endif
|
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": glcontext not ready, postpone init";
|
||||||
|
plater_->canvas3D()->enable_render(true);
|
||||||
|
plater_->canvas3D()->set_as_dirty();
|
||||||
|
#ifdef __linux__
|
||||||
|
// Wayland/EGL may not have committed the GL surface yet; ask the
|
||||||
|
// idle loop to retry post_init when the canvas is actually mapped.
|
||||||
|
// Without this, GL function pointers stay null and the first
|
||||||
|
// Preview focus crashes in Camera::apply_viewport.
|
||||||
|
m_post_initialized = false;
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
Size canvas_size = plater_->canvas3D()->get_canvas_size();
|
Size canvas_size = plater_->canvas3D()->get_canvas_size();
|
||||||
wxGetApp().imgui()->set_display_size(static_cast<float>(canvas_size.get_width()), static_cast<float>(canvas_size.get_height()));
|
wxGetApp().imgui()->set_display_size(static_cast<float>(canvas_size.get_width()), static_cast<float>(canvas_size.get_height()));
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", start to init opengl";
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", start to init opengl";
|
||||||
@@ -809,14 +820,7 @@ void GUI_App::post_init()
|
|||||||
plater_->canvas3D()->render(false);
|
plater_->canvas3D()->render(false);
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished rendering a first frame for test";
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished rendering a first frame for test";
|
||||||
}
|
}
|
||||||
//#ifdef __linux__
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << "Found glcontext not ready, postpone the init";
|
|
||||||
plater_->canvas3D()->enable_render(true);
|
|
||||||
plater_->canvas3D()->set_as_dirty();
|
|
||||||
}
|
|
||||||
//#endif
|
|
||||||
if (is_editor())
|
if (is_editor())
|
||||||
mainframe->select_tab(size_t(0));
|
mainframe->select_tab(size_t(0));
|
||||||
if (app_config->get("default_page") == "1")
|
if (app_config->get("default_page") == "1")
|
||||||
|
|||||||
Reference in New Issue
Block a user