Swapchain display only image #0

With NVIDIA GT 740M on Windows I’m only seeing rendering which goes into swapchain image #0.

I’m trying to find a good way to use swapchain for CAD-like scenarios. Rendering is performed not in a loop frame after frame but only if something is changed.

My code is here: https://bitbucket.org/rusteddreams/vulwf/src See ‘example’ folder for MSVC 2015 project.
Pre-built windows binary can be downloaded from here: http://rusteddreams.bitbucket.org/vulkan/bin.zip

I create VK_PRESENT_MODE_FIFO_KHR swapchain with 2 images, basic vsync mode.
In this demo app frame is re-rendered on each left mouse button click. Each time with a different color, color and swapchain image are logged to console.

And on my NVIDIA GT 740M with 368.22 and 368.39 drivers on Win10 x64 I have 2 problems with this code:

  1. Only rendering into swapchain image #0 is visible. Looks like vkQueuePresentKHR with image #1 is ignored by driver.

  2. If window is left without updates for some time (around 30 seconds) index buffer (in device local memory) gets corrupted: http://rusteddreams.bitbucket.org/vulkan/ibcorrupt.png

Also, I’ve tried to modify Gears example by Sascha Willems https://github.com/SaschaWillems/Vulkan/blob/master/gears/gears.cpp to set clear color to red for frames which go into #1 and #2 swapchain images. If all frames are shown this should result in flickering background. But for me it still solid dark background from image #0.
Here is modified buildCommandBuffers function from Gears example (my change is marked by ///):


    void buildCommandBuffers()
    {
        VkCommandBufferBeginInfo cmdBufInfo = vkTools::initializers::commandBufferBeginInfo();

        VkClearValue clearValues[2];
        clearValues[0].color = defaultClearColor;
        clearValues[1].depthStencil = { 1.0f, 0 };

        VkRenderPassBeginInfo renderPassBeginInfo = vkTools::initializers::renderPassBeginInfo();
        renderPassBeginInfo.renderPass = renderPass;
        renderPassBeginInfo.renderArea.offset.x = 0;
        renderPassBeginInfo.renderArea.offset.y = 0;
        renderPassBeginInfo.renderArea.extent.width = width;
        renderPassBeginInfo.renderArea.extent.height = height;
        renderPassBeginInfo.clearValueCount = 2;
        renderPassBeginInfo.pClearValues = clearValues;

        for (int32_t i = 0; i < drawCmdBuffers.size(); ++i)
        {
            /// red background for images other than 0
            if( i != 0 )
                clearValues[0].color = { 1.f, 0.f, 0.f, 1.f };
            /// 

            renderPassBeginInfo.framebuffer = frameBuffers[i];

            VK_CHECK_RESULT(vkBeginCommandBuffer(drawCmdBuffers[i], &cmdBufInfo));

            vkCmdBeginRenderPass(drawCmdBuffers[i], &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);

            VkViewport viewport = vkTools::initializers::viewport((float)width, (float)height, 0.0f, 1.0f);
            vkCmdSetViewport(drawCmdBuffers[i], 0, 1, &viewport);

            VkRect2D scissor = vkTools::initializers::rect2D(width, height, 0, 0);
            vkCmdSetScissor(drawCmdBuffers[i], 0, 1, &scissor);

            vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.solid);

            for (auto& gear : gears)
            {
                gear->draw(drawCmdBuffers[i], pipelineLayout);
            }

            vkCmdEndRenderPass(drawCmdBuffers[i]);

            VK_CHECK_RESULT(vkEndCommandBuffer(drawCmdBuffers[i]));
        }
    }

You example bin.zip crash on my Windows 7 Intel I5 Radeon HD 7950.

Your modification has absolutely no effect. clearValues is not used anymore after you set it.

it is actually; The line “renderPassBeginInfo.pClearValues = clearValues;” stores a pointer to the static array. So updating the value in the array will update the value vulkan will see.

^ right, sorry. Actually that modification works for me on AMD as intended bar one shader related validation error. So, let’s blame driver :wink: