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

Win10 direct3d & SDL_HINT_RENDER_BATCHING, "0" breaks the renderer #4933

Closed
AntTheAlchemist opened this issue Nov 9, 2021 · 10 comments
Closed
Assignees
Milestone

Comments

@AntTheAlchemist
Copy link
Contributor

A recent change to the current source has caused this bug. I don't seem to be getting any resize events when the window is resized by dragging the window to resize or with calls to SDL_SetWindowFullscreen() to restore from full screen. Only happens if batching is turned off. I'm using the default renderer (-1).

@slouken
Copy link
Collaborator

slouken commented Nov 9, 2021

What platform are you running on, and what renderer are you getting?

@slouken slouken added this to the 2.0.18 milestone Nov 9, 2021
@AntTheAlchemist
Copy link
Contributor Author

Windows 10 and the default renderer is direct3d. This doesn't happen on the opengl renderers.

Looking deeper. I am getting windows events but it seems the renderer is breaking and giving a Present(): INVALIDCALL error. The window doesn't get updated once you've tried to resized, or other things like restoring from full screen.

@AntTheAlchemist AntTheAlchemist changed the title Win10: SDL_HINT_RENDER_BATCHING, "0" blocks windows events and invalidates renderer Win10 direct3d & SDL_HINT_RENDER_BATCHING, "0" breaks the renderer Nov 9, 2021
@slouken
Copy link
Collaborator

slouken commented Nov 9, 2021

Do you have repro steps with the SDL test programs, or a standalone test case?

@slouken
Copy link
Collaborator

slouken commented Nov 9, 2021

I ran testsprite2 with --resizable --renderer direct3d, and confirmed that batching was off (which it is by default if you specify a renderer) and resized the window with no issues... ?

@slouken
Copy link
Collaborator

slouken commented Nov 9, 2021

Are you using render targets? They need to be recreated in response to the SDL_RENDER_TARGETS_RESET event.

@AntTheAlchemist
Copy link
Contributor Author

I'm not using render targets.

It's happening in my game controller diagnostics app which is fairly large. Let me set up a simple test case to see if I can reproduce it - stand by :-)

@slouken
Copy link
Collaborator

slouken commented Nov 9, 2021

I'm also happy to try to repro with your app, if you want.

@AntTheAlchemist
Copy link
Contributor Author

Just to note that the problem doesn't happen with the direct3d11 renderer either. Only the direct3d renderer seems affected.

My app's source isn't accessible online anywhere, so it's easier if I knock something up, which will help identify if it's something else that's sparking the problem. Nearly there, bare with...

@AntTheAlchemist
Copy link
Contributor Author

AntTheAlchemist commented Nov 10, 2021

@slouken I think I found found the trigger. SDL_SetHint(SDL_HINT_WINDOWS_USE_D3D9EX, "1"). You should be able to recreate the error with this example when resizing the window. You'll notice the title will display the error.

#include <SDL.h>
int main(int argc, char** argv) {
	SDL_SetHint(SDL_HINT_RENDER_BATCHING, "0");
	SDL_SetHint(SDL_HINT_WINDOWS_USE_D3D9EX, "1");
	SDL_Init(SDL_INIT_VIDEO);
	SDL_Window *w = SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 500, 500, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
	SDL_Renderer* r = SDL_CreateRenderer(w, -1, SDL_RENDERER_PRESENTVSYNC);
	bool running = true;
	SDL_FRect box = { 20, 20, 460, 460 };
	Uint8 colour = 0;
	while(running) {
		SDL_PumpEvents();
		SDL_Event event;
		while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, 0, SDL_LASTEVENT) == 1) {
			switch (event.type) {
			case SDL_QUIT:
				running = SDL_FALSE;
				break;
			}
		}
		SDL_SetRenderDrawColor(r, 0x00, 0x00, 0x00, 0xFF);
		SDL_RenderClear(r);
		SDL_SetRenderDrawColor(r, colour++, 0xFF, 0xFF, 0xFF);
		SDL_RenderFillRectF(r, &box);
		SDL_RenderPresent(r);
		if (SDL_GetError()) {
			SDL_SetWindowTitle(w, SDL_GetError());
			SDL_ClearError();
		}
	}
	SDL_DestroyRenderer(r);
	SDL_DestroyWindow(w);
	SDL_Quit();
	return 0;
}

@slouken
Copy link
Collaborator

slouken commented Nov 10, 2021

Hah, I found it. It's a one line fix.

Thanks for the good repro!

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