anv: refactor to use DETECT_OS_ANDROID instead of ANDROID

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Acked-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 10:52:43 -08:00
committed by Marge Bot
parent a678b7434a
commit 4fd4a6109d
4 changed files with 15 additions and 12 deletions

View File

@@ -24,7 +24,9 @@
#ifndef ANV_ANDROID_H
#define ANV_ANDROID_H
#if defined(ANDROID) && ANDROID_API_LEVEL >= 26
#include "util/detect_os.h"
#if DETECT_OS_ANDROID && ANDROID_API_LEVEL >= 26
#include <vndk/hardware_buffer.h>
#endif
#include <vulkan/vulkan.h>

View File

@@ -48,7 +48,7 @@
#include "util/os_file.h"
#include "util/os_misc.h"
#include "util/u_atomic.h"
#ifdef ANDROID
#if DETECT_OS_ANDROID
#include "util/u_gralloc/u_gralloc.h"
#endif
#include "util/u_string.h"
@@ -101,7 +101,7 @@ static const driOptionDescription anv_dri_options[] = {
DRI_CONF_ANV_MESH_CONV_PRIM_ATTRS_TO_VERT_ATTRS(-2)
DRI_CONF_FORCE_VK_VENDOR(0)
DRI_CONF_FAKE_SPARSE(false)
#if defined(ANDROID) && ANDROID_API_LEVEL >= 34
#if DETECT_OS_ANDROID && ANDROID_API_LEVEL >= 34
DRI_CONF_VK_REQUIRE_ASTC(true)
#else
DRI_CONF_VK_REQUIRE_ASTC(false)
@@ -405,7 +405,7 @@ get_device_extensions(const struct anv_physical_device *device,
.EXT_vertex_input_dynamic_state = true,
.EXT_ycbcr_image_arrays = true,
.AMD_buffer_marker = true,
#ifdef ANDROID
#if DETECT_OS_ANDROID
.ANDROID_external_memory_android_hardware_buffer = true,
.ANDROID_native_buffer = true,
#endif
@@ -2566,7 +2566,7 @@ void anv_GetPhysicalDeviceProperties2(
/* Unfortunately the runtime isn't handling ANDROID extensions. */
vk_foreach_struct(ext, pProperties->pNext) {
switch (ext->sType) {
#ifdef ANDROID
#if DETECT_OS_ANDROID
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch"
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID: {
@@ -3118,7 +3118,7 @@ VkResult anv_CreateDevice(
true);
override_initial_entrypoints = false;
}
#ifdef ANDROID
#if DETECT_OS_ANDROID
vk_device_dispatch_table_from_entrypoints(&dispatch_table,
&anv_android_device_entrypoints,
true);
@@ -3593,7 +3593,7 @@ VkResult anv_CreateDevice(
goto fail_internal_cache;
}
#ifdef ANDROID
#if DETECT_OS_ANDROID
device->u_gralloc = u_gralloc_create(U_GRALLOC_TYPE_AUTO);
#endif
@@ -3750,7 +3750,7 @@ void anv_DestroyDevice(
if (!device)
return;
#ifdef ANDROID
#if DETECT_OS_ANDROID
u_gralloc_destroy(&device->u_gralloc);
#endif

View File

@@ -1639,7 +1639,7 @@ anv_image_init(struct anv_device *device, struct anv_image *image,
if (image->vk.external_handle_types &
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID) {
image->from_ahb = true;
#ifdef ANDROID
#if DETECT_OS_ANDROID
image->vk.ahb_format = anv_ahb_format_for_vk_format(image->vk.format);
#endif
return VK_SUCCESS;
@@ -1933,7 +1933,7 @@ resolve_ahw_image(struct anv_device *device,
struct anv_image *image,
struct anv_device_memory *mem)
{
#if defined(ANDROID) && ANDROID_API_LEVEL >= 26
#if DETECT_OS_ANDROID && ANDROID_API_LEVEL >= 26
assert(mem->vk.ahardware_buffer);
AHardwareBuffer_Desc desc;
AHardwareBuffer_describe(mem->vk.ahardware_buffer, &desc);

View File

@@ -56,6 +56,7 @@
#include "ds/intel_driver_ds.h"
#include "util/bitset.h"
#include "util/bitscan.h"
#include "util/detect_os.h"
#include "util/macros.h"
#include "util/hash_table.h"
#include "util/list.h"
@@ -63,7 +64,7 @@
#include "util/set.h"
#include "util/sparse_array.h"
#include "util/u_atomic.h"
#ifdef ANDROID
#if DETECT_OS_ANDROID
#include "util/u_gralloc/u_gralloc.h"
#endif
#include "util/u_vector.h"
@@ -1800,7 +1801,7 @@ struct anv_device {
uint32_t draw_call_count;
struct anv_state breakpoint;
#ifdef ANDROID
#if DETECT_OS_ANDROID
struct u_gralloc *u_gralloc;
#endif