mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-02 13:01:18 +12:00
Vulkan: Fix imgui validation error when sRGB framebuffer is used
This commit is contained in:
parent
cd6eb1097b
commit
4972381edc
1 changed files with 30 additions and 29 deletions
|
@ -1595,37 +1595,35 @@ void VulkanRenderer::DeleteNullObjects()
|
||||||
|
|
||||||
void VulkanRenderer::ImguiInit()
|
void VulkanRenderer::ImguiInit()
|
||||||
{
|
{
|
||||||
if (m_imguiRenderPass == VK_NULL_HANDLE)
|
VkRenderPass prevRenderPass = m_imguiRenderPass;
|
||||||
{
|
|
||||||
// TODO: renderpass swapchain format may change between srgb and rgb -> need reinit
|
|
||||||
VkAttachmentDescription colorAttachment = {};
|
|
||||||
colorAttachment.format = m_mainSwapchainInfo->m_surfaceFormat.format;
|
|
||||||
colorAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
|
|
||||||
colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
|
|
||||||
colorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
|
||||||
colorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
|
||||||
colorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
|
||||||
colorAttachment.initialLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
|
||||||
colorAttachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
|
||||||
|
|
||||||
VkAttachmentReference colorAttachmentRef = {};
|
VkAttachmentDescription colorAttachment = {};
|
||||||
colorAttachmentRef.attachment = 0;
|
colorAttachment.format = m_mainSwapchainInfo->m_surfaceFormat.format;
|
||||||
colorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
colorAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
VkSubpassDescription subpass = {};
|
colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||||
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
colorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
subpass.colorAttachmentCount = 1;
|
colorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||||
subpass.pColorAttachments = &colorAttachmentRef;
|
colorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||||
|
colorAttachment.initialLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||||
|
colorAttachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||||
|
|
||||||
VkRenderPassCreateInfo renderPassInfo = {};
|
VkAttachmentReference colorAttachmentRef = {};
|
||||||
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
colorAttachmentRef.attachment = 0;
|
||||||
renderPassInfo.attachmentCount = 1;
|
colorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||||
renderPassInfo.pAttachments = &colorAttachment;
|
VkSubpassDescription subpass = {};
|
||||||
renderPassInfo.subpassCount = 1;
|
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||||
renderPassInfo.pSubpasses = &subpass;
|
subpass.colorAttachmentCount = 1;
|
||||||
const auto result = vkCreateRenderPass(m_logicalDevice, &renderPassInfo, nullptr, &m_imguiRenderPass);
|
subpass.pColorAttachments = &colorAttachmentRef;
|
||||||
if (result != VK_SUCCESS)
|
|
||||||
throw VkException(result, "can't create imgui renderpass");
|
VkRenderPassCreateInfo renderPassInfo = {};
|
||||||
}
|
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||||
|
renderPassInfo.attachmentCount = 1;
|
||||||
|
renderPassInfo.pAttachments = &colorAttachment;
|
||||||
|
renderPassInfo.subpassCount = 1;
|
||||||
|
renderPassInfo.pSubpasses = &subpass;
|
||||||
|
const auto result = vkCreateRenderPass(m_logicalDevice, &renderPassInfo, nullptr, &m_imguiRenderPass);
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
throw VkException(result, "can't create imgui renderpass");
|
||||||
|
|
||||||
ImGui_ImplVulkan_InitInfo info{};
|
ImGui_ImplVulkan_InitInfo info{};
|
||||||
info.Instance = m_instance;
|
info.Instance = m_instance;
|
||||||
|
@ -1639,6 +1637,9 @@ void VulkanRenderer::ImguiInit()
|
||||||
info.ImageCount = info.MinImageCount;
|
info.ImageCount = info.MinImageCount;
|
||||||
|
|
||||||
ImGui_ImplVulkan_Init(&info, m_imguiRenderPass);
|
ImGui_ImplVulkan_Init(&info, m_imguiRenderPass);
|
||||||
|
|
||||||
|
if (prevRenderPass != VK_NULL_HANDLE)
|
||||||
|
vkDestroyRenderPass(GetLogicalDevice(), prevRenderPass, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanRenderer::Initialize()
|
void VulkanRenderer::Initialize()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue