pub struct WarpPipeline {
pipeline: RenderPipeline,
bind_group_layout: BindGroupLayout,
bind_group: BindGroup,
sampler: Sampler,
uniforms_buffer: Buffer,
vertex_buffer: Buffer,
index_buffer: Buffer,
index_count: u32,
vertex_count: u32,
user_pipeline: Option<UserWarpPipeline>,
target_format: TextureFormat,
}Fields§
§pipeline: RenderPipeline§bind_group_layout: BindGroupLayout§bind_group: BindGroup§sampler: Sampler§uniforms_buffer: Buffer§vertex_buffer: Buffer§index_buffer: Buffer§index_count: u32§vertex_count: u32§user_pipeline: Option<UserWarpPipeline>Active when a preset’s translated warp shader compiled
successfully. The default pipeline above stays built so failed
compiles fall back transparently. See UserWarpPipeline.
target_format: TextureFormatTarget format remembered so the user pipeline can be rebuilt after a preset swap without re-asking the caller.
Implementations§
Source§impl WarpPipeline
impl WarpPipeline
pub fn new( device: &Device, target_format: TextureFormat, prev_texture_view: &TextureView, mesh: &WarpMesh, ) -> Result<Self>
Sourcepub fn set_user_shader_with_plan(
&mut self,
device: &Device,
queue: &Queue,
wrapped_wgsl: &str,
prev_view: &TextureView,
aux: &WarpAuxViews<'_>,
user_views: [Option<TextureView>; 8],
) -> Result<()>
pub fn set_user_shader_with_plan( &mut self, device: &Device, queue: &Queue, wrapped_wgsl: &str, prev_view: &TextureView, aux: &WarpAuxViews<'_>, user_views: [Option<TextureView>; 8], ) -> Result<()>
Swap in a user-translated warp fragment shader. Mirrors
[CompPipeline::set_user_shader_with_plan]: the WGSL must have
already been validated by onedrop_codegen::ShaderCompiler, the
renderer threads prev_view + aux (noise textures, etc.) + a
per-preset user_views array of disk-loaded textures.
On success the warp pass uses the user pipeline; on failure the default mesh-warp pipeline keeps running.
Sourcepub fn reset_to_default(&mut self)
pub fn reset_to_default(&mut self)
Drop the user warp shader and route the pass back through the
engine’s default warp.wgsl. Idempotent.
Sourcepub fn has_user_shader(&self) -> bool
pub fn has_user_shader(&self) -> bool
true when the user pipeline is currently driving the warp
pass.
Sourcepub fn update_user_uniforms(&self, queue: &Queue, uniforms: &ShaderUniforms)
pub fn update_user_uniforms(&self, queue: &Queue, uniforms: &ShaderUniforms)
Upload ShaderUniforms to the user pipeline’s uniform buffer.
Caller passes the same ShaderUniforms the comp pass receives
— q-channels, time, audio levels, roam vectors, etc.
Sourcepub fn rebind_user_textures(
&mut self,
device: &Device,
prev_view: &TextureView,
aux: &WarpAuxViews<'_>,
)
pub fn rebind_user_textures( &mut self, device: &Device, prev_view: &TextureView, aux: &WarpAuxViews<'_>, )
Rebind the user pipeline’s texture views after a resize. No-op
when no user shader is active. The renderer threads the new
prev_view + refreshed aux (blur/noise views may have been
recreated by [ChainTextures] on resize).
fn create_bind_group( device: &Device, layout: &BindGroupLayout, uniforms_buffer: &Buffer, prev_texture_view: &TextureView, sampler: &Sampler, ) -> BindGroup
Sourcepub fn rebind_prev_texture(
&mut self,
device: &Device,
prev_texture_view: &TextureView,
)
pub fn rebind_prev_texture( &mut self, device: &Device, prev_texture_view: &TextureView, )
Re-create the bind group after the prev texture view is invalidated (e.g., on resize).
pub fn update_uniforms( &self, queue: &Queue, decay: f32, aspect: f32, flags: u32, )
Sourcepub fn rebuild_mesh(&mut self, device: &Device, mesh: &WarpMesh)
pub fn rebuild_mesh(&mut self, device: &Device, mesh: &WarpMesh)
Reallocate the vertex + index buffers for a different-sized mesh.
Used by MilkRenderer::set_mesh_size when the user picks a new
mesh quality at runtime. The bind group is unaffected because it
references the prev-texture view, not the vertex buffer.
Sourcepub fn update_vertices(&self, queue: &Queue, vertices: &[WarpVertex])
pub fn update_vertices(&self, queue: &Queue, vertices: &[WarpVertex])
Upload new per-vertex warped UVs.
vertices.len() must equal the original mesh vertex count.
Sourcepub fn render(&self, encoder: &mut CommandEncoder, output_view: &TextureView)
pub fn render(&self, encoder: &mut CommandEncoder, output_view: &TextureView)
Issue draw commands. Caller owns the encoder.
When the user warp pipeline is active (set_user_shader_with_plan
has succeeded), delegate to it; the vertex/index buffers are
shared so the per-frame mesh upload still applies. Otherwise the
engine’s hand-written warp.wgsl runs as before.
pub fn vertex_count(&self) -> u32
Auto Trait Implementations§
impl Freeze for WarpPipeline
impl !RefUnwindSafe for WarpPipeline
impl Send for WarpPipeline
impl Sync for WarpPipeline
impl Unpin for WarpPipeline
impl !UnwindSafe for WarpPipeline
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