[][src]Trait wgpu_core::track::ResourceState

pub trait ResourceState: Clone + Default {
    type Id: Copy + Debug + TypedId;
    type Selector: Debug;
    type Usage: Debug;
    fn query(&self, selector: Self::Selector) -> Option<Self::Usage>;
fn change(
        &mut self,
        id: Self::Id,
        selector: Self::Selector,
        usage: Self::Usage,
        output: Option<&mut Vec<PendingTransition<Self>>>
    ) -> Result<(), PendingTransition<Self>>;
fn merge(
        &mut self,
        id: Self::Id,
        other: &Self,
        output: Option<&mut Vec<PendingTransition<Self>>>
    ) -> Result<(), PendingTransition<Self>>;
fn optimize(&mut self); }

The main trait that abstracts away the tracking logic of a particular resource type, like a buffer or a texture.

Associated Types

type Id: Copy + Debug + TypedId

Corresponding HUB identifier.

type Selector: Debug

A type specifying the sub-resources.

type Usage: Debug

Usage type for a Unit of a sub-resource.

Loading content...

Required methods

fn query(&self, selector: Self::Selector) -> Option<Self::Usage>

Check if all the selected sub-resources have the same usage, and return it.

Returns None if no sub-resources are intersecting with the selector, or their usage isn't consistent.

fn change(
    &mut self,
    id: Self::Id,
    selector: Self::Selector,
    usage: Self::Usage,
    output: Option<&mut Vec<PendingTransition<Self>>>
) -> Result<(), PendingTransition<Self>>

Change the last usage of the selected sub-resources.

If output is specified, it's filled with the PendingTransition objects corresponding to smaller sub-resource transitions. The old usage is replaced by the new one.

If output is None, the old usage is extended with the new usage. The error is returned if it's not possible, specifying the conflicting transition. Extension can only be done for read-only usages.

fn merge(
    &mut self,
    id: Self::Id,
    other: &Self,
    output: Option<&mut Vec<PendingTransition<Self>>>
) -> Result<(), PendingTransition<Self>>

Merge the state of this resource tracked by a different instance with the current one.

Same rules for output apply as with change(): last usage state is either replaced (when output is provided) with a PendingTransition pushed to this vector, or extended with the other read-only usage, unless there is a usage conflict, and the error is generated (returning the conflict).

fn optimize(&mut self)

Try to optimize the internal representation.

Loading content...

Implementations on Foreign Types

impl<I: Copy + Debug + TypedId> ResourceState for PhantomData<I>[src]

type Id = I

type Selector = ()

type Usage = ()

Loading content...

Implementors

impl ResourceState for TextureState[src]

type Id = TextureId

type Selector = SubresourceRange

type Usage = TextureUsage

impl ResourceState for BufferState[src]

type Id = BufferId

type Selector = ()

type Usage = BufferUsage

Loading content...