void VulkanCamera::adjust_projection_matrix(Matrix &proj_matrix)
{
Matrix adjust;
- adjust(1, 1) = -1.0f;
adjust(2, 2) = 0.5f;
adjust(2, 3) = 0.5f;
proj_matrix = adjust*proj_matrix;
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();
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;
}
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);
}
const PipelineState *pipeline_state = 0;
const Framebuffer *framebuffer = 0;
const Rect *viewport = 0;
+ bool fb_is_swapchain = false;
VulkanCommands();
~VulkanCommands();
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();
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;
}
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);
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;
}
VkDescriptorSetLayout get_descriptor_set_layout(unsigned) const;
unsigned fill_descriptor_writes(unsigned, std::vector<char> &) const;
- void apply(VkCommandBuffer) const;
+ void apply(VkCommandBuffer, bool) const;
};
using PipelineStateBackend = VulkanPipelineState;