]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/pipelinestate_backend.cpp
Refactor handling of viewport Y axis
[libs/gl.git] / source / backends / vulkan / pipelinestate_backend.cpp
index 419a7e4c149545b3de9ce19cd211da7bef5e563d..a1a03d3d8fcb31d2646027036bb4936a237d4194 100644 (file)
@@ -356,7 +356,7 @@ unsigned VulkanPipelineState::fill_descriptor_writes(unsigned index, vector<char
        return n_writes;
 }
 
-void VulkanPipelineState::apply(VkCommandBuffer command_buffer) const
+void VulkanPipelineState::apply(VkCommandBuffer command_buffer, bool negative_viewport) const
 {
        const PipelineState &self = *static_cast<const PipelineState *>(this);
        const VulkanFunctions &vk = device.get_functions();
@@ -387,7 +387,7 @@ void VulkanPipelineState::apply(VkCommandBuffer command_buffer) const
        if(self.viewport)
        {
                viewport.x = self.viewport->left;
-               viewport.y = self.framebuffer->get_height()-(self.viewport->bottom+self.viewport->height);
+               viewport.y = self.viewport->bottom;
                viewport.width = self.viewport->width;
                viewport.height = self.viewport->height;
        }
@@ -398,6 +398,11 @@ void VulkanPipelineState::apply(VkCommandBuffer command_buffer) const
                viewport.width = self.framebuffer->get_width();
                viewport.height = self.framebuffer->get_height();
        }
+       if(negative_viewport)
+       {
+               viewport.y += viewport.height;
+               viewport.height = -viewport.height;
+       }
        viewport.minDepth = 0.0f;
        viewport.maxDepth = 1.0f;
        vk.CmdSetViewport(command_buffer, 0, 1, &viewport);
@@ -406,7 +411,7 @@ void VulkanPipelineState::apply(VkCommandBuffer command_buffer) const
        if(self.scissor)
        {
                scissor.offset.x = self.scissor->left;
-               scissor.offset.y = self.framebuffer->get_height()-(self.scissor->bottom+self.scissor->height);
+               scissor.offset.y = self.scissor->bottom;
                scissor.extent.width = self.scissor->width;
                scissor.extent.height = self.scissor->height;
        }