1use std::ops::Range;
2
3use crate::{Binding, BufferId, NodeKey, PassId, ProgramId, Size, TextureId};
4
5#[derive(Debug, Clone, Copy, PartialEq)]
6pub enum LoadOp {
7 Load,
8 Clear(wgpu::Color),
9}
10
11#[derive(Debug, Clone, Copy, PartialEq)]
12pub struct RenderTargetRef {
13 pub texture: TextureId,
14 pub load: LoadOp,
15 pub store: wgpu::StoreOp,
16}
17
18#[derive(Debug, Clone, Copy, PartialEq, Eq)]
19pub struct ScissorRect {
20 pub x: u32,
21 pub y: u32,
22 pub width: u32,
23 pub height: u32,
24}
25
26#[derive(Debug, Clone, PartialEq, Eq)]
27pub struct Draw {
28 pub vertices: Range<u32>,
29 pub instances: Range<u32>,
30}
31
32#[derive(Debug, Clone, PartialEq, Eq)]
33pub struct DrawIndexed {
34 pub indices: Range<u32>,
35 pub base_vertex: i32,
36 pub instances: Range<u32>,
37}
38
39#[derive(Debug, Clone, PartialEq, Eq)]
40pub enum DrawCommand {
41 Draw(Draw),
42 DrawIndexed(DrawIndexed),
43}
44
45#[derive(Debug, Clone)]
46pub struct RenderPassDesc {
47 pub label: Option<String>,
48 pub owner: Option<NodeKey>,
49 pub program: ProgramId,
50 pub targets: Vec<RenderTargetRef>,
51 pub bindings: Vec<Binding>,
52 pub vertex_buffers: Vec<BufferId>,
53 pub index_buffer: Option<(BufferId, wgpu::IndexFormat)>,
54 pub draw: DrawCommand,
55 pub scissor: Option<ScissorRect>,
56}
57
58#[derive(Debug, Clone, Copy, PartialEq, Eq)]
59pub struct Dispatch {
60 pub x: u32,
61 pub y: u32,
62 pub z: u32,
63}
64
65#[derive(Debug, Clone, Copy, PartialEq, Eq)]
66pub enum ComputeDispatch {
67 Direct(Dispatch),
68 Indirect { buffer: BufferId, offset: u64 },
69}
70
71impl From<Dispatch> for ComputeDispatch {
72 fn from(dispatch: Dispatch) -> Self {
73 Self::Direct(dispatch)
74 }
75}
76
77#[derive(Debug, Clone)]
78pub struct ComputePassDesc {
79 pub label: Option<String>,
80 pub owner: Option<NodeKey>,
81 pub program: ProgramId,
82 pub bindings: Vec<Binding>,
83 pub dispatch: ComputeDispatch,
84}
85
86#[derive(Debug, Clone)]
87pub struct CopyTextureDesc {
88 pub label: Option<String>,
89 pub source: TextureId,
90 pub destination: TextureId,
91 pub origin: wgpu::Origin3d,
92 pub size: Size,
93}
94
95#[derive(Debug, Clone)]
96pub enum PassDesc {
97 Render(RenderPassDesc),
98 Compute(ComputePassDesc),
99 CopyTexture(CopyTextureDesc),
100}
101
102#[derive(Debug, Clone)]
103pub struct Pass {
104 pub id: PassId,
105 pub desc: PassDesc,
106}