Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRTC size incorrectly detected when using xrandr --scale-from #2335

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 3 comments
Closed

CRTC size incorrectly detected when using xrandr --scale-from #2335

SDLBugzilla opened this issue Feb 11, 2021 · 3 comments
Labels
abandoned Bug has been abandoned for various reasons
Milestone

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 2.0.5
Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2016-12-14 22:05:37 +0000, James Le Cuirot wrote:

Alien Isolation has very bad aliasing and none of the game's built-in anti-aliasing methods are very effective. This is even a problem on Windows but at least those users have the option of using a mod that adds TXAA. Sadly it's very Windows/D3D specific. The best available option to Linux users is to render at a higher resolution and downscale. The game does not allow this natively so you need to use xrandr's --scale-from option. I have come here after filing a freedesktop.org bug and then realising the issue is with SDL.

https://bugs.freedesktop.org/show_bug.cgi?id=99052

I am using --scale-from like so to downscale from 4K to 1080p. You get very odd results without the --panning option but this is arguably an xrandr bug.

xrandr --output HDMI-A-0 --mode 1920x1080 --scale-from 3840x2160 --panning 3840x2160

SDL initially gets the correct CRTC size in X11_InitModes_XRandR directly from the XRRCrtcInfo with crtc->width and crtc->height. The problem is that it then throws these away of favour of values associated with the current mode in SetXRandRModeInfo. The result is games like Alien Isolation and SuperTux being rendered in the bottom-left quarter of the screen.

If I simply comment out the call to SetXRandRModeInfo then both games work fine. Neither offer this size in the options but both render at 3840x2160 while in fullscreen anyway. I initially tested Neverball but this is a bad example as it has a hardcoded list of modes.

SetXRandRModeInfo's main purpose in this context seems to be to deal with rotation and yet I get the exact same result with it commented out when I apply rotation. I had hoped to try --rotate and --scale-from at the same time but I could not get these to play well together.

I know that SetXRandRModeInfo cannot simply be removed and the rotation handling is still needed as it also used to get information about other modes in X11_GetDisplayModes. It is additionally used to fetch the refresh rate, which isn't used by the library, but may be used by games.

I think that X11_InitModes_XRandR should only consider the values reported by crtc->width and crtc->height but not check for rotation. It should still fetch the refresh rate.

X11_GetDisplayModes should continue to work as it does now except that it could add a mode for crtc->width and crtc->height if this size is found not to match any of the modes listed by XRRGetScreenResources. This will allow the size to appear in option screens. The games I tried work anyway but other games may forcefully restrict themselves to this mode list.

On a side note, switching mode in a game while rotated gives weird results but this is due to the aforementioned --panning bug in xrandr.

What do you think? I could whip up a patch for this.

On 2016-12-14 22:15:17 +0000, James Le Cuirot wrote:

I see that I overlooked this line in SetXRandRModeInfo:

((SDL_DisplayModeData*)mode->driverdata)->xrandr_mode = modeID;

Obviously this is critically important so I'll take that into account too. :) When adding the larger size (e.g. 4K) then this would actually be the modeID for the smaller size (e.g. 1080p).

@slouken slouken removed the bug label May 11, 2022
@slouken slouken added this to the 2.30.0 milestone Nov 4, 2023
@slouken
Copy link
Collaborator

slouken commented Nov 4, 2023

@chewi, do you still have this issue and are you still able to create a PR to address it?

@chewi
Copy link
Contributor

chewi commented Nov 4, 2023

Heh, I finally completed this game just this year, but by that time, I had a 1440p screen. I'm also using Wayland now. I don't really want to poke at this without any need to, so I'll let someone else tackle it if they want.

@slouken slouken added the abandoned Bug has been abandoned for various reasons label Nov 4, 2023
@slouken
Copy link
Collaborator

slouken commented Nov 4, 2023

Hah, okay. I'll go ahead and close this, but if someone else runs into it they are welcome to reopen this.

Congrats on your game!

@slouken slouken closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abandoned Bug has been abandoned for various reasons
Projects
None yet
Development

No branches or pull requests

3 participants