Fixing swap chain scissoring; surface is still not resized right.

This commit is contained in:
Ben Vanik 2016-02-17 19:33:14 -08:00
parent 9f52f2e819
commit a97fa36512
2 changed files with 7 additions and 3 deletions

View File

@ -614,6 +614,8 @@ void VulkanImmediateDrawer::Begin(int render_target_width,
auto swap_chain = context_->swap_chain(); auto swap_chain = context_->swap_chain();
assert_null(current_cmd_buffer_); assert_null(current_cmd_buffer_);
current_cmd_buffer_ = swap_chain->render_cmd_buffer(); current_cmd_buffer_ = swap_chain->render_cmd_buffer();
current_render_target_width_ = render_target_width;
current_render_target_height_ = render_target_height;
// Viewport changes only once per batch. // Viewport changes only once per batch.
VkViewport viewport; VkViewport viewport;
@ -704,15 +706,15 @@ void VulkanImmediateDrawer::Draw(const ImmediateDraw& draw) {
VkRect2D scissor; VkRect2D scissor;
if (draw.scissor) { if (draw.scissor) {
scissor.offset.x = draw.scissor_rect[0]; scissor.offset.x = draw.scissor_rect[0];
scissor.offset.y = swap_chain->surface_height() - scissor.offset.y = current_render_target_height_ -
(draw.scissor_rect[1] + draw.scissor_rect[3]); (draw.scissor_rect[1] + draw.scissor_rect[3]);
scissor.extent.width = draw.scissor_rect[2]; scissor.extent.width = draw.scissor_rect[2];
scissor.extent.height = draw.scissor_rect[3]; scissor.extent.height = draw.scissor_rect[3];
} else { } else {
scissor.offset.x = 0; scissor.offset.x = 0;
scissor.offset.y = 0; scissor.offset.y = 0;
scissor.extent.width = swap_chain->surface_width(); scissor.extent.width = current_render_target_width_;
scissor.extent.height = swap_chain->surface_height(); scissor.extent.height = current_render_target_height_;
} }
vkCmdSetScissor(current_cmd_buffer_, 0, 1, &scissor); vkCmdSetScissor(current_cmd_buffer_, 0, 1, &scissor);

View File

@ -60,6 +60,8 @@ class VulkanImmediateDrawer : public ImmediateDrawer {
bool batch_has_index_buffer_ = false; bool batch_has_index_buffer_ = false;
VkCommandBuffer current_cmd_buffer_ = nullptr; VkCommandBuffer current_cmd_buffer_ = nullptr;
int current_render_target_width_ = 0;
int current_render_target_height_ = 0;
}; };
} // namespace vulkan } // namespace vulkan