mesa/vulkan: use DETECT_OS_ANDROID

This uses DETECT_OS_ANDROID instead of defined(ANDROID).
This better supports glibc based host builds in the Soong
build system.

Reviewed-by: Aaron Ruby <aruby@blackberry.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26874>
This commit is contained in:
Gurchetan Singh
2023-11-16 13:26:52 -08:00
committed by Marge Bot
parent c27cd96f31
commit a1e67b3933
2 changed files with 11 additions and 8 deletions

View File

@@ -25,11 +25,13 @@
#include "vulkan/vulkan_core.h"
#include "util/detect_os.h"
#ifdef __cplusplus
extern "C" {
#endif
#if ANDROID_API_LEVEL >= 26
#if DETECT_OS_ANDROID && ANDROID_API_LEVEL >= 26
VkFormat vk_ahb_format_to_image_format(uint32_t ahb_format);
@@ -41,7 +43,7 @@ uint64_t vk_image_usage_to_ahb_usage(const VkImageCreateFlags vk_create,
struct AHardwareBuffer *
vk_alloc_ahardware_buffer(const VkMemoryAllocateInfo *pAllocateInfo);
#else /* ANDROID_API_LEVEL >= 26 */
#else /* DETECT_OS_ANDROID && ANDROID_API_LEVEL >= 26 */
static inline VkFormat
vk_ahb_format_to_image_format(uint32_t ahb_format)

View File

@@ -27,7 +27,7 @@
#include "vk_common_entrypoints.h"
#include "vk_util.h"
#if defined(ANDROID) && ANDROID_API_LEVEL >= 26
#if DETECT_OS_ANDROID && ANDROID_API_LEVEL >= 26
#include <vndk/hardware_buffer.h>
#endif
@@ -56,7 +56,7 @@ vk_device_memory_create(struct vk_device *device,
}
case VK_STRUCTURE_TYPE_IMPORT_ANDROID_HARDWARE_BUFFER_INFO_ANDROID: {
#if defined(ANDROID) && ANDROID_API_LEVEL >= 26
#if DETECT_OS_ANDROID && ANDROID_API_LEVEL >= 26
const VkImportAndroidHardwareBufferInfoANDROID *ahb_info = (void *)ext;
assert(mem->import_handle_type == 0);
@@ -80,7 +80,7 @@ vk_device_memory_create(struct vk_device *device,
break;
#else
unreachable("AHardwareBuffer import requires Android >= 26");
#endif /* ANDROID_API_LEVEL >= 26 */
#endif /* DETECT_OS_ANDROID && ANDROID_API_LEVEL >= 26 */
}
case VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR: {
@@ -181,15 +181,16 @@ vk_device_memory_destroy(struct vk_device *device,
const VkAllocationCallbacks *alloc,
struct vk_device_memory *mem)
{
#if defined(ANDROID) && ANDROID_API_LEVEL >= 26
#if DETECT_OS_ANDROID && ANDROID_API_LEVEL >= 26
if (mem->ahardware_buffer)
AHardwareBuffer_release(mem->ahardware_buffer);
#endif /* ANDROID_API_LEVEL >= 26 */
#endif /* DETECT_OS_ANDROID && ANDROID_API_LEVEL >= 26 */
vk_object_free(device, alloc, mem);
}
#if defined(ANDROID) && ANDROID_API_LEVEL >= 26
#if DETECT_OS_ANDROID && ANDROID_API_LEVEL >= 26
VkResult
vk_common_GetMemoryAndroidHardwareBufferANDROID(
VkDevice _device,