anv/android: Enable shared presentable image support

Signed-off-by: Chris Spencer <spencercw@gmail.com>
Reviewed-by: Roman Stratiienko <r.stratiienko@gmail.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24941>
This commit is contained in:
Chris Spencer
2023-08-29 20:26:20 +01:00
committed by Marge Bot
parent 574bdee19d
commit b492f73f87
4 changed files with 36 additions and 2 deletions

View File

@@ -570,7 +570,8 @@ VkResult anv_GetSwapchainGrallocUsage2ANDROID(
*grallocConsumerUsage = 0;
*grallocProducerUsage = 0;
mesa_logd("%s: format=%d, usage=0x%x", __func__, format, imageUsage);
mesa_logd("%s: format=%d, usage=0x%x, swapchainUsage=0x%x", __func__, format,
imageUsage, swapchainImageUsage);
result = format_supported_with_usage(device_h, format, imageUsage);
if (result != VK_SUCCESS)
@@ -599,6 +600,13 @@ VkResult anv_GetSwapchainGrallocUsage2ANDROID(
*grallocConsumerUsage |= GRALLOC1_CONSUMER_USAGE_HWCOMPOSER;
}
if ((swapchainImageUsage & VK_SWAPCHAIN_IMAGE_USAGE_SHARED_BIT_ANDROID) &&
device->u_gralloc != NULL) {
uint64_t front_rendering_usage = 0;
u_gralloc_get_front_rendering_usage(device->u_gralloc, &front_rendering_usage);
*grallocProducerUsage |= front_rendering_usage;
}
return VK_SUCCESS;
}
#endif

View File

@@ -48,6 +48,9 @@
#include "util/os_file.h"
#include "util/os_misc.h"
#include "util/u_atomic.h"
#ifdef ANDROID
#include "util/u_gralloc/u_gralloc.h"
#endif
#include "util/u_string.h"
#include "util/driconf.h"
#include "git_sha1.h"
@@ -2449,15 +2452,23 @@ void anv_GetPhysicalDeviceProperties2(
break;
}
#ifdef ANDROID
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch"
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID: {
VkPhysicalDevicePresentationPropertiesANDROID *props =
(VkPhysicalDevicePresentationPropertiesANDROID *)ext;
props->sharedImage = VK_FALSE;
uint64_t front_rendering_usage = 0;
struct u_gralloc *gralloc = u_gralloc_create(U_GRALLOC_TYPE_AUTO);
if (gralloc != NULL) {
u_gralloc_get_front_rendering_usage(gralloc, &front_rendering_usage);
u_gralloc_destroy(&gralloc);
}
props->sharedImage = front_rendering_usage ? VK_TRUE : VK_FALSE;
break;
}
#pragma GCC diagnostic pop
#endif
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_PROPERTIES_EXT: {
VkPhysicalDeviceProvokingVertexPropertiesEXT *properties =
@@ -3447,6 +3458,10 @@ VkResult anv_CreateDevice(
goto fail_internal_cache;
}
#ifdef ANDROID
device->u_gralloc = u_gralloc_create(U_GRALLOC_TYPE_AUTO);
#endif
device->robust_buffer_access =
device->vk.enabled_features.robustBufferAccess ||
device->vk.enabled_features.nullDescriptor;
@@ -3546,6 +3561,10 @@ void anv_DestroyDevice(
if (!device)
return;
#ifdef ANDROID
u_gralloc_destroy(&device->u_gralloc);
#endif
struct anv_physical_device *pdevice = device->physical;
anv_device_utrace_finish(device);

View File

@@ -63,6 +63,9 @@
#include "util/set.h"
#include "util/sparse_array.h"
#include "util/u_atomic.h"
#ifdef ANDROID
#include "util/u_gralloc/u_gralloc.h"
#endif
#include "util/u_vector.h"
#include "util/u_math.h"
#include "util/vma.h"
@@ -1298,6 +1301,9 @@ struct anv_device {
uint32_t draw_call_count;
struct anv_state breakpoint;
#ifdef ANDROID
struct u_gralloc *u_gralloc;
#endif
};
static inline struct anv_state

View File

@@ -210,6 +210,7 @@ if with_xlib_lease
endif
if with_platform_android
anv_deps += idep_u_gralloc
libanv_files += files('anv_android.c')
else
libanv_files += files('anv_android_stubs.c')