zeux / niagara

A Vulkan renderer written from scratch on stream
MIT License
1.26k stars 72 forks source link

AMD RX 560: cannot create VkDevice due Failed in ICD #18

Closed Andreyogld3d closed 2 years ago

Andreyogld3d commented 3 years ago

Hi @zeux vkCreateDevice failed: ERROR: terminator_CreateDevice: Failed in ICD C:\Windows\System32\DriverStore\FileRepository\u0364232.inf_amd64_ac01b1fb8d253d0b\B364161.\amdvlk64.dll vkCreateDevicecall

Later, I will try to fix problem and create a pull request

Vincent-P commented 3 years ago

The problem comes from the createDevice() function. Basically features are getting enabled without checking if the device supports them. Instead of forcing features to true you can query the device features directly using vkGetPhysicalDeviceFeatures2(physicalDevice, &features);. Note that in my case with a RX 5700XT I had to add a VkPhysicalDeviceVulkan11Features struct and enable the storageBuffer16BitAccess feature.

Here is my code if you just want to copy-paste:

    VkPhysicalDeviceVulkan12Features features12 = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES };
    VkPhysicalDeviceVulkan11Features features11 = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES };
    features11.pNext = &features12;

    VkPhysicalDeviceFeatures2 features = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 };
    features.pNext = &features11;

    vkGetPhysicalDeviceFeatures2(physicalDevice, &features);

    assert(features.features.multiDrawIndirect == true);
    assert(features.features.pipelineStatisticsQuery == true);
    assert(features.features.shaderInt16 == true);
    assert(features.features.shaderInt64 == true);

    assert(features12.drawIndirectCount == true);
    assert(features12.storageBuffer8BitAccess == true);
    assert(features11.storageBuffer16BitAccess == true);
    assert(features12.uniformAndStorageBuffer8BitAccess == true);
    // assert(features12.storagePushConstant8 == true); // not supported and not actually used?
    assert(features12.shaderFloat16 == true);
    assert(features12.shaderInt8 == true);
    assert(features12.samplerFilterMinmax == true);
    assert(features12.scalarBlockLayout == true);
zeux commented 2 years ago

This should be fixed now I believe.