Skip to content

Conversation

@tarek-y-ismail
Copy link
Contributor

@tarek-y-ismail tarek-y-ismail commented Jan 16, 2026

Closes #4035

What's new?

  • Adds a fallback path in gbm_bo_with_modifiers_or_linear to account for nvidia non-compliance
  • Adds a codepath in DMABufEGLProvider to copy buffers via the CPU
  • Adds a quirk to detect to determine which codepath to use for buffer transfers, and passes that down to DMABufEGLProvider
  • Any transfer involving nvidia goes through the GPU for now until we get to the bottom of the bug.

How to test

On a machine with an intel iGPU and an nvidia dGPU, with one output connected to each:

  1. Launch mir as follows:
miral-app --platform-display-libs=mir:atomic-kms --platform-rendering-libs=mir:gbm-kms --display-config=sidebyside --driver-quirks=gbm-buffer-transfer-strategy:nvidia:nvidia:dma
  1. Launch one of firefox, ghostty, gtk4-demo as follows
__EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/50_mesa.json  DRI_PRIME=1 <command>
  1. Drag the window onto the screen connected to the nvidia card
  2. If the app still renders correctly, resize the width it using the mouse
  3. Observe as the window warps in a sawtooth pattern as you change the width
  4. Repeat steps 1-4, but remove the last flag or change it to --driver-quirks=gbm-buffer-transfer-strategy:nvidia:nvidia:cpu
  5. Observe as the window renders correctly.

Checklist

  • Adequate documentation added (How should we document this?)

@tarek-y-ismail tarek-y-ismail self-assigned this Jan 16, 2026
Co-authored-by: Christopher James Halse Rogers <chris@cooperteam.net>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a workaround for rendering issues on NVIDIA GPUs when using Atomic KMS with GBM KMS. The primary issue was a "warping sawtooth pattern" that occurred when resizing windows on NVIDIA-connected displays in a hybrid GPU setup.

Changes:

  • Added a BufferTransferStrategy enum to support CPU-based buffer transfers as an alternative to DMA transfers
  • Modified buffer allocation to handle NVIDIA's non-compliant GBM behavior when allocating with modifiers
  • Added a driver quirk detection system to automatically apply the CPU transfer strategy for NVIDIA GPUs

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/platforms/renderer-generic-egl/rendering_platform.cpp Added default CPU buffer transfer strategy for generic EGL renderer
src/platforms/renderer-generic-egl/buffer_allocator.cpp Updated texture allocation to pass full Buffer instead of NativeBufferBase
src/platforms/gbm-kms/server/kms/quirks.h Added BufferTransferStrategy enum and quirk tracking
src/platforms/gbm-kms/server/kms/quirks.cpp Implemented quirk parsing and application for NVIDIA buffer transfer strategy
src/platforms/gbm-kms/server/kms/platform.cpp Added fallback allocation paths and integrated quirks into buffer provider creation
src/platforms/gbm-kms/server/buffer_allocator.cpp Updated texture allocation to pass full Buffer instead of NativeBufferBase
src/platform/graphics/linux_dmabuf.cpp Implemented CPU transfer path, refactored DMA transfer logic, and added strategy selection
include/platform/mir/graphics/linux_dmabuf.h Added BufferTransferStrategy enum and updated DMABufEGLProvider interface

@tarek-y-ismail tarek-y-ismail force-pushed the MIRENG-1289/fix-warping-on-nvidia-atomic-kms branch from fa2ee7d to ee9a17e Compare January 16, 2026 16:10
@Saviq
Copy link
Contributor

Saviq commented Jan 16, 2026

How should we document this?

These seem appropriate?

Copy link
Contributor

@RAOF RAOF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quirk is pragmatic, but it would ideally take into account both GPUs - as far as I can tell, this bug only manifests when importing from Intel to NVIDIA (it imports fine from AMD to NVIDIA on my system).

@tarek-y-ismail
Copy link
Contributor Author

tarek-y-ismail commented Jan 19, 2026

The more I work on this problem, the weirder it gets:

  • Apparently the warping occurs when we import from nvidia to nvidia for some reason.
    Forcing that to use the CPU path via --driver-quirks=gbm-buffer-transfer-strategy:nvidia-drm:nvidia-drm:cpu fixes the warping. That points to the following code path:
    if (dmabuf_tex->on_same_egl_display(dpy))
    {
    auto tex = dmabuf_tex->as_texture();
    return std::shared_ptr<gl::Texture>(std::move(dmabuf_tex), tex);
    }
  • Logs show the source and importing sides are flipped. Isn't the buffer provider the source?
    Rendering a firefox window on the iGPU, and dragging it to the iGPU's output causes transfers from the dGPU to the iGPU??
  • Rendering a firefox window on the dGPU and dragging it from the dGPU output to the iGPU output causes the iGPU output to stop displaying frames altogether, even if firefox is shutdown and relaunched on the iGPU
    The splash screen seems to trigger this as well. This might be related to the next point too.
  • Still have freezes during shutdown. Dunno from where exactly but last time I checked it was the iGPU rendering thread getting stuck in eglSwap. Won't snoop after it right now until the main bug is fixed

EDIT: Attaching a log. Opened qterminal, then firefox rendering on the iGPU and displaying on the dGPU. Then dragged the window to the iGPU's output and back. Closed firefox. Relaunched it without specifying GPUs (which usually renders on the dGPU). Repeated the roundtrip to the iGPU output and back. Shut down.

20260119_141900-mir-atomic-kms-hybrid-log.txt

@tarek-y-ismail tarek-y-ismail force-pushed the MIRENG-1289/fix-warping-on-nvidia-atomic-kms branch from 410365a to 8372373 Compare January 19, 2026 15:12
@tarek-y-ismail
Copy link
Contributor Author

tarek-y-ismail commented Jan 20, 2026

Looks like DMA transfers from nvidia to intel in the case where firefox is rendering on nvidia and should display on intel cause the intel compositing thread to completely freeze somewhere in the mesa stack in dri_flush. Again, going through the CPU alleviates this.

Edit: Forgot to add, checking dmesg logs shows no errors being thrown, mesa debugging symbols don't help too. I think I might have to build from source to investigate this further. But I think I've spent enough time on this issue as is.

@tarek-y-ismail tarek-y-ismail requested a review from RAOF January 20, 2026 08:43
@tarek-y-ismail
Copy link
Contributor Author

tarek-y-ismail commented Jan 20, 2026

Well, this is awkward. I just tried running kgx rendering on the nvidia GPU and it still suffers from warping. Its colors are broken compared to KDE as well. Pluma and gedit work fine though.

@github-actions
Copy link

TICS Quality Gate

❌ Failed

mir

Coding Standards: ❌ 9 Blocking Issues

❌ Condition “No new Coding Standard Violations for level 1, 2, 3 with respect to Previous analysis” failed 2 times.
FileIssues
🪲 Total❌ Blocking

src/platform/graphics/linux_dmabuf.cpp

47+7

src/platforms/gbm-kms/server/kms/quirks.cpp

3+2

See the results in the TICS Viewer

The following files have been checked for this project
  • include/platform/mir/graphics/linux_dmabuf.h
  • include/platform/mir/graphics/quirk_common.h
  • src/platform/graphics/linux_dmabuf.cpp
  • src/platform/graphics/quirk_common.cpp
  • src/platforms/atomic-kms/server/kms/quirks.cpp
  • src/platforms/gbm-kms/server/buffer_allocator.cpp
  • src/platforms/gbm-kms/server/kms/platform.cpp
  • src/platforms/gbm-kms/server/kms/quirks.cpp
  • src/platforms/gbm-kms/server/kms/quirks.h
  • src/platforms/renderer-generic-egl/buffer_allocator.cpp
  • src/platforms/renderer-generic-egl/rendering_platform.cpp

TICS / TICS / Run TICS analysis

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.

Rendered applications are warped when rendered on one GPU and displayed on another (intel + nvidia)

4 participants