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 unsetting vertex attributes in gles backend #3706

Merged
merged 4 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,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