Fix ImGui overlay and add extension dependencies for dynamicrendering example
This commit is contained in:
parent
62f6dcf767
commit
54d0b27e4a
4 changed files with 23 additions and 4 deletions
|
|
@ -217,7 +217,7 @@ namespace vks
|
|||
}
|
||||
|
||||
/** Prepare a separate pipeline for the UI overlay rendering decoupled from the main application */
|
||||
void UIOverlay::preparePipeline(const VkPipelineCache pipelineCache, const VkRenderPass renderPass)
|
||||
void UIOverlay::preparePipeline(const VkPipelineCache pipelineCache, const VkRenderPass renderPass, const VkFormat colorFormat, const VkFormat depthFormat)
|
||||
{
|
||||
// Pipeline layout
|
||||
// Push constants for UI rendering parameters
|
||||
|
|
@ -276,6 +276,19 @@ namespace vks
|
|||
pipelineCreateInfo.stageCount = static_cast<uint32_t>(shaders.size());
|
||||
pipelineCreateInfo.pStages = shaders.data();
|
||||
pipelineCreateInfo.subpass = subpass;
|
||||
|
||||
#if defined(VK_KHR_dynamic_rendering)
|
||||
// SRS - if we are using dynamic rendering (i.e. renderPass null), must define color, depth and stencil attachments at pipeline create time
|
||||
VkPipelineRenderingCreateInfo pipelineRenderingCreateInfo = {};
|
||||
if (renderPass == VK_NULL_HANDLE) {
|
||||
pipelineRenderingCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO;
|
||||
pipelineRenderingCreateInfo.colorAttachmentCount = 1;
|
||||
pipelineRenderingCreateInfo.pColorAttachmentFormats = &colorFormat;
|
||||
pipelineRenderingCreateInfo.depthAttachmentFormat = depthFormat;
|
||||
pipelineRenderingCreateInfo.stencilAttachmentFormat = depthFormat;
|
||||
pipelineCreateInfo.pNext = &pipelineRenderingCreateInfo;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Vertex bindings an attributes based on ImGui vertex definition
|
||||
std::vector<VkVertexInputBindingDescription> vertexInputBindings = {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ namespace vks
|
|||
UIOverlay();
|
||||
~UIOverlay();
|
||||
|
||||
void preparePipeline(const VkPipelineCache pipelineCache, const VkRenderPass renderPass);
|
||||
void preparePipeline(const VkPipelineCache pipelineCache, const VkRenderPass renderPass, const VkFormat colorFormat, const VkFormat depthFormat);
|
||||
void prepareResources();
|
||||
|
||||
bool update();
|
||||
|
|
@ -89,4 +89,4 @@ namespace vks
|
|||
bool button(const char* caption);
|
||||
void text(const char* formatstr, ...);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ void VulkanExampleBase::prepare()
|
|||
loadShader(getShadersPath() + "base/uioverlay.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT),
|
||||
};
|
||||
UIOverlay.prepareResources();
|
||||
UIOverlay.preparePipeline(pipelineCache, renderPass);
|
||||
UIOverlay.preparePipeline(pipelineCache, renderPass, swapChain.colorFormat, depthFormat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@ public:
|
|||
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
|
||||
|
||||
enabledInstanceExtensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
||||
enabledDeviceExtensions.push_back(VK_KHR_MAINTENANCE2_EXTENSION_NAME);
|
||||
enabledDeviceExtensions.push_back(VK_KHR_MULTIVIEW_EXTENSION_NAME);
|
||||
enabledDeviceExtensions.push_back(VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME);
|
||||
enabledDeviceExtensions.push_back(VK_KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME);
|
||||
enabledDeviceExtensions.push_back(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
|
||||
}
|
||||
|
||||
|
|
@ -157,6 +161,8 @@ public:
|
|||
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
||||
|
||||
model.draw(drawCmdBuffers[i], vkglTF::RenderFlags::BindImages, pipelineLayout);
|
||||
|
||||
drawUI(drawCmdBuffers[i]);
|
||||
|
||||
// End dynamic rendering
|
||||
vkCmdEndRenderingKHR(drawCmdBuffers[i]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue