russelltg / wl-screenrec

High performance wlroots screen recording, featuring hardware encoding
Apache License 2.0
266 stars 10 forks source link

Fail to record on AMD GPU #60

Closed herrwusel closed 4 months ago

herrwusel commented 4 months ago

I switched to an AMD laptop and wl-screenrec stopped working for me:

RUST_BACKTRACE=full wl-screenrec -g "$(slurp -d)" --low-power off
Using output DP-2
Opening libva device from DRM device /dev/dri/renderD128
[h264_vaapi @ 0x643f87ae4680] Driver does not support some wanted packed headers (wanted 0xd, found 0x1).
Protocol error 6 on object zwp_linux_buffer_params_v1@14: invalid buffer stride or height for plane 0
thread 'main' panicked at src/main.rs:1703:45:
called `Result::unwrap()` on an `Err` value: Backend(Protocol(ProtocolError { code: 6, object_id: 14, object_interface: "zwp_linux_buffer_params_v1", message: "invalid buffer stride or height for plane 0" }))
stack backtrace:
   0:     0x643f870971fe - <unknown>
   1:     0x643f8705e8c0 - <unknown>
   2:     0x643f870953c3 - <unknown>
   3:     0x643f87096fa4 - <unknown>
   4:     0x643f87098680 - <unknown>
   5:     0x643f87098395 - <unknown>
   6:     0x643f87098b8e - <unknown>
   7:     0x643f87098a8e - <unknown>
   8:     0x643f870976c6 - <unknown>
   9:     0x643f87098812 - <unknown>
  10:     0x643f87001855 - <unknown>
  11:     0x643f87001cf3 - <unknown>
  12:     0x643f870dff7c - <unknown>
  13:     0x643f87109ab3 - <unknown>
  14:     0x643f87116a39 - <unknown>
  15:     0x643f87090a45 - <unknown>
  16:     0x643f87116a2e - <unknown>
  17:     0x7818a4643cd0 - <unknown>
  18:     0x7818a4643d8a - __libc_start_main
  19:     0x643f87006e45 - <unknown>
  20:                0x0 - <unknown>

Here is my system:

CPU:
  Info: 8-core model: AMD Ryzen 7 7840U w/ Radeon 780M Graphics bits: 64
    type: MT MCP arch: Zen 4 rev: 1 cache: L1: 512 KiB L2: 8 MiB L3: 16 MiB
  Speed (MHz): avg: 1277 high: 2311
    min/max: 400/5289:5132:5447:6076:5605:5760:5918 cores: 1: 1397 2: 400
    3: 1397 4: 1822 5: 1397 6: 1891 7: 1397 8: 1396 9: 1397 10: 400 11: 1397
    12: 400 13: 1645 14: 400 15: 2311 16: 1395 bogomips: 105434
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
Graphics:
  Device-1: AMD Phoenix1 vendor: Framework driver: amdgpu v: kernel
    arch: RDNA-3 bus-ID: c1:00.0 temp: 48.0 C
  Device-2: Realtek Laptop Camera driver: uvcvideo type: USB bus-ID: 3-1:2
  Display: wayland server: Xwayland v: 23.2.4 compositor: Hyprland driver:
    gpu: amdgpu resolution: 1: 3840x2160~60Hz 2: 2256x1504~60Hz
  API: OpenGL v: 4.6 compat-v: 4.5 vendor: amd mesa v: 23.3.5-arch1.1
    glx-v: 1.4 direct-render: yes renderer: AMD Radeon Graphics (radeonsi
    gfx1103_r1 LLVM 16.0.6 DRM 3.57 6.7.4-arch1-1)
russelltg commented 4 months ago

Are you comfortable with building Hyprland? The error is a bit unhelpful as is. If you could apply this patch to wlroots and try again....

diff --git a/types/wlr_linux_dmabuf_v1.c b/types/wlr_linux_dmabuf_v1.c
index 9560ace30..4b257a7b6 100644
--- a/types/wlr_linux_dmabuf_v1.c
+++ b/types/wlr_linux_dmabuf_v1.c
@@ -338,7 +338,8 @@ static void params_create_common(struct wl_resource *params_resource,
                                attribs.stride[i] * height > size) {
                        wl_resource_post_error(params_resource,
                                ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS,
-                               "invalid buffer stride or height for plane %d", i);
+                               "invalid buffer stride or height for plane %d: offset=%u stride=%u height=%d size=%zd. format=0x%08x", 
+                               i, attribs.offset[i], attribs.stride[i], height, size, format);
                        goto err_out;
                }
        }
herrwusel commented 4 months ago

Sure:

RUST_BACKTRACE=full wl-screenrec -g "$(slurp -d)" --low-power off
Using output DP-2
Opening libva device from DRM device /dev/dri/renderD128
[h264_vaapi @ 0x606d136878c0] Driver does not support some wanted packed headers (wanted 0xd, found 0x1).
Protocol error 6 on object zwp_linux_buffer_params_v1@14: invalid buffer stride or height for plane 0: offset=0 stride=15360 height=2164 size=33177600. format=0x34325258
thread 'main' panicked at src/main.rs:1703:45:
called `Result::unwrap()` on an `Err` value: Backend(Protocol(ProtocolError { code: 6, object_id: 14, object_interface: "zwp_linux_buffer_params_v1", message: "invalid buffer stride or height for plane 0: offset=0 stride=15360 height=2164 size=33177600. format=0x34325258" }))
stack backtrace:
   0:     0x606d128281fe - <unknown>
   1:     0x606d127ef8c0 - <unknown>
   2:     0x606d128263c3 - <unknown>
   3:     0x606d12827fa4 - <unknown>
   4:     0x606d12829680 - <unknown>
   5:     0x606d12829395 - <unknown>
   6:     0x606d12829b8e - <unknown>
   7:     0x606d12829a8e - <unknown>
   8:     0x606d128286c6 - <unknown>
   9:     0x606d12829812 - <unknown>
  10:     0x606d12792855 - <unknown>
  11:     0x606d12792cf3 - <unknown>
  12:     0x606d12870f7c - <unknown>
  13:     0x606d1289aab3 - <unknown>
  14:     0x606d128a7a39 - <unknown>
  15:     0x606d12821a45 - <unknown>
  16:     0x606d128a7a2e - <unknown>
  17:     0x78c81a443cd0 - <unknown>
  18:     0x78c81a443d8a - __libc_start_main
  19:     0x606d12797e45 - <unknown>
  20:                0x0 - <unknown>
russelltg commented 4 months ago

Could you test the rgb_size_from_compositor branch?

herrwusel commented 4 months ago

It is recording now. One issue: When using slurp, wl-screenrec only records my top-left corner. The size from the slurp selection is applied, but not the position.

I greatly appreciate your help!

russelltg commented 4 months ago

That issue is #47