Fixed some imgui scissor edge cases

docking
TheCherno 4 years ago
parent 10ace70f96
commit 09c9a04f9f

@ -432,8 +432,9 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
VkRect2D scissor; VkRect2D scissor;
scissor.offset.x = (int32_t)(clip_rect.x); scissor.offset.x = (int32_t)(clip_rect.x);
scissor.offset.y = (int32_t)(clip_rect.y); scissor.offset.y = (int32_t)(clip_rect.y);
scissor.extent.width = (uint32_t)(clip_rect.z - clip_rect.x); // NOTE(Yan): sometimes x > z which is invalid, hence the abs
scissor.extent.height = (uint32_t)(clip_rect.w - clip_rect.y); scissor.extent.width = (uint32_t)(glm::abs(clip_rect.z - clip_rect.x));
scissor.extent.height = (uint32_t)(glm::abs(clip_rect.w - clip_rect.y));
vkCmdSetScissor(command_buffer, 0, 1, &scissor); vkCmdSetScissor(command_buffer, 0, 1, &scissor);
// Bind descriptorset with font or user texture // Bind descriptorset with font or user texture

@ -437,7 +437,12 @@ void ImDrawList::AddDrawCmd()
draw_cmd.VtxOffset = _CmdHeader.VtxOffset; draw_cmd.VtxOffset = _CmdHeader.VtxOffset;
draw_cmd.IdxOffset = IdxBuffer.Size; draw_cmd.IdxOffset = IdxBuffer.Size;
IM_ASSERT(draw_cmd.ClipRect.x <= draw_cmd.ClipRect.z && draw_cmd.ClipRect.y <= draw_cmd.ClipRect.w); // NOTE(Yan): Not sure why this happens but sometimes x > z which causes a crash in vkCmdSetScissor later on
// IM_ASSERT(draw_cmd.ClipRect.x <= draw_cmd.ClipRect.z && draw_cmd.ClipRect.y <= draw_cmd.ClipRect.w);
if (draw_cmd.ClipRect.x > draw_cmd.ClipRect.z)
draw_cmd.ClipRect.z = draw_cmd.ClipRect.x + 1;
if (draw_cmd.ClipRect.y > draw_cmd.ClipRect.y)
draw_cmd.ClipRect.w = draw_cmd.ClipRect.w + 1;
CmdBuffer.push_back(draw_cmd); CmdBuffer.push_back(draw_cmd);
} }

Loading…
Cancel
Save