pub struct WgpuRenderer {
pub device: Arc<Device>,
pub queue: Arc<Queue>,
pub surface_config: SurfaceConfiguration,
pub msaa_sample_count: u32,
pub direct_line_pipeline: Option<RenderPipeline>,
pub direct_triangle_pipeline: Option<RenderPipeline>,
pub direct_point_pipeline: Option<RenderPipeline>,
pub grid_uniform_bind_group: BindGroup,
pub direct_uniform_bind_group: BindGroup,
pub depth_mode: DepthMode,
/* private fields */
}Expand description
High-performance WGPU renderer for interactive plotting
Fields§
§device: Arc<Device>§queue: Arc<Queue>§surface_config: SurfaceConfiguration§msaa_sample_count: u32§direct_line_pipeline: Option<RenderPipeline>§direct_triangle_pipeline: Option<RenderPipeline>§direct_point_pipeline: Option<RenderPipeline>§grid_uniform_bind_group: BindGroup§direct_uniform_bind_group: BindGroup§depth_mode: DepthModeDepth mapping mode for camera-based 3D pipelines.
Implementations§
Source§impl WgpuRenderer
impl WgpuRenderer
pub fn ensure_axes_uniform_capacity(&mut self, axes_count: usize)
Sourcepub async fn new(
device: Arc<Device>,
queue: Arc<Queue>,
surface_config: SurfaceConfiguration,
) -> Self
pub async fn new( device: Arc<Device>, queue: Arc<Queue>, surface_config: SurfaceConfiguration, ) -> Self
Create a new WGPU renderer
pub fn update_grid_uniforms(&mut self, uniforms: GridUniforms)
pub fn update_grid_uniforms_for_axes( &mut self, axes_index: usize, uniforms: GridUniforms, )
pub fn get_grid_uniform_bind_group_for_axes( &self, axes_index: usize, ) -> &BindGroup
pub fn set_depth_mode(&mut self, mode: DepthMode)
Sourcepub fn ensure_msaa(&mut self, requested_count: u32)
pub fn ensure_msaa(&mut self, requested_count: u32)
Ensure MSAA state matches requested count. Rebuild pipelines if changed.
pub fn ensure_depth_view(&mut self) -> Arc<TextureView>
pub fn ensure_msaa_color_view(&mut self) -> Arc<TextureView>
Sourcepub fn create_image_texture_and_bind_group(
&self,
width: u32,
height: u32,
data: &[u8],
) -> (Texture, TextureView, BindGroup)
pub fn create_image_texture_and_bind_group( &self, width: u32, height: u32, data: &[u8], ) -> (Texture, TextureView, BindGroup)
Create a GPU texture and bind group for an RGBA8 image
Sourcepub fn create_vertex_buffer(&self, vertices: &[Vertex]) -> Buffer
pub fn create_vertex_buffer(&self, vertices: &[Vertex]) -> Buffer
Create a vertex buffer from vertex data
Sourcepub fn vertex_buffer_from_sources(
&self,
gpu: Option<&GpuVertexBuffer>,
cpu_vertices: &[Vertex],
) -> Option<Arc<Buffer>>
pub fn vertex_buffer_from_sources( &self, gpu: Option<&GpuVertexBuffer>, cpu_vertices: &[Vertex], ) -> Option<Arc<Buffer>>
Choose the most efficient vertex buffer source for the provided data.
Sourcepub fn create_direct_point_vertices(
&self,
points: &[Vertex],
size_px: f32,
) -> Vec<Vertex>
pub fn create_direct_point_vertices( &self, points: &[Vertex], size_px: f32, ) -> Vec<Vertex>
Create a vertex buffer for direct points by expanding each point to a quad. This reuses Vertex but encodes corner index via tex_coords and marker size in normal.z
Sourcepub fn create_index_buffer(&self, indices: &[u32]) -> Buffer
pub fn create_index_buffer(&self, indices: &[u32]) -> Buffer
Create an index buffer from index data
Sourcepub fn update_uniforms(&mut self, view_proj: Mat4, model: Mat4)
pub fn update_uniforms(&mut self, view_proj: Mat4, model: Mat4)
Update uniform buffer with new matrices
pub fn update_uniforms_for_axes( &mut self, axes_index: usize, view_proj: Mat4, model: Mat4, )
Sourcepub fn get_uniform_bind_group(&self) -> &BindGroup
pub fn get_uniform_bind_group(&self) -> &BindGroup
Get the uniform bind group for rendering
pub fn get_uniform_bind_group_for_axes(&self, axes_index: usize) -> &BindGroup
Sourcepub fn ensure_pipeline(&mut self, pipeline_type: PipelineType)
pub fn ensure_pipeline(&mut self, pipeline_type: PipelineType)
Ensure pipeline exists for the specified type
Sourcepub fn get_pipeline(&self, pipeline_type: PipelineType) -> &RenderPipeline
pub fn get_pipeline(&self, pipeline_type: PipelineType) -> &RenderPipeline
Get a pipeline reference (pipeline must already exist)
pub fn ensure_grid_plane_pipeline(&mut self)
pub fn grid_plane_pipeline(&self) -> Option<&RenderPipeline>
Sourcepub fn create_point_style_bind_group(
&self,
style: PointStyleUniforms,
) -> (Buffer, BindGroup)
pub fn create_point_style_bind_group( &self, style: PointStyleUniforms, ) -> (Buffer, BindGroup)
Create style bind group for scatter points. Returns (buffer, bind_group).
Sourcepub fn begin_render_pass<'a>(
&'a self,
encoder: &'a mut CommandEncoder,
view: &'a TextureView,
_depth_view: &'a TextureView,
) -> RenderPass<'a>
pub fn begin_render_pass<'a>( &'a self, encoder: &'a mut CommandEncoder, view: &'a TextureView, _depth_view: &'a TextureView, ) -> RenderPass<'a>
Begin a render pass
Sourcepub fn render_vertices<'a>(
&'a mut self,
render_pass: &mut RenderPass<'a>,
pipeline_type: PipelineType,
vertex_buffer: &'a Buffer,
vertex_count: u32,
index_buffer: Option<(&'a Buffer, u32)>,
indirect: Option<(&'a Buffer, u64)>,
)
pub fn render_vertices<'a>( &'a mut self, render_pass: &mut RenderPass<'a>, pipeline_type: PipelineType, vertex_buffer: &'a Buffer, vertex_count: u32, index_buffer: Option<(&'a Buffer, u32)>, indirect: Option<(&'a Buffer, u64)>, )
Render vertices with the specified pipeline
Sourcepub fn ensure_direct_line_pipeline(&mut self)
pub fn ensure_direct_line_pipeline(&mut self)
Ensure direct line pipeline exists
Sourcepub fn ensure_direct_triangle_pipeline(&mut self)
pub fn ensure_direct_triangle_pipeline(&mut self)
Ensure direct triangle pipeline exists
Sourcepub fn ensure_direct_point_pipeline(&mut self)
pub fn ensure_direct_point_pipeline(&mut self)
Ensure direct point pipeline exists
Sourcepub fn ensure_image_pipeline(&mut self)
pub fn ensure_image_pipeline(&mut self)
Ensure image pipeline exists
Sourcepub fn update_direct_uniforms(
&mut self,
data_min: [f32; 2],
data_max: [f32; 2],
viewport_min: [f32; 2],
viewport_max: [f32; 2],
viewport_px: [f32; 2],
)
pub fn update_direct_uniforms( &mut self, data_min: [f32; 2], data_max: [f32; 2], viewport_min: [f32; 2], viewport_max: [f32; 2], viewport_px: [f32; 2], )
Update transformation uniforms for direct viewport rendering
pub fn update_direct_uniforms_for_axes( &mut self, axes_index: usize, data_min: [f32; 2], data_max: [f32; 2], viewport_min: [f32; 2], viewport_max: [f32; 2], viewport_px: [f32; 2], )
pub fn get_direct_uniform_bind_group_for_axes( &self, axes_index: usize, ) -> &BindGroup
Auto Trait Implementations§
impl !Freeze for WgpuRenderer
impl !RefUnwindSafe for WgpuRenderer
impl Send for WgpuRenderer
impl Sync for WgpuRenderer
impl Unpin for WgpuRenderer
impl UnsafeUnpin for WgpuRenderer
impl !UnwindSafe for WgpuRenderer
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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