admin管理员组

文章数量:1122846

I want to ues vulkan with imgui, but encounter some problems. The details are as follows.

Use glfw.

I create renderpass with two subpass to render 3d object and imGui. The result is that I only get 3d object on screen. I can't see imgui object on screen. Besides, I also encounter some error in validation layer. Some code are as below.

void createRenderPass() {
        VkAttachmentDescription colorAttachment = {};
        colorAttachment.format = swapChainImageFormat;
        colorAttachment.samples = msaaSamples;//
        colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
        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_UNDEFINED;
        colorAttachment.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;

        VkAttachmentDescription depthAttachment = {};
        depthAttachment.format = findDepthFormat();
        depthAttachment.samples = msaaSamples;//
        depthAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
        depthAttachment.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
        depthAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
        depthAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
        depthAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
        depthAttachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;

        VkAttachmentDescription colorAttachmentResolve = {};
        colorAttachmentResolve.format = swapChainImageFormat;
        colorAttachmentResolve.samples = msaaSamples;
        colorAttachmentResolve.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
        colorAttachmentResolve.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
        colorAttachmentResolve.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
        colorAttachmentResolve.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
        colorAttachmentResolve.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
        colorAttachmentResolve.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; //VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;

        VkAttachmentDescription imguiColorAttachment = {};
        imguiColorAttachment.format = swapChainImageFormat;
        imguiColorAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
        imguiColorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
        imguiColorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
        imguiColorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
        imguiColorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
        imguiColorAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
        imguiColorAttachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;

        VkAttachmentReference colorAttachmentRef = {};
        colorAttachmentRef.attachment = 0;
        colorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;

        VkAttachmentReference depthAttachmentRef = {};
        depthAttachmentRef.attachment = 1;
        depthAttachmentRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;

        VkAttachmentReference colorAttachmentResolveRef = {};
        colorAttachmentResolveRef.attachment = 2;
        colorAttachmentResolveRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;

        VkAttachmentReference imguiColorAttachmentRef = {};
        colorAttachmentResolveRef.attachment = 3;
        colorAttachmentResolveRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;

        VkSubpassDescription subpass = {};
        subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
        subpass.colorAttachmentCount = 1;
        subpass.pColorAttachments = &colorAttachmentRef;
        subpass.pDepthStencilAttachment = &depthAttachmentRef;
        subpass.pResolveAttachments = &colorAttachmentResolveRef;

        VkSubpassDescription subpassImGui = {};
        subpassImGui.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
        subpassImGui.colorAttachmentCount = 1;
        subpassImGui.pColorAttachments = &imguiColorAttachmentRef; 

        std::array<VkAttachmentDescription, 4> attachments = { colorAttachment, depthAttachment, colorAttachmentResolve ,imguiColorAttachment };

        std::array<VkSubpassDescription, 2>subpasses = { subpass, subpassImGui };

        VkRenderPassCreateInfo renderPassInfo = {};
        renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
        renderPassInfo.attachmentCount = static_cast<uint32_t>(attachments.size());
        renderPassInfo.pAttachments = attachments.data();
        renderPassInfo.subpassCount = subpasses.size();
        renderPassInfo.pSubpasses = subpasses.data();

        VkSubpassDependency dependency = {};
        dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
        dependency.dstSubpass = 0;
        dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
        dependency.srcAccessMask = 0;
        dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
        dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;

        VkSubpassDependency dependency1 = {};
        dependency1.srcSubpass = 0,
        dependency1.dstSubpass = 1,
        dependency1.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
        dependency1.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
        dependency1.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
        dependency1.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;

        std::array<VkSubpassDependency, 2>dependencys = {dependency, dependency1};

        renderPassInfo.dependencyCount = dependencys.size();
        renderPassInfo.pDependencies = dependencys.data();

        if (vkCreateRenderPass(device, &renderPassInfo, nullptr, &renderPass) != VK_SUCCESS) {
            throw std::runtime_error("failed to create render pass!");
        }

void createColorResources() {
    VkFormat colorFormat = swapChainImageFormat;
    createImage(swapChainExtent.width, swapChainExtent.height, 1, msaaSamples, colorFormat, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, colorImage, colorImageMemory);
    colorImageView = createImageView(colorImage, colorFormat, VK_IMAGE_ASPECT_COLOR_BIT, 1);
    transitionImageLayout(colorImage, colorFormat, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 1);

    createImage(swapChainExtent.width, swapChainExtent.height, 1, VK_SAMPLE_COUNT_1_BIT, colorFormat, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, colorImage1, colorImageMemory1);
    colorImageView1 = createImageView(colorImage1, colorFormat, VK_IMAGE_ASPECT_COLOR_BIT, 1);
    transitionImageLayout(colorImage1, colorFormat, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 1);

}

void createFramebuffers() {
    swapChainFramebuffers.resize(swapChainImageViews.size());
    for (size_t i = 0; i < swapChainImageViews.size(); i++) {
        std::array<VkImageView, 4> attachments = {
                colorImageView,
                depthImageView,
                colorImageView1,
                swapChainImageViews[i]
        };
        VkFramebufferCreateInfo framebufferInfo = {};
        framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
        framebufferInfo.renderPass = renderPass;
        framebufferInfo.attachmentCount = static_cast<uint32_t>(attachments.size());
        framebufferInfo.pAttachments = attachments.data();
        framebufferInfo.width = swapChainExtent.width;
        framebufferInfo.height = swapChainExtent.height;
        framebufferInfo.layers = 1;

        if (vkCreateFramebuffer(device, &framebufferInfo, nullptr, &swapChainFramebuffers[i]) != VK_SUCCESS) {
            throw std::runtime_error("failed to create framebuffer!");
        }
    }
}
void createCommandBuffers() {
    commandBuffers.resize(swapChainFramebuffers.size());
    VkCommandBufferAllocateInfo allocInfo = {};
    allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
    allocInfomandPool = commandPool;
    allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
    allocInfomandBufferCount = (uint32_t)commandBuffers.size();

    if (vkAllocateCommandBuffers(device, &allocInfo, commandBuffers.data()) != VK_SUCCESS) {
        throw std::runtime_error("failed to allocate command buffers!");
    }

    for (size_t i = 0; i < commandBuffers.size(); i++) {
        VkCommandBufferBeginInfo beginInfo = {};
        beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
        beginInfo.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
        beginInfo.pInheritanceInfo = nullptr; // Optional

        vkBeginCommandBuffer(commandBuffers[i], &beginInfo);

        VkRenderPassBeginInfo renderPassInfo = {};
        renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
        renderPassInfo.renderPass = renderPass;
        renderPassInfo.framebuffer = swapChainFramebuffers[i];

        renderPassInfo.renderArea.offset = { 0, 0 };
        renderPassInfo.renderArea.extent = swapChainExtent;

        std::array<VkClearValue, 4> clearValues = {};
        clearValues[0].color = { 0.1f, 0.1f, 0.3f, 0.5f }; // 
        clearValues[1].depthStencil = { 1.0f, 0 }; //
        clearValues[2].color = { 0.0f, 0.0f, 0.0f, 0.0f }; // 
        clearValues[3].color = { 0.0f, 0.0f, 0.0f, 0.0f }; // ImGui

        renderPassInfo.clearValueCount = static_cast<uint32_t>(clearValues.size());
        renderPassInfo.pClearValues = clearValues.data();

        vkCmdBeginRenderPass(commandBuffers[i], &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);

        
        vkCmdBindPipeline(commandBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, graphicsPipeline);

        VkBuffer vertexBuffers[] = { vertexBuffer };
        VkDeviceSize offsets[] = { 0 };
        
        vkCmdBindVertexBuffers(commandBuffers[i], 0, 1, vertexBuffers, offsets);
        vkCmdBindIndexBuffer(commandBuffers[i], indexBuffer, 0, VK_INDEX_TYPE_UINT32);
        vkCmdBindDescriptorSets(commandBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSet, 0, nullptr);
        vkCmdDrawIndexed(commandBuffers[i], static_cast<uint32_t>(indices.size()), 1, 0, 0, 0);
        //vkCmdDraw(commandBuffers[i], static_cast<uint32_t>(vertices.size()), 1, 0, 0);

        vkCmdNextSubpass(commandBuffers[i], VK_SUBPASS_CONTENTS_INLINE);
        xgImgui->startFrame(commandBuffers[i]);

        vkCmdEndRenderPass(commandBuffers[i]);

        if (vkEndCommandBuffer(commandBuffers[i]) != VK_SUCCESS) {
            throw std::runtime_error("failed to record command buffer!");
        }
    }

}
void XgImgui::startFrame(const VkCommandBuffer& commandBuffer)
{
    // Start the Dear ImGui frame
    ImGui_ImplVulkan_NewFrame();
    ImGui_ImplGlfw_NewFrame();
    ImGui::NewFrame();

    static float f = 0.0f;
    static int counter = 0;

    // Our state
    bool show_demo_window = true;
    bool show_another_window = false;
    ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);

    ImGui::Begin("Hello, world!");                          // Create a window called "Hello, world!" and append into it.

    ImGui::Text("This is some useful text.");               // Display some text (you can use a format strings too)
    ImGui::Checkbox("Demo Window", &show_demo_window);      // Edit bools storing our window open/close state
    ImGui::Checkbox("Another Window", &show_another_window);

    ImGui::SliderFloat("float", &f, 0.0f, 1.0f);            // Edit 1 float using a slider from 0.0f to 1.0f
    ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color

    if (ImGui::Button("Button"))                            // Buttons return true when clicked (most widgets return true when edited/activated)
        counter++;
    ImGui::SameLine();
    ImGui::Text("counter = %d", counter);

    ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
    ImGui::End();

    ImGui::Render();
    ImDrawData* draw_data = ImGui::GetDrawData();

    // Record dear imgui primitives into command buffer
    ImGui_ImplVulkan_RenderDrawData(draw_data, commandBuffer);
    
}
xgImgui->init(window, instance, physicalDevice, device, indices.graphicsFamily, graphicsQueue,VK_NULL_HANDLE , renderPass, 2, 2, VK_SAMPLE_COUNT_1_BIT, VK_NULL_HANDLE, 1);

