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

Why drawIndexed(indexCount) indexCount should > indexBuffer size? #5430

Closed
microaaron opened this issue Mar 23, 2024 · 3 comments · Fixed by #5441
Closed

Why drawIndexed(indexCount) indexCount should > indexBuffer size? #5430

microaaron opened this issue Mar 23, 2024 · 3 comments · Fixed by #5441
Labels
area: validation Issues related to validation, diagnostics, and error handling type: bug Something isn't working
Milestone

Comments

@microaaron
Copy link

microaaron commented Mar 23, 2024

Description
indexCount needs to be larger than indexBuffer size to operate normally, otherwise an error will be reported.

Repro steps

...
    var indexBuffer = device.createBuffer({
      size:36*4,
      usage:GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST,
      label:`indexBuffer`,
    });
    device.queue.writeBuffer( indexBuffer, 0, new Uint32Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35]), 0, 36 );
...
renderBundleEncoder.setIndexBuffer( indexBuffer, "uint32" );
renderBundleEncoder.drawIndexed( 36 );
...

Uncaptured WebGPU error: In a draw command, indexed:true indirect:false, caused by: Index 36 extends beyond limit 36. Did you bind the correct index buffer?

renderBundleEncoder.drawIndexed( 37 ); or larger will work properly.

This phenomenon only occurs in Firefox, in Chrome indexCount should <= indexBuffer size.

Expected vs observed behavior
Clearly describe what you get, and how it goes across your expectations.

Extra materials
Screenshots to help explain your problem.
Validation logs can be attached in case there are warnings and errors.
Zip-compressed API traces and GPU captures can also land here.

Platform
win10, Firefox Nightly 126.0a1

@Wumpf Wumpf added type: bug Something isn't working area: validation Issues related to validation, diagnostics, and error handling labels Mar 25, 2024
@Wumpf
Copy link
Member

Wumpf commented Mar 25, 2024

had a quick browse and indeed the max index limit is broken
https://github.com/gfx-rs/wgpu/blob/trunk/wgpu-core/src/command/bundle.rs#L169

it says if last_index <= index_limit {but should be if last_index > index_limit {

easy to fix, but needs to have a unit test added - concerning that this wasn't caught

@Wumpf Wumpf added this to the v0.20 milestone Mar 25, 2024
@microaaron
Copy link
Author

easy to fix, but needs to have a unit test added - concerning that this wasn't caught

Thanks. This function is very commonly used, please fix it as soon as possible.

@Wumpf
Copy link
Member

Wumpf commented Mar 25, 2024

likely won't get to it myself super soon. contributions welcome! :)

microaaron added a commit to microaaron/wgpu that referenced this issue Mar 25, 2024
…Count)

[fix bug gfx-rs#5430] index_limit judgment error in drawIndexed(indexCount)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: validation Issues related to validation, diagnostics, and error handling type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants