CyberShadow / hax11

Hackbrary to Hook and Augment X11 protocol calls
MIT License
116 stars 9 forks source link

Add support for (something like) JoinTILE #12

Open rubin55 opened 9 months ago

rubin55 commented 9 months ago

The current version of hax11 supports JoinMST, which makes it possible to present a screen that presents itself as two or more xrandr screens using MST, as one.

Another way this is done is with the TILE property. A good example of this is the Dell UP3218k 8K monitor, which is attached using two DisplayPort 1.4 cables. This screen presents itself as two 3840x4320 screens, a left and a right, with TILE information, that lets modern drivers (Nvidia, AMDGPU) set up the display "as one". However, Xrandr, will still see two connectors. Example xrandr --query output:

Screen 0: minimum 8 x 8, current 11520 x 4320, maximum 32767 x 32767
HDMI-0 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
   3840x2160     60.00*+  59.94    50.00    29.97    25.00    23.98  
   2560x1440     59.95  
   1920x1080     60.00    59.94    50.00    29.97    25.00    23.98  
   1680x1050     59.95  
   1600x1200     60.00  
   1440x900      59.89  
   1400x1050     59.98  
   1280x1024     75.02    60.02  
   1280x960      60.00  
   1280x720      60.00    59.94    50.00  
   1024x768      75.03    70.07    60.00  
   800x600       75.00    72.19    60.32    56.25  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    72.81    59.94    59.93  
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 connected 3840x4320+3840+0 (normal left inverted right x axis y axis) 700mm x 390mm
   3840x2160     60.00 +  29.98  
   7680x4320     29.93    24.00  
   3840x4320     60.00*   48.00  
   2560x1440     59.95  
   2048x1080     59.99    23.90  
   1920x1200     59.88  
   1920x1080     60.00    59.94    50.00    23.98  
   1680x1050     59.95  
   1600x1200     60.00  
   1280x1024     75.02    60.02  
   1280x800      59.81  
   1280x720      59.94    50.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.94    59.93  
DP-3 disconnected (normal left inverted right x axis y axis)
DP-4 connected 3840x4320+7680+0 (normal left inverted right x axis y axis) 700mm x 390mm
   3840x2160     60.00 +  29.98  
   7680x4320     29.93    24.00  
   3840x4320     60.00*   48.00  
   2560x1440     59.95  
   2048x1080     59.99    23.90  
   1920x1200     59.88  
   1920x1080     60.00    59.94    50.00    23.98  
   1680x1050     59.95  
   1600x1200     60.00  
   1280x1024     75.02    60.02  
   1280x800      59.81  
   1280x720      59.94    50.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.94    59.93  
DP-5 disconnected (normal left inverted right x axis y axis)

In the Above, DP-2 and DP-4 are the connectors attached to the TILE'd display. Example xrandr --listactivemonitors output:

Monitors: 2
 0: +*HDMI-0 3840/344x2160/193+0+0  HDMI-0
 1: DELL UP3218K-495 7680/700x4320/390+3840+0  DP-2 DP-4

It would be great if a new feature, maybe called JoinTILE or a more generic Join could also handle these kind of monitors that instead of MST use TILE.

rubin55 commented 9 months ago

For completeness' sake, also output for xrandr --props here:

Screen 0: minimum 8 x 8, current 11520 x 4320, maximum 32767 x 32767
HDMI-0 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
    _MUTTER_PRESENTATION_OUTPUT: 0 
    CTM: 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 
        0 1 
    CscMatrix: 65536 0 0 0 0 65536 0 0 0 0 65536 0 
    EDID: 
        00ffffffffffff005a633f6601010101
        1c210103802213782a38d5ae513bb823
        0b5054bfef80d1c0b300a94095009040
        8180814081c050d000a0f0703e803020
        350058c11000001e000000ff00584241
        3233323830303730380a000000fd0028
        4b0fa03c000a202020202020000000fc
        005658313635352d4f4c45440a2001fc
        020349f153010304050710121314161f
        20212260615d5e5f23097f0783010000
        6d030c001000387820006001020367d8
        5dc401788003e305e301e40f00c007e6
        0607016d6d02e200d5565e00a0a0a029
        503020350058c11000001e023a801871
        382d40582c450058c11000001e000000
        0000000000000000000000000000006a
    BorderDimensions: 4 
        supported: 4
    Border: 0 0 0 0 
        range: (0, 65535)
    SignalFormat: TMDS 
        supported: TMDS
    ConnectorType: HDMI 
    ConnectorNumber: 3 
    _ConnectorLocation: 3 
    non-desktop: 0 
        supported: 0, 1
   3840x2160     60.00*+  59.94    50.00    29.97    25.00    23.98  
   2560x1440     59.95  
   1920x1080     60.00    59.94    50.00    29.97    25.00    23.98  
   1680x1050     59.95  
   1600x1200     60.00  
   1440x900      59.89  
   1400x1050     59.98  
   1280x1024     75.02    60.02  
   1280x960      60.00  
   1280x720      60.00    59.94    50.00  
   1024x768      75.03    70.07    60.00  
   800x600       75.00    72.19    60.32    56.25  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    72.81    59.94    59.93  
DP-0 disconnected (normal left inverted right x axis y axis)
    CTM: 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 
        0 1 
    CscMatrix: 65536 0 0 0 0 65536 0 0 0 0 65536 0 
    BorderDimensions: 4 
        supported: 4
    Border: 0 0 0 0 
        range: (0, 65535)
    SignalFormat: DisplayPort 
        supported: DisplayPort
    ConnectorType: DisplayPort 
    ConnectorNumber: 2 
    _ConnectorLocation: 2 
    non-desktop: 0 
        supported: 0, 1
DP-1 disconnected (normal left inverted right x axis y axis)
    CTM: 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 
        0 1 
    CscMatrix: 65536 0 0 0 0 65536 0 0 0 0 65536 0 
    BorderDimensions: 4 
        supported: 4
    Border: 0 0 0 0 
        range: (0, 65535)
    SignalFormat: TMDS 
        supported: TMDS
    ConnectorType: DisplayPort 
    ConnectorNumber: 2 
    _ConnectorLocation: 2 
    non-desktop: 0 
        supported: 0, 1
DP-2 connected 3840x4320+3840+0 (normal left inverted right x axis y axis) 700mm x 390mm
    _MUTTER_PRESENTATION_OUTPUT: 0 
    CTM: 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 
        0 1 
    CscMatrix: 65536 0 0 0 0 65536 0 0 0 0 65536 0 
    TILE: 495 1 2 1 0 0 3840 4320 
    EDID: 
        00ffffffffffff0010ac47414c393730
        01200104b54627783a7645ae5133ba26
        0d5054a54b008100b300d100a9408180
        d1c0010101014dd000a0f0703e803020
        3500ba892100001a000000ff0036324e
        57523231343037394c0a000000fc0044
        454c4c205550333231384b0a000000fd
        00184b1eb46c010a20202020202002b1
        02031df150101f200514041312110302
        161507060123091f0783010000a36600
        a0f0701f8030203500ba892100001a56
        5e00a0a0a0295030203500ba89210000
        1a7c3900a080381f4030203a00ba8921
        00001aa81600a08038134030203a00ba
        892100001a0000000000000000000000
        00000000000000000000000000000047
        701279000012001682100000ff0edf10
        000000000044454c47414c3937300301
        5070920184ff1dc7001d800900df102f
        0002000400c1420184ff1dc7002f801f
        00df10300002000400a84e0104ff0ec7
        002f801f00df10610002000900979d01
        04ff0ec7002f801f00df102f00020009
        00000000000000000000000000009490
    BorderDimensions: 4 
        supported: 4
    Border: 0 0 0 0 
        range: (0, 65535)
    SignalFormat: DisplayPort 
        supported: DisplayPort
    ConnectorType: DisplayPort 
    ConnectorNumber: 1 
    _ConnectorLocation: 1 
    non-desktop: 0 
        supported: 0, 1
   3840x2160     60.00 +  29.98  
   7680x4320     29.93    24.00  
   3840x4320     60.00*   48.00  
   2560x1440     59.95  
   2048x1080     59.99    23.90  
   1920x1200     59.88  
   1920x1080     60.00    59.94    50.00    23.98  
   1680x1050     59.95  
   1600x1200     60.00  
   1280x1024     75.02    60.02  
   1280x800      59.81  
   1280x720      59.94    50.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.94    59.93  
DP-3 disconnected (normal left inverted right x axis y axis)
    CTM: 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 
        0 1 
    CscMatrix: 65536 0 0 0 0 65536 0 0 0 0 65536 0 
    BorderDimensions: 4 
        supported: 4
    Border: 0 0 0 0 
        range: (0, 65535)
    SignalFormat: TMDS 
        supported: TMDS
    ConnectorType: DisplayPort 
    ConnectorNumber: 1 
    _ConnectorLocation: 1 
    non-desktop: 0 
        supported: 0, 1
