-
Notifications
You must be signed in to change notification settings - Fork 250
Compute a collatz sequence in the compute example #623
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
Conversation
I will change the SpirvBuilder invocation to only use the vulkan version which they need - i.e. make only the compute example use vulkan 1.1. (Edit: Done) I'm also not sure whether the dummy bind group still needs to exist, and ideally I'd remove the new unsafe code (i.e. using Additionally, now that multiple things are async it might be worth threading that through further. (Edit: I've made a custom I should also create a CPU runner, because this shader is simple enough that the naïve implementation of that would work fine (it seems to me that the CPU runner could live in I found the change/run/execute cycle to be excruciatingly slow - am I missing some tricks I can use to get it faster? For reference, my current invocation is: $ cargo run -p example-runner-wgpu -- --shader Compute |
examples/runners/wgpu/build.rs
Outdated
@@ -2,7 +2,7 @@ use spirv_builder::SpirvBuilder; | |||
use std::error::Error; | |||
|
|||
fn build_shader(path_to_create: &str) -> Result<(), Box<dyn Error>> { | |||
SpirvBuilder::new(path_to_create, "spirv-unknown-vulkan1.0").build()?; | |||
SpirvBuilder::new(path_to_create, "spirv-unknown-vulkan1.1").build()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's odd to me that this requires Vulkan 1.1. Playing with it, it seems it needs the VK_KHR_storage_buffer_storage_class
extension, probably because the SPV refers to StorageBuffer. If you look at the GLSL version and the spv it compiles to, it looks pretty different - it's a BufferBlock.
I'm not super expert on this, but it seems like it's using more advanced features than it really needs to, which might hurt compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forget if we documented this anywhere, but a decision made in rust-gpu is to be pretty opinionated in that we should only support non-deprecated SPIR-V features, and be pretty "modern" in that sense (for now at least - perhaps when we have more fundamentals in place, we can look at supporting older things). BufferBlock
is explicitly deprecated, replaced with Block
/StorageBuffer
, and so we don't plan on supporting BufferBlock
right now, and so require vulkan 1.1+ for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the only things left are:
|
If these performance counters are done correctly, then we should also add them to the other example, closing the saga of #259 I have also only now realised that I have inadvertently duplicated #360. I was just trying to show @raphlinus that rust-gpu can be used to make compute shaders 😅 |
97ee533
to
1c7df2a
Compare
59ccc4f
to
1870129
Compare
Build the compute shader for vulkan1.1 as required
These changes were made at the behest of @raphlinus.
The expected values can be found at https://oeis.org/A006877
Should we rename the example to
compute_collatz
?I'm also planning on integrating the overflow detection from wgpu. (Edit: Done - unfortunately can't use
checked_add
and friends (yet?))We also should insert the timing queries into this example, since wgpu now supports them.