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 */
|
/** 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
|
// Pipeline layout
|
||||||
// Push constants for UI rendering parameters
|
// Push constants for UI rendering parameters
|
||||||
|
|
@ -277,6 +277,19 @@ namespace vks
|
||||||
pipelineCreateInfo.pStages = shaders.data();
|
pipelineCreateInfo.pStages = shaders.data();
|
||||||
pipelineCreateInfo.subpass = subpass;
|
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
|
// Vertex bindings an attributes based on ImGui vertex definition
|
||||||
std::vector<VkVertexInputBindingDescription> vertexInputBindings = {
|
std::vector<VkVertexInputBindingDescription> vertexInputBindings = {
|
||||||
vks::initializers::vertexInputBindingDescription(0, sizeof(ImDrawVert), VK_VERTEX_INPUT_RATE_VERTEX),
|
vks::initializers::vertexInputBindingDescription(0, sizeof(ImDrawVert), VK_VERTEX_INPUT_RATE_VERTEX),
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ namespace vks
|
||||||
UIOverlay();
|
UIOverlay();
|
||||||
~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();
|
void prepareResources();
|
||||||
|
|
||||||
bool update();
|
bool update();
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ void VulkanExampleBase::prepare()
|
||||||
loadShader(getShadersPath() + "base/uioverlay.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT),
|
loadShader(getShadersPath() + "base/uioverlay.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT),
|
||||||
};
|
};
|
||||||
UIOverlay.prepareResources();
|
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);
|
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
|
||||||
|
|
||||||
enabledInstanceExtensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
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);
|
enabledDeviceExtensions.push_back(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,6 +162,8 @@ public:
|
||||||
|
|
||||||
model.draw(drawCmdBuffers[i], vkglTF::RenderFlags::BindImages, pipelineLayout);
|
model.draw(drawCmdBuffers[i], vkglTF::RenderFlags::BindImages, pipelineLayout);
|
||||||
|
|
||||||
|
drawUI(drawCmdBuffers[i]);
|
||||||
|
|
||||||
// End dynamic rendering
|
// End dynamic rendering
|
||||||
vkCmdEndRenderingKHR(drawCmdBuffers[i]);
|
vkCmdEndRenderingKHR(drawCmdBuffers[i]);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue