maplibre/render/resource/shader.rs
1//! Utilities for creating shader states.
2
3/// Describes how the vertex buffer is interpreted.
4#[derive(Clone, Debug)]
5pub struct VertexBufferLayout {
6 /// The stride, in bytes, between elements of this buffer.
7 pub array_stride: wgpu::BufferAddress,
8 /// How often this vertex buffer is "stepped" forward.
9 pub step_mode: wgpu::VertexStepMode,
10 /// The list of attributes which comprise a single vertex.
11 pub attributes: Vec<wgpu::VertexAttribute>,
12}
13
14/// Describes the fragment process in a render pipeline.
15#[derive(Clone, Debug, PartialEq, Eq)]
16pub struct FragmentState {
17 /// The shader source
18 pub source: &'static str,
19 /// The name of the entry point in the compiled shader. There must be a
20 /// function with this name in the shader.
21 pub entry_point: &'static str,
22 /// The color state of the render targets.
23 pub targets: Vec<Option<wgpu::ColorTargetState>>,
24}
25
26#[derive(Clone, Debug)]
27pub struct VertexState {
28 /// The shader source
29 pub source: &'static str,
30 /// The name of the entry point in the compiled shader. There must be a
31 /// function with this name in the shader.
32 pub entry_point: &'static str,
33 /// The format of any vertex buffers used with this pipeline.
34 pub buffers: Vec<VertexBufferLayout>,
35}