86 lines
No EOL
2.5 KiB
C++
86 lines
No EOL
2.5 KiB
C++
#include "DebugGUI.hpp"
|
|
|
|
|
|
VkRenderPass createRenderPass(VkDevice device, VkFormat format, VkImageLayout finalImageLayout) {
|
|
VkRenderPass renderPass = VK_NULL_HANDLE;
|
|
|
|
VkAttachmentDescription colorAttachment{
|
|
.format = format,
|
|
.samples = VK_SAMPLE_COUNT_1_BIT,
|
|
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
|
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
|
.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE,
|
|
.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE,
|
|
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
|
.finalLayout = finalImageLayout,
|
|
};
|
|
|
|
VkAttachmentReference colorAttachmentReference{
|
|
.attachment = 0,
|
|
.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
|
};
|
|
|
|
VkSubpassDescription subpassDescription{
|
|
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
|
|
.colorAttachmentCount = 1,
|
|
.pColorAttachments = &colorAttachmentReference,
|
|
};
|
|
|
|
VkSubpassDependency dependency{
|
|
.srcSubpass = VK_SUBPASS_EXTERNAL,
|
|
.dstSubpass = 0,
|
|
.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
|
.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
|
.srcAccessMask = 0,
|
|
.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
|
};
|
|
|
|
VkRenderPassCreateInfo renderPassCreateInfo{
|
|
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
|
|
.attachmentCount = 1,
|
|
.pAttachments = &colorAttachment,
|
|
.subpassCount = 1,
|
|
.pSubpasses = &subpassDescription,
|
|
.dependencyCount = 1,
|
|
.pDependencies = &dependency
|
|
};
|
|
|
|
vkCreateRenderPass(device, &renderPassCreateInfo, nullptr, &renderPass);
|
|
|
|
return renderPass;
|
|
}
|
|
|
|
int main() {
|
|
VulkanWindow app;
|
|
ImGuiVk imgui;
|
|
|
|
auto renderInfo = app.getRenderInfo();
|
|
VkRenderPass renderPass = createRenderPass(renderInfo.device, renderInfo.format, renderInfo.finalImageLayout);
|
|
|
|
app.setRenderPass(renderPass);
|
|
|
|
imgui.create(&app);
|
|
imgui.setRenderPass(renderPass);
|
|
|
|
while (!glfwWindowShouldClose(app.getWindow())) {
|
|
app.pollEvents();
|
|
|
|
auto drawData = app.startDrawFrame();
|
|
|
|
imgui.beginFrame();
|
|
ImGuiVk::demo();
|
|
imgui.endFrame();
|
|
|
|
imgui.cmdRender(drawData.commandBuffer, drawData.frameBuffer, drawData.extent2D);
|
|
|
|
// renderer.fillRenderCommands(drawData.commandBuffer, drawData.frameBuffer, drawData.extent2D);
|
|
// renderer.updateUniformBuffer({drawData.extent2D.width, drawData.extent2D.height});
|
|
|
|
app.endDrawFrame(drawData);
|
|
}
|
|
|
|
app.waitDevice();
|
|
|
|
vkDestroyRenderPass(app.getDevice(), renderPass, nullptr);
|
|
imgui.destroy(app.getDevice());
|
|
} |