Linux Direct Mode: Left-eye image duplicated on both eyes with Shiftall MeganeX 8K Mark II – Desktop mode works correctly

Hello,
I’m reporting a Direct Mode issue with the Shiftall MeganeX 8K Mark II on Linux + NVIDIA proprietary drivers.
Symptoms:

In Direct Mode the left-eye image is displayed simultaneously on both the left and right displays. Stereo is completely broken.
In Desktop / Extended mode the image is correct on both eyes.

This exact behaviour is also documented by sboys3 (maintainer of the community OpenVR driver for this headset) on his GitHub repository:

In the README he notes that the headsets currently do not work properly on Linux due to external issues, and specifically describes that the left image appears on both eyes in Direct Mode while Desktop mode works correctly.
Environment:

GPU: RTX 5090
Driver: Last
Distro: Ubuntu
Headset: Shiftall MeganeX 8K Mark II (DisplayPort + USB)

The fact that Desktop mode works while Direct Mode duplicates the left eye strongly suggests a problem in the driver’s stereo / multi-view handling under DRM lease.
Is this a known issue with certain micro-OLED HMDs?

I can provide an nvidia-bug-report.log if needed.
Thank you.

Same issue for Fedora Linux, would heavily appreciate expanding Linux VR Support.

But i got the Shiftall MeganeX 8K Mark I

I have tried direct mode in SteamVR, Monado, and an AI generated minimal test case. All of them have this problem when leasing the display from X11 using Vulkan. The fact that it works correctly when used as a monitor on the desktop makes me think there’s something specifically wrong with the Vulkan Direct Mode APIs in NVIDIA’s driver. This seems to be a universal problem across all Linux systems with the MeganeX.
Here is the Edid of the MeganeX if it helps: DisplayInfo/outputs-nv/meganex superlight 8k.txt at main · sboys3/DisplayInfo · GitHub

I have looked into the issue. It appears that the issue only happens on 40-series cards and lower, where to drive the headset a dual head configuration is required for DSC.

The issue is that the viewport offset for the second head is only set when the viewport is specified by the client. The standard desktop mode specifies a viewport, but the Vulkan direct path does not. The code that normally sets the offset can be found at: open-gpu-kernel-modules/src/nvidia-modeset/src/nvkms-hw-flip.c at 61dcc93722ecb418bb5f2e00923f05b4b8051dd1 · NVIDIA/open-gpu-kernel-modules · GitHub

Naively patching this code to remove the viewport in requirement resulted in “SLI raster lock timeout exceeded” outside of the Vulkan direct path, since this function is invoked multiple times for the display. To workaround this issue I made a patch to AssignProposedModeSetNVFlipEvoHwState, which is called once during modeset.

diff --git a/src/nvidia-modeset/src/nvkms-modeset.c b/src/nvidia-modeset/src/nvkms-modeset.c
index f51f97b..de21978 100644
--- a/src/nvidia-modeset/src/nvkms-modeset.c
+++ b/src/nvidia-modeset/src/nvkms-modeset.c
@@ -620,6 +620,25 @@ AssignProposedModeSetNVFlipEvoHwState(
         return FALSE;
     }
 
+    /*
+     * nvUpdateFlipEvoHwState() only applies the per-merge-head viewport
+     * offset when the client specifies a viewport. A client that does not --
+     * a VK_KHR_display swapchain, for instance -- would leave the secondary
+     * merge head of a 2Heads1OR configuration scanning out from x == 0, i.e.
+     * displaying the left half of the surface in the right half of the
+     * screen. Program the offset here, as part of the modeset, so that it is
+     * established exactly once; doing it per-flip instead disturbs the raster
+     * lock between the two merged heads.
+     */
+    if (!pRequestHead->flip.viewPortIn.specified &&
+            (pProposedHead->mergeHeadSection != 0)) {
+        pFlip->dirty.viewPortPointIn = TRUE;
+        pFlip->viewPortPointIn.x =
+            pProposedHead->timings.viewPort.in.width *
+            pProposedHead->mergeHeadSection;
+        pFlip->viewPortPointIn.y = 0;
+    }
+
     /*
      * EVO3 hal simulates USE_CORE_LUT behavior.
      * NVDisplay window channel does allow to change the input LUT

While that’s the patch I currently tested, another alternative could be to patch open-gpu-kernel-modules/src/nvidia-modeset/src/nvkms-evo.c at 61dcc93722ecb418bb5f2e00923f05b4b8051dd1 · NVIDIA/open-gpu-kernel-modules · GitHub to `EvoSetViewportPointIn(pDispEvo, head, pViewPort->in.width * pHeadState->mergeHeadSection, 0 /* y */, updateState);`, which might be simpler.

The simplified patch is as follows:

diff --git a/src/nvidia-modeset/src/nvkms-evo.c b/src/nvidia-modeset/src/nvkms-evo.c
index 600003f..0c3d12d 100644
--- a/src/nvidia-modeset/src/nvkms-evo.c
+++ b/src/nvidia-modeset/src/nvkms-evo.c
@@ -4516,16 +4516,18 @@ void nvSetViewPortsEvo(NVDispEvoPtr pDispEvo,
 
     /*
-     * Specify safe default values of 0 for viewPortPointIn x and y; these
-     * may be changed when panning out of band of a modeset.
+     * Specify default values for viewPortPointIn x and y; these may be
+     * changed when panning out of band of a modeset.
      */
-    EvoSetViewportPointIn(pDispEvo, head, 0 /* x */, 0 /* y */, updateState);
+    EvoSetViewportPointIn(pDispEvo, head,
+                          pViewPort->in.width * pHeadState->mergeHeadSection,
+                          0 /* y */, updateState);
 }
 
 
 
 static void EvoSetViewportPointIn(NVDispEvoPtr pDispEvo, const NvU32 head,
                                   NvU16 x, NvU16 y,
                                   NVEvoUpdateState *updateState)
 {
     NVDevEvoPtr pDevEvo = pDispEvo->pDevEvo;
 

@sboys3sev has tested it (driver version 595.104.02) and confirmed it to work on their hardware. Thanks for helping!

I think this version of the patch should be preferred.