-
Notifications
You must be signed in to change notification settings - Fork 439
/
Copy pathcamera.rs
51 lines (45 loc) · 1.56 KB
/
camera.rs
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
use cap_project::XY;
use crate::{frame_pipeline::FramePipeline, CompositeVideoFrameUniforms, DecodedFrame};
pub struct CameraLayer;
impl CameraLayer {
pub fn render(
pipeline: &mut FramePipeline,
camera_size: XY<u32>,
camera_frame: &DecodedFrame,
uniforms: &CompositeVideoFrameUniforms,
(texture, texture_view): (&wgpu::Texture, &wgpu::TextureView),
) {
let constants = pipeline.state.constants;
constants.queue.write_texture(
wgpu::ImageCopyTexture {
texture: &texture,
mip_level: 0,
origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All,
},
camera_frame,
wgpu::ImageDataLayout {
offset: 0,
bytes_per_row: Some(camera_size.x * 4),
rows_per_image: None,
},
wgpu::Extent3d {
width: camera_size.x,
height: camera_size.y,
depth_or_array_layers: 1,
},
);
pipeline.state.switch_output();
pipeline.encoder.do_render_pass(
pipeline.state.get_current_texture_view(),
&constants.composite_video_frame_pipeline.render_pipeline,
constants.composite_video_frame_pipeline.bind_group(
&constants.device,
&uniforms.to_buffer(&constants.device),
&texture_view,
pipeline.state.get_other_texture_view(),
),
wgpu::LoadOp::Load,
);
}
}