From c2f454103e1c039ba3d2c9348a486b581c3778d7 Mon Sep 17 00:00:00 2001 From: Gon Solo Date: Thu, 10 Nov 2022 09:50:08 +0100 Subject: [PATCH 1/2] Fix crash on Wayland. --- src/pbrt/gpu/cudagl.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pbrt/gpu/cudagl.h b/src/pbrt/gpu/cudagl.h index db6e055f..8fe1cd2b 100644 --- a/src/pbrt/gpu/cudagl.h +++ b/src/pbrt/gpu/cudagl.h @@ -352,9 +352,10 @@ CUDAOutputBuffer::CUDAOutputBuffer(int32_t width, int32_t height) CUDA_CHECK(cudaGetDevice(¤t_device)); CUDA_CHECK(cudaDeviceGetAttribute(&is_display_device, cudaDevAttrKernelExecTimeout, current_device)); - if (!is_display_device) - LOG_FATAL("GL interop is only available on display device."); - + if (getenv("XDG_SESSION_TYPE") != std::string("wayland")) { + if (!is_display_device) + LOG_FATAL("GL interop is only available on display device."); + } CUDA_CHECK(cudaGetDevice(&m_device_idx)); m_width = width; From 703026e31c836b2b8b80770f829c21e6fd3a42db Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 10 Nov 2022 05:58:54 -0800 Subject: [PATCH 2/2] Update cudagl.h Avoid segfault if XDG_SESSION_TYPE is unset --- src/pbrt/gpu/cudagl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pbrt/gpu/cudagl.h b/src/pbrt/gpu/cudagl.h index 8fe1cd2b..2695844f 100644 --- a/src/pbrt/gpu/cudagl.h +++ b/src/pbrt/gpu/cudagl.h @@ -352,7 +352,7 @@ CUDAOutputBuffer::CUDAOutputBuffer(int32_t width, int32_t height) CUDA_CHECK(cudaGetDevice(¤t_device)); CUDA_CHECK(cudaDeviceGetAttribute(&is_display_device, cudaDevAttrKernelExecTimeout, current_device)); - if (getenv("XDG_SESSION_TYPE") != std::string("wayland")) { + if (getenv("XDG_SESSION_TYPE") == nullptr || getenv("XDG_SESSION_TYPE") != std::string("wayland")) { if (!is_display_device) LOG_FATAL("GL interop is only available on display device."); }