Vulkan SDK warns about "bufferDeviceAddress" features

I am playing with Vulkan 1.2’s new feature VK_KHR_buffer_device_address. There are some issues.

  1. The vkGetPhysicalDeviceProperties say it is supported, but the vkGetBufferDeviceAddress is nullptr.
  2. Then I have to enable “VK_KHR_buffer_device_address” and fetch the address vkGetBufferDeviceAddress from ICD. But then the Vulkan validation layer says

VUID-vkGetBufferDeviceAddress-bufferDeviceAddress-03324(ERROR / SPEC): msgNum: -1505668325 - Validation Error: [ VUID-vkGetBufferDeviceAddress-bufferDeviceAddress-03324 ] Object 0: handle = 0xed70170000000012, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0xa641531b | The bufferDeviceAddress feature must: be enabled. The Vulkan spec states: The bufferDeviceAddress or VkPhysicalDeviceBufferDeviceAddressFeaturesEXT::bufferDeviceAddress feature must be enabled

UNASSIGNED-CoreValidation-Shader-FeatureNotEnabled(ERROR / SPEC): msgNum: -1940616195 - Validation Error: [ UNASSIGNED-CoreValidation-Shader-FeatureNotEnabled ] Object 0: handle = 0x1d17c4f5e60, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x8c548bfd | Shader requires (one of) [ VkPhysicalDeviceBufferDeviceAddressFeatures::bufferDeviceAddress VkPhysicalDeviceBufferDeviceAddressFeaturesEXT::bufferDeviceAddress ] but is not enabled on the device

My device is NVidia RTX 2080 Max-Q. Driver version: 451.48
The lunarG Vulkan SDK version 1.2.141.2

Moreover, when validation layer is enabled, the program will crash when submitting commands. If I run the program in NV NSight, everything works fine.

The fragment shader is

#version 460

#extension GL_EXT_buffer_reference : enable

layout(buffer_reference, std430, buffer_reference_align = 16) buffer ColorsPointer {
    vec4 data[];
};

layout(std430, binding = 1) buffer Colors {
    ColorsPointer colors;
};

layout (location = 0) out vec4 outFragColor;

void main() 
{
    uint index = uint(gl_FragCoord.x + 0.5);
    outFragColor = colors.data[index];
}

The right result:

Thanks guys.

You say that you need to enable the feature. The Vulkan validation layer says that you didn’t enable the feature. So… did you?

I think I did.

vkEnumerateDeviceExtensionProperties(physicalDevice, VK_NULL_HANDLE, &extCount, vExtensions.data());

        for (auto&& vExtension : vExtensions) {
            if (!strcmp("VK_KHR_swapchain", vExtension.extensionName)) {
                swapchainFound = true;
                extensionNames[supportedExtCount++] = "VK_KHR_swapchain";
            }
    
            if (!strcmp("VK_KHR_buffer_device_address", vExtension.extensionName)) {
                extensionNames[supportedExtCount++] = "VK_KHR_buffer_device_address";
            }
            if ( !strcmp("VK_KHR_shader_draw_parameters", vExtension.extensionName)) {
                extensionNames[supportedExtCount++] = "VK_KHR_shader_draw_parameters";
            }
            if (!strcmp("VK_KHR_draw_indirect_count", vExtension.extensionName)) {
                extensionNames[supportedExtCount++] = "VK_KHR_draw_indirect_count";
            }
        }

What about VkPhysicalDeviceBufferDeviceAddressFeaturesKHR in the pNext of VkDeviceCreateInfo?

You enabled the extension. The extension function name is vkGetBufferDeviceAddressKHR. The core feature function name is vkGetBufferDeviceAddress. If you want to use the latter, you need to activate the feature, not the extension.

Thanks Alfonse.

I enabled the features and get the correct vkGetBufferDeviceAddress function pointer.

But another problem comes up. The validation layer keeps warning that command buffer is not marked for simultaneous use, and the command is not submitted successfully.

If I modify my main() in the fragment shader to a simple one like

outFragColor = vec4(1, 0, 0, 1);

The warning is gone and the I get a fullscreen red quad.

I am sure if I should enable more features to use the bufferDeviceAddress. Thanks.

I think I found the root cause. The buffer address is only for those device local buffer. Need to bind a “VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT” memory to that buffer.