MCPcopy Create free account
hub / github.com/donkeyteethUX/iced_plot / encode

Method encode

src/plot_renderer/shader.rs:1567–1743  ·  view source on GitHub ↗
(&self, params: RenderParams)

Source from the content-addressed store, hash-verified

1565
1566 // Add vertical line vertices
1567 data.extend_from_slice(&top);
1568 data.extend_from_slice(&CROSSHAIR_RGBA);
1569 data.extend_from_slice(&bottom);
1570 data.extend_from_slice(&CROSSHAIR_RGBA);
1571
1572 let raw = bytemuck::cast_slice(&data);
1573 self.buffers.crosshairs = Some(VertexBuffer {
1574 buffer: device.create_buffer(&BufferDescriptor {
1575 label: Some("crosshairs vb"),
1576 size: raw.len() as u64,
1577 usage: BufferUsages::VERTEX | BufferUsages::COPY_DST,
1578 mapped_at_creation: false,
1579 }),
1580 vertex_count: 4,
1581 });
1582 if let Some(vb) = &self.buffers.crosshairs {
1583 queue.write_buffer(&vb.buffer, 0, raw);
1584 }
1585 }
1586
1587 /// Draws all plot content into an existing render pass (iced's main
1588 /// surface pass). The caller (iced's `shader::Primitive::draw` path) has
1589 /// already set the viewport to the widget bounds and the scissor to the
1590 /// clip bounds — the same state `encode` sets on its own passes.
1591 ///
1592 /// Rendering in-pass avoids tearing the surface render pass down per plot
1593 /// (`Load`/`Store` round-trips). On tile-based mobile GPUs (Mali/Adreno)
1594 /// that pass fragmentation triggered driver-level frame corruption: text
1595 /// drawn by other passes intermittently disappeared on screens containing
1596 /// plots.
1597 pub fn draw_in_pass(&self, pass: &mut iced::wgpu::RenderPass<'_>) {
1598 // Main content (grid, fills, lines, reference lines, markers)
1599 self.grid.draw(pass, &self.camera_bind_group);
1600 if let (Some(pipeline), Some(vb)) = (self.pipelines.fill.as_ref(), &self.buffers.fills) {
1601 pass.set_pipeline(pipeline);
1602 pass.set_bind_group(0, &self.camera_bind_group, &[]);
1603 pass.set_vertex_buffer(0, vb.buffer.slice(..));
1604 pass.draw(0..vb.vertex_count, 0..1);
1605 }
1606 if let (Some(pipeline), Some(lb)) = (self.pipelines.line.as_ref(), &self.buffers.lines) {
1607 pass.set_pipeline(pipeline);
1608 pass.set_bind_group(0, &self.camera_bind_group, &[]);
1609 pass.set_vertex_buffer(0, lb.buffer.slice(..));
1610 for seg in &lb.segments {
1611 pass.draw(seg.first_vertex..seg.first_vertex + seg.vertex_count, 0..1);
1612 }
1613 }
1614 if let (Some(pipeline), Some(lb)) = (self.pipelines.line.as_ref(), &self.buffers.reflines) {
1615 pass.set_pipeline(pipeline);
1616 pass.set_bind_group(0, &self.camera_bind_group, &[]);
1617 pass.set_vertex_buffer(0, lb.buffer.slice(..));
1618 for seg in &lb.segments {
1619 pass.draw(seg.first_vertex..seg.first_vertex + seg.vertex_count, 0..1);
1620 }
1621 }
1622 if let (Some(pipeline), Some(vb)) = (self.pipelines.marker.as_ref(), &self.buffers.markers)
1623 {
1624 pass.set_pipeline(pipeline);

Callers 1

renderMethod · 0.80

Calls 3

msaa_attachmentFunction · 0.85
target_attachmentFunction · 0.85
drawMethod · 0.45

Tested by

no test coverage detected