From 9824b0c25bec1bc7cbc8c70817beb12b2400e366 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sun, 21 Dec 2025 21:00:59 +1100 Subject: [PATCH] add set scissor functions --- vulkan.d | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/vulkan.d b/vulkan.d index 5c03964..cedabe1 100644 --- a/vulkan.d +++ b/vulkan.d @@ -1544,16 +1544,34 @@ BindPipeline(Vulkan* vk, VkCommandBuffer cmd, PipelineHandles* pipeline) vkCmdSetViewport(cmd, 0, 1, &viewport); - VkRect2D scissor = { - extent: { - width: vk.swapchain_extent.width, - height: vk.swapchain_extent.height, - }, - }; - - vkCmdSetScissor(cmd, 0, 1, &scissor); + ResetScissor(vk, cmd); } +void +SetScissor(Vulkan* vk, u32 x, u32 y, u32 h, u32 w) +{ + VkRect2D scissor = { + offset: { x: x, y: y }, + extent: { width: w, height: h }, + }; + + vkCmdSetScissor(vk.cmds[vk.frame_index], 0, 1, &scissor); +} + +void +ResetScissor(Vulkan* vk, VkCommandBuffer cmd = cast(VkCommandBuffer)VK_NULL_HANDLE) +{ + cmd = cmd == VK_NULL_HANDLE ? vk.cmds[vk.frame_index] : cmd; + + VkRect2D scissor = { + offset: { x: 0, y: 0 }, + extent: { width: vk.swapchain_extent.width, height: vk.swapchain_extent.height }, + }; + + vkCmdSetScissor(cmd, 0, 1, &scissor); +} + + pragma(inline): void Transition(VkCommandBuffer cmd, VkImage image, VkImageLayout current_layout, VkImageLayout new_layout) {