Skip to content

Compute example - #22

Draft
samoylovfp wants to merge 8 commits into
Bevy-Rust-GPU:masterfrom
samoylovfp:compute-example
Draft

Compute example#22
samoylovfp wants to merge 8 commits into
Bevy-Rust-GPU:masterfrom
samoylovfp:compute-example

Conversation

@ProfLander

Copy link
Copy Markdown
Member

Thanks for putting in the effort on this - I've not had chance to test it yet, but if it runs and produces the expected output then I'd say it's a strong start!

@samoylovfp

Copy link
Copy Markdown
Author

Not yet. I need to read more about how bevy handles shaders and didn't have the energy to do so yet. Planning on taking another stab this or the next weekend

@samoylovfp

Copy link
Copy Markdown
Author

I hope that I am missing something obvious, but the ways of achieving the result, that I see, feel a bit backwards.

The current problem is that the bevy compute pipeline requires the bevy shader handle,
which in the bevy compute example is obtained by loading the shader from a path via an AssetServer.
For rust-gpu shader we first need to convert it into a bevy shader to build the compute pipeline.

I initially thought it will be easiest to just do this processing in the render graph node "update" method,
but seems like the render-sub-app's World does not provide the Assets<Shader> or Assets<RustGpuBuilderOutput>,
so I cannot just take the shader builder output, convert it and put into the Assets<Shader>. Maybe it is possible by converting them in the bevy app and then "extracting" them into the render world, but it seems more backwards than other solutions.

I think maybe at this point the most straightforward way is to provide a custom AssetLoader, that builds a bevy Shader out of the RustGpuBuilderOutput,
then the bevy compute example requires little change,
only the addition of the assetloader and the name of the shader,
maybe using the "hashpound fragment" syntax to indicate the entrypoint; I'll try that.

@samoylovfp

Copy link
Copy Markdown
Author

I ended up in a situation where I think it should work, but it doesn't and it doesn't even complain that something is wrong.
I suspect I might have messed up the signature of the shader entrypoint, will try to debug it somehow

@samoylovfp

Copy link
Copy Markdown
Author

I'll take another stab in two weeks unless someone figures it out sooner

@tombh

tombh commented Jun 14, 2023

Copy link
Copy Markdown

Sounds like great progress, I'm excited to try it out!

@samoylovfp

Copy link
Copy Markdown
Author

Wasn't able to debug why nothing is showing, lost the remainder of my motivation reading through the SPIR-V specification. Might take another stab in a few months

@tombh

tombh commented Jul 6, 2023

Copy link
Copy Markdown

Ha yeah SPIR-V is pretty esoteric. Awesome work @samoylovfp 🙇

@tombh

tombh commented Nov 6, 2023

Copy link
Copy Markdown

That's great! Did you mean to post a link to the branch? Or were just mentioning it? I see the link now.

Do you think the notably slower frame rate is because of Bevy's rust-gpu integration? Or just because your implementation is prioritising proof of concept for now?

@tombh

tombh commented Nov 11, 2023

Copy link
Copy Markdown

That's a lot of great info and insight. Even if its slower, it's just great to know that it all works. I'm still a newbie to all this, so it'll take me a while to pore over everything.

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

Successfully merging this pull request may close these issues.

Compute example

3 participants