Closed Gordon-F closed 3 years ago
bindBuffer: ELEMENT_ARRAY_BUFFER, WebGLBuffer - ID: 1 getError -> INVALID_OPERATION bindBuffer: ARRAY_BUFFER, WebGLBuffer - ID: 1 vertexAttribPointer: 0, 3, FLOAT, false, 24, 0 vertexAttribDivisor: 0, 0 enableVertexAttribArray: 0
Weird, so it's a vertex buffer? If so, why are we binding it to the ELEMENT_ARRAY_BUFFER
point first?
Does the user code try to use the same buffer for both vertices and indices, perhaps?
Weird, so it's a vertex buffer? If so, why are we binding it to the ELEMENT_ARRAY_BUFFER point first?
I will try to investigate it. Maybe we should check first if the buffer already bounded to another target and try to create a new one 🤔
Does the user code try to use the same buffer for both vertices and indices, perhaps?
No, I used different buffers. Anyway, you can see the same error with any wgpu-rs
example that using an index buffer.
let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("VertexBuffer"),
contents: bytemuck::cast_slice(VERTICES),
usage: wgpu::BufferUsage::VERTEX,
});
let index_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("IndexBuffer"),
contents: bytemuck::cast_slice(INDICES),
usage: wgpu::BufferUsage::INDEX,
});
Also this issue, not an error for OpenGL ES
. The same examples work well with it. I don't understand why there is such a limitation for WebGL
.
IIRC, that's because the browser needs to know exactly what the indices are, so that it can prevent out-of-bounds access on vertex fetching. So it's a safety requirement on the Web...
@kvark Could buffer rebinding potentially be a problem for OpenGL ES
targets? Should we avoid it?
If it's not a problem for OpenGL ES
we should properly check buffer binding and create a new clear buffer only on WebGL
(because of extra performance costs).
I don't think it will affect GLES in any way, no. Having a WebGL-specific workaround sounds fine.
From WebGL docs:
SpectorJS trace:
Note: Error was found with code from https://github.com/gfx-rs/gfx/pull/3668