libdqg/renderer/
draw_pass.rs1use std::ops::Range;
2use crate::types::Color;
3use crate::renderer::types::IndexFormat;
4
5pub struct DrawPass<'a> {
6 pub(crate) pass: wgpu::RenderPass<'a>,
7 pub(crate) device: &'a wgpu::Device,
8 pub(crate) queue: &'a wgpu::Queue,
9 pub(crate) immediate_pipeline: &'a wgpu::RenderPipeline,
10 pub(crate) sprite_pipeline: &'a wgpu::RenderPipeline,
11 pub(crate) world_sprite_pipeline: &'a wgpu::RenderPipeline,
12 pub(crate) world_sprite_outline_pipeline: &'a wgpu::RenderPipeline,
13 pub(crate) model_pipeline: &'a wgpu::RenderPipeline,
14 pub(crate) model_outline_pipeline: &'a wgpu::RenderPipeline,
15 pub(crate) camera_bind_group: &'a wgpu::BindGroup,
16 pub(crate) screen_w: u32,
17 pub(crate) screen_h: u32,
18}
19
20impl DrawPass<'_> {
21 pub fn draw(&mut self, vertices: Range<u32>, instances: Range<u32>) {
22 self.pass.draw(vertices, instances);
23 }
24
25 pub fn draw_indexed(&mut self, indices: Range<u32>, base_vertex: i32, instances: Range<u32>) {
26 self.pass.draw_indexed(indices, base_vertex, instances);
27 }
28
29 pub fn set_viewport(&mut self, x: f32, y: f32, w: f32, h: f32, min_depth: f32, max_depth: f32) {
30 self.pass.set_viewport(x, y, w, h, min_depth, max_depth);
31 }
32
33 pub fn set_scissor_rect(&mut self, x: u32, y: u32, w: u32, h: u32) {
34 self.pass.set_scissor_rect(x, y, w, h);
35 }
36
37 pub fn set_blend_constant(&mut self, color: Color) {
38 self.pass.set_blend_constant(color.as_wgpu_color());
39 }
40
41 pub fn set_stencil_reference(&mut self, reference: u32) {
42 self.pass.set_stencil_reference(reference);
43 }
44
45 pub fn set_pipeline(&mut self, pipeline: &wgpu::RenderPipeline) {
46 self.pass.set_pipeline(pipeline);
47 }
48
49 pub fn set_vertex_buffer(&mut self, slot: u32, buffer: &wgpu::Buffer, offset: u64, size: u64) {
50 self.pass.set_vertex_buffer(slot, buffer.slice(offset..offset + size));
51 }
52
53 pub fn set_index_buffer(&mut self, buffer: &wgpu::Buffer, format: IndexFormat, offset: u64, size: u64) {
54 self.pass.set_index_buffer(buffer.slice(offset..offset + size), format.to_wgpu());
55 }
56
57 pub fn set_bind_group(&mut self, group: u32, bind_group: &wgpu::BindGroup, offsets: &[u32]) {
58 self.pass.set_bind_group(group, bind_group, offsets);
59 }
60
61 pub fn push_debug_group(&mut self, label: &str) {
62 self.pass.push_debug_group(label);
63 }
64
65 pub fn pop_debug_group(&mut self) {
66 self.pass.pop_debug_group();
67 }
68
69 pub fn insert_debug_marker(&mut self, label: &str) {
70 self.pass.insert_debug_marker(label);
71 }
72}