ranim_render/graph/
clear.rs1use crate::{RenderContext, graph::GlobalRenderNodeTrait, resource::RenderTextures};
2
3pub struct ClearNode;
4
5impl GlobalRenderNodeTrait for ClearNode {
6 type Query = ();
7 fn run(
8 &self,
9 #[cfg(not(feature = "profiling"))] encoder: &mut wgpu::CommandEncoder,
10 #[cfg(feature = "profiling")] encoder: &mut wgpu_profiler::Scope<'_, wgpu::CommandEncoder>,
11 _render_packets: <Self::Query as super::RenderPacketsQuery>::Output<'_>,
12 render_ctx: RenderContext,
13 ) {
14 #[cfg(feature = "profiling")]
15 profiling::scope!("clear_screen");
16 let RenderTextures {
17 render_view,
18 depth_stencil_view,
20 ..
21 } = render_ctx.render_textures;
22
23 let pass_desc = wgpu::RenderPassDescriptor {
24 label: Some("Clear Pass"),
25 color_attachments: &[Some(wgpu::RenderPassColorAttachment {
26 depth_slice: None,
29 view: render_view,
30 resolve_target: None,
31 ops: wgpu::Operations {
32 load: wgpu::LoadOp::Clear(render_ctx.clear_color),
33 store: wgpu::StoreOp::Store,
34 },
35 })],
36 depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
37 view: depth_stencil_view,
38 depth_ops: Some(wgpu::Operations {
39 load: wgpu::LoadOp::Clear(1.0),
40 store: wgpu::StoreOp::Store,
41 }),
42 stencil_ops: None,
43 }),
44 occlusion_query_set: None,
46 timestamp_writes: None,
47 };
48 encoder.begin_render_pass(&pass_desc);
49 }
50}