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

Effect batching #73

Open
djeedai opened this issue Oct 29, 2022 · 0 comments
Open

Effect batching #73

djeedai opened this issue Oct 29, 2022 · 0 comments
Labels
C - bug Something isn't working C - enhancement New feature or request

Comments

@djeedai
Copy link
Owner

djeedai commented Oct 29, 2022

Effect batching, the process of processing multiple compatible* effect instances with a single compute or render shader pass, is currently broken due to the fact it doesn't account for the variability in GpuSpawnerParams, which is per-effect data and cannot be batched. Since particles do not "remember" which effect they're part of, this means we effectively cannot batch them.

One possible fix would be to leverage the "particle index", passed in the thread ID of compute shaders and the instance of the render shader, to encode both the index of the particle into the particle buffer and the index of the effect in the batch it's from. This would allow each particle to index an array of GpuSpawnerParams in the various shaders, to consume the proper data for their effect. For example, with a 32-bit index, it's reasonable to assume only 24 bits (16 millions particles; 512 MB buffer @ 32B/particle) are needed for the particle itself, leaving 8 bits to batch together up to 256 compatible effect instances.

*compatible = which has the same GPU layout and shaders.

@djeedai djeedai added the C - enhancement New feature or request label Oct 29, 2022
djeedai added a commit that referenced this issue Oct 29, 2022
Batching of compatible effects (and in particular, multiple instances of
the same effect) is currently broken due to the inability for a particle
to tell which effect it's associated with, and therefore which
`GpuSpawnerParams` struct it should index.

To prevent batching to trigger, set the minimum buffer capacity to 1
particle, which effectively means each effect will get a dedicated GPU
buffer that just fits it, preventing another effect from using the same
buffer, and effectively disabling batching.o

Bug: #73
djeedai added a commit that referenced this issue Oct 29, 2022
Batching of compatible effects (and in particular, multiple instances of
the same effect) is currently broken due to the inability for a particle
to tell which effect it's associated with, and therefore which
`GpuSpawnerParams` struct it should index.

To prevent batching to trigger, set the minimum buffer capacity to 1
particle, which effectively means each effect will get a dedicated GPU
buffer that just fits it, preventing another effect from using the same
buffer, and effectively disabling batching.o

Bug: #73
@djeedai djeedai added the C - bug Something isn't working label Oct 29, 2022
djeedai added a commit that referenced this issue Oct 29, 2022
Batching of compatible effects (and in particular, multiple instances of
the same effect) is currently broken due to the inability for a particle
to tell which effect it's associated with, and therefore which
`GpuSpawnerParams` struct it should index.

To prevent batching to trigger, set the minimum buffer capacity to 1
particle, which effectively means each effect will get a dedicated GPU
buffer that just fits it, preventing another effect from using the same
buffer, and effectively disabling batching.o

Bug: #73
@djeedai djeedai mentioned this issue Jul 31, 2023
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C - bug Something isn't working C - enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant