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
use crate::{
pod::ViewArgs,
rendy::{command::RenderPassEncoder, factory::Factory},
submodules::{gather::CameraGatherer, uniform::DynamicUniform},
types::Backend,
};
use amethyst_core::ecs::World;
#[cfg(feature = "profiler")]
use thread_profiler::profile_scope;
#[derive(Debug)]
pub struct FlatEnvironmentSub<B: Backend> {
uniform: DynamicUniform<B, ViewArgs>,
}
impl<B: Backend> FlatEnvironmentSub<B> {
pub fn new(factory: &Factory<B>) -> Result<Self, failure::Error> {
Ok(Self {
uniform: DynamicUniform::new(factory, rendy::hal::pso::ShaderStageFlags::VERTEX)?,
})
}
pub fn raw_layout(&self) -> &B::DescriptorSetLayout {
self.uniform.raw_layout()
}
pub fn process(&mut self, factory: &Factory<B>, index: usize, world: &World) {
#[cfg(feature = "profiler")]
profile_scope!("process");
let projview = CameraGatherer::gather(world).projview;
self.uniform.write(factory, index, projview);
}
#[inline]
pub fn bind(
&self,
index: usize,
pipeline_layout: &B::PipelineLayout,
set_id: u32,
encoder: &mut RenderPassEncoder<'_, B>,
) {
self.uniform.bind(index, pipeline_layout, set_id, encoder);
}
}