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

[0.4] Transition and binding fixes #389

Merged
merged 3 commits into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## v0.4.1 (28-11-2019)
- fixed depth/stencil transitions
- fixed dynamic offset iteration

## v0.4 (03-11-2019)
- Platforms: removed OpenGL/WebGL support temporarily
- Features:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wgpu-native/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wgpu-native"
version = "0.4.0"
version = "0.4.1"
authors = [
"Dzmitry Malyshau <kvark@mozilla.com>",
"Joshua Groves <josh@joshgroves.com>",
Expand Down
42 changes: 19 additions & 23 deletions wgpu-native/src/command/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{

use smallvec::{smallvec, SmallVec};

use std::convert::identity;
use std::slice;

pub const DEFAULT_BIND_GROUPS: usize = 4;
type BindGroupMask = u8;
Expand All @@ -38,16 +38,21 @@ pub enum Provision {
Changed { was_compatible: bool },
}

struct TakeSome<I> {
iter: I,
#[derive(Clone)]
pub struct FollowUpIter<'a> {
iter: slice::Iter<'a, BindGroupEntry>,
}
impl<T, I> Iterator for TakeSome<I>
where
I: Iterator<Item = Option<T>>,
{
type Item = T;
fn next(&mut self) -> Option<T> {
self.iter.next().and_then(identity)
impl<'a> Iterator for FollowUpIter<'a> {
type Item = (BindGroupId, &'a [BufferAddress]);
fn next(&mut self) -> Option<Self::Item> {
self.iter
.next()
.and_then(|entry| {
Some((
entry.actual_value()?,
entry.dynamic_offsets.as_slice(),
))
})
}
}

Expand Down Expand Up @@ -165,11 +170,7 @@ impl Binder {
bind_group_id: BindGroupId,
bind_group: &BindGroup<B>,
offsets: &[BufferAddress],
) -> Option<(
PipelineLayoutId,
impl 'a + Iterator<Item = BindGroupId>,
impl 'a + Iterator<Item = &'a BufferAddress>,
)> {
) -> Option<(PipelineLayoutId, FollowUpIter<'a>)> {
log::trace!("\tBinding [{}] = group {:?}", index, bind_group_id);
debug_assert_eq!(B::VARIANT, bind_group_id.backend());

Expand All @@ -186,14 +187,9 @@ impl Binder {
log::trace!("\t\tbinding up to {}", end);
Some((
self.pipeline_layout_id?,
TakeSome {
iter: self.entries[index + 1 .. end]
.iter()
.map(|entry| entry.actual_value()),
},
self.entries[index + 1 .. end]
.iter()
.flat_map(|entry| entry.dynamic_offsets.as_slice()),
FollowUpIter {
iter: self.entries[index + 1 .. end].iter(),
}
))
} else {
log::trace!("\t\tskipping above compatible {}", compatible_count);
Expand Down
6 changes: 3 additions & 3 deletions wgpu-native/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,20 @@ pub fn compute_pass_set_bind_group<B: GfxBackend>(
&*texture_guard,
);

if let Some((pipeline_layout_id, follow_up_sets, follow_up_offsets)) = pass
if let Some((pipeline_layout_id, follow_ups)) = pass
.binder
.provide_entry(index as usize, bind_group_id, bind_group, offsets)
{
let bind_groups = iter::once(bind_group.raw.raw())
.chain(follow_up_sets.map(|bg_id| bind_group_guard[bg_id].raw.raw()));
.chain(follow_ups.clone().map(|(bg_id, _)| bind_group_guard[bg_id].raw.raw()));
unsafe {
pass.raw.bind_compute_descriptor_sets(
&pipeline_layout_guard[pipeline_layout_id].raw,
index as usize,
bind_groups,
offsets
.iter()
.chain(follow_up_offsets)
.chain(follow_ups.flat_map(|(_, offsets)| offsets))
.map(|&off| off as hal::command::DescriptorSetOffset),
);
}
Expand Down
6 changes: 3 additions & 3 deletions wgpu-native/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,20 +258,20 @@ pub fn render_pass_set_bind_group<B: GfxBackend>(

pass.trackers.merge_extend(&bind_group.used);

if let Some((pipeline_layout_id, follow_up_sets, follow_up_offsets)) = pass
if let Some((pipeline_layout_id, follow_ups)) = pass
.binder
.provide_entry(index as usize, bind_group_id, bind_group, offsets)
{
let bind_groups = iter::once(bind_group.raw.raw())
.chain(follow_up_sets.map(|bg_id| bind_group_guard[bg_id].raw.raw()));
.chain(follow_ups.clone().map(|(bg_id, _)| bind_group_guard[bg_id].raw.raw()));
unsafe {
pass.raw.bind_graphics_descriptor_sets(
&&pipeline_layout_guard[pipeline_layout_id].raw,
index as usize,
bind_groups,
offsets
.iter()
.chain(follow_up_offsets)
.chain(follow_ups.flat_map(|(_, offsets)| offsets))
.map(|&off| off as hal::command::DescriptorSetOffset),
);
}
Expand Down
2 changes: 1 addition & 1 deletion wgpu-native/src/track/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl ResourceState for TextureState {
let pending = PendingTransition {
id,
selector: hal::image::SubresourceRange {
aspects: hal::format::Aspects::COLOR,
aspects: aspect,
levels: level .. level + 1,
layers: range.clone(),
},
Expand Down