gfx-rs / gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
http://gfx-rs.github.io/
Apache License 2.0
5.35k stars 549 forks source link

UpdateBuffer command fails when using WebGL #2811

Open MillerJames opened 5 years ago

MillerJames commented 5 years ago

Short info header:

When the GL backend processes an UpdateBuffer command, it always binds the buffer using buffer::Role::Vertex. When using WebGL, updating an index buffer this way causes a runtime error: INVALID_OPERATION: bindBuffer: element array buffers can not be bound to a different target.

Passing the buffer's actual role into gfx::core::command::Buffer::update_buffer() resolves this, but I realize this isn't ideal, since it modifies the public interface for command::Buffer. Is there a simpler way to accomplish this that I'm just missing? You can see my changes in this PR: tangmi/gfx#4

(I'm happy to PR changes here as well if we land on a good approach)

kvark commented 5 years ago

Looks good! Mind making this a PR against 0.18 branch (with a patch version bump for GL backend)?