DP-4 connected 3840x4320+7680+0 (normal left inverted right x axis y axis) 700mm x 390mm
    _MUTTER_PRESENTATION_OUTPUT: 0 
    CTM: 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 
        0 1 
    CscMatrix: 65536 0 0 0 0 65536 0 0 0 0 65536 0 
    TILE: 495 1 2 1 1 0 3840 4320 
    EDID: 
        00ffffffffffff0010ac47414c393730
        01200104b54627783a7645ae5133ba26
        0d5054a54b008100b300d100a9408180
        d1c0010101014dd000a0f0703e803020
        3500ba892100001a000000ff0036324e
        57523231343037394c0a000000fc0044
        454c4c205550333231384b0a000000fd
        00184b1eb46c010a20202020202002b1
        02031df150101f200514041312110302
        161507060123091f0783010000a36600
        a0f0701f8030203500ba892100001a56
        5e00a0a0a0295030203500ba89210000
        1a7c3900a080381f4030203a00ba8921
        00001aa81600a08038134030203a00ba
        892100001a0000000000000000000000
        00000000000000000000000000000047
        701279000012001682101000ff0edf10
        000000000044454c47414c3937300301
        5070920184ff1dc7001d800900df102f
        0002000400c1420184ff1dc7002f801f
        00df10300002000400a84e0104ff0ec7
        002f801f00df10610002000900979d01
        04ff0ec7002f801f00df102f00020009
        00000000000000000000000000008490
    BorderDimensions: 4 
        supported: 4
    Border: 0 0 0 0 
        range: (0, 65535)
    SignalFormat: DisplayPort 
        supported: DisplayPort
    ConnectorType: DisplayPort 
    ConnectorNumber: 0 
    _ConnectorLocation: 0 
    non-desktop: 0 
        supported: 0, 1
   3840x2160     60.00 +  29.98  
   7680x4320     29.93    24.00  
   3840x4320     60.00*   48.00  
   2560x1440     59.95  
   2048x1080     59.99    23.90  
   1920x1200     59.88  
   1920x1080     60.00    59.94    50.00    23.98  
   1680x1050     59.95  
   1600x1200     60.00  
   1280x1024     75.02    60.02  
   1280x800      59.81  
   1280x720      59.94    50.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.94    59.93  
DP-5 disconnected (normal left inverted right x axis y axis)
    CTM: 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 
        0 1 
    CscMatrix: 65536 0 0 0 0 65536 0 0 0 0 65536 0 
    BorderDimensions: 4 
        supported: 4
    Border: 0 0 0 0 
        range: (0, 65535)
    SignalFormat: TMDS 
        supported: TMDS
    ConnectorType: DisplayPort 
    ConnectorNumber: 0 
    _ConnectorLocation: 0 
    non-desktop: 0 
        supported: 0, 1

Ignore HDMI-0, That's just a regular 4K monitor; the Dell 8K is on DP-2 and DP-4. Note the TILE: entries.

CyberShadow commented 9 months ago

So if I understand correctly, the suggestion is to:

  1. Query the tiles/monitors using XRandR 1.5
  2. Present the monitor output tiles as a single output, so that applications which do not support XRandR 1.5 monitors see tiles as a single output?
rubin55 commented 9 months ago

Yes, more or less: the "problem" with these displays when gaming for example, is very similar as what you describe in your README.md with MST-using monitors: A game would see one half of the display, and then try and 16:9 fullscreen to that, giving you a weird 3840x2160 on one half of your screen, right in the middle of the half:

-------------------------------------
|   black border  |                 |
|-----------------|                 |
|    game 16:9    |                 |
|                 |   still shows   |
|-----------------|     half of     |
|   black border  |     desktop     |
-------------------------------------
      (DP-2)            (DP-4)
CyberShadow commented 9 months ago

OK, though JoinMST should still work there, just with manual configuration instead of getting data out of XRandR. (JoinMST is not a very good name.)

rubin55 commented 9 months ago

Fair enough, I thought JoinMST was MST only, because, when I would run xrandr with LD_PRELOAD set-up, It still shows me all displays + ports and all monitors, which put me on the track "this probably doesn't work with TILE'd displays, only MST".

Could you provide me with an example configuration that would make this work?

CyberShadow commented 9 months ago

I think this should work:

Enable=1
JoinMST=1
MainX=3840
MainY=0
MainW=7680
MainH=4320
Debug=2

With Debug=2 you should see feedback of hax11 rewriting geometry in X11 messages to cover the entire monitor.

rubin55 commented 9 months ago

Alright, it worked, I got Assassin's Creed Odyssey running on my Dell UP3218k at 8k, doing about 45 fps, everything at Ultra, anti-aliasing off (4090, 13900T).

I had to add the MaskOtherMonitors=1 option though, because it became confused about which screen to use.

I also noted (for other people that might hit this issue) that I could work-around the sometimes-occuring freeze at the warning screen, by going to the videos folder and creating a disabled folder there, and moving the en/ folder and the amd.bk2, blackscreen.bk2 and Ubisoftlogo.bk2 files into that disabled folder. This causes the game to skip all intros and in my case helped avoid a 50/50 chance freeze occuring at start.