Skip to content

Add NvFBC support on X11#4

Draft
CheesecakeCG wants to merge 4 commits intogalister:mainfrom
CheesecakeCG:nvfbc-support
Draft

Add NvFBC support on X11#4
CheesecakeCG wants to merge 4 commits intogalister:mainfrom
CheesecakeCG:nvfbc-support

Conversation

@CheesecakeCG
Copy link

@CheesecakeCG CheesecakeCG commented Mar 4, 2025

This adds Nvidia Framebuffer Capture support on X11 using this wrapper.

This PR still copies to the framebuffer to system memory, but it's still noticeably a lot faster than Xshm, but NvFBC does support copying into a OpenGL texture, but copying to system memory first seems fast enough in wlx-overlay-s.

The other issue is that this NvFBC wrapper package doesn't seem to support capturing from other monitors besides the first one, but I think I must be doing something wrong. I haven't tested this with multiple monitors.

The capture frame rate is also currently hardcoded and it should probably match the monitor refresh rate or the headset refresh rate, which ever is lower.

Meant to be used with wlx-team/wayvr#173

@galister
Copy link
Owner

galister commented Mar 9, 2025

Might want to check out what WayVR does; WayVR's Smithay library works with GLES/EGL, so the GL texture is exported via DMA-buf before it's finally imported as a VkImage.

@CheesecakeCG
Copy link
Author

Might want to check out what WayVR does; WayVR's Smithay library works with GLES/EGL, so the GL texture is exported via DMA-buf before it's finally imported as a VkImage.

Thanks, I'll look into this.

Also, I just tested with WayVR and wlx-overlay-s crashes when opening the dash if NvFBC is picked over Xshm or Pipewire. This issue seems related: timothee-haudebourg/khronos-egl#25

2025-03-10T01:38:56.255544Z  INFO wlx_overlay_s::backend::wayvr: Initializing WayVR
    at src/backend/wayvr/mod.rs:138

  2025-03-10T01:38:56.255766Z  INFO smithay::output: Creating new Output, name: "wayvr_display"
    at /home/chrisd/.cargo/registry/src/index.crates.io-6f17d22bba15001f/smithay-0.5.1/src/output.rs:259
    in smithay::output::new with name: "wayvr_display", physical: PhysicalProperties { size: Size<smithay::utils::geometry::Raw> { w: 1280, h: 720 }, subpixel: None, make: "Completely Legit", model: "Virtual WayVR Display" }

  2025-03-10T01:38:56.255800Z  INFO smithay::wayland::output: Creating new wl_output, output: "wayvr_display"
    at /home/chrisd/.cargo/registry/src/index.crates.io-6f17d22bba15001f/smithay-0.5.1/src/wayland/output/mod.rs:205

  2025-03-10T01:38:56.294956Z ERROR panic: thread 'main' panicked at 'called `Option::unwrap()` on a `None` value': /home/chrisd/.cargo/registry/src/index.crates.io-6f17d22bba15001f/khronos-egl-6.0.0/src/lib.rs:1095
   0: <backtrace::capture::Backtrace as core::default::Default>::default
   1: log_panics::Config::install_panic_hook::{{closure}}
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::begin_panic_handler::{{closure}}
   4: std::sys::backtrace::__rust_end_short_backtrace
   5: rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::panicking::panic
   8: core::option::unwrap_failed
   9: khronos_egl::egl1_0::<impl khronos_egl::Instance<T>>::make_current
  10: wlx_overlay_s::backend::wayvr::egl_data::EGLData::new
  11: wlx_overlay_s::backend::wayvr::WayVR::new
  12: wlx_overlay_s::state::AppState::get_wayvr
  13: wlx_overlay_s::overlays::wayvr::wayvr_action
  14: wlx_overlay_s::backend::openxr::openxr_run
  15: wlx_overlay_s::main
  16: std::sys::backtrace::__rust_begin_short_backtrace
  17: std::rt::lang_start::{{closure}}
  18: std::rt::lang_start_internal
  19: main
  20: <unknown>
  21: __libc_start_main
  22: _start

    at /home/chrisd/.cargo/registry/src/index.crates.io-6f17d22bba15001f/log-panics-2.1.0/src/lib.rs:130

  2025-03-10T01:38:56.301618Z  WARN wlx_capture::nvfbc: NvFBC Main Monitor: capture thread channel closed (recv)
    at /home/chrisd/.cargo/git/checkouts/wlx-capture-ed18ea0789d86c93/1f033b0/src/nvfbc.rs:79

  2025-03-10T01:38:56.301640Z  WARN wlx_capture::nvfbc: NvFBC capture thread stopped
    at /home/chrisd/.cargo/git/checkouts/wlx-capture-ed18ea0789d86c93/1f033b0/src/nvfbc.rs:84

  2025-03-10T01:38:56.474712Z  INFO wlx_overlay_s::backend::notifications: Notification listener stopped.
    at src/backend/notifications.rs:194

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants