CompPipeline

Struct CompPipeline 

Source
pub struct CompPipeline {
Show 16 fields default_pipeline: RenderPipeline, user_pipeline: Option<RenderPipeline>, pipeline_layout: PipelineLayout, target_format: TextureFormat, bind_group_layout: BindGroupLayout, bind_group: BindGroup, sampler: Sampler, sampler_fw: Sampler, sampler_fc: Sampler, sampler_pw: Sampler, sampler_pc: Sampler, uniforms_buffer: Buffer, fallback_user_view: TextureView, user_texture_views: [TextureView; 8], cached_input_view: TextureView, cached_aux: OwnedCompAuxViews,
}

Fields§

§default_pipeline: RenderPipeline

Built once at startup and never replaced. Used when no preset is loaded, when a preset has no comp_shader, or when the user shader fails to compile / validate.

§user_pipeline: Option<RenderPipeline>

Active when a preset’s translated user shader compiled successfully. Always built against the same pipeline_layout and bind group as the default, so the bind group can stay valid across swaps.

§pipeline_layout: PipelineLayout§target_format: TextureFormat§bind_group_layout: BindGroupLayout§bind_group: BindGroup§sampler: Sampler

sampler_main — the original linear/clamp-to-edge sampler the comp pass has always used. Bound at binding(2). Backwards-compatible with every user shader the wrapper has shipped.

§sampler_fw: Sampler

Four MD2 sampler variants — name encodes filter × address mode: fw = filtered+wrap, fc = filtered+clamp, pw = point+wrap, pc = point+clamp. Each authored preset chooses one per sample site (tex2D(sampler_fw_main, uv), …); the translator maps the name to the correct binding at translation time. Order in bindings 11..14.

§sampler_fc: Sampler§sampler_pw: Sampler§sampler_pc: Sampler§uniforms_buffer: Buffer§fallback_user_view: TextureView

1×1 opaque white texture bound into any unfilled user-texture slot. Owned by the pipeline so a default CompPipeline::new (no texture pool wired up) still produces a complete bind group.

§user_texture_views: [TextureView; 8]

One view per user-texture slot. Initially all set to the fallback; set_user_shader_with_plan updates them with pool-backed views. Kept across rebind_input_texture calls so resize doesn’t clobber the active preset’s textures.

§cached_input_view: TextureView

Latest input view + aux views, retained so we can rebuild the bind group when the user texture set changes mid-frame without re-passing them. Cloned once per resize / preset load.

§cached_aux: OwnedCompAuxViews

Implementations§

Source§

impl CompPipeline

Source

pub fn new( device: &Device, queue: &Queue, target_format: TextureFormat, input_texture_view: &TextureView, aux: &CompAuxViews<'_>, ) -> Result<Self>

Source

pub fn set_user_shader( &mut self, device: &Device, wrapped_wgsl: &str, ) -> Result<()>

Swap in a user fragment shader for the comp pass.

wrapped_wgsl must be a complete WGSL module exposing vs_main and fs_main and binding the standard ShaderUniforms layout — exactly what onedrop-codegen::wrap_user_comp_shader produces. The bind group layout is reused, so the existing bind group stays valid.

Returns Ok(()) on a successful swap. wgpu’s runtime validation may surface errors only at draw time (uncaptured-error callback) — the caller upstream is expected to have already validated via naga in ShaderCompiler::compile(), so reaching this method with broken WGSL is a programming error.

Source

pub fn reset_to_default(&mut self, device: &Device)

Drop the user shader and route the comp pass back through the default pipeline. Idempotent. User-texture slots are reset to the 1×1 white fallback so the bind group stays consistent — the default pipeline doesn’t sample them, but bind-group validity is layout-driven, not shader-driven.

Source

pub fn has_user_shader(&self) -> bool

true when a user shader is currently active. Tests / GUI use this to surface whether the visible frame is the user’s authored composite or the engine’s gamma-only fallback.

Source

pub fn comp_aux_views(&self) -> CompAuxViews<'_>

Borrow the comp pass’s cached CompAuxViews. The renderer hands these to the warp pipeline’s user-shader path so the same noise textures + prev_main view get bound on both passes.

Source

fn create_bind_group( device: &Device, layout: &BindGroupLayout, uniforms_buffer: &Buffer, input_texture_view: &TextureView, sampler: &Sampler, aux: &CompAuxViews<'_>, sampler_fw: &Sampler, sampler_fc: &Sampler, sampler_pw: &Sampler, sampler_pc: &Sampler, user_textures: &[&TextureView; 8], ) -> BindGroup

Source

pub fn rebind_input_texture( &mut self, device: &Device, input_texture_view: &TextureView, aux: &CompAuxViews<'_>, )

Re-create the bind group after any input texture view is invalidated (e.g., on resize). The noise texture views never change after init — the caller forwards them through aux unchanged. User-texture views are preserved across resize — the active preset’s textures stay bound.

Source

fn rebuild_bind_group(&mut self, device: &Device)

Rebuild the bind group from the currently-cached views + user textures. Internal helper called by both rebind_input_texture (resize) and set_user_shader_with_plan (preset load).

Source

fn install_user_textures(&mut self, views: [Option<TextureView>; 8])

Swap user texture views before a user-shader pipeline swap. Pass None in any slot to bind the 1×1 white fallback. Length must be USER_TEXTURE_SLOTS. Doesn’t rebuild the bind group — the renderer calls set_user_shader_with_plan next, which rebuilds in one go.

Source

pub fn set_user_shader_with_plan( &mut self, device: &Device, wrapped_wgsl: &str, views: [Option<TextureView>; 8], ) -> Result<()>

Swap in a user fragment shader and bind disk-loaded user textures per the supplied slot list. The renderer prepares views by resolving the preset’s onedrop_hlsl::TextureBindingPlan against its crate::TexturePool — see MilkRenderer::set_user_comp_shader.

wrapped_wgsl must be a complete WGSL module exposing vs_main and fs_main and binding the standard ShaderUniforms + user-texture layout — exactly what onedrop-codegen::wrap_user_comp_shader_with_plan produces.

Source

pub fn update_uniforms(&self, queue: &Queue, uniforms: &ShaderUniforms)

Upload a fully-populated ShaderUniforms for this frame.

Source

pub fn render(&self, encoder: &mut CommandEncoder, output_view: &TextureView)

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,