GpuContext

Struct GpuContext 

Source
pub struct GpuContext {
Show 14 fields pub device: Arc<Device>, pub queue: Arc<Queue>, pub config: RenderConfig, pub noise_lq_texture: Texture, pub noise_lq_view: TextureView, pub noise_mq_texture: Texture, pub noise_mq_view: TextureView, pub noise_hq_texture: Texture, pub noise_hq_view: TextureView, pub noisevol_lq_texture: Texture, pub noisevol_lq_view: TextureView, pub noisevol_hq_texture: Texture, pub noisevol_hq_view: TextureView, pub noise_texsizes: NoiseTexsizes,
}
Expand description

Shared GPU resources: device + queue + the procedural noise pack that every chain samples from. Per-chain feedback textures (render, prev, final, blur1/2/3, blur_scratch) used to live here too; they have moved to ChainTextures so each rendering chain can own its own feedback loop without crossing the streams. The primary chain’s textures are still owned by GpuContext for convenience — secondary chains during transitions own their own ChainTextures inside crate::RenderChain.

Fields§

§device: Arc<Device>

WGPU device.

§queue: Arc<Queue>

Command queue.

§config: RenderConfig

Render configuration (resolution, format).

§noise_lq_texture: Texture§noise_lq_view: TextureView§noise_mq_texture: Texture§noise_mq_view: TextureView§noise_hq_texture: Texture§noise_hq_view: TextureView§noisevol_lq_texture: Texture§noisevol_lq_view: TextureView§noisevol_hq_texture: Texture§noisevol_hq_view: TextureView§noise_texsizes: NoiseTexsizes

vec4(w, h, 1/w, 1/h) per texture, available to the wrapper as texsize_<name> constants without going through a uniform buffer.

Implementations§

Source§

impl GpuContext

Source

pub async fn new(config: RenderConfig) -> Result<Self>

Create a new GPU context.

Source

pub fn from_device( device: Arc<Device>, queue: Arc<Queue>, config: RenderConfig, ) -> Self

Create a GPU context from an existing device and queue. Used when sharing one GPU device across multiple components (e.g. the GUI passes its surface device into the engine).

Source

fn build(device: Arc<Device>, queue: Arc<Queue>, config: RenderConfig) -> Self

Source

fn make_noise_2d( device: &Device, queue: &Queue, n: &NoiseTexture, label: &str, ) -> (Texture, TextureView)

Allocate an immutable 2D Rgba8Unorm noise texture and upload its bytes. Used for noise_lq / noise_mq / noise_hq — small fixed- resolution textures that live for the program’s lifetime and are never re-rendered.

Source

fn make_noise_3d( device: &Device, queue: &Queue, n: &NoiseTexture, label: &str, ) -> (Texture, TextureView)

Allocate an immutable 3D Rgba8Unorm noise texture (volume).

Source

pub fn comp_aux_views_for<'a>( &'a self, chain: &'a ChainTextures, ) -> CompAuxViews<'a>

Bundle the comp-pass auxiliary texture views for the given chain (blur pyramid + noise pack + previous-frame display) into a borrow group. The chain provides the per-chain views (blur + prev); this context provides the shared noise views.

Source

pub fn set_resolution(&mut self, width: u32, height: u32)

Update the recorded resolution; the renderer is responsible for re-allocating each chain’s ChainTextures separately.

Source

pub fn aspect_ratio(&self) -> f32

Get aspect ratio.

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<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.

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> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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,