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: RenderConfigRender 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: NoiseTexsizesvec4(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
impl GpuContext
Sourcepub async fn new(config: RenderConfig) -> Result<Self>
pub async fn new(config: RenderConfig) -> Result<Self>
Create a new GPU context.
Sourcepub fn from_device(
device: Arc<Device>,
queue: Arc<Queue>,
config: RenderConfig,
) -> Self
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).
fn build(device: Arc<Device>, queue: Arc<Queue>, config: RenderConfig) -> Self
Sourcefn make_noise_2d(
device: &Device,
queue: &Queue,
n: &NoiseTexture,
label: &str,
) -> (Texture, TextureView)
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.
Sourcefn make_noise_3d(
device: &Device,
queue: &Queue,
n: &NoiseTexture,
label: &str,
) -> (Texture, TextureView)
fn make_noise_3d( device: &Device, queue: &Queue, n: &NoiseTexture, label: &str, ) -> (Texture, TextureView)
Allocate an immutable 3D Rgba8Unorm noise texture (volume).
Sourcepub fn comp_aux_views_for<'a>(
&'a self,
chain: &'a ChainTextures,
) -> CompAuxViews<'a>
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.
Sourcepub fn set_resolution(&mut self, width: u32, height: u32)
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.
Sourcepub fn aspect_ratio(&self) -> f32
pub fn aspect_ratio(&self) -> f32
Get aspect ratio.
Auto Trait Implementations§
impl Freeze for GpuContext
impl !RefUnwindSafe for GpuContext
impl Send for GpuContext
impl Sync for GpuContext
impl Unpin for GpuContext
impl !UnwindSafe for GpuContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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