瀏覽代碼

Backends: Vulkan: comments about user using VK_DYNAMIC_STATE_VIEWPORT / VK_DYNAMIC_STATE_SCISSOR and not calling vkCmdSetViewport() / vkCmdSetScissor(). (#4644)

ocornut 4 年之前
父節點
當前提交
bbd5119a26
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      backends/imgui_impl_vulkan.cpp

+ 8 - 0
backends/imgui_impl_vulkan.cpp

@@ -537,6 +537,14 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
         global_idx_offset += cmd_list->IdxBuffer.Size;
         global_idx_offset += cmd_list->IdxBuffer.Size;
         global_vtx_offset += cmd_list->VtxBuffer.Size;
         global_vtx_offset += cmd_list->VtxBuffer.Size;
     }
     }
+
+    // Note: at this point both vkCmdSetViewport() and vkCmdSetScissor() have been called.
+    // Our last values will leak into user/application rendering IF:
+    // - Your app uses a pipeline with VK_DYNAMIC_STATE_VIEWPORT or VK_DYNAMIC_STATE_SCISSOR dynamic state
+    // - And you forgot to call vkCmdSetViewport() and vkCmdSetScissor() yourself to explicitely set that state.
+    // If you use VK_DYNAMIC_STATE_VIEWPORT or VK_DYNAMIC_STATE_SCISSOR you are responsible for setting the values before rendering.
+    // In theory we should aim to backup/restore those values but I am not sure this is possible.
+    // If we add a call to vkCmdSetScissor() to cover the full viewport that would fix things for majority of users BUT would made it harder to notice your bug. (See github #4644)
 }
 }
 
 
 bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer)
 bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer)