Skip to content

fix(gpu): run on rutabaga's 2D component when virgl is off - #117

Open
ya-luotao wants to merge 1 commit into
superradcompany:krunfrom
ya-luotao:gpu-2d-only-mode
Open

fix(gpu): run on rutabaga's 2D component when virgl is off#117
ya-luotao wants to merge 1 commit into
superradcompany:krunfrom
ya-luotao:gpu-2d-only-mode

Conversation

@ya-luotao

Copy link
Copy Markdown

Problem

The virtio-gpu device always builds a VirglRenderer rutabaga component, whatever the flags. With VIRGL_RENDERER_NO_VIRGL and no VENUS — i.e. a host with no 3D renderer at all, which is what a headless macOS build gets — virglrenderer has no vrend state and rejects every non-blob resource. From the guest's side, after a KMS modeset:

[drm:virtio_gpu_dequeue_ctrl_func] *ERROR* response 0x1200 (command 0x101)   RESOURCE_CREATE_2D
[drm:virtio_gpu_dequeue_ctrl_func] *ERROR* response 0x1200 (command 0x106)   ATTACH_BACKING
[drm:virtio_gpu_dequeue_ctrl_func] *ERROR* response 0x1202 (command 0x103)   SET_SCANOUT
[drm:virtio_gpu_dequeue_ctrl_func] *ERROR* response 0x1200 (command 0x105)   TRANSFER_TO_HOST_2D
[drm:virtio_gpu_dequeue_ctrl_func] *ERROR* response 0x1203 (command 0x104)   RESOURCE_FLUSH

so a scanout never reaches the krun_display backend, and the device advertises +virgl with 5 capsets that cannot work, which also makes guest mesa try the virgl driver.

Change

  • is_2d_only(virgl_flags) = NO_VIRGL set and VENUS clear. In that mode create_rutabaga (and the fallback) build RutabagaComponentType::Rutabaga2D with no channels or export table; the device advertises only VERSION_1 | EDID and reports num_capsets = 0. Venus/virgl configurations are untouched (this is complementary to virtio-gpu venus: fix blob mapping on macOS/HVF and Linux/KVM #91, which fixes the Venus blob path).
  • flush_resource read the whole resource with resource.width * 4 as the stride into a frame buffer sized by the SET_SCANOUT rectangle. When the two differ (Hyprland's GBM dumb buffers), rutabaga's transfer_2d returns InvalidIovec and the unwrap() took the gpu worker thread down. VirtioGpuScanout now records the rectangle, read_2d_resource copies the intersection with the destination stride, and a failed read-back answers ErrUnspec instead of panicking.

Verification

macOS/HVF, Arch Linux ARM guest, libkrunfw 6.12: modetest -M virtio_gpu -s 37@36:1920x1080 completes with zero errors in dmesg (ten before); the guest logs features: -virgl +edid -resource_blob …; Hyprland 0.56 on llvmpipe delivers 1920x1080 BGRX frames to a krun_display backend, and they render as a native window in https://github.com/ya-luotao/msb-omarchy. cargo check -p msb_krun_devices --features gpu,input passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01A2DMienRTQjgR5CF3uQ2AZ

With VIRGL_RENDERER_NO_VIRGL and no VENUS the host has no 3D renderer
at all (macOS without a display server, for instance), yet the device
always built a VirglRenderer component. virglrenderer then rejects every
non-blob resource (RESOURCE_CREATE_2D, ATTACH_BACKING,
TRANSFER_TO_HOST_2D, SET_SCANOUT, FLUSH all fail), so a guest with a
KMS scanout never gets a frame to the host. In that mode build a
Rutabaga2D component, advertise only VERSION_1 | EDID, and report zero
capsets so the guest does not probe virgl either.

flush_resource also read the whole resource with the resource stride
into a frame buffer sized by the SET_SCANOUT rectangle; when the two
differ (Hyprland's dumb buffers), transfer_2d fails and the unwrap
took the gpu worker thread down. Record the scanout rectangle, copy
only the intersection with the destination stride, and answer
ErrUnspec instead of panicking.
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.

1 participant