void XgImgui::init(GLFWwindow* window, VkInstance instance, VkPhysicalDevice physicalDevice, VkDevice device,
    uint32_t                        QueueFamily,
    VkQueue                         Queue,
    VkDescriptorPool                DescriptorPool,               // See requirements in note above; ignored if using DescriptorPoolSize > 0
    VkRenderPass                    RenderPass,               // Ignored if using dynamic rendering
    uint32_t                        MinImageCount,                // >= 2
    uint32_t                        ImageCount,                // >= MinImageCount
    VkSampleCountFlagBits           MSAASamples,                  // 0 defaults to VK_SAMPLE_COUNT_1_BIT
    // (Optional)
    VkPipelineCache                 PipelineCache,
    uint32_t                        Subpass)
{
    this->device = device;

    // Setup Dear ImGui context
    IMGUI_CHECKVERSION();
    ImGui::CreateContext();
    io = ImGui::GetIO(); (void)io;
    io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;     // Enable Keyboard Controls
    io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;      // Enable Gamepad Controls

    // Setup Dear ImGui style
    ImGui::StyleColorsDark();
    //ImGui::StyleColorsLight();

    if (DescriptorPool==VK_NULL_HANDLE)
    {
        VkDescriptorPoolSize pool_sizes[] =
        {
            { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1 },
        };
        VkDescriptorPoolCreateInfo pool_info = {};
        pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
        pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
        pool_info.maxSets = 1;
        pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes);
        pool_info.pPoolSizes = pool_sizes;
        vkCreateDescriptorPool(device, &pool_info, VK_NULL_HANDLE, &descriptorPool);
    }
   
    // Setup Platform/Renderer backends
    ImGui_ImplGlfw_InitForVulkan(window, true);
    ImGui_ImplVulkan_InitInfo init_info = {};
    init_info.Instance = instance;
    init_info.PhysicalDevice = physicalDevice;
    init_info.Device = device;
    init_info.QueueFamily = QueueFamily;
    init_info.Queue = Queue;
    init_info.PipelineCache = PipelineCache;
    init_info.DescriptorPool = descriptorPool;
    init_info.RenderPass = RenderPass;
    init_info.Subpass = Subpass;
    init_info.MinImageCount = MinImageCount;
    init_info.ImageCount = ImageCount;
    init_info.MSAASamples = MSAASamples;
    init_info.Allocator = VK_NULL_HANDLE;
    init_info.CheckVkResultFn =check_vk_result;
    ImGui_ImplVulkan_Init(&init_info);

}

Validation error:

validation layer: Validation Error: [ VUID-VkAttachmentReference-layout-03077 ] | MessageID = 0xdfca001c | vkCreateRenderPass(): pCreateInfo->pSubpasses[1].pColorAttachments[0] is VK_IMAGE_LAYOUT_UNDEFINED.
The Vulkan spec states: If attachment is not VK_ATTACHMENT_UNUSED, layout must not be VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_PREINITIALIZED, or VK_IMAGE_LAYOUT_PRESENT_SRC_KHR (.3.296.0/windows/1.3-extensions/vkspec.html#VUID-VkAttachmentReference-layout-03077)
validation layer: Validation Error: [ VUID-VkFramebufferCreateInfo-pAttachments-00881 ] Object 0: handle = 0xcfef35000000000a, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xd897d90000000016, type = VK_OBJECT_TYPE_IMAGE_VIEW; Object 2: handle = 0x9fde6b0000000014, type = VK_OBJECT_TYPE_IMAGE; | MessageID = 0x2ff52eec | vkCreateFramebuffer(): pCreateInfo->pAttachments[2] has VK_SAMPLE_COUNT_1_BIT samples that do not match the VK_SAMPLE_COUNT_8_BIT samples used by the corresponding attachment for VkRenderPass 0xcfef35000000000a[].
The Vulkan spec states: If flags does not include VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, each element of pAttachments must have been created with a samples value that matches the samples value specified by the corresponding VkAttachmentDescription in renderPass (.3.296.0/windows/1.3-extensions/vkspec.html#VUID-VkFramebufferCreateInfo-pAttachments-00881)
validation layer: Validation Error: [ VUID-VkFramebufferCreateInfo-pAttachments-00881 ] Object 0: handle = 0xcfef35000000000a, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xd897d90000000016, type = VK_OBJECT_TYPE_IMAGE_VIEW; Object 2: handle = 0x9fde6b0000000014, type = VK_OBJECT_TYPE_IMAGE; | MessageID = 0x2ff52eec | vkCreateFramebuffer(): pCreateInfo->pAttachments[2] has VK_SAMPLE_COUNT_1_BIT samples that do not match the VK_SAMPLE_COUNT_8_BIT samples used by the corresponding attachment for VkRenderPass 0xcfef35000000000a[].
The Vulkan spec states: If flags does not include VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, each element of pAttachments must have been created with a samples value that matches the samples value specified by the corresponding VkAttachmentDescription in renderPass (.3.296.0/windows/1.3-extensions/vkspec.html#VUID-VkFramebufferCreateInfo-pAttachments-00881)
validation layer: Validation Error: [ VUID-VkFramebufferCreateInfo-pAttachments-00881 ] Object 0: handle = 0xcfef35000000000a, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xd897d90000000016, type = VK_OBJECT_TYPE_IMAGE_VIEW; Object 2: handle = 0x9fde6b0000000014, type = VK_OBJECT_TYPE_IMAGE; | MessageID = 0x2ff52eec | vkCreateFramebuffer(): pCreateInfo->pAttachments[2] has VK_SAMPLE_COUNT_1_BIT samples that do not match the VK_SAMPLE_COUNT_8_BIT samples used by the corresponding attachment for VkRenderPass 0xcfef35000000000a[].
The Vulkan spec states: If flags does not include VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, each element of pAttachments must have been created with a samples value that matches the samples value specified by the corresponding VkAttachmentDescription in renderPass (.3.296.0/windows/1.3-extensions/vkspec.html#VUID-VkFramebufferCreateInfo-pAttachments-00881)
validation layer: Validation Error: [ VUID-VkGraphicsPipelineCreateInfo-multisampledRenderToSingleSampled-06853 ] | MessageID = 0x3108bb9b | vkCreateGraphicsPipelines(): pCreateInfos[0].pMultisampleState->rasterizationSamples (1) does not match the number of samples of the RenderPass color and/or depth attachment (8).
The Vulkan spec states: If the pipeline requires fragment output interface state, and none of the VK_AMD_mixed_attachment_samples extension, the VK_NV_framebuffer_mixed_samples extension, or the multisampledRenderToSingleSampled feature are enabled, rasterizationSamples is not dynamic, and if subpass uses color and/or depth/stencil attachments, then the rasterizationSamples member of pMultisampleState must be the same as the sample count for those subpass attachments (.3.296.0/windows/1.3-extensions/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-multisampledRenderToSingleSampled-06853)
validation layer: Validation Error: [ VUID-vkCmdDrawIndexed-multisampledRenderToSingleSampled-07284 ] Object 0: handle = 0x14163d0a140, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0x4295ab0000000035, type = VK_OBJECT_TYPE_PIPELINE; Object 2: handle = 0xcfef35000000000a, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x576454a4 | vkCmdDrawIndexed():  In VkPipeline 0x4295ab0000000035[] the sample count is VK_SAMPLE_COUNT_1_BIT while the current VkRenderPass 0xcfef35000000000a[] has VK_SAMPLE_COUNT_8_BIT and they need to be the same.
The Vulkan spec states: If rasterization is not disabled in the bound graphics pipeline, and none of the following is enabled: the VK_AMD_mixed_attachment_samples extension the VK_NV_framebuffer_mixed_samples extension the multisampledRenderToSingleSampled feature then rasterizationSamples for the currently bound graphics pipeline must be the same as the current subpass color and/or depth/stencil attachments (.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexed-multisampledRenderToSingleSampled-07284)
validation layer: Validation Error: [ VUID-vkCmdDrawIndexed-multisampledRenderToSingleSampled-07284 ] Object 0: handle = 0x14163d0a140, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0x4295ab0000000035, type = VK_OBJECT_TYPE_PIPELINE; Object 2: handle = 0xcfef35000000000a, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x576454a4 | vkCmdDrawIndexed():  In VkPipeline 0x4295ab0000000035[] the sample count is VK_SAMPLE_COUNT_1_BIT while the current VkRenderPass 0xcfef35000000000a[] has VK_SAMPLE_COUNT_8_BIT and they need to be the same.
The Vulkan spec states: If rasterization is not disabled in the bound graphics pipeline, and none of the following is enabled: the VK_AMD_mixed_attachment_samples extension the VK_NV_framebuffer_mixed_samples extension the multisampledRenderToSingleSampled feature then rasterizationSamples for the currently bound graphics pipeline must be the same as the current subpass color and/or depth/stencil attachments (.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexed-multisampledRenderToSingleSampled-07284)
validation layer: Validation Error: [ VUID-vkCmdDrawIndexed-multisampledRenderToSingleSampled-07284 ] Object 0: handle = 0x14163d15ae0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0x4295ab0000000035, type = VK_OBJECT_TYPE_PIPELINE; Object 2: handle = 0xcfef35000000000a, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x576454a4 | vkCmdDrawIndexed():  In VkPipeline 0x4295ab0000000035[] the sample count is VK_SAMPLE_COUNT_1_BIT while the current VkRenderPass 0xcfef35000000000a[] has VK_SAMPLE_COUNT_8_BIT and they need to be the same.
The Vulkan spec states: If rasterization is not disabled in the bound graphics pipeline, and none of the following is enabled: the VK_AMD_mixed_attachment_samples extension the VK_NV_framebuffer_mixed_samples extension the multisampledRenderToSingleSampled feature then rasterizationSamples for the currently bound graphics pipeline must be the same as the current subpass color and/or depth/stencil attachments (.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexed-multisampledRenderToSingleSampled-07284)
validation layer: Validation Error: [ VUID-vkCmdDrawIndexed-multisampledRenderToSingleSampled-07284 ] Object 0: handle = 0x14163d15ae0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0x4295ab0000000035, type = VK_OBJECT_TYPE_PIPELINE; Object 2: handle = 0xcfef35000000000a, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x576454a4 | vkCmdDrawIndexed():  In VkPipeline 0x4295ab0000000035[] the sample count is VK_SAMPLE_COUNT_1_BIT while the current VkRenderPass 0xcfef35000000000a[] has VK_SAMPLE_COUNT_8_BIT and they need to be the same.
The Vulkan spec states: If rasterization is not disabled in the bound graphics pipeline, and none of the following is enabled: the VK_AMD_mixed_attachment_samples extension the VK_NV_framebuffer_mixed_samples extension the multisampledRenderToSingleSampled feature then rasterizationSamples for the currently bound graphics pipeline must be the same as the current subpass color and/or depth/stencil attachments (.3.296.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexed-multisampledRenderToSingleSampled-07284)

本文标签: cHow to use vulkan with imguiStack Overflow