mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 14:55:05 +00:00
Initialize trackers with full selector
This commit is contained in:
parent
aa14f7f76d
commit
0569bc6956
@ -5,7 +5,7 @@
|
||||
use crate::{
|
||||
id::{BindGroupLayoutId, BufferId, DeviceId, SamplerId, TextureViewId},
|
||||
resource::TextureViewDimension,
|
||||
track::TrackerSet,
|
||||
track::{DUMMY_SELECTOR, TrackerSet},
|
||||
BufferAddress,
|
||||
LifeGuard,
|
||||
RefCount,
|
||||
@ -125,3 +125,9 @@ impl<B: hal::Backend> Borrow<RefCount> for BindGroup<B> {
|
||||
&self.life_guard.ref_count
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: hal::Backend> Borrow<()> for BindGroup<B> {
|
||||
fn borrow(&self) -> &() {
|
||||
&DUMMY_SELECTOR
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ use crate::{
|
||||
pipeline,
|
||||
resource,
|
||||
swap_chain,
|
||||
track::{Stitch, TrackerSet},
|
||||
track::{SEPARATE_DEPTH_STENCIL_STATES, Stitch, TrackerSet},
|
||||
BufferAddress,
|
||||
FastHashMap,
|
||||
Features,
|
||||
@ -931,10 +931,14 @@ impl<F: IdentityFilter<TextureViewId>> Global<F> {
|
||||
(desc.base_array_layer + desc.array_layer_count) as u16
|
||||
};
|
||||
let range = hal::image::SubresourceRange {
|
||||
aspects: match desc.aspect {
|
||||
resource::TextureAspect::All => texture.full_range.aspects,
|
||||
resource::TextureAspect::DepthOnly => hal::format::Aspects::DEPTH,
|
||||
resource::TextureAspect::StencilOnly => hal::format::Aspects::STENCIL,
|
||||
aspects: if SEPARATE_DEPTH_STENCIL_STATES {
|
||||
match desc.aspect {
|
||||
resource::TextureAspect::All => texture.full_range.aspects,
|
||||
resource::TextureAspect::DepthOnly => hal::format::Aspects::DEPTH,
|
||||
resource::TextureAspect::StencilOnly => hal::format::Aspects::STENCIL,
|
||||
}
|
||||
} else {
|
||||
texture.full_range.aspects
|
||||
},
|
||||
levels: desc.base_mip_level as u8 .. end_level,
|
||||
layers: desc.base_array_layer as u16 .. end_layer,
|
||||
|
@ -5,6 +5,7 @@
|
||||
use crate::{
|
||||
device::{BufferMapReadCallback, BufferMapWriteCallback},
|
||||
id::{DeviceId, SwapChainId, TextureId},
|
||||
track::DUMMY_SELECTOR,
|
||||
BufferAddress,
|
||||
Extent3d,
|
||||
LifeGuard,
|
||||
@ -103,6 +104,12 @@ impl<B: hal::Backend> Borrow<RefCount> for Buffer<B> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: hal::Backend> Borrow<()> for Buffer<B> {
|
||||
fn borrow(&self) -> &() {
|
||||
&DUMMY_SELECTOR
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum TextureDimension {
|
||||
@ -225,6 +232,12 @@ impl<B: hal::Backend> Borrow<RefCount> for Texture<B> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: hal::Backend> Borrow<hal::image::SubresourceRange> for Texture<B> {
|
||||
fn borrow(&self) -> &hal::image::SubresourceRange {
|
||||
&self.full_range
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum TextureAspect {
|
||||
@ -292,6 +305,12 @@ impl<B: hal::Backend> Borrow<RefCount> for TextureView<B> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: hal::Backend> Borrow<()> for TextureView<B> {
|
||||
fn borrow(&self) -> &() {
|
||||
&DUMMY_SELECTOR
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum AddressMode {
|
||||
@ -367,3 +386,9 @@ impl<B: hal::Backend> Borrow<RefCount> for Sampler<B> {
|
||||
&self.life_guard.ref_count
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: hal::Backend> Borrow<()> for Sampler<B> {
|
||||
fn borrow(&self) -> &() {
|
||||
&DUMMY_SELECTOR
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ use buffer::BufferState;
|
||||
use texture::TextureState;
|
||||
|
||||
|
||||
pub const SEPARATE_DEPTH_STENCIL_STATES: bool = false;
|
||||
|
||||
/// A single unit of state tracking. It keeps an initial
|
||||
/// usage as well as the last/current one, similar to `Range`.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
@ -349,7 +351,7 @@ impl<S: ResourceState> ResourceTracker<S> {
|
||||
/// the last read-only usage, if possible.
|
||||
///
|
||||
/// Returns the old usage as an error if there is a conflict.
|
||||
pub fn use_extend<'a, T: 'a + Borrow<RefCount>>(
|
||||
pub fn use_extend<'a, T: 'a + Borrow<RefCount> + Borrow<S::Selector>>(
|
||||
&mut self,
|
||||
storage: &'a Storage<T, S::Id>,
|
||||
id: S::Id,
|
||||
@ -366,7 +368,7 @@ impl<S: ResourceState> ResourceTracker<S> {
|
||||
/// Combines storage access by 'Id' with the transition that replaces
|
||||
/// the last usage with a new one, returning an iterator over these
|
||||
/// transitions.
|
||||
pub fn use_replace<'a, T: 'a + Borrow<RefCount>>(
|
||||
pub fn use_replace<'a, T: 'a + Borrow<RefCount> + Borrow<S::Selector>>(
|
||||
&mut self,
|
||||
storage: &'a Storage<T, S::Id>,
|
||||
id: S::Id,
|
||||
@ -412,6 +414,8 @@ impl<I: Copy + Debug + TypedId> ResourceState for PhantomData<I> {
|
||||
fn optimize(&mut self) {}
|
||||
}
|
||||
|
||||
pub const DUMMY_SELECTOR: () = ();
|
||||
|
||||
|
||||
/// A set of trackers for all relevant resources.
|
||||
#[derive(Debug)]
|
||||
|
@ -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(),
|
||||
},
|
||||
@ -158,7 +158,7 @@ impl ResourceState for TextureState {
|
||||
|
||||
for (mip_id, (mip_self, mip_other)) in self.mips.iter_mut().zip(&other.mips).enumerate() {
|
||||
let level = mip_id as hal::image::Level;
|
||||
for &mut (aspects, ref mut planes_self, planes_other) in &mut [
|
||||
for &mut (aspect, ref mut planes_self, planes_other) in &mut [
|
||||
(
|
||||
hal::format::Aspects::COLOR,
|
||||
&mut mip_self.color,
|
||||
@ -203,7 +203,7 @@ impl ResourceState for TextureState {
|
||||
let pending = PendingTransition {
|
||||
id,
|
||||
selector: hal::image::SubresourceRange {
|
||||
aspects,
|
||||
aspects: aspect,
|
||||
levels: level .. level + 1,
|
||||
layers: layers.clone(),
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user