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: RenderPipelineBuilt 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: Samplersampler_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: SamplerFour 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: TextureView1×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: TextureViewLatest 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: OwnedCompAuxViewsImplementations§
Source§impl CompPipeline
impl CompPipeline
pub fn new( device: &Device, queue: &Queue, target_format: TextureFormat, input_texture_view: &TextureView, aux: &CompAuxViews<'_>, ) -> Result<Self>
Sourcepub fn set_user_shader(
&mut self,
device: &Device,
wrapped_wgsl: &str,
) -> Result<()>
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.
Sourcepub fn reset_to_default(&mut self, device: &Device)
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.
Sourcepub fn has_user_shader(&self) -> bool
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.
Sourcepub fn comp_aux_views(&self) -> CompAuxViews<'_>
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.
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
Sourcepub fn rebind_input_texture(
&mut self,
device: &Device,
input_texture_view: &TextureView,
aux: &CompAuxViews<'_>,
)
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.
Sourcefn rebuild_bind_group(&mut self, device: &Device)
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).
Sourcefn install_user_textures(&mut self, views: [Option<TextureView>; 8])
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.
Sourcepub fn set_user_shader_with_plan(
&mut self,
device: &Device,
wrapped_wgsl: &str,
views: [Option<TextureView>; 8],
) -> Result<()>
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.
Sourcepub fn update_uniforms(&self, queue: &Queue, uniforms: &ShaderUniforms)
pub fn update_uniforms(&self, queue: &Queue, uniforms: &ShaderUniforms)
Upload a fully-populated ShaderUniforms for this frame.
pub fn render(&self, encoder: &mut CommandEncoder, output_view: &TextureView)
Auto Trait Implementations§
impl Freeze for CompPipeline
impl !RefUnwindSafe for CompPipeline
impl Send for CompPipeline
impl Sync for CompPipeline
impl Unpin for CompPipeline
impl !UnwindSafe for CompPipeline
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