vulkan/runtime: refactor to use DETECT_OS_ANDROID instead of ANDROID

Also update vk_android_native_buffer.h to use __ANDROID__ directly.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27374>
This commit is contained in:
Yiwei Zhang 2024-01-30 13:36:17 -08:00 committed by Marge Bot
parent f7d35be362
commit 2dd95bc4b7
9 changed files with 13 additions and 12 deletions

View file

@ -18,7 +18,7 @@
#define __VK_ANDROID_NATIVE_BUFFER_H__
/* MESA: A hack to avoid #ifdefs in driver code. */
#ifdef ANDROID
#ifdef __ANDROID__
#include <cutils/native_handle.h>
#include <vulkan/vulkan.h>

View file

@ -197,7 +197,7 @@ vk_common_SetDebugUtilsObjectNameEXT(
{
VK_FROM_HANDLE(vk_device, device, _device);
#ifdef ANDROID
#if DETECT_OS_ANDROID
if (pNameInfo->objectType == VK_OBJECT_TYPE_SWAPCHAIN_KHR ||
pNameInfo->objectType == VK_OBJECT_TYPE_SURFACE_KHR) {
#else

View file

@ -175,10 +175,10 @@ vk_device_init(struct vk_device *device,
unreachable("Invalid timeline mode");
}
#ifdef ANDROID
#if DETECT_OS_ANDROID
mtx_init(&device->swapchain_private_mtx, mtx_plain);
device->swapchain_private = NULL;
#endif /* ANDROID */
#endif /* DETECT_OS_ANDROID */
simple_mtx_init(&device->trace_mtx, mtx_plain);
@ -193,13 +193,13 @@ vk_device_finish(struct vk_device *device)
vk_memory_trace_finish(device);
#ifdef ANDROID
#if DETECT_OS_ANDROID
if (device->swapchain_private) {
hash_table_foreach(device->swapchain_private, entry)
util_sparse_array_finish(entry->data);
ralloc_free(device->swapchain_private);
}
#endif /* ANDROID */
#endif /* DETECT_OS_ANDROID */
simple_mtx_destroy(&device->trace_mtx);

View file

@ -38,7 +38,7 @@
#include "vk_util.h"
#include "vulkan/wsi/wsi_common.h"
#ifdef ANDROID
#if DETECT_OS_ANDROID
#include "vk_android.h"
#include <vulkan/vulkan_android.h>
#endif
@ -100,7 +100,7 @@ vk_image_init(struct vk_device *device,
image->drm_format_mod = ((1ULL << 56) - 1) /* DRM_FORMAT_MOD_INVALID */;
#endif
#ifdef ANDROID
#if DETECT_OS_ANDROID
const VkExternalFormatANDROID *ext_format =
vk_find_struct_const(pCreateInfo->pNext, EXTERNAL_FORMAT_ANDROID);
if (ext_format && ext_format->externalFormat != 0) {

View file

@ -76,7 +76,7 @@ struct vk_image {
uint64_t drm_format_mod;
#endif
#ifdef ANDROID
#if DETECT_OS_ANDROID
/* AHARDWAREBUFFER_FORMAT for this image or 0
*
* A default is provided by the Vulkan runtime code based on the VkFormat

View file

@ -243,7 +243,7 @@ vk_object_base_private_data(struct vk_device *device,
* vkGet/SetPrivateData call on a swapchain because the loader will
* handle it.
*/
#ifdef ANDROID
#if DETECT_OS_ANDROID
if (objectType == VK_OBJECT_TYPE_SWAPCHAIN_KHR ||
objectType == VK_OBJECT_TYPE_SURFACE_KHR) {
#else

View file

@ -27,6 +27,7 @@
#include <vulkan/vk_icd.h>
#include "c11/threads.h"
#include "util/detect_os.h"
#include "util/macros.h"
#include "util/sparse_array.h"

View file

@ -1124,7 +1124,7 @@ vk_queue_finish(struct vk_queue *queue)
vk_queue_submit_destroy(queue, submit);
}
#ifdef ANDROID
#if DETECT_OS_ANDROID
if (queue->anb_semaphore != VK_NULL_HANDLE) {
struct vk_device *device = queue->base.device;
device->dispatch_table.DestroySemaphore(vk_device_to_handle(device),

View file

@ -146,7 +146,7 @@ struct vk_queue {
struct util_dynarray labels;
bool region_begin;
#ifdef ANDROID
#if DETECT_OS_ANDROID
/** SYNC_FD signal semaphore for vkQueueSignalReleaseImageANDROID
*
* VK_ANDROID_native_buffer enforces explicit fencing on the present api