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

Regression: Resources not included in reflection if used directly as array index #59

Open
alienself opened this issue Sep 27, 2024 · 3 comments

Comments

@alienself
Copy link

Hi,

I am seeing the reappearance of the same issue described in the following issue which got fixed: #52, the binding is not added to the resources array in the program entry.

struct BatchIndex {
   index: u32,
}
@group(0) @binding(2) var<uniform> batchIndex: BatchIndex;
@group(0) @binding(3) var<storage, read> batchOffsets: array<u32>;

@vertex
fn vertex_main(
  vertex: VertexInput
) -> VertexOutput {
    let batchOffset = batchOffsets[batchIndex.index]; // will NOT work
    // ...
}

Workaround but not ideal:

@vertex
fn vertex_main(
  vertex: VertexInput
) -> VertexOutput {
    let index = batchIndex;
    let batchOffset = batchOffsets[index]; // will work
    // ...
}
@brendan-duncan
Copy link
Owner

Sorry about that. Work deadlines are making me not test thoroughly. I don't know why I didn't add a unit test for that. I'll get it fixed up as soon as I get a chance.

@alienself
Copy link
Author

Okay no worries! Let me know when you are able to have a look.

@brendan-duncan
Copy link
Owner

brendan-duncan commented Sep 28, 2024

Getting a chance to look at this.

I do have a unit test for that shader code to index an array with uniform. I modified it with this version to index it with a struct member, and it passes. I checked

struct BatchIndex {
    index: u32,
}
@group(0) @binding(2) var<uniform>  batchIndex: BatchIndex;
@group(0) @binding(3) var<storage, read> batchOffsets: array<u32>;
@vertex
fn main() {
    let batchOffset = batchOffsets[batchIndex.index];
}

in the little tester page, https://brendan-duncan.github.io/wgsl_reflect/example.html, and it parsed fine.

This is from the github main branch. Is that what you're testing against?

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

No branches or pull requests

2 participants