libretro / RetroArch

Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.
http://www.libretro.com
GNU General Public License v3.0
10.09k stars 1.81k forks source link

Video width and height are switched when a vertically-oriented game is loaded #8551

Closed Patrickdroid closed 5 years ago

Patrickdroid commented 5 years ago

Description

With vertically oriented games, Retroarch switches the emulator-provided width and height. For example, if the width/height is supposed to be 320x240, RA will switch this to 240x320. This only occurs with vertically oriented games. I tested this in both MAME and FBA using the Windows 64 bit version of RA.

Expected behavior

The game to be displayed using the correct resolution (width/height).

Actual behavior

The height and width is switched when a vertically oriented game is loaded.

Steps to reproduce the bug

  1. load any vertically oriented game in either FBA or MAME using Windows 64 bit version of RA (example: DonPachi)
  2. under video settings, enable integer scale.
  3. set "custom aspect ratio width/height" to 1x.
  4. look at "custom aspect ratio width/height" to see that it says 240 for width and 320 for height. This is the reverse of what it should be; it should be 240 for height and 320 for width.

Bisect Results

I first noticed this a few days ago.

Version/Commit

You can find this information under Information/System Information

Environment information

image

image

ghost commented 5 years ago

some arcades have the monitor rotated 90 degrees. The can the emulator can either rotate the image to the displays orientation or display it as intended and you rotated your display 90 degrees

Patrickdroid commented 5 years ago

I understand that, but the emulator-provided resolution should not be changed from the correct resolution, regardless of orientation. If the game is 320x240 it should be output as 320x240, not 240x320. The user can flip it or rotate it or resize it or whatever, but the output resolution from the emulator should remain the same (eg, 320x240 should be output as 320x240 before the user does stuff to it). Otherwise you get scaling artifacts unless you just happen to adjust the y axis to a multiple of both 240 and 320 (eg, 960). And if you’re playing a game that uses a weird resolution like 19XX (384x240), then it causes big problems with overscan or underscan when using integer scaling. As of right now, video aspect ratio for vertical games must be configured manually (custom ratio width/height, non-integer) along with custom ratio x/y position, because the resolution/ratio for vertical games isn’t being detected correctly.

ghost commented 5 years ago

the thing is the topic say the width and height are switched they simply arent it just a rotated monitor. It draws the image on the monitor as 4:3 then you flip the monitor physically this changes it to 3:4 on real hardware as far as the hardware is concerned its a normal 4:3 device but your rendering the image 90 degrees rotated.

In mame2003 or plus just use tate mode this stop the rotation and you need to flip your monitor like a real one. look at sf2 this is on a 4:3 screen look at the resolution of the game it use crt timing when rendering to look the way it does in a crt if you used the literal resolution for sf2 the gfx would be overly stretched.

ghost commented 5 years ago

it looks like your talking about capcom games watch this to understand whats going on and it is indeed 4:3

https://www.youtube.com/watch?v=LHfPA4n0TRo&feature=youtu.be

Patrickdroid commented 5 years ago

I’m not referring exclusively to capcom games. You can see this behavior in the example screenshots I posted above, which are from Donpachi.

I understand very well that certain games are meant to be displayed vertically. This doesn’t change anything that I’ve said.

With a vertically-oriented 320x240 game, width should say 320 and height should say 240, and the displayed image should be sideways. On a 4:3 CRT monitor the image would be 320x240 and sideways. You then rotate the monitor 90 degrees. This doesn’t change the image to 240x320. It is still 320x240 but now it is rotated 90 degrees so it is no longer sideways.

Altering the internal resolution of the game is incorrect, and will always result in scaling artifacts unless you happen to use a resolution that is a multiple of both 320 and 240.

Patrickdroid commented 5 years ago

If you display the arcade pcb to a CRT monitor in normal orientation it will be a 320x240 image that is sideways. You rotate the CRT 90 degrees. The resolution of the game remains unchanged.

ghost commented 5 years ago

yes resolution of you display remains unchanged. I dont have a crt to test whats going on there I would assume you should be using core provided information and tate mode on for mame2003 and plus dont know if the others support tate mode

Patrickdroid commented 5 years ago

You just aren’t getting what I’m saying. I’m going to have to post some screenshots later to help illustrate what’s going on currently and what should be going on instead.

ghost commented 5 years ago

can you make them screenshot in mame2003 and 2003+ with tate mode on so i can see what going on make sure your using core provided for aspect ratio as well in them screenshots will help a lot in seeing whats going on

Patrickdroid commented 5 years ago

First of all, just look at the first two screenshots I posted above. See where it says "custom aspect ratio width" and "custom aspect ratio height" Both of these screenshots were taken with video rotation disabled.

Width/height should be the reverse of what is shown in the above screenshots.

Patrickdroid commented 5 years ago

Here is what it SHOULD look like with video rotation disabled. This is what is NOT happening, currently. I created this in GIMP by manually switching the height/width in GIMP.

image

Patrickdroid commented 5 years ago

Here is what currently happens. Both of these are incorrect.

video rotation disabled:

image

video rotation enabled:

image

Patrickdroid commented 5 years ago

Next, here are some tests conducted by HunterK. See how video height/width are switched from what it is in my screenshots in the very first post? That's what it should be. image

image

ghost commented 5 years ago

what emulator is this from here is screenshots from with ?

Patrickdroid commented 5 years ago

Next, I made this shot by manually resizing the resolution to 1600x1200, and used a scanlines shader. Notice how the scanlines and mask are perfectly scaled with no scaling artifacts present. This could only be the case if the game's resolution is indeed 320x240. With the currently reported resolution of 240x320, you get scaling artifacts.

image

Patrickdroid commented 5 years ago

In my initial post, I said that the behavior is present in both MAME and FBA in the Windows 64 bit version of RA. As you can see in the tests conducted by HunterK, this behavior is not present in the Linux version of RA.

ghost commented 5 years ago

this is mame2003 with tate mode on and off using core provided aspect ratio I cant speak for the other emulators

fshark-190407-183154 fshark-190407-183227

ghost commented 5 years ago

have you even tried running mame2003 with these settings it what it shoud do tate mode skips the rotating and renders like its should.

Patrickdroid commented 5 years ago

How are we supposed to know what the core reported width and height are from the screenshots you just posted? Again, the issue is that the emulator reported height and width are not correct.

Patrickdroid commented 5 years ago

Tate mode ON solves the issue in MAME 2003.

Tate mode off: image

Tate mode on: image

ghost commented 5 years ago

i think mame current has rotation options in the tab menu dont know if they will work as expected though

Patrickdroid commented 5 years ago

The problem is, tate mode ON in MAME 2003 should be the default for all emulators including FBA. This is what the image looks like when you connect the actual hardware to a CRT that isn't rotated. There shouldn't be any automatic switching for vertical-oriented games. Switching height/width (Tate mode off) should be something that the user has to select because it's altering the original output of the emulated hardware. Anything done to alter the original output of the emulated hardware in this way should be something that the user has to manually select.

Still no idea how HunterK was able to get the image to to display correctly using FBA, and I'm still unable to get the other version of MAME to display the image correctly.

ghost commented 5 years ago

sure that can be true im sure most people dont have there displays rotated unless they have a barcade of some sort setup for vertical games only.

Its a personal opinion but feel free to post an issue on it is easy enough to change the defaults through issues in the emulators in question. I dont really feel strongly about this its one for the people in charge of the repos it switchable in mame2003 and plus anyway in the options so the default wont really matter it can be changed to suit your display

Patrickdroid commented 5 years ago

I'm not just being pedantic, here. The width/height being switched isn't helpful and causes numerous potential issues. With the current behavior of height/width being automatically switched with vertical games, you still have to rotate the image if you want correct aspect ratio and orientation or to avoid a huge amount of letterboxing, and with height/width being switched like this, it results in scaling artifacts unless you happen to choose a resolution that is a multiple of both 320 and 240.

Furthermore, there is still no way that I know of to get any emulator besides MAME 2003 to work correctly.

The current rationale of "people don't want to rotate their displays" just isn't sufficient to justify this.

ghost commented 5 years ago

first of all i completely agree with you all options should be clear to change and i feel fba does cover this option well its just you have to restart for it to take effect/

ill need to look into mame current at a later time. I will tell you how to to fix fba got quick menu options turn vertical mode on and restart the emulator it should work as expected.

Patrickdroid commented 5 years ago

In FBA, enabling vertical mode in the quick menu options and restarting the emulator does not fix the problem. I'm still getting this:

image

Patrickdroid commented 5 years ago

Another problem related to this is the sheer number of knobs and dials related to video rotation. There are options related to video rotation in all of these places:

main menu ->quick menu -> options settings -> video settings -> core

If I'm an average user, how am I supposed to know what to do with all of this? Even as an experienced user, this is quite confusing.

Patrickdroid commented 5 years ago

SUCCESS.

Actually, in FBA I have to turn vertical mode OFF under quick menu -> options.

image

So, yes, there is a lot going on here. Each of the cores seems to be handling this in a different way and there are far too many knobs and dials related to this. Disabling vertical mode makes it work in FBA, while enabling tate mode in MAME 2003 makes it work there... how does that make any sense?! As things currently stand, the options for this are an incoherent mess.

Even you thought that enabling vertical mode would be the same as enabling tate mode, which makes sense, intuitively. There just seems to be no rhyme or reason to the way these settings currently work.

Patrickdroid commented 5 years ago

I'm still getting the same problem in FBA 2012. There is no option in quick menu -> options for vertical mode. Under settings -> core there is an option for "enable rotation." I'm getting the same results with this turned either ON or OFF.

settings -> core -> allow rotation ON: image

settings -> core -> allow rotation OFF: image

andres-asm commented 5 years ago

as far as I can tell, the problem is the frontend based rotation not taking into account the aspect ratio change. I don't think we need so many knobs in the cores to do this, it should be one option in the frontend and that's all.

I'm not even sure why there is a ROTATION ENV callback in the API

ghost commented 5 years ago

there is a reason for it to be there clearly this isint a front end issue. It cant guess if you have rotated you monitor 90 degrees physically you need to deal with this as a core option if that is the case.

Patrickdroid commented 5 years ago

Agree w/fr500.

In my opinion, a vertically-oriented game should look like this by default:

image

The user can then rotate the image using the advanced user option under settings -> video -> rotation

You could also add an option under video settings ("automatically rotate vertical games 90 degrees" or something) to automatically set settings -> video -> rotation -> 90 degrees whenever a vertical oriented game is detected. But, I'm getting ahead of myself. EDIT, okay yeah this wouldn't work. But I still think that the core shouldn't be doing stuff to alter the output resolution (at least not by default) and that the user should do this with the frontend options for rotation and aspect ratio, or by manually selecting a core option to switch width/height for non-rotated displays.

Patrickdroid commented 5 years ago

there is a reason for it to be there clearly this isint a front end issue. It cant guess if you have rotated you monitor 90 degrees physically you need to deal with this as a core option if that is the case.

The resolution/aspect ratio output by the emulator should remain unchanged by the core- see above. A vertical game that is 320x240 should be output as 320x240. The frontend options for video rotation and aspect ratio are more than sufficient and solve the problems related to the way things are currently handled, which are, to wit:

  1. it's incorrect according to what the original hardware does
  2. it's counter-intuitive
  3. it results in scaling artifacts with integer scaling

If people want to play vertical games rotated 90 degrees on their monitors, then they should use the frontend for that. The emulator/core shouldn't alter the actual output.

ghost commented 5 years ago

and how is the front end supposed to guess that this particular arcade is rotated or not mame2003 covers this i dont see how you can get the front end to be psychic

Patrickdroid commented 5 years ago

I'm saying that the front end options are sufficient and that the cores are currently doing something wrong/there's too much going on with the cores. Just make the cores output the original resolution, unaltered, and let the user use the frontend options for rotation and aspect ratio. That would solve the problem(s).

In standalone FBA, you get this by default, which is as it should be:

image

With "Video -> rotate vertically aligned games -> enabled" you get this, which is again as it should be:

image

ghost commented 5 years ago

ok with you so far you failing to mention the users monitors physical orientation in all this

Patrickdroid commented 5 years ago

I don't see why the monitor orientation is relevant to what resolution the core is outputting. Altering the height/width of the resolution so that the image is correctly oriented on a non-rotated monitor is altering the output resolution, and thus incorrect. Furthermore, in some cases you still have to rotate the image using the frontend options to get a properly oriented image even though the height/width are being switched; automatically switching the height/width doesn't solve the problem that it is intended to solve and is introducing more problems. You can see this in the above example with MAME 2003; TATE mode on or off still results in a sideways image so that the user either has to rotate it using a front end option or physically rotate their display. The core should just output the unaltered resolution. Altering the resolution, aspect ratio or video rotation is all stuff that should happen on the frontend or through a user option that has to be selected.

At the very least, it would be preferable to stop enabling automatic rotation by default and have this be something that the user has to enable through a core option. The default should be the original unaltered image (see the example of standalone FBA, above). The user shouldn't have to dig through multiple menus of confusingly-named settings and apply a lot of trial and error in order to get the emulator to display the original unaltered image.

Patrickdroid commented 5 years ago

Also, as we can see, there's just a lot of weird stuff going on. TATE mode ON in MAME results in the same behavior as vertical mode OFF in FBA, and FBA 2012 won't display a correct image no matter what settings are applied, and I haven't even tested all the emulators yet. I understand the lack of standardization when it comes to core options, but this just seems somewhat ridiculous.

ghost commented 5 years ago

im trying to understand where you are hitting this from the cores arent scaling the resolution RA scaless the resolution to your display.

Patrickdroid commented 5 years ago

To what are you referring with this statement?

Patrickdroid commented 5 years ago

and how is the front end supposed to guess that this particular arcade is rotated or not mame2003 covers this i dont see how you can get the front end to be psychic

If the front end can't detect whether a game is vertical or not, then it's the cores that are automatically switching the height/width for vertical games.

ghost commented 5 years ago

yes they do people that dont rotate there monitors dont want to play there vertical games sideways or rotate there monitor by default. Tate mode wont rotated vertical games at all on mame2003 that what you requested. You have t do your part now and rotate your monitor physically to match the arcade.

andres-asm commented 5 years ago

This whole discussion is pointless.

and how is the front end supposed to guess that this particular arcade is rotated or not mame2003 covers this i dont see how you can get the front end to be psychic

There is not need to guess anything, this is software development, there is an API, an implementation, and a frontend.

There is an API for this: https://github.com/libretro/RetroArch/blob/master/libretro-common/include/libretro.h#L486

So the players are:

Who knows the content needs rotation? The core does. The environment callback is a set, which means it's telling the frontend to "do something"

So what should happen could go two ways

a. The core tells the frontend: "hey video is rotated, adjust aspect ratio from what I reported accordingly" b. The core tells the frontend: "hey this content requires rotation, do whatever you need to do so it works properly"

That's all. This is a frontend problem, but before anything can be do about it what we need is clarification from the API side so we can adjust both the frontend and the cores to do whatever needs to be done. That's all.

ghost commented 5 years ago

there is no front end issue some arcades have different rotations not just 90 degrees. The core needs to work this out the user will need to be more specific from what he says he wants vertical games to display like this by default which is perfectly valid if you have a rotated monitor.

fshark-190407-183227

this is how it displays when you dont have a rotated monitor the user seems to think this is wrong fshark-190407-183154

andres-asm commented 5 years ago

Ok, you win, have fun arguing forever instead of proposing a solution.

ghost commented 5 years ago

Ok you have a 4:3 monitor it draws as 4:3 like the fist picture you rotate it the monitor in the arcade 90 degrees what aspect ratio is it now for us to display on out normal monitor sitting on the tv stand? ill leave you two to it.

Despite what the op said before fba mainline are set this way by default i just downloaded it. Its default rotate vertical games mame mainline and all our lr coresdo this by default afaik. However not all lr cores have the option not to rotate.

Patrickdroid commented 5 years ago

This whole discussion is pointless.

and how is the front end supposed to guess that this particular arcade is rotated or not mame2003 covers this i dont see how you can get the front end to be psychic

There is not need to guess anything, this is software development, there is an API, an implementation, and a frontend.

There is an API for this: https://github.com/libretro/RetroArch/blob/master/libretro-common/include/libretro.h#L486

So the players are:

* core

* api

* frontend

Who knows the content needs rotation? The core does. The environment callback is a set, which means it's telling the frontend to "do something"

So what should happen could go two ways

a. The core tells the frontend: "hey video is rotated, adjust aspect ratio from what I reported accordingly" b. The core tells the frontend: "hey this content requires rotation, do whatever you need to do so it works properly"

That's all. This is a frontend problem, but before anything can be do about it what we need is clarification from the API side so we can adjust both the frontend and the cores to do whatever needs to be done. That's all.

I don't understand all of this, but it sounds very reasonable.

Yes, it does seem grant2258 and I have been going in circles with this. I think I've provided enough info on the problem as it currently stands to work towards a solution, but since I'm not a programmer, I've probably done all I can by this point.

ghost commented 5 years ago

i agree with that @CharlesBukowski im sure @fr500 has some idea looking forward to seeing what he is going to do since he thinks there is an issue and what exactly is wrong as i cant see any issue at all with mame2003 or fba on libretro it both have the ability rotate or not rotate vertical games. It does it the same way as mainline fba and mame.

So i wll digress im at a bit of a loss what you two seem to think the issue is is you want to maintain a 4:3 ratio you need to rotate the Monitor or physically force the aspect ratio to 4:3 when rotating and put up with the streched gfx

Patrickdroid commented 5 years ago

The issue is that the behavior isn't consistent across cores and it's confusing as hell what is actually going on.

There is the separate issue of what the default behavior should be for vertical games, which you seem to be caught up on. Just having this stuff standardized across cores would be a huge improvement over the current situation, regardless of what the default behavior is set to.

As of right now, MAME and FBA do the exact opposite thing with video_allow_rotate = true/false. And that's just two cores. Who knows what's going on with other cores; I haven't even had a chance to test them yet.

TATE on and video_allow_rotate = true in MAME 2003 produces the same results as vertical mode on and video_allow_rotate = false in FBA. How does this make any sense?

posting this for reference, read from this post down.

https://forums.libretro.com/t/switch-video-width-height-when-video-is-rotated/21674/35?u=nesguy

Patrickdroid commented 5 years ago

i agree with that @CharlesBukowski im sure @fr500 has some idea looking forward to seeing what he is going to do since he thinks there is an issue and what exactly is wrong as i cant see any issue at all with mame2003 or fba on libretro it both have the ability rotate or not rotate vertical games. It does it the same way as mainline fba and mame.

So i wll digress im at a bit of a loss what you two seem to think the issue is is you want to maintain a 4:3 ratio you need to rotate the Monitor or physically force the aspect ratio to 4:3 when rotating and put up with the streched gfx

  1. automatically switching the width/height for vertical oriented games is altering the output resolution, which is incorrect. The emulator should just output the resolution completely unaltered. Altering what is output by the emulator should always be done by the frontend, or through an option that the user has to manually select, but maybe that's just my opinion. The default should just be whatever the emulator spits out before you start doing stuff to it.

  2. rotating the game is something that can be easily handled in the frontend without all of the confusion that currently exists

  3. 2 is something that can even be done automatically if desired by the user, through the frontend as explained by fr500.

  4. the current method of automatically switching the height/width with vertical games will always result in scaling artifacts no matter what you set the aspect ratio to (unless it's a multiple of both 240 and 320). How can this be considered correct?

  5. the current method of automatically switching the height/width of vertical games isn't even making things easier for the user in all cases, because video_allow_rotate = true/false isn't doing the same thing in all cores. The current method is just adding more confusion.

My brain is tired. Hopefully the thread I linked to above sheds some additional light on the problem.