Fix render pass viewport in custom_shader example

This commit is contained in:
Joonas Satka 2025-01-21 09:38:13 +02:00 • committed by Héctor Ramón Jiménez
parent 5195a59e20
commit 56bb4ce721
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 18 additions and 16 deletions

View file

@ -357,7 +357,7 @@ impl Pipeline {
&self,
target: &wgpu::TextureView,
encoder: &mut wgpu::CommandEncoder,
viewport: Rectangle<u32>,
clip_bounds: Rectangle<u32>,
num_cubes: u32,
show_depth: bool,
) {
@ -390,11 +390,13 @@ impl Pipeline {
occlusion_query_set: None,
});
pass.set_scissor_rect(
viewport.x,
viewport.y,
viewport.width,
viewport.height,
pass.set_viewport(
clip_bounds.x as f32,
clip_bounds.y as f32,
clip_bounds.width as f32,
clip_bounds.height as f32,
0.0,
1.0,
);
pass.set_pipeline(&self.pipeline);
pass.set_bind_group(0, &self.uniform_bind_group, &[]);
@ -404,7 +406,7 @@ impl Pipeline {
}
if show_depth {
self.depth_pipeline.render(encoder, target, viewport);
self.depth_pipeline.render(encoder, target, clip_bounds);
}
}
}
@ -562,7 +564,7 @@ impl DepthPipeline {
&self,
encoder: &mut wgpu::CommandEncoder,
target: &wgpu::TextureView,
viewport: Rectangle<u32>,
clip_bounds: Rectangle<u32>,
) {
let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("cubes.pipeline.depth_pass"),
@ -586,11 +588,13 @@ impl DepthPipeline {
occlusion_query_set: None,
});
pass.set_scissor_rect(
viewport.x,
viewport.y,
viewport.width,
viewport.height,
pass.set_viewport(
clip_bounds.x as f32,
clip_bounds.y as f32,
clip_bounds.width as f32,
clip_bounds.height as f32,
0.0,
1.0,
);
pass.set_pipeline(&self.pipeline);
pass.set_bind_group(0, &self.bind_group, &[]);