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

SDL3: Make metal the default renderer on Apple platforms #11150

Open
andreasgrabher opened this issue Oct 10, 2024 · 6 comments
Open

SDL3: Make metal the default renderer on Apple platforms #11150

andreasgrabher opened this issue Oct 10, 2024 · 6 comments

Comments

@andreasgrabher
Copy link

Because the gpu renderer has multiple issues when used in threaded applications (#11048, #9698) I think metal should be the default renderer on all Apple platforms. The metal renderer does not suffer from these limitations. Multi-threading should work out of the box in 2024.

@slime73
Copy link
Contributor

slime73 commented Oct 10, 2024

What about all the other platforms? Is this just a feature request to make using SDL_Render on another (single) thread a supported situation?

@andreasgrabher
Copy link
Author

I don't know if renderers that support threaded rendering are available on other plaforms or how the gpu renderer behaves on other platforms. Therefore I opened this issue only for Apple platforms.

But of course there should be a thread-safe renderer default on any platform if available.

@icculus
Copy link
Collaborator

icculus commented Oct 10, 2024

What is the specific issue with the GPU backend? Is it just the Present operation has to happen on the main thread? For the Metal GPU backend we can dispatch that to main.

@slouken
Copy link
Collaborator

slouken commented Oct 10, 2024

What is the specific issue with the GPU backend? Is it just the Present operation has to happen on the main thread? For the Metal GPU backend we can dispatch that to main.

It's this call that needs to be made on the main thread:

SDL_GetWindowSizeInPixels(window, &w, &h);

@andreasgrabher
Copy link
Author

These functions are called from the secondary thread:

SDL_RenderClear(sdlRenderer);
SDL_RenderTexture(sdlRenderer, fbTexture, NULL, &screenRect);
SDL_RenderTexture(sdlRenderer, uiTexture, NULL, &screenRect);
/* Sleeps until next VSYNC */
SDL_RenderPresent(sdlRenderer);

@Akaricchi
Copy link
Contributor

Multi-threading should work out of the box in 2024.

Hot take: SDL_Render is absolutely not a "2024" API. If you want to live in 2024, use the GPU API directly. It has great support for multi-threading.

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

5 participants