From 5cfa3b410818286022b33b87cb4e34b8c9b82cfd Mon Sep 17 00:00:00 2001 From: "Erik W. Gren" Date: Fri, 27 Dec 2024 21:00:20 +0100 Subject: [PATCH 1/2] vulkan: shift viewport y by height --- blade-graphics/src/vulkan/command.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blade-graphics/src/vulkan/command.rs b/blade-graphics/src/vulkan/command.rs index 1d1753f..a31a7ab 100644 --- a/blade-graphics/src/vulkan/command.rs +++ b/blade-graphics/src/vulkan/command.rs @@ -857,7 +857,7 @@ impl crate::Viewport { fn to_vk(&self) -> vk::Viewport { vk::Viewport { x: self.x, - y: self.y, + y: self.y + self.h, // shift since always flipped y and vulkan >= 1.1 width: self.w, height: -self.h, // flip Y min_depth: self.depth.start, From 5f9be98e3e2d9b9aca8da26c342a84d11f32b9f3 Mon Sep 17 00:00:00 2001 From: "Erik W. Gren" Date: Fri, 27 Dec 2024 21:13:47 +0100 Subject: [PATCH 2/2] vulkan: use our conversion functions for viewport and scissor --- blade-graphics/src/vulkan/command.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/blade-graphics/src/vulkan/command.rs b/blade-graphics/src/vulkan/command.rs index a31a7ab..5d4b744 100644 --- a/blade-graphics/src/vulkan/command.rs +++ b/blade-graphics/src/vulkan/command.rs @@ -389,21 +389,21 @@ impl super::CommandEncoder { } } - let render_area = vk::Rect2D { - offset: Default::default(), - extent: vk::Extent2D { - width: target_size[0] as u32, - height: target_size[1] as u32, - }, - }; - let viewport = vk::Viewport { + let render_area = crate::ScissorRect { + x: 0, + y: 0, + w: target_size[0] as u32, + h: target_size[1] as u32, + } + .to_vk(); + let viewport = crate::Viewport { x: 0.0, - y: target_size[1] as f32, - width: target_size[0] as f32, - height: -(target_size[1] as f32), - min_depth: 0.0, - max_depth: 1.0, - }; + y: 0.0, + w: target_size[0] as f32, + h: target_size[1] as f32, + depth: 0.0..1.0, + } + .to_vk(); rendering_info.render_area = render_area; let cmd_buf = self.buffers.first_mut().unwrap();