Rename expectation to LayoutChange

This commit is contained in:
Dzmitry Malyshau 2019-03-31 14:09:13 -04:00
parent 5e041ab239
commit a8a6b45c9a
3 changed files with 15 additions and 15 deletions

View File

@ -14,7 +14,7 @@ pub struct BindGroupPair {
group_id: Stored<BindGroupId>,
}
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

View File

@ -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,

View File

@ -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(