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
//! The render-pass bracket and viewport / scissor that a fullscreen pass not yet
//! drawn through the shared post seam (`render::post`) writes by hand: the
//! reflection composite's blur and composite.
use ash::vk;
use crate::vulkan::context::VkContext;
impl VkContext {
// Begin a fullscreen render pass: begin `render_pass` over `framebuffer` at the
// full render extent and set the matching viewport / scissor. Paired with
// `end_fullscreen_pass`.
pub(in crate::vulkan) fn begin_fullscreen_pass(
&self,
cmd: vk::CommandBuffer,
render_pass: vk::RenderPass,
framebuffer: vk::Framebuffer,
) {
self.begin_fullscreen_pass_sized(cmd, render_pass, framebuffer, self.targets.render_extent);
}
// As `begin_fullscreen_pass`, but with an explicit target extent for a pass
// whose framebuffer is not the full render resolution -- the reflection
// blur -- so its render area + viewport match that smaller framebuffer.
pub(in crate::vulkan) fn begin_fullscreen_pass_sized(
&self,
cmd: vk::CommandBuffer,
render_pass: vk::RenderPass,
framebuffer: vk::Framebuffer,
extent: vk::Extent2D,
) {
let rp_begin = vk::RenderPassBeginInfo::default()
.render_pass(render_pass)
.framebuffer(framebuffer)
.render_area(vk::Rect2D::default().extent(extent));
let vp = vk::Viewport {
x: 0.0,
y: 0.0,
width: extent.width as f32,
height: extent.height as f32,
min_depth: 0.0,
max_depth: 1.0,
};
let scissor = vk::Rect2D::default().extent(extent);
// SAFETY: `cmd` is a command buffer in the recording state, and every handle and slice
// these commands name is live for the call.
unsafe {
self.hw
.device
.cmd_begin_render_pass(cmd, &rp_begin, vk::SubpassContents::INLINE);
self.hw
.device
.cmd_set_viewport(cmd, 0, std::slice::from_ref(&vp));
self.hw
.device
.cmd_set_scissor(cmd, 0, std::slice::from_ref(&scissor));
}
}
// End a fullscreen render pass. Paired with `begin_fullscreen_pass`.
pub(in crate::vulkan) fn end_fullscreen_pass(&self, cmd: vk::CommandBuffer) {
// SAFETY: `cmd` is a command buffer in the recording state, and every handle and slice
// these commands name is live for the call.
unsafe { self.hw.device.cmd_end_render_pass(cmd) };
}
}