From 5d03193f29d6a84bc33bdf5fb552aee16605d8e1 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 19 Apr 2026 00:42:00 +0200 Subject: [PATCH] Fix compile error with old vulkan header: ifdef check vulkan video encoding --- TODO | 3 +++ src/capture/v4l2.c | 1 - src/codec_query/vulkan.c | 20 +++++++++++++++++++- src/shader.c | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index bc08d75..23981dd 100644 --- a/TODO +++ b/TODO @@ -413,3 +413,6 @@ Allow av1 in the flatpak. Do that by patching ffmpeg to support multiple nvenc c Increase qp on av1 non-nvidia, decrease qp on h264 nvidia. For vulkan. Check if the vulkan codec query works on nvidia x11. + +Fix webcam capture on nvidia x11. It doesn't work when capturing a webcam at the same time as capturing the monitor (nvfbc) because nvfbc requires glx context active (in older nvfbc version, works with egl in newer version) + while v4l2 requires egl. All other capture methods require egl so they cant be used together with nvfbc. \ No newline at end of file diff --git a/src/capture/v4l2.c b/src/capture/v4l2.c index 79c3c08..cd72293 100644 --- a/src/capture/v4l2.c +++ b/src/capture/v4l2.c @@ -466,7 +466,6 @@ static bool gsr_capture_v4l2_map_buffer(gsr_capture_v4l2 *self, const struct v4l if(!self->dma_image[i]) { self->yuyv_conversion_fallback = true; - // This doesn't work for everybody on nvidia. On pop os 24.04 when egl_display is NULL (when capturing monitor on x11) then this fails with EGL_BAD_DISPLAY self->dma_image[i] = self->params.egl->eglCreateImage(self->params.egl->egl_display, 0, EGL_LINUX_DMA_BUF_EXT, NULL, (intptr_t[]) { EGL_WIDTH, fmt->fmt.pix.width, EGL_HEIGHT, fmt->fmt.pix.height, diff --git a/src/codec_query/vulkan.c b/src/codec_query/vulkan.c index 6ab484f..7dcb44e 100644 --- a/src/codec_query/vulkan.c +++ b/src/codec_query/vulkan.c @@ -24,6 +24,7 @@ static const char *required_device_extensions[] = { static int num_required_device_extensions = 8; static void set_h264_max_resolution(PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR vkGetPhysicalDeviceVideoCapabilitiesKHR, VkPhysicalDevice physical_device, gsr_supported_video_codecs *video_codecs) { +#ifdef VK_KHR_video_encode_h264 const VkVideoEncodeH264ProfileInfoKHR h264_profile = { .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_PROFILE_INFO_KHR, .pNext = NULL, @@ -53,9 +54,15 @@ static void set_h264_max_resolution(PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR video_codecs->h264.max_resolution.x = video_caps.maxCodedExtent.width; video_codecs->h264.max_resolution.y = video_caps.maxCodedExtent.height; } +#else + (void)vkGetPhysicalDeviceVideoCapabilitiesKHR; + (void)physical_device; + (void)video_codecs; +#endif } static void set_hevc_max_resolution(PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR vkGetPhysicalDeviceVideoCapabilitiesKHR, VkPhysicalDevice physical_device, gsr_supported_video_codecs *video_codecs) { +#ifdef VK_KHR_video_encode_h265 const VkVideoEncodeH265ProfileInfoKHR hevc_profile = { .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_PROFILE_INFO_KHR, .pNext = NULL, @@ -91,9 +98,15 @@ static void set_hevc_max_resolution(PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR video_codecs->hevc_10bit.max_resolution.x = video_caps.maxCodedExtent.width; video_codecs->hevc_10bit.max_resolution.y = video_caps.maxCodedExtent.height; } +#else + (void)vkGetPhysicalDeviceVideoCapabilitiesKHR; + (void)physical_device; + (void)video_codecs; +#endif } static void set_av1_max_resolution(PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR vkGetPhysicalDeviceVideoCapabilitiesKHR, VkPhysicalDevice physical_device, gsr_supported_video_codecs *video_codecs) { +#ifdef VK_KHR_video_encode_av1 const VkVideoEncodeAV1ProfileInfoKHR av1_profile = { .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_AV1_PROFILE_INFO_KHR, .pNext = NULL, @@ -109,7 +122,7 @@ static void set_av1_max_resolution(PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR v .chromaBitDepth = VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR }; - VkVideoEncodeH265CapabilitiesKHR encode_caps = { + VkVideoEncodeAV1CapabilitiesKHR encode_caps = { .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_AV1_CAPABILITIES_KHR, .pNext = NULL }; @@ -129,6 +142,11 @@ static void set_av1_max_resolution(PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR v video_codecs->av1_10bit.max_resolution.x = video_caps.maxCodedExtent.width; video_codecs->av1_10bit.max_resolution.y = video_caps.maxCodedExtent.height; } +#else + (void)vkGetPhysicalDeviceVideoCapabilitiesKHR; + (void)physical_device; + (void)video_codecs; +#endif } bool gsr_get_supported_video_codecs_vulkan(gsr_supported_video_codecs *video_codecs, const char *card_path, int *device_index_ret, bool cleanup) { diff --git a/src/shader.c b/src/shader.c index d952d5d..f20ebb2 100644 --- a/src/shader.c +++ b/src/shader.c @@ -91,6 +91,7 @@ static unsigned int load_program(gsr_egl *egl, const char *vertex_shader, const if(!success) { if(program_id) egl->glDeleteProgram(program_id); + program_id = 0; } if(fragment_shader_id) egl->glDeleteShader(fragment_shader_id);