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

SDL_GPU: Prevent allocating/copying uniform buffers when possible #72

Open
flibitijibibo opened this issue Sep 12, 2024 · 1 comment
Open
Assignees

Comments

@flibitijibibo
Copy link
Collaborator

sdlgpu.c's update_uniform_buffer function stands out in profiles of FNA3D trace data. For OpenGL we were able to reduce glUniform's impact on CPU performance by memcmp'ing the buffer first, and only pushing when a change actually happened...

https://github.com/icculus/mojoshader/blob/main/mojoshader_opengl.c#L2813

... but sdlgpu.c currently allocs a buffer for every constant buffer push:

https://github.com/icculus/mojoshader/blob/main/mojoshader_sdlgpu.c#L195

We should try to remove this middle buffer and shadow buffer state, this can improve performance quite a bit!

@flibitijibibo flibitijibibo self-assigned this Sep 16, 2024
@flibitijibibo
Copy link
Collaborator Author

Latest revision removes most of the malloc calls and a lot of the other goo that was in update_uniform_buffer. The remaining issue is the memcpys, which mostly comes down to figuring out the scope of the uniform buffer state and shadowing state accordingly.

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

1 participant