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

renderer: vrr support and borderless window optimizations #3549

Closed
wants to merge 5 commits into from

Conversation

tadanokojin
Copy link
Member

@tadanokojin tadanokojin commented Jul 15, 2020

Description of Changes

  • Enable Flip model and tearing in D3D
  • Enable tearing in OpenGL
  • Changes the default VSync setting to Standard so users without VRR support don't experience tearing by default.

Rationale behind Changes

  • Allows support for GSync and FreeSync technologies in both OpenGL and D3D11.
  • Improves latency in windowed and borderless fullscreen modes

Suggested Testing Steps

  1. Run a game and enter borderless fullscreen
  2. By default there should be no tearing
  3. In General Settings -> GS Window set the Wait for VSync on refresh option to Disabled and enter fullscreen again
  4. With GSync disabled you should observe tearing in both D3D and OpenGL.
  5. With GSync enabled you should not observe tearing (my display additionally has an OSD showing me the current framerate).

Often things like buffering pauses can help with visualizing tearing.

Known Issues

  • OpenGL may not work on AMD/Intel. I believe NV implements a driver-level optimization which allows for tearing in borderless window mode when the buffer dims match the resolution of the monitor and is focused.
  • Switching from D3D11 to OpenGL will result in a black/frozen screen in windowed mode.

@OCRBonk
Copy link

OCRBonk commented Aug 19, 2020

Ok, so testing this after figuring out how to reliably get it to switch to tearing mode. It actually works great.
I can use Scanline Sync or even force Vsync through the driver (The frame limiter needs to be disabled for both to work correctly.)
I was concerned about fit to window for 4:3 content as I don't always like using Widescreen patches. But using a custom 4:3 resolution is a reasonable compromise and it works perfectly then.

Using the same mode built in for OpenGL works as well though there can be performance differences. In Xenosaga I for example, using any kind of Blending Accuracy is needed for shadows to render properly but it absolutely wrecks performance in cutscenes even on an RTX 2080. (Difference on average just from None to Basic can be 30-40+% GPU usage. Less so during gameplay but when using AWGS in battle with Blending Accuracy Basic in OGL causes the same GPU usage jump without any visual differences at all when I took comparison screens.).

Back on topic, the shadows aren't rendered correctly I think no matter what in DX11 (Not that they look bad and actually it renders with blending accuracy high in DX11 but that tanks performance from 175FPS down to 55FPS or so in one scene on a 2080 at 4x res) so that's not an issue there. So your build seems to work really well to enable tearing and allow the driver to take over Vsync control in Flip Model or use Scanline Sync and get the best frame pacing without major stuttering in Windows 10. (And introduce the least latency in the process). So I hope this ends up getting merged. Is there a reason why it doesn't work when using a 4:3 aspect ratio in a 16:9 window?

@tadanokojin
Copy link
Member Author

Thank you for posting your experience

So I hope this ends up getting merged. Is there a reason why it doesn't work when using a 4:3 aspect ratio in a 16:9 window?

Yes, it's because of how we handle aspect ratio via the gui instead of the rendering so driver fails to detect it as fullscreen. Waiting for #3588 to be merged before proceeding. Should be sorted after that.

@masterotaku
Copy link

I hope this can get merged. I tried a build with it a few months ago and it's exactly what I needed to make PCSX2 trigger 3D Vision in DX11 without the need of using an old Special K build in a hacky way.

Also, playing in 2D with G-Sync is a lot better than without it, when you can get some fps drops.

@tadanokojin
Copy link
Member Author

Cool, good to hear that it's offering some improvements there.

As far as merging is concerned there are two major problems with this PR:

  1. Because GL and D3D11 share a surface in PCSX2, this creates a problem where switching to OpenGL results in a black screen which is obviously not something I can merge into master. I did some research into this and the consensus seems to be that you have to destroy it which makes sense considering I've seen Dolphin code that suggest this is also a problem with VK drivers and as far as I have read sharing a surface between APIs like this is undefined behavior. So the solution to that has to be to destroy and recreate the window whenever the emulation is paused and resumed (ie when settings are opened and then closed).
  2. A slightly less annoying problem is the way we are handling aspect ratio via Wx which breaks driver heuristics causing the effects of this PR to only be enabled when the rendering takes up the entire window (ie stretch). WIP: Move aspect ratio changes to the GS plugin. #3588 was created to address that problem but the author has since closed it (not sure I know why).

Right now GSdx is getting ready to be merged into core. So I'm going to wait for that as I imagine the logistics of that will be taking much of my time. As I understand it the TAS guys need 1 anyway so that should be likely to be addressed sometime hopefully in the semi-near future. Again, hopefully after the GSdx merge.

@JordanTheToaster
Copy link
Member

I resized the window after switching from OpenGL to D3D11 and caused this to happen.
wrehwerhntejhntr

@tadanokojin
Copy link
Member Author

Must have broke it in my latest push, thanks I'll look at it.

@github-actions github-actions bot removed the GUI/WX label Jul 27, 2021
@tadanokojin tadanokojin changed the title gsdx-d3d: switch to flip model renderer: vrr support and borderless window optimizations Jul 27, 2021
@github-actions github-actions bot added Dependencies Pull requests that update a dependency file GUI/WX labels Jul 27, 2021
@tadanokojin
Copy link
Member Author

Rebased and pulled in a commit from #4615 (for testing, I'll rebase it off master later).
Additionally added some experimental tearing support for OpenGL.

Details in updated pr description.

@JordanTheToaster
Copy link
Member

Works great only problem I could find was if you are full screen in Direct3D11 and switch to OpenGL then double click to go back to windowed it will be frozen on an old frame.

@refractionpcsx2
Copy link
Member

refractionpcsx2 commented Jul 27, 2021

@JordanTheToaster can you test if that's a result of #4615 or this one please? (since Kojin has temporarily merged the two)

@JordanTheToaster
Copy link
Member

@JordanTheToaster can you test if that's a result of #4615 or this one please? (since Kojin has temporarily merged the two)

Works correctly on #4615 so it's this PR that causes the issue.

@tadanokojin
Copy link
Member Author

Works great only problem I could find was if you are full screen in Direct3D11 and switch to OpenGL then double click to go back to windowed it will be frozen on an old frame.

I mentioned it in the known issues section.

@Immersion95
Copy link
Contributor

I can confirm that AMD works (GL & DX11).

@refractionpcsx2
Copy link
Member

I can confirm that AMD works (GL & DX11).

I don't think GL has any code for this yet?

@HighBunkerHxH
Copy link

I can confirm that AMD works (GL & DX11).

I don't think GL has any code for this yet?

It sorta does, but it's frame pacing is terrible when using G-Sync on OGL

@GiladN1
Copy link
Contributor

GiladN1 commented Sep 18, 2021

I would like to test this as well if possible, but I can't download the builds. Can anyone send me a link to the AVX2 build?

FWIW, I have an Nvidia GPU and running windows 10 x64.

@Immersion95
Copy link
Contributor

Immersion95 commented Oct 17, 2021

Is there any reason it was closed ? This is the only way to have lagless D3D11 (I have AMD so OpenGL in Hardware mode is not a great choice for me).

@JordanTheToaster
Copy link
Member

Is there any reason it was closed ? This is the only way to have lagless D3D11 (I have AMD so OpenGL in Hardware mode is not a great choice for me).

It's being superseded by something coming in the future.

@HighBunkerHxH
Copy link

Is there any reason it was closed ? This is the only way to have lagless D3D11 (I have AMD so OpenGL in Hardware mode is not a great choice for me).

It's being superseded by something coming in the future.

Superseded by what?
I'm curious?

@refractionpcsx2
Copy link
Member

You'll find out when it comes, but you will get your VRR eventually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dependencies Pull requests that update a dependency file GS: Direct3D 11 GS: OpenGL GS
Projects
None yet
Development

Successfully merging this pull request may close these issues.