Open bl4ckb0ne opened 4 weeks ago
I'm not sure yet if this is simply an error from my side, a driver issue or a hole in the spec.
That is what I think everytime I have to deal with Android Hardware Buffers :laughing:
The spec has a section that says
Ha so I'm not crazy! Thanks!
I made this function to pick the proper VkImageUsageFlagBits
static VkImageUsageFlagBits
ahb_format_usage(uint32_t fmt)
{
switch (fmt) {
case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
case AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM:
case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM:
case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM:
case AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT:
case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM: return VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
case AHARDWAREBUFFER_FORMAT_D16_UNORM:
case AHARDWAREBUFFER_FORMAT_D24_UNORM:
case AHARDWAREBUFFER_FORMAT_D24_UNORM_S8_UINT:
case AHARDWAREBUFFER_FORMAT_D32_FLOAT:
case AHARDWAREBUFFER_FORMAT_D32_FLOAT_S8_UINT:
case AHARDWAREBUFFER_FORMAT_S8_UINT: return VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
default: return 0;
}
}
Environment:
Intel(R) Arc(tm) A750 Graphics (DG2)
with mesa 24.2.2Describe the Issue
I was debugging a
VK_ERROR_FORMAT_NOT_SUPPORTED
fromvkGetPhysicalDeviceImageFormatProperties2
which was also ringin the validation layerI caught this in the emulator output window
The AHardwareBuffer format
AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM
doesn't supportVK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
as a usage flag. Removing it from my code madevkGetPhysicalDeviceImageFormatProperties2
returnVK_SUCCESS
, but the layer unconditionally assumes(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)
for theAHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER
here 1.Expected behavior
I'm not sure yet if this is simply an error from my side, a driver issue or a hole in the spec. Nevertheless, the validation message is popping on my side even though my AHardwareBuffer has the
VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT
flag set.Valid Usage ID
VUID-VkImageCreateInfo-pNext-00990
&VUID-VkImportAndroidHardwareBufferInfoANDROID-buffer-01880
Additional context
This was caught on the Android emulator with the Android 14 profile on the Pixel 6. I've had reports of the same issue on real HW but I can't reproduce on my side to conclude.