Skip to main content

Resource

Enum Resource 

Source
pub enum Resource {
    Buffer(Buffer),
    Texture(Texture),
    TextureView(TextureView),
    Sampler(Sampler),
    Array(ArrayHandle),
    BindGroup(BindGroup),
    Virtual,
}
Expand description

A wgpu resource owned by the graph, or a virtual node standing in for one.

This is the stored form, and the way to name a resource whose kind is only known at runtime: it is the erased ResHandle’s kind. Variants are thin — each holds the wgpu handle itself — so callers can keep working with raw wgpu and use the graph purely for bookkeeping.

Variants§

§

Buffer(Buffer)

A buffer (vertex, index, uniform or storage).

§

Texture(Texture)

A texture.

§

TextureView(TextureView)

A texture view, with the format it views its texture as.

§

Sampler(Sampler)

A sampler.

§

Array(ArrayHandle)

A flat array of fixed-size elements, held either in a storage buffer or in a texture.

The two are one kind rather than two because they are one thing to a caller: which of them an array lives in follows from the device, not from what the array holds. See ArrayHandle.

§

BindGroup(BindGroup)

A bind group.

§

Virtual

A virtual node: no wgpu handle, purely a graph citizen.

It carries no GPU resource of its own: it is what an id over Virtual resolves to, and it exists to group or stand in for other nodes. The edges leaving it express ownership or derivation rather than handle derivation, which makes it the natural aggregation root for a group of resources that live and die together (see Retention).

It is an ordinary node otherwise: it takes dependencies like any other, and replacing it swaps one virtual value for another — a node’s kind never changes — while marking the nodes built from it dirty.

Implementations§

Source§

impl Resource

Source

pub fn kind_name(&self) -> &'static str

The name of this resource’s kind.

The stored form erases the kind, so this is how a caller that only has a Resource — a graph-wide read, a debug dump — reports which of the stored kinds it is looking at. The name matches the ResourceKind type it stands for: "Buffer", "TextureView", "Virtual", and so on.

Trait Implementations§

Source§

impl Clone for Resource

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Resource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ArrayHandle> for Resource

Source§

fn from(value: ArrayHandle) -> Self

Converts to this type from the input type.
Source§

impl From<BindGroup> for Resource

Source§

fn from(value: BindGroup) -> Self

Converts to this type from the input type.
Source§

impl From<Buffer> for Resource

Source§

fn from(value: Buffer) -> Self

Converts to this type from the input type.
Source§

impl From<Sampler> for Resource

Source§

fn from(value: Sampler) -> Self

Converts to this type from the input type.
Source§

impl From<Texture> for Resource

Source§

fn from(value: Texture) -> Self

Converts to this type from the input type.
Source§

impl From<TextureView> for Resource

Source§

fn from(value: TextureView) -> Self

Converts to this type from the input type.
Source§

impl ResourceKind for Resource

Source§

fn borrow_from(resource: &Resource) -> Option<&Self>

Borrow this kind out of a stored Resource, or None when that resource is of another kind.
Source§

fn take_from(resource: Resource) -> Option<Self>

Take this kind out of a stored Resource, or None when that resource is of another kind.
Source§

fn into_resource(self) -> Resource

This value as a stored Resource.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more