You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be a bug in gles/command/set_push_constants where the indices into the actual push constant data are incorrect if the start_index is not zero. I believe this is because of a confusion in two different address spaces:
In the above image, I've highlighted in cyan variables that index into the command buffer's data_bytes. This is a separate space from the magenta which are the conceptual push constant indices. So if I push two sets of constants for two different draw calls with the same (magenta) start index - they will be stored at different (cyan) indices within data_bytes.
But we're wrongly combining them in the C::SetPushConstants command, because offset starts at start_offset, but the actual data is stored in range. When start_offset is zero, this doesn't matter - but with any other number, you end up with the wrong indices. For example in my app I was seeing:
panicked at 'range start index 448 out of range for slice of length 432', /.../wgpu/wgpu-hal/src/gles/queue.rs:1412:32
Description
Note: I have a possible fix for this bug: https://github.com/mistodon/wgpu/tree/gles_push_constant_fix - but I would like to clarify my understanding of the bug first.
There seems to be a bug in gles/command/set_push_constants where the indices into the actual push constant data are incorrect if the
start_index
is not zero. I believe this is because of a confusion in two different address spaces:In the above image, I've highlighted in cyan variables that index into the command buffer's
data_bytes
. This is a separate space from the magenta which are the conceptual push constant indices. So if I push two sets of constants for two different draw calls with the same (magenta) start index - they will be stored at different (cyan) indices withindata_bytes
.But we're wrongly combining them in the
C::SetPushConstants
command, becauseoffset
starts atstart_offset
, but the actual data is stored inrange
. Whenstart_offset
is zero, this doesn't matter - but with any other number, you end up with the wrong indices. For example in my app I was seeing:And with some janky logging:
Repro steps
I modified the
hello-triangle
example in a branch to demonstrate the bug: https://github.com/mistodon/wgpu/tree/gles_push_constants_bug_example/examples/hello-triangleTo run in browser, from the
hello-triangle
dir:Expected vs observed behavior
Expected behaviour is that push constants will not be out of range. Observed behaviour as described above.
Extra materials
Possible fix: https://github.com/mistodon/wgpu/tree/gles_push_constant_fix
Screenshot of above repro with the fix applied:
Platform
The text was updated successfully, but these errors were encountered: