qt: gate EglDmabufTarget references on the Vulkan variant

Pass 1 made src/opengl/EglDmabufTarget.cpp opengl-variant-only in
qt/CMakeLists.txt, but GhosttySurface kept referencing
opengl::EglDmabufTarget unconditionally — the Vulkan link failed
with undefined references to ::create and ::~EglDmabufTarget.

Wrap the field declaration, the include, and every call site that
touches m_eglTarget with #ifndef GHASTTY_USE_VULKAN. The runtime
m_useVulkan branches above each block already make these paths
dead on Vulkan builds; preprocessing them out additionally drops
the link reference, which matches the libEGL gating in the cmake
file (Vulkan binary stays free of libEGL).

Co-Authored-By: claude-flow <ruv@ruv.net>
pull/12846/head
Nathan 2026-05-25 19:34:37 -05:00
parent 1a24a88394
commit 04afc177fa
2 changed files with 27 additions and 2 deletions

View File

@ -10,8 +10,9 @@
#include "Util.h"
#ifdef GHASTTY_USE_VULKAN
#include "vulkan/Host.h"
#endif
#else
#include "opengl/EglDmabufTarget.h"
#endif
#include "wayland/DmabufRegistry.h"
#include "wayland/SubsurfacePresenter.h"
@ -324,6 +325,11 @@ void GhosttySurface::syncSurfaceSize() {
return;
}
#ifndef GHASTTY_USE_VULKAN
// OpenGL path. Vulkan-variant builds always take the `m_useVulkan`
// branch above and never reach here; the entire block is excluded
// at preprocessor time so the Vulkan binary doesn't pull in
// EglDmabufTarget (and transitively libEGL).
if (!makeCurrent()) return;
m_eglTarget.reset();
delete m_fbo;
@ -362,6 +368,7 @@ void GhosttySurface::syncSurfaceSize() {
ghostty_surface_set_size(m_surface, static_cast<uint32_t>(w),
static_cast<uint32_t>(h));
renderTerminal();
#endif
}
void GhosttySurface::moveEvent(QMoveEvent *) {
@ -432,11 +439,14 @@ bool GhosttySurface::event(QEvent *e) {
// re-creates the QPA window (QSplitter reparent, fullscreen
// toggle, screen change). Make the owning context current
// before tearing down. Vulkan-variant builds have no
// `m_context` and skip the makeCurrent.
// `m_context` or `m_eglTarget` and the whole block is
// preprocessed out below.
#ifndef GHASTTY_USE_VULKAN
if (m_eglTarget) {
if (m_context) makeCurrent();
m_eglTarget.reset();
}
#endif
m_subsurfacePresenter.reset();
}
// SurfaceCreated is handled implicitly: the next QEvent::Show
@ -593,6 +603,10 @@ void GhosttySurface::renderTerminal() {
return;
}
#ifndef GHASTTY_USE_VULKAN
// OpenGL path. Vulkan-variant builds always take the early
// `m_useVulkan` return above; preprocessing the block out keeps
// the Vulkan binary free of EglDmabufTarget (and libEGL).
if (!makeCurrent()) return;
if (!m_eglTarget && !m_fbo) return;
@ -658,6 +672,7 @@ void GhosttySurface::renderTerminal() {
m_fbo->release();
update();
#endif
}
void GhosttySurface::paintEvent(QPaintEvent *) {

View File

@ -18,9 +18,11 @@
namespace wayland {
class SubsurfacePresenter;
}
#ifndef GHASTTY_USE_VULKAN
namespace opengl {
class EglDmabufTarget;
}
#endif
class MainWindow;
class QContextMenuEvent;
@ -286,6 +288,7 @@ private:
QOpenGLContext *m_context = nullptr;
QOffscreenSurface *m_offscreen = nullptr;
QOpenGLFramebufferObject *m_fbo = nullptr;
#ifndef GHASTTY_USE_VULKAN
// Dmabuf-exporting GL target (zero-copy path). Set when the EGL
// display advertises EGL_MESA_image_dma_buf_export and the
// wl_subsurface presenter is up; the renderer draws into this
@ -293,7 +296,14 @@ private:
// subsurface — no glReadPixels, no QImage, no QPainter blit.
// Stays null when EGL support is missing or the subsurface failed
// to bring up, and the legacy m_fbo path runs as fallback.
//
// Vulkan-variant builds export dmabufs directly from
// VkDeviceMemory via VK_KHR_external_memory_fd and never touch
// EGL, so the field (and the entire EglDmabufTarget translation
// unit) is excluded from those binaries — matching the libEGL
// gating in qt/CMakeLists.txt.
std::unique_ptr<opengl::EglDmabufTarget> m_eglTarget;
#endif
QImage m_image; // last frame, read back from m_fbo
// True when this surface is using the Vulkan platform. The