This allows us to reduce ANDROID #ifdef's.
v2: always include vk_android.h in radv_formats.c
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22619>
#include "sid.h"
#include "vk_format.h"
+#include "vk_android.h"
#include "vk_util.h"
#include "ac_drm_fourcc.h"
#include "vulkan/util/vk_format.h"
#include "vulkan/util/vk_enum_defines.h"
-#ifdef ANDROID
-#include "vk_android.h"
-#endif
-
uint32_t
radv_translate_buffer_dataformat(const struct util_format_description *desc, int first_non_void)
{
bool ahb_supported =
physical_device->vk.supported_extensions.ANDROID_external_memory_android_hardware_buffer;
if (android_usage && ahb_supported) {
-#if RADV_SUPPORT_ANDROID_HARDWARE_BUFFER
android_usage->androidHardwareBufferUsage =
vk_image_usage_to_ahb_usage(base_info->flags, base_info->usage);
-#endif
}
/* From the Vulkan 1.0.97 spec:
#include "anv_private.h"
#include "drm-uapi/drm_fourcc.h"
+#include "vk_android.h"
#include "vk_enum_defines.h"
#include "vk_enum_to_str.h"
#include "vk_format.h"
#include "vk_util.h"
-#if defined(ANDROID) && ANDROID_API_LEVEL >= 26
-#include "vk_android.h"
-#endif
-
/*
* gcc-4 and earlier don't allow compound literals where a constant
* is required in -std=c99/gnu99 mode, so we can't use ISL_SWIZZLE()
bool ahw_supported =
physical_device->vk.supported_extensions.ANDROID_external_memory_android_hardware_buffer;
-#if defined(ANDROID) && ANDROID_API_LEVEL >= 26
if (ahw_supported && android_usage) {
android_usage->androidHardwareBufferUsage =
vk_image_usage_to_ahb_usage(base_info->flags, base_info->usage);
/* Limit maxArrayLayers to 1 for AHardwareBuffer based images for now. */
base_props->imageFormatProperties.maxArrayLayers = 1;
}
-#endif
/* From the Vulkan 1.0.42 spec:
*
#include "anv_private.h"
#include "drm-uapi/drm_fourcc.h"
+#include "vk_android.h"
#include "vk_enum_defines.h"
#include "vk_enum_to_str.h"
#include "vk_format.h"
#include "vk_util.h"
-#if defined(ANDROID) && ANDROID_API_LEVEL >= 26
-#include "vk_android.h"
-#endif
-
/*
* gcc-4 and earlier don't allow compound literals where a constant
* is required in -std=c99/gnu99 mode, so we can't use ISL_SWIZZLE()
bool ahw_supported =
physical_device->vk.supported_extensions.ANDROID_external_memory_android_hardware_buffer;
-#if defined(ANDROID) && ANDROID_API_LEVEL >= 26
if (ahw_supported && android_usage) {
android_usage->androidHardwareBufferUsage =
vk_image_usage_to_ahb_usage(base_info->flags,
/* Limit maxArrayLayers to 1 for AHardwareBuffer based images for now. */
base_props->imageFormatProperties.maxArrayLayers = 1;
}
-#endif
/* From the Vulkan 1.0.42 spec:
*
#endif
#if ANDROID_API_LEVEL >= 26
+
uint64_t vk_image_usage_to_ahb_usage(const VkImageCreateFlags vk_create,
const VkImageUsageFlags vk_usage);
struct AHardwareBuffer *
vk_alloc_ahardware_buffer(const VkMemoryAllocateInfo *pAllocateInfo);
-#endif
+
+#else /* ANDROID_API_LEVEL >= 26 */
+
+static inline uint64_t
+vk_image_usage_to_ahb_usage(const VkImageCreateFlags vk_create,
+ const VkImageUsageFlags vk_usage)
+{
+ return 0;
+}
+
+static inline struct AHardwareBuffer *
+vk_alloc_ahardware_buffer(const VkMemoryAllocateInfo *pAllocateInfo)
+{
+ return NULL;
+}
+
+#endif /* ANDROID_API_LEVEL >= 26 */
#ifdef __cplusplus
}
}
}
-#if defined(ANDROID) && ANDROID_API_LEVEL >= 26
if ((mem->export_handle_types &
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID) &&
mem->ahardware_buffer == NULL) {
return NULL;
}
}
-#endif
return mem;
}