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

Gpu Driven Rendering By Default #1342

Open
DrewRidley opened this issue Jan 29, 2021 · 9 comments
Open

Gpu Driven Rendering By Default #1342

DrewRidley opened this issue Jan 29, 2021 · 9 comments
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible C-Performance A change motivated by improving speed, memory usage or compile times

Comments

@DrewRidley
Copy link

Performant Rendering

the default gpu pipeline used in bevy should be one that takes in to consideration concepts from guides like this https://vkguide.dev/docs/gpudriven/gpu_driven_engines/. In this way, bevy can render objects with extreme performance, and will never bottleneck on the cpu. In general, GPU Driven Rendering has some tradeoffs that would need to be made, but would increase performance, sustainability, and would enhance any future efforts to include ray-tracing and other novel tech.

@twitchyliquid64
Copy link

Im pretty sure Bevy already uses the GPU @DrewDaPilot ?

@bjorn3
Copy link
Contributor

bjorn3 commented Jan 29, 2021

According to the article the idea is to compute what to draw on the GPU instead of CPU and then use an indirect draw call to actually draw what was computed. Webgpu probably doesn't have support for this.

@twitchyliquid64
Copy link

twitchyliquid64 commented Jan 29, 2021

The article link is broken. Got it working with some copypasta. Heres a direct link.

The idea is to compute what to draw on the GPU instead of CPU

Bevy does this

then use an indirect draw call to actually draw what was computed

Could you be more specific? If you mean scan out, this is already quite efficient on most systems - compositors rarely copy around rasters like the old days.

@twitchyliquid64
Copy link

Ohhh, based on the article i think the OP is talking about supporting the approach where compute shaders generate most/all of the graphics, in lieu of shipping big buffers back and forth from the CPU.

@cart
Copy link
Member

cart commented Jan 29, 2021

Yeah theres plenty of room for offloading more work to the gpu in Bevy. The big issue (in the short term) is that those techniques don't work well or at all on some platforms/apis (ex: webgl and older hardware). So in the short term while we sort out the core render apis I'd prefer to use more universally compatible techniques. This helps the codebase stay lean and easy to refactor. Engines like Bevy should be able to run everywhere by default and that will take precedence over squeezing every ounce of performance from each individual platform.

In the medium term when the renderer has stabilized, we can start specializing to squeeze the most out of each platform. We're already using modern apis, so this should be a "high level addition", not a major rewrite of everything.

Fortunately theres nothing stopping people from forging on ahead now. Its just not something I'm ready to invest in or maintain (yet)

@DrewRidley
Copy link
Author

That's a fair argument to be made, however, even WebGL can support GPU driven rendering through the use of vertex and fragment shaders. As for IOS/Android, compute shaders are usually a thing if the OpenGL ES version is 3.1 or above, but a gpu driven pipeline can exist without compute shaders. I think it's at least worth looking into and investigating the feasibility.

@bjorn3
Copy link
Contributor

bjorn3 commented Jan 29, 2021

While compute shaders can be emulated using vertex and fragment shaders, GPU driven rendering needs the draw indirect command to actually draw the generated drawlist. This is command is only supported by OpenGL with the extension ARB_draw_indirect, which requires OpenGL 3.1 or in the core with OpenGL 4.0. For WebGL neither version 1, nor version 2 provide it as part of the core or even as extension. This means that it is simply impossible to use GPU driven rendering with WebGL.

@DrewRidley
Copy link
Author

Fair enough, so maybe WebGL support would be finicky or impossible in the short term, but I think in the long-term WebGL will probably support such features when it updates to OpenGL ES 3.2. But I digress, I think it's still worth considering the extra performance on compatible platforms. I think it's fair to say that it's worth implementing since every platform supports indirect draw calls (except for WebGL).

@bjorn3
Copy link
Contributor

bjorn3 commented Jan 29, 2021

but I think in the long-term WebGL will probably support such features when it updates to OpenGL ES 3.2

If we don't get WebGPU before then.

@karroffel karroffel added C-Feature A new feature, making something new possible C-Performance A change motivated by improving speed, memory usage or compile times A-Rendering Drawing game state to the screen labels Jan 30, 2021
github-merge-queue bot pushed a commit that referenced this issue Mar 25, 2024
# Objective
- Implements a more efficient, GPU-driven
(#1342) rendering pipeline
based on meshlets.
- Meshes are split into small clusters of triangles called meshlets,
each of which acts as a mini index buffer into the larger mesh data.
Meshlets can be compressed, streamed, culled, and batched much more
efficiently than monolithic meshes.


![image](https://github.com/bevyengine/bevy/assets/47158642/cb2aaad0-7a9a-4e14-93b0-15d4e895b26a)

![image](https://github.com/bevyengine/bevy/assets/47158642/7534035b-1eb7-4278-9b99-5322e4401715)

# Misc
* Future work: #11518
* Nanite reference:
https://advances.realtimerendering.com/s2021/Karis_Nanite_SIGGRAPH_Advances_2021_final.pdf
Two pass occlusion culling explained very well:
https://medium.com/@mil_kru/two-pass-occlusion-culling-4100edcad501

---------

Co-authored-by: Ricky Taylor <rickytaylor26@gmail.com>
Co-authored-by: vero <email@atlasdostal.com>
Co-authored-by: François <mockersf@gmail.com>
Co-authored-by: atlas dostal <rodol@rivalrebels.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible C-Performance A change motivated by improving speed, memory usage or compile times
Projects
None yet
Development

No branches or pull requests

5 participants