1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
use draw_state::target;
use {Resources, IndexType, InstanceCount, VertexCount};
use {pso, shade, tex};
use state as s;
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
pub enum ClearColor {
Float([f32; 4]),
Int([i32; 4]),
Uint([u32; 4]),
}
pub type InstanceOption = Option<(InstanceCount, VertexCount)>;
#[allow(missing_docs)]
pub trait CommandBuffer<R: Resources> {
fn clone_empty(&self) -> Self;
fn reset(&mut self);
fn bind_pipeline_state(&mut self, R::PipelineStateObject);
fn bind_vertex_buffers(&mut self, pso::VertexBufferSet<R>);
fn bind_constant_buffers(&mut self, &[pso::ConstantBufferParam<R>]);
fn bind_global_constant(&mut self, shade::Location, shade::UniformValue);
fn bind_resource_views(&mut self, &[pso::ResourceViewParam<R>]);
fn bind_unordered_views(&mut self, &[pso::UnorderedViewParam<R>]);
fn bind_samplers(&mut self, &[pso::SamplerParam<R>]);
fn bind_pixel_targets(&mut self, pso::PixelTargetSet<R>);
fn bind_index(&mut self, R::Buffer, IndexType);
fn set_scissor(&mut self, target::Rect);
fn set_ref_values(&mut self, s::RefValues);
fn update_buffer(&mut self, R::Buffer, data: &[u8], offset: usize);
fn update_texture(&mut self, R::Texture, tex::Kind, Option<tex::CubeFace>,
data: &[u8], tex::RawImageInfo);
fn generate_mipmap(&mut self, R::ShaderResourceView);
fn clear_color(&mut self, R::RenderTargetView, ClearColor);
fn clear_depth_stencil(&mut self, R::DepthStencilView,
Option<target::Depth>, Option<target::Stencil>);
fn call_draw(&mut self, VertexCount, VertexCount, InstanceOption);
fn call_draw_indexed(&mut self, VertexCount, VertexCount,
VertexCount, InstanceOption);
}
macro_rules! impl_clear {
{ $( $ty:ty = $sub:ident[$a:expr, $b:expr, $c:expr, $d:expr], )* } => {
$(
impl From<$ty> for ClearColor {
fn from(v: $ty) -> ClearColor {
ClearColor::$sub([v[$a], v[$b], v[$c], v[$d]])
}
}
)*
}
}
impl_clear! {
[f32; 4] = Float[0, 1, 2, 3],
[f32; 3] = Float[0, 1, 2, 0],
[f32; 2] = Float[0, 1, 0, 0],
[i32; 4] = Int [0, 1, 2, 3],
[i32; 3] = Int [0, 1, 2, 0],
[i32; 2] = Int [0, 1, 0, 0],
[u32; 4] = Uint [0, 1, 2, 3],
[u32; 3] = Uint [0, 1, 2, 0],
[u32; 2] = Uint [0, 1, 0, 0],
}
impl From<f32> for ClearColor {
fn from(v: f32) -> ClearColor {
ClearColor::Float([v, 0.0, 0.0, 0.0])
}
}
impl From<i32> for ClearColor {
fn from(v: i32) -> ClearColor {
ClearColor::Int([v, 0, 0, 0])
}
}
impl From<u32> for ClearColor {
fn from(v: u32) -> ClearColor {
ClearColor::Uint([v, 0, 0, 0])
}
}