From 5f1b3e56bc00eb3f805ffa8ae8ecde4a1bf09949 Mon Sep 17 00:00:00 2001 From: Inseok Lee Date: Sat, 30 Oct 2021 12:46:04 +0900 Subject: [PATCH] Unset existing vertex attributes on gles set_render_pipeline (#2131) --- wgpu-hal/src/gles/command.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wgpu-hal/src/gles/command.rs b/wgpu-hal/src/gles/command.rs index 3e5d74674b..7aaaf7fcf9 100644 --- a/wgpu-hal/src/gles/command.rs +++ b/wgpu-hal/src/gles/command.rs @@ -606,12 +606,6 @@ impl crate::CommandEncoder for super::CommandEncoder { unsafe fn set_render_pipeline(&mut self, pipeline: &super::RenderPipeline) { self.state.topology = conv::map_primitive_topology(pipeline.primitive.topology); - for index in self.state.vertex_attributes.len()..pipeline.vertex_attributes.len() { - self.cmd_buffer - .commands - .push(C::UnsetVertexAttribute(index as u32)); - } - if self .private_caps .contains(super::PrivateCapabilities::VERTEX_BUFFER_LAYOUT) @@ -626,6 +620,13 @@ impl crate::CommandEncoder for super::CommandEncoder { }); } } else { + for index in 0..self.state.vertex_attributes.len() { + self.cmd_buffer + .commands + .push(C::UnsetVertexAttribute(index as u32)); + } + self.state.vertex_attributes.clear(); + self.state.dirty_vbuf_mask = 0; // copy vertex attributes for vat in pipeline.vertex_attributes.iter() {