Skip to content

vdev/wm: Allow DRM rendering#39

Draft
obiwac wants to merge 6 commits intomainfrom
bugfix/wm-drm-render
Draft

vdev/wm: Allow DRM rendering#39
obiwac wants to merge 6 commits intomainfrom
bugfix/wm-drm-render

Conversation

@obiwac
Copy link
Copy Markdown
Member

@obiwac obiwac commented Mar 3, 2026

Allow rendering to DRM. Previously, the swapchain buffers wouldn't be written to at all, and so they'd just flash between pure black and pure white as their default contents, at least on my machine (AMD 7040, amdgpu, FreeBSD).

Here are the other issues that need to be fixed before we can merge this:

  • Currently, we're hardcoding resolution to 1280x720.
  • We're breaking UI frost to be able to render to the swapchain buffer, as we can't use it as a copy texture destination as we were doing previously. See the description of 67bc87d.
  • We still haven't really gotten to the bottom of what's happening. We've just narrowed it down and have a horrible disgusting hack as a workaround atm.
  • Related to previous point, but we still have some crazy visual glitches, probably due to our pretty much non-existent approach to rigorous synchronization.

Here are the notes I had in #33 before opening this PR:

Flashing black and white when rendering directly to DRM (instead of in nested window)

Presumably, one of the swapchain buffers is purely white and the other is purely black, and we're flipping between these. Probably some sync error where we're not waiting for rendering to complete. To figure out where the problem is (bearing in mind I don't understand what I'm doing), I'm trying to disable stuff in the simple example until we get the same behaviour (in render_pass_submit(), where simple is doing its queue submission):

  • Checked vulkan_sync_render_buffer().
  • Checked pWaitSemaphoreInfos in VkSubmitInfo2KHR. (Would need an API for giving these to the Vulkan wgpu-hal for its submission.)
  • Checked pSignalSemaphoreInfos.

Here's a couple assumptions I need to verify:

  • Is it really the case that one of the swapchain buffers is pure black and the other white? Can I prove this by just displaying one or the other? Why could this be the case.

obiwac added 2 commits March 3, 2026 19:38
…e swapchain texture

Previously, we were copying the last of the temporary ping-pong
renderbuffers to the frame renderbuffer at the end of rendering. This
was probably firstly not great for performance, but also we can't do
this for images gotten from DRM because they can't use
`VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL`, and that is set when
`wgpu.TextureUsageCopyDst` is set on the WebGPU texture, which is
necessary for being able to use it as a texture copy destination.

Breaks if there are any frost element at the moment, because only the
initial render buffer knows to select between one of the temporary
ping-pong renderbuffers and the frame renderbuffer.
@obiwac obiwac added the vdev VDEV-related stuff label Mar 3, 2026
@obiwac obiwac mentioned this pull request Mar 3, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vdev VDEV-related stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant