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

Window/direct3d renderer does not update after second CreateRenderer call with PRESENTVSYNC on Windows 11 #5099

Closed
ephphatha opened this issue Dec 14, 2021 · 2 comments
Assignees

Comments

@ephphatha
Copy link

I'll preface this by saying I'm not 100% sure even this simple example program is performing the correct steps to recreate a renderer, any clarification on the expected usage would be great.

I'm running Windows 11 with a GTX 1070 outputting to a two monitor setup, the primary being a g-sync enabled display. Using GeForce driver version 497.09 (released Dec 01, 2022). I've created a simple program that creates a window, creates a renderer using the default driver (direct3d on my system) and then clears and redraws the display: https://gist.github.com/ephphatha/d0e68a79f38e8762145bdc47a16f8483 - Tested this with SDL 2.0.14, 2.0.16, 2.0.18.

On my system I can observe the clear colour changing. I can also trigger the recreation of a renderer to one of the SDL_RENDERER_PRESENTVSYNC enabled renderers once and the clear colour resets to black. I can continue to change colours and observe the window updating.

If I then trigger the recreation of the renderer with SDL_RENDERER_PRESENTVSYNC enabled a second time the display freezes on the last frame/clear colour. I can recreate the renderer without SDL_RENDERER_PRESENTVSYNC and it'll start updating as normal, but every attempt to go back to SDL_RENDERER_PRESENTVSYNC gives me the same "frozen" display. The window still responds to events and can be moved.

No error value is returned from any of the SDL API functions including when the renderer is recreated, the only error message I can get is by using SDL_SetAllPriority to WARN or higher, which gives me the following on every call to SDL_CreateRenderer:

ERROR: SDL failed to get a vertex buffer for this Direct3D 9 rendering batch!
ERROR: Dropping back to a slower method.
ERROR: This might be a brief hiccup, but if performance is bad, this is probably why.
ERROR: This error will not be logged again for this renderer.

This doesn't appear to be related to having g-sync active, I've tried turning it to "Fullscreen apps only", "Fullscreen and windowed apps", and disabling it completely with no change in behaviour.

@slouken slouken self-assigned this Dec 14, 2021
@slouken slouken added this to the 2.0.20 milestone Dec 14, 2021
@slouken
Copy link
Collaborator

slouken commented Dec 14, 2021

This looks like a bug in the D3D9 layer in Windows 11. It seems like the present is synchronized using a timer and that timer is never triggered if you recreate the device a second time. I tried using D3DPRESENT_INTERVAL_DEFAULT and that has the same problem. It happens with both D3D9 and D3D9Ex.

It looks like this bug isn't present in the D3D11 driver, so a possible workaround might be to set this hint before you create your renderer:
SDL_SetHint( SDL_HINT_RENDER_DRIVER, "direct3d11" );

@slouken
Copy link
Collaborator

slouken commented Dec 14, 2021

BTW, I fixed the vertex buffer warning. It was harmless and not related to the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants