RetroPie-Setup icon indicating copy to clipboard operation
RetroPie-Setup copied to clipboard

Incorrect Resolution Set in /dev/shm/retroarch.cfg

Open theofficialgman opened this issue 3 years ago • 9 comments

Screen is rotated with xrandr left at boot time on this system (nintendo switch)

Retropie incorrectly populates the /dev/shm/retroarch.cfg with

video_fullscreen = "true"
video_fullscreen_x = "720"
video_fullscreen_y = "1280"

the X and Y values are backwards and causes all retroarch emulators to crash with output such as

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  152 (XFree86-VidModeExtension)
  Minor opcode of failed request:  10 (XF86VidModeSwitchToMode)
  Value in failed request:  0x193
  Serial number of failed request:  31
  Current serial number in output stream:  33

reversing the X and Y values manually in this file and launching with the same command works fine this is not an issue for display configurations where the screen is not rotated

https://github.com/RetroPie/RetroPie-Setup/blob/d6d715b8867f101d2ef6cdf66dec23f20d0aa2ad/scriptmodules/supplementary/runcommand/runcommand.sh#L1089 https://github.com/RetroPie/RetroPie-Setup/blob/d6d715b8867f101d2ef6cdf66dec23f20d0aa2ad/scriptmodules/supplementary/runcommand/runcommand.sh#L404 applicable code linked above

theofficialgman avatar May 12 '21 00:05 theofficialgman

video_refresh_rate is also set incorrectly to 60 instead of the reported 59.93Hz but according to the code that is the desired function (to round to an integer)

theofficialgman avatar May 12 '21 00:05 theofficialgman

output from xrandr --verbose to help debug the issue

Screen 0: minimum 8 x 8, current 1280 x 720, maximum 16384 x 16384
DSI-0 connected primary 1280x720+0+0 (0x18d) left (normal left inverted right x axis y axis) 0mm x 0mm
	Identifier: 0x18c
	Timestamp:  2192869
	Subpixel:   unknown
	Gamma:      1.0:1.0:1.0
	Brightness: 1.0
	Clones:    
	CRTC:       0
	CRTCs:      0
	Transform:  1.000000 0.000000 0.000000
	            0.000000 1.000000 0.000000
	            0.000000 0.000000 1.000000
	           filter: 
	_MUTTER_PRESENTATION_OUTPUT: 0 
	TegraOverlayBlendmode: Opaque 
		supported: Opaque, SourceAlphaBlend, PremultSourceAlphaBlend
	TegraOverlayPriority: 255 
		range: (0, 255)
	BorderDimensions: 4 
		supported: 4
	Border: 0 0 0 0 
		range: (0, 65535)
	SignalFormat: TMDS 
		supported: TMDS
	ConnectorType: Panel 
	non-desktop: 0 
		supported: 0, 1
  720x1280 (0x18d) 77.905MHz +HSync +VSync *current +preferred
        h: width   720 start  856 end  928 total 1000 skew    0 clock  77.91KHz
        v: height 1280 start 1290 end 1291 total 1300           clock  59.93Hz
DP-0 disconnected (normal left inverted right x axis y axis)
	Identifier: 0x18e
	Timestamp:  2192869
	Subpixel:   unknown
	Clones:    
	CRTCs:      1
	Transform:  1.000000 0.000000 0.000000
	            0.000000 1.000000 0.000000
	            0.000000 0.000000 1.000000
	           filter: 
	_MUTTER_PRESENTATION_OUTPUT: 0 
	TegraOverlayBlendmode: Opaque 
		supported: Opaque, SourceAlphaBlend, PremultSourceAlphaBlend
	TegraOverlayPriority: 255 
		range: (0, 255)
	BorderDimensions: 4 
		supported: 4
	Border: 0 0 0 0 
		range: (0, 65535)
	SignalFormat: DisplayPort 
		supported: DisplayPort
	ConnectorType: DisplayPort 
	non-desktop: 0 
		supported: 0, 1

theofficialgman avatar May 12 '21 00:05 theofficialgman

This code was done by @psyke83 - maybe he has an idea

The code grabs the primary display and all modes supported by it then references them via the connected display ID (0x18d in this case).

Although the first reference has 1280x720 the first mode is actually 720x1280.

We might be able to workaround it by adding an option to ignore xrandr completely or swap the values based on the string "inverted" , but not sure the best fix if retroarch requires the values swapped as it would seem correct how we have them set in regards to the orientation.

joolswills avatar Jun 27 '21 02:06 joolswills

I will need to look at the retroarch code also.

joolswills avatar Jun 27 '21 02:06 joolswills

I think that this part of the log signifies the orientation:

"DSI-0 connected primary 1280x720+0+0 (0x18d) left (normal left inverted right x axis y axis) 0mm x 0mm"

The possible orientation types reported by xrandr are normal, left, right and inverted. When I have time, I'll check the retroarch config to see if there's an additional setting that we need to map to handle the specific orientation type, as simply doing an x/y resolution flip may not work for everybody.

psyke83 avatar Jun 27 '21 13:06 psyke83

Thanks.

joolswills avatar Jun 27 '21 13:06 joolswills

If I might ask, what is the reason for this functionality at all? setting the resolution values to empty eg: video_fullscreen_x="" seems to work fine at least for my config

I will note xrandr is a mess.. you have to be careful how you get that resolution and rotation info, you can get different output depending if your xrandr backend uses v1.2 and newer commands or v1.1 older (one might say 720x1280 normal while the other will say 1280x720 left)

theofficialgman avatar Jun 29 '21 22:06 theofficialgman

@psyke83 can you look at this again? still an issue

theofficialgman avatar Jul 21 '22 20:07 theofficialgman

basically the issue is this function https://github.com/RetroPie/RetroPie-Setup/blob/f271ce9dee01fb224aaac44d6e9c1230d1ab5087/scriptmodules/supplementary/runcommand/runcommand.sh#L272-L323

doesn't take into account rotation values left/right/inverted etc, AT ALL all it does is report back the actual screen resolution (which doesn't factor in rotation)

here is verbose output to help with your fixing. you will need to switch to reading the resolution from the first line since this is the only correct spot to query it

Screen 0: minimum 8 x 8, current 1280 x 720, maximum 16384 x 16384
DSI-0 connected primary 1280x720+0+0 (0x18d) left (normal left inverted right x axis y axis) 0mm x 0mm
	Identifier: 0x18c
	Timestamp:  1746173
	Subpixel:   unknown
	Gamma:      1.0:1.0:1.0
	Brightness: 1.0
	Clones:    
	CRTC:       0
	CRTCs:      0
	Transform:  1.000000 0.000000 0.000000
	            0.000000 1.000000 0.000000
	            0.000000 0.000000 1.000000
	           filter: 
	_MUTTER_PRESENTATION_OUTPUT: 0 
	TegraOverlayBlendmode: Opaque 
		supported: Opaque, SourceAlphaBlend, PremultSourceAlphaBlend
	TegraOverlayPriority: 255 
		range: (0, 255)
	BorderDimensions: 4 
		supported: 4
	Border: 0 0 0 0 
		range: (0, 65535)
	SignalFormat: TMDS 
		supported: TMDS
	ConnectorType: Panel 
  720x1280 (0x18d) 78.003MHz +HSync +VSync *current +preferred
        h: width   720 start  856 end  928 total 1000 skew    0 clock  78.00KHz
        v: height 1280 start 1290 end 1291 total 1300           clock  60.00Hz
DP-0 disconnected (normal left inverted right x axis y axis)
	Identifier: 0x18e
	Timestamp:  1746173
	Subpixel:   unknown
	Clones:    
	CRTCs:      1
	Transform:  1.000000 0.000000 0.000000
	            0.000000 1.000000 0.000000
	            0.000000 0.000000 1.000000
	           filter: 
	_MUTTER_PRESENTATION_OUTPUT: 0 
	TegraOverlayBlendmode: Opaque 
		supported: Opaque, SourceAlphaBlend, PremultSourceAlphaBlend
	TegraOverlayPriority: 255 
		range: (0, 255)
	BorderDimensions: 4 
		supported: 4
	Border: 0 0 0 0 
		range: (0, 65535)
	SignalFormat: DisplayPort 
		supported: DisplayPort
	ConnectorType: DisplayPort

theofficialgman avatar Jul 21 '22 20:07 theofficialgman