Vulkan SDK cube example draw/presentation synchronization not working

I am using Vulkan SDK 1.0.37. I made a small modification to the cube example (C:\VulkanSDK\1.0.37.0\Demos), in demo_draw_build_cmd(); I made every other image to be cleared red and every other green. When I run the cube example, sometimes I do not see fully red or green frames as expected. Instead I see frames which are partially red and partially green. Typically there is diagonal from top left corner to bottom right, and one of the triangles is different from the other. To me it seems that the image draw / presentation synchronization is not working as expected.

I am using Dell XPS 15 9550 with Geforce GTX 960M, Window 10 Enterprise 64-bit, driver version 376.33.

Here is how I modified demo_draw_build_cmd():

static void demo_draw_build_cmd(struct demo *demo, VkCommandBuffer cmd_buf) {
    const VkCommandBufferBeginInfo cmd_buf_info = {
        .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
        .pNext = NULL,
        .flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT,
        .pInheritanceInfo = NULL,
    };
    static bool toggle = false;
    toggle = !toggle;
    VkClearValue clear_values[2];
    clear_values[0].color.float32[0] = toggle ? 1.0f : 0.0f;
    clear_values[0].color.float32[1] = toggle ? 0.0f : 1.0f;
    clear_values[0].color.float32[2] = 0.0f;
    clear_values[0].color.float32[3] = 1.0f;
    clear_values[1].depthStencil.depth = 1.0f;
    clear_values[1].depthStencil.stencil = 0;
    const VkRenderPassBeginInfo rp_begin = {
    ...

Here is video showing the issue: [url]Vulkan SDK 1.0.37 cube example - YouTube

I suspect this may be Optimus issue. My guesstimate is that NVIDIA might be producing images otherwise correctly, but Intel may be presenting them too yearly.

I have set NVIDIA control panel global settings preferred graphics processor to High-performance NVIDIA processor, and in program settings Vulkan Demos (cube.exe) reports use global setting (High-performance NVIDIA processor). I have Intel driver version 4542 installed.

I tried to insert vkDeviceWaitIdle() before vkAcquireNextImageKHR(), vkQueueSubmit(), vkQueuePresentKHR(), but that did not make the issue go away. Both MAILBOX and FIFO show the issue.

I was not able to reproduce this issue on a Razer Blade 2016 laptop (GeForce GTX 1060) with Windows 10-64, NVIDIA 376.33 drivers and Intel 4542 drivers. The flashing red/green covered the whole window as expected.

Could you share the output of vulkaninfo to pastebin.com or similar. I wonder if there are any implicit layers messing things up. You can disable them by going to:
HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\ImplicitLayers
and temporarily modifying the DWORD value to be “1” (disabled) instead of “0” (enabled).

Also, are there any old VulkanSDKs or VulkanRTs in the system? You can see what’s still installed from by looking at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall and running the “UninstallString” from any VulkanRT* or VulkanSDK* entries.

Is the problem you’re seeing intermittent?

According to Dustin Graves at LunarXchange this issue is not specific to Vulkan. So I suppose this is Maxwell-Optimus issue.

Here is my vulkaninfo anyway as requested: ===========VULKAN INFO===========Vulkan API Version: 1.0.37INFO: [lo - Pastebin.com

I had vulkan RT versions 1.0.26, 1.0.33 and 1.0.37. I uninstalled everything else except 1.0.37. Issue remains.

Thanks for the vulkaninfo and the pointer to the other bug report. Your vulkaninfo looks good to me. You could try disabling the renderdoc implicit layer as an experiment, but I doubt that will resolve the issue.

I have filed an internal bug report with all your details. Someone with a Maxwell+Optimus combination will try to repro and investigate.

tksuoran,

Thank you for reporting the issue. I believe this bug should be fixed by 385.41 driver at [url]GeForce Game Ready Driver | 385.41 | Windows 10 64-bit | NVIDIA.

Could you give it a try? Thanks for your help.