From a8a6b45c9a82a06bf0d317cf5bf54a6e0e572103 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sun, 31 Mar 2019 14:09:13 -0400 Subject: [PATCH] Rename expectation to LayoutChange --- wgpu-native/src/command/bind.rs | 14 +++++++------- wgpu-native/src/command/compute.rs | 10 +++++----- wgpu-native/src/command/render.rs | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/wgpu-native/src/command/bind.rs b/wgpu-native/src/command/bind.rs index d66d5ae5f..ed491d4d9 100644 --- a/wgpu-native/src/command/bind.rs +++ b/wgpu-native/src/command/bind.rs @@ -14,7 +14,7 @@ pub struct BindGroupPair { group_id: Stored, } -pub enum Expectation { +pub enum LayoutChange { Unchanged, Match(BindGroupId), Mismatch, @@ -78,7 +78,7 @@ impl BindGroupEntry { pub fn expect_layout( &mut self, bind_group_layout_id: BindGroupLayoutId, - ) -> Expectation { + ) -> LayoutChange { let some = Some(bind_group_layout_id); if self.expected_layout_id != some { self.expected_layout_id = some; @@ -86,11 +86,11 @@ impl BindGroupEntry { Some(BindGroupPair { layout_id, ref group_id, - }) if layout_id == bind_group_layout_id => Expectation::Match(group_id.value), - Some(_) | None => Expectation::Mismatch, + }) if layout_id == bind_group_layout_id => LayoutChange::Match(group_id.value), + Some(_) | None => LayoutChange::Mismatch, } } else { - Expectation::Unchanged + LayoutChange::Unchanged } } @@ -121,13 +121,13 @@ pub struct Binder { } impl Binder { - pub(crate) fn cut_expectations(&mut self, length: usize) { + pub(crate) fn reset_expectations(&mut self, length: usize) { for entry in self.entries[length ..].iter_mut() { entry.expected_layout_id = None; } } - /// Attemt to set the value of the specified bind group index. + /// Attempt to set the value of the specified bind group index. /// Returns Some() when the new bind group is ready to be actually bound /// (i.e. compatible with current expectations). Also returns an iterator /// of bind group IDs to be bound with it: those are compatible bind groups diff --git a/wgpu-native/src/command/compute.rs b/wgpu-native/src/command/compute.rs index fb770302d..0a3f617b5 100644 --- a/wgpu-native/src/command/compute.rs +++ b/wgpu-native/src/command/compute.rs @@ -1,5 +1,5 @@ use crate::{ - command::bind::{Binder, Expectation}, + command::bind::{Binder, LayoutChange}, hub::HUB, track::{Stitch, TrackerSet}, BindGroupId, CommandBuffer, CommandBufferId, ComputePassId, ComputePipelineId, Stored, @@ -111,10 +111,10 @@ pub extern "C" fn wgpu_compute_pass_set_pipeline( let pipeline_layout_guard = HUB.pipeline_layouts.read(); let pipeline_layout = &pipeline_layout_guard[pipeline.layout_id]; - let bing_group_guard = HUB.bind_groups.read(); + let bind_group_guard = HUB.bind_groups.read(); pass.binder.pipeline_layout_id = Some(pipeline.layout_id.clone()); - pass.binder.cut_expectations(pipeline_layout.bind_group_layout_ids.len()); + pass.binder.reset_expectations(pipeline_layout.bind_group_layout_ids.len()); for (index, (entry, &bgl_id)) in pass .binder @@ -123,8 +123,8 @@ pub extern "C" fn wgpu_compute_pass_set_pipeline( .zip(&pipeline_layout.bind_group_layout_ids) .enumerate() { - if let Expectation::Match(bg_id) = entry.expect_layout(bgl_id) { - let desc_set = &bing_group_guard[bg_id].raw; + if let LayoutChange::Match(bg_id) = entry.expect_layout(bgl_id) { + let desc_set = &bind_group_guard[bg_id].raw; unsafe { pass.raw.bind_compute_descriptor_sets( &pipeline_layout.raw, diff --git a/wgpu-native/src/command/render.rs b/wgpu-native/src/command/render.rs index 4446722ad..3bc4a6eeb 100644 --- a/wgpu-native/src/command/render.rs +++ b/wgpu-native/src/command/render.rs @@ -1,5 +1,5 @@ use crate::{ - command::bind::{Binder, Expectation}, + command::bind::{Binder, LayoutChange}, conv, device::RenderPassContext, hub::HUB, @@ -265,7 +265,7 @@ pub extern "C" fn wgpu_render_pass_set_pipeline( let bind_group_guard = HUB.bind_groups.read(); pass.binder.pipeline_layout_id = Some(pipeline.layout_id.clone()); - pass.binder.cut_expectations(pipeline_layout.bind_group_layout_ids.len()); + pass.binder.reset_expectations(pipeline_layout.bind_group_layout_ids.len()); for (index, (entry, &bgl_id)) in pass .binder @@ -274,7 +274,7 @@ pub extern "C" fn wgpu_render_pass_set_pipeline( .zip(&pipeline_layout.bind_group_layout_ids) .enumerate() { - if let Expectation::Match(bg_id) = entry.expect_layout(bgl_id) { + if let LayoutChange::Match(bg_id) = entry.expect_layout(bgl_id) { let desc_set = &bind_group_guard[bg_id].raw; unsafe { pass.raw.bind_graphics_descriptor_sets(