Skip to content

Commit

Permalink
Fix unsetting vertex attributes in gles backend (#3706)
Browse files Browse the repository at this point in the history
Co-authored-by: Connor Fitzgerald <[email protected]>
  • Loading branch information
Azorlogh and cwfitzgerald authored Apr 19, 2023
1 parent 85fc427 commit c86f977
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ By @cwfitzgerald in [#3671](https://github.com/gfx-rs/wgpu/pull/3671).
- Reset the state of `SAMPLE_ALPHA_TO_COVERAGE` on queue reset. By @jleibs [#3589](https://github.com/gfx-rs/wgpu/pull/3589)
- Fix `Vertex buffer is not big enough for the draw call.` for ANGLE/Web when rendering with instance attributes on a single instance. By @wumpf in [#3597](https://github.com/gfx-rs/wgpu/pull/3597)
- Fix `copy_external_image_to_texture`, `copy_texture_to_texture` and `copy_buffer_to_texture` not taking the specified index into account if the target texture is a cube map, 2D texture array or cube map array. By @daxpedda [#3641](https://github.com/gfx-rs/wgpu/pull/3641)
- Fix disabling of vertex attributes with non-consecutive locations [#3706](https://github.com/gfx-rs/wgpu/pull/3706)

#### Metal

Expand Down
8 changes: 4 additions & 4 deletions wgpu-hal/src/gles/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,10 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
self.state.dirty_vbuf_mask = 0;
self.state.active_first_instance = 0;
self.state.color_targets.clear();
for index in 0..self.state.vertex_attributes.len() {
for vat in &self.state.vertex_attributes {
self.cmd_buffer
.commands
.push(C::UnsetVertexAttribute(index as u32));
.push(C::UnsetVertexAttribute(vat.location));
}
self.state.vertex_attributes.clear();
self.state.primitive = super::PrimitiveState::default();
Expand Down Expand Up @@ -761,10 +761,10 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
});
}
} else {
for index in 0..self.state.vertex_attributes.len() {
for vat in &self.state.vertex_attributes {
self.cmd_buffer
.commands
.push(C::UnsetVertexAttribute(index as u32));
.push(C::UnsetVertexAttribute(vat.location));
}
self.state.vertex_attributes.clear();

Expand Down
5 changes: 4 additions & 1 deletion wgpu/tests/regression/issue_3457.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ use wgpu::*;
/// submit, delete the second vertex buffer and `poll(Wait)`. Because we maintained the device,
/// the actual underlying buffer for the second vertex buffer is deleted, causing a draw call
/// that is invalid if the second attribute is still enabled.
///
/// We use non-consecutive vertex attribute locations (0 and 5) in order to also test
/// that we unset the correct locations (see PR #3706).
#[wasm_bindgen_test]
#[test]
fn pass_reset_vertex_buffer() {
Expand Down Expand Up @@ -60,7 +63,7 @@ fn pass_reset_vertex_buffer() {
VertexBufferLayout {
array_stride: 4,
step_mode: VertexStepMode::Vertex,
attributes: &vertex_attr_array![1 => Float32],
attributes: &vertex_attr_array![5 => Float32],
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion wgpu/tests/regression/issue_3457.wgsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
struct DoubleVertexIn {
@location(0) position: vec4<f32>,
@location(1) value: f32,
@location(5) value: f32,
}

struct DoubleVertexOut {
Expand Down

0 comments on commit c86f977

Please sign in to comment.