-
Notifications
You must be signed in to change notification settings - Fork 4
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
Using bindgroup other than 0 #6
Comments
Is it possible that you're confusing So if we look at the example in the README: let worker = AppComputeWorkerBuilder::new(world)
// Add a uniform variable
.add_uniform("uni", &5.)
// Add a staging buffer, it will be available from
// both CPU and GPU land.
.add_staging("values", &[1., 2., 3., 4.])
// Create a compute pass from your compute shader
// and define used variables
.add_pass::<SimpleShader>([4, 1, 1], &["uni", "values"])
.build(); Then @group(0) @binding(0)
var<uniform> uni: f32; And @group(0) @binding(1)
var<storage, read_write> my_storage: array<f32>; |
Sorry if it wasn't clear, I meant the @group(0) @binding(0)
var<uniform> uni: f32; @group(1) @binding(0)
var<storage, read_write> my_storage: array<f32>; |
Ahh yes, I see what you mean. I must say I've never actually used a group, and have to admit I'm not sure what it's for. But anyway, it's set in the first arg here: |
@rYuuk What use-case are you trying to solve by not using the default group 0 in your compute shader? |
I had a compute shader which calculate height change for vertex, following is small example. So instead using binding index which going till 10 for me I wanted to just change the group to 1 to make it easier manage. #import "shaders/crater.wgsl"::calculateCraterDepth
@group(0) @binding(0)
var<storage, read> vertices: array<vec3<f32>>;
@group(0) @binding(1)
var<storage, read_write> heights: array<f32>;
@compute @workgroup_size(1024)
fn main(@builtin(global_invocation_id) id: vec3<u32>) {
let index = id.x;
if (index >= num_vertices) {
return;
}
// some other stuff here ...
let craterDepth = calculateCraterDepth(vertexPos);
let finalHeight = 1 + craterDepth + noiseSum;
heights[index] = finalHeight;
} @group(1) @binding(0)
var<uniform> num_craters: u32;
@group(1) @binding(1)
var<uniform> rim_steepness: f32;
fn calculateCraterDepth(vertexPos: vec3<f32>) -> f32 {
var craterHeight: f32 = 0.0;
// some calculation here
retrun craterHeight;
} |
Ah I understand your usecase. I'm pretty busy right now, so I won't be able to work on this within short order. If you want to make a PR implementing this, I would be happy to review it and merge it in. If you do make a PR, try to avoid creating any breaking changes with the current API. |
I am not sure, how to use bind group other than 0 for my compute shader. Is this functionality available?
It seems that by default it goes to 0
The text was updated successfully, but these errors were encountered: