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

Fix buffer target corruption in WebGL2 backend. #506

Merged
merged 4 commits into from
Sep 11, 2021

Conversation

hadronized
Copy link
Owner

@hadronized hadronized commented May 3, 2021

In the OpenGL 3.3 backend, there is an optimization that allows a
buffer object to be created and bound to a given target (for instance
ARRAY_BUFFER) and allows to rebind the buffer later to another
target (for instance ELEMENT_ARRAY_BUFFER). That optimization is handy
because it allows to dissociate data storage from data representation,
allowing to send a bunch of bytes and then using the target as source of
representation.

Well, turns out that optimization doesn’t work in WebGL2, so this commit
implements a way to keep track of what a buffer was created as and then
re-use that information every time we need to bind the buffer. That
should fix #483 (and probably other bugs no one has encountered yet).

Some integration tests are needed to ensure the fix does what it should.

@hadronized hadronized force-pushed the fix/483-webgl-index-buffer-corruption branch 3 times, most recently from 352a90a to 0bb49ae Compare May 4, 2021 15:03
@hadronized hadronized force-pushed the fix/483-webgl-index-buffer-corruption branch 3 times, most recently from f40d179 to e3c1628 Compare June 28, 2021 17:46
In the OpenGL 3.3 backend, there is an optimization that allows a
buffer object to be created and bound to a given target (for instance
`ARRAY_BUFFER`) and allows to rebind the buffer later to another
target (for instance `ELEMENT_ARRAY_BUFFER`). That optimization is handy
because it allows to dissociate data storage from data representation,
allowing to send a bunch of bytes and then using the target as source of
representation.

Well, turns out that optimization doesn’t work in WebGL2, so this commit
implements a way to keep track of what a buffer was created as and then
re-use that information every time we need to bind the buffer. That
should fix #483 (and probably other bugs no one has encountered yet).

Some integration tests are needed to ensure the fix does what it should.
This relates to #483 for testing corruption of `indices_mut()`. The
example showcases the bug when used on the `web` executor (no issue with
the `desktop` one).

This bug is fixed in the next commit.
The bug was due to still using `bind_array_buffer` when streaming buffer
updates to the GPU.

Relates to #483.
@hadronized hadronized force-pushed the fix/483-webgl-index-buffer-corruption branch from e3c1628 to ba6d169 Compare September 5, 2021 20:07
@hadronized
Copy link
Owner Author

Merging this as it’s already a fix, and I will continue fixing the buffer problems by redesigning them a bit. It shouldn’t be a big breaking change but it might still be one so I want to do that in another PR.

@hadronized hadronized force-pushed the fix/483-webgl-index-buffer-corruption branch from a33140b to e491d41 Compare September 6, 2021 22:05
@hadronized hadronized merged commit 11b0e62 into master Sep 11, 2021
@hadronized hadronized deleted the fix/483-webgl-index-buffer-corruption branch September 11, 2021 11:18
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

Successfully merging this pull request may close these issues.

WebGL bindBuffer & bufferSubData errors/corruption when using Tess::indices_mut()
1 participant