Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.

Commit 74ef6c4

Browse files
committed
FROMLIST: anv/android: handle storage images in vkGetSwapchainGrallocUsageANDROID
Android P and earlier expect that the surface supports storage images, and so many of the tests fail when the framework checks for that support. The framework also includes various image format and usage combinations that are invalid for the hardware. Drop the STORAGE restriction from the HAL and whitelist a pair of formats so that existing versions of Android can pass these tests. Fixes: dEQP-VK.wsi.android.* Signed-off-by: Kevin Strasser <[email protected]> (am from https://patchwork.freedesktop.org/patch/247681/)
1 parent 1065e9a commit 74ef6c4

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/intel/vulkan/anv_android.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ VkResult anv_GetSwapchainGrallocUsageANDROID(
234234
*grallocUsage = 0;
235235
intel_logd("%s: format=%d, usage=0x%x", __func__, format, imageUsage);
236236

237-
/* WARNING: Android Nougat's libvulkan.so hardcodes the VkImageUsageFlags
237+
/* WARNING: Android's libvulkan.so hardcodes the VkImageUsageFlags
238238
* returned to applications via VkSurfaceCapabilitiesKHR::supportedUsageFlags.
239239
* The relevant code in libvulkan/swapchain.cpp contains this fun comment:
240240
*
@@ -247,14 +247,25 @@ VkResult anv_GetSwapchainGrallocUsageANDROID(
247247
* dEQP-VK.wsi.android.swapchain.*.image_usage to fail.
248248
*/
249249

250-
const VkPhysicalDeviceImageFormatInfo2KHR image_format_info = {
250+
VkPhysicalDeviceImageFormatInfo2KHR image_format_info = {
251251
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR,
252252
.format = format,
253253
.type = VK_IMAGE_TYPE_2D,
254254
.tiling = VK_IMAGE_TILING_OPTIMAL,
255255
.usage = imageUsage,
256256
};
257257

258+
/* Android P and earlier doesn't check if the physical device supports a
259+
* given format and usage combination before calling this function. Omit the
260+
* storage requirement to make the tests pass.
261+
*/
262+
#if ANDROID_API_LEVEL <= 28
263+
if (format == VK_FORMAT_R8G8B8A8_SRGB ||
264+
format == VK_FORMAT_R5G6B5_UNORM_PACK16) {
265+
image_format_info.usage &= ~VK_IMAGE_USAGE_STORAGE_BIT;
266+
}
267+
#endif
268+
258269
VkImageFormatProperties2KHR image_format_props = {
259270
.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR,
260271
};
@@ -268,19 +279,13 @@ VkResult anv_GetSwapchainGrallocUsageANDROID(
268279
"inside %s", __func__);
269280
}
270281

271-
/* Reject STORAGE here to avoid complexity elsewhere. */
272-
if (imageUsage & VK_IMAGE_USAGE_STORAGE_BIT) {
273-
return vk_errorf(device->instance, device, VK_ERROR_FORMAT_NOT_SUPPORTED,
274-
"VK_IMAGE_USAGE_STORAGE_BIT unsupported for gralloc "
275-
"swapchain");
276-
}
277-
278282
if (unmask32(&imageUsage, VK_IMAGE_USAGE_TRANSFER_DST_BIT |
279283
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT))
280284
*grallocUsage |= GRALLOC_USAGE_HW_RENDER;
281285

282286
if (unmask32(&imageUsage, VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
283287
VK_IMAGE_USAGE_SAMPLED_BIT |
288+
VK_IMAGE_USAGE_STORAGE_BIT |
284289
VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT))
285290
*grallocUsage |= GRALLOC_USAGE_HW_TEXTURE;
286291

0 commit comments

Comments
 (0)