]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/commands_backend.cpp
Refactor handling of viewport Y axis
[libs/gl.git] / source / backends / vulkan / commands_backend.cpp
index 643710d5aefeb103d7e3380f5c9f50423ce4ed4f..9c074c87da184e279c1a0d9b0120b74e0ed12324 100644 (file)
@@ -81,14 +81,14 @@ void VulkanCommands::begin_render_pass(bool clear, const ClearValue *clear_value
        Synchronizer &sync = device.get_synchronizer();
        sync.reset();
 
-       bool to_present = false;
+       fb_is_swapchain = false;
        unsigned n_attachments = framebuffer->get_format().size();
-       for(unsigned i=0; i<n_attachments; ++i)
+       for(unsigned i=0; (!fb_is_swapchain && i<n_attachments); ++i)
                if(dynamic_cast<const SwapChainTexture *>(framebuffer->get_attachment(i)))
-                       to_present = true;
-       if(!to_present)
+                       fb_is_swapchain = true;
+       if(!fb_is_swapchain)
                framebuffer->prepare_image_layouts(clear && !viewport);
-       VkRenderPass render_pass = device.get_pipeline_cache().get_render_pass(framebuffer->get_format(), clear, (!clear_values && !viewport), to_present);
+       VkRenderPass render_pass = device.get_pipeline_cache().get_render_pass(framebuffer->get_format(), clear, (!clear_values && !viewport), fb_is_swapchain);
 
        framebuffer->refresh();
 
@@ -102,7 +102,7 @@ void VulkanCommands::begin_render_pass(bool clear, const ClearValue *clear_value
        if(viewport)
        {
                begin_info.renderArea.offset.x = viewport->left;
-               begin_info.renderArea.offset.y = framebuffer->get_height()-(viewport->bottom+viewport->height);
+               begin_info.renderArea.offset.y = viewport->bottom;
                begin_info.renderArea.extent.width = viewport->width;
                begin_info.renderArea.extent.height = viewport->height;
        }
@@ -233,7 +233,7 @@ void VulkanCommands::draw_instanced(const Batch &batch, unsigned count)
                 begin_render_pass(false, 0);
 
        pipeline_state->refresh();
-       pipeline_state->apply(current_buffer);
+       pipeline_state->apply(current_buffer, fb_is_swapchain);
        unsigned first_index = batch.get_offset()/batch.get_index_size();
        vk.CmdDrawIndexed(current_buffer, batch.size(), count, first_index, 0, 0);
 }