Update PhysicalDevice::getProperties(<AHB properties>)

... to use AHardwareBuffer Usage Equivalence Table from the spec. Bug: b/169439421 Test: launch Cuttlefish with SwANGLE Test: dEQP-VK.api.external.memory.android_hardware_buffer.* Change-Id: Iad6bf6424a1139c623b0fc664b949eb40bbb11bb Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/53148 Presubmit-Ready: Jason Macnak <natsu@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarJason Macnak <natsu@google.com> Commit-Queue: Jason Macnak <natsu@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 349abcce
......@@ -710,13 +710,40 @@ void PhysicalDevice::getProperties(VkPhysicalDevicePresentationPropertiesANDROID
properties->sharedImage = VK_FALSE;
}
void PhysicalDevice::getProperties(VkAndroidHardwareBufferUsageANDROID *properties) const
void PhysicalDevice::getProperties(const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkAndroidHardwareBufferUsageANDROID *ahbProperties) const
{
// TODO(b/169439421)
// This AHB could be either a framebuffer, OR a sampled image
// Here we just say it's both
// Need to pass down info on the type of image in question
properties->androidHardwareBufferUsage |= AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE | AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT;
// Maps VkImageUsageFlags to AHB usage flags using this table from the Vulkan spec
// https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#memory-external-android-hardware-buffer-usage
// VK_IMAGE_CREATE_PROTECTED_BIT not currently supported.
ASSERT((pImageFormatInfo->flags & VK_IMAGE_CREATE_PROTECTED_BIT) == 0);
// "It must include at least one GPU usage flag (AHARDWAREBUFFER_USAGE_GPU_*), even if none of the corresponding Vulkan usages or flags are requested."
uint64_t ahbUsage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
// Already covered by the default GPU usage flag above.
//
// if ((vkUsageFlags & VK_IMAGE_USAGE_SAMPLED_BIT) || (vkUsageFlags & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT))
// {
// ahbUsage |= AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
// }
if((pImageFormatInfo->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) || (pImageFormatInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT))
{
ahbUsage |= AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER;
}
if(pImageFormatInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT)
{
ahbUsage |= AHARDWAREBUFFER_USAGE_GPU_CUBE_MAP;
}
if(pImageFormatInfo->flags & VK_IMAGE_CREATE_PROTECTED_BIT)
{
ahbUsage |= AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT;
}
ahbProperties->androidHardwareBufferUsage = ahbUsage;
}
#endif
......
......@@ -50,7 +50,7 @@ public:
void getProperties(VkSamplerYcbcrConversionImageFormatProperties *properties) const;
#ifdef __ANDROID__
void getProperties(VkPhysicalDevicePresentationPropertiesANDROID *properties) const;
void getProperties(VkAndroidHardwareBufferUsageANDROID *properties) const;
void getProperties(const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkAndroidHardwareBufferUsageANDROID *properties) const;
#endif
void getProperties(const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo, VkExternalBufferProperties *pExternalBufferProperties) const;
void getProperties(const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo, VkExternalFenceProperties *pExternalFenceProperties) const;
......
......@@ -3234,7 +3234,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2(VkPhysi
case VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_USAGE_ANDROID:
{
auto properties = reinterpret_cast<VkAndroidHardwareBufferUsageANDROID *>(extensionProperties);
vk::Cast(physicalDevice)->getProperties(properties);
vk::Cast(physicalDevice)->getProperties(pImageFormatInfo, properties);
hasAHBUsage = true;
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment