v3dv: 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:
@@ -53,7 +53,7 @@
|
||||
#include "util/u_debug.h"
|
||||
#include "util/format/u_format.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
#include "vk_android.h"
|
||||
#endif
|
||||
|
||||
@@ -213,7 +213,7 @@ get_device_extensions(const struct v3dv_physical_device *device,
|
||||
.EXT_texel_buffer_alignment = true,
|
||||
.EXT_tooling_info = true,
|
||||
.EXT_vertex_attribute_divisor = true,
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
.ANDROID_external_memory_android_hardware_buffer = true,
|
||||
.ANDROID_native_buffer = true,
|
||||
.EXT_queue_family_foreign = true,
|
||||
@@ -1443,7 +1443,7 @@ v3dv_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
|
||||
props->allowCommandBufferQueryCopies = true;
|
||||
break;
|
||||
}
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wswitch"
|
||||
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID: {
|
||||
@@ -1757,7 +1757,7 @@ v3dv_CreateDevice(VkPhysicalDevice physicalDevice,
|
||||
return vk_error(NULL, result);
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
device->gralloc = u_gralloc_create(U_GRALLOC_TYPE_AUTO);
|
||||
assert(device->gralloc);
|
||||
#endif
|
||||
@@ -1828,7 +1828,7 @@ fail:
|
||||
v3dv_event_free_resources(device);
|
||||
v3dv_query_free_resources(device);
|
||||
vk_device_finish(&device->vk);
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
u_gralloc_destroy(&device->gralloc);
|
||||
#endif
|
||||
vk_free(&device->vk.alloc, device);
|
||||
@@ -1869,7 +1869,7 @@ v3dv_DestroyDevice(VkDevice _device,
|
||||
mtx_destroy(&device->query_mutex);
|
||||
|
||||
vk_device_finish(&device->vk);
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
u_gralloc_destroy(&device->gralloc);
|
||||
#endif
|
||||
vk_free2(&device->vk.alloc, pAllocator, device);
|
||||
@@ -2175,7 +2175,7 @@ v3dv_AllocateMemory(VkDevice _device,
|
||||
if (result == VK_SUCCESS)
|
||||
close(fd_info->fd);
|
||||
} else if (mem->vk.ahardware_buffer) {
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
const native_handle_t *handle = AHardwareBuffer_getNativeHandle(mem->vk.ahardware_buffer);
|
||||
assert(handle->numFds > 0);
|
||||
size_t size = lseek(handle->data[0], 0, SEEK_END);
|
||||
@@ -2433,7 +2433,7 @@ v3dv_BindImageMemory2(VkDevice _device,
|
||||
const VkBindImageMemoryInfo *pBindInfos)
|
||||
{
|
||||
for (uint32_t i = 0; i < bindInfoCount; i++) {
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
V3DV_FROM_HANDLE(v3dv_device_memory, mem, pBindInfos[i].memory);
|
||||
V3DV_FROM_HANDLE(v3dv_device, device, _device);
|
||||
if (mem != NULL && mem->vk.ahardware_buffer) {
|
||||
@@ -2470,7 +2470,7 @@ v3dv_BindImageMemory2(VkDevice _device,
|
||||
vk_find_struct_const(pBindInfos->pNext,
|
||||
BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR);
|
||||
if (swapchain_info && swapchain_info->swapchain) {
|
||||
#ifndef ANDROID
|
||||
#if !DETECT_OS_ANDROID
|
||||
struct v3dv_image *swapchain_image =
|
||||
v3dv_wsi_get_image_from_swapchain(swapchain_info->swapchain,
|
||||
swapchain_info->imageIndex);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
#include "v3dv_private.h"
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
#include "vk_android.h"
|
||||
#endif
|
||||
#include "vk_enum_defines.h"
|
||||
@@ -732,7 +732,7 @@ v3dv_GetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
|
||||
if (external_props)
|
||||
external_props->externalMemoryProperties = prime_fd_props;
|
||||
break;
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID:
|
||||
if (external_props) {
|
||||
external_props->externalMemoryProperties.exportFromImportedHandleTypes = 0;
|
||||
@@ -748,7 +748,7 @@ v3dv_GetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
|
||||
}
|
||||
|
||||
if (android_usage) {
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
android_usage->androidHardwareBufferUsage =
|
||||
vk_image_usage_to_ahb_usage(base_info->flags, base_info->usage);
|
||||
#endif
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "util/u_math.h"
|
||||
#include "vk_util.h"
|
||||
#include "vulkan/wsi/wsi_common.h"
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
#include "vk_android.h"
|
||||
#endif
|
||||
|
||||
@@ -409,7 +409,7 @@ v3dv_image_init(struct v3dv_device *device,
|
||||
uint64_t modifier = DRM_FORMAT_MOD_INVALID;
|
||||
const VkImageDrmFormatModifierListCreateInfoEXT *mod_info = NULL;
|
||||
const VkImageDrmFormatModifierExplicitCreateInfoEXT *explicit_mod_info = NULL;
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
if (image->is_native_buffer_memory) {
|
||||
assert(image->android_explicit_layout);
|
||||
explicit_mod_info = image->android_explicit_layout;
|
||||
@@ -490,7 +490,7 @@ v3dv_image_init(struct v3dv_device *device,
|
||||
*/
|
||||
image->vk.create_flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
|
||||
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
/* At this time, an AHB handle is not yet provided.
|
||||
* Image layout will be filled up during vkBindImageMemory2
|
||||
*/
|
||||
@@ -517,7 +517,7 @@ create_image(struct v3dv_device *device,
|
||||
if (image == NULL)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
const VkExternalMemoryImageCreateInfo *external_info =
|
||||
vk_find_struct_const(pCreateInfo->pNext, EXTERNAL_MEMORY_IMAGE_CREATE_INFO);
|
||||
|
||||
@@ -572,7 +572,7 @@ create_image(struct v3dv_device *device,
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
if (image->is_native_buffer_memory) {
|
||||
result = v3dv_import_native_buffer_fd(v3dv_device_to_handle(device),
|
||||
native_buffer->handle->data[0], pAllocator,
|
||||
@@ -587,7 +587,7 @@ create_image(struct v3dv_device *device,
|
||||
return VK_SUCCESS;
|
||||
|
||||
fail:
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
if (image->android_explicit_layout)
|
||||
vk_free2(&device->vk.alloc, pAllocator, image->android_explicit_layout);
|
||||
if (image->android_plane_layouts)
|
||||
@@ -653,7 +653,7 @@ v3dv_CreateImage(VkDevice _device,
|
||||
{
|
||||
V3DV_FROM_HANDLE(v3dv_device, device, _device);
|
||||
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
/* VkImageSwapchainCreateInfoKHR is not useful at all */
|
||||
const VkImageSwapchainCreateInfoKHR *swapchain_info = NULL;
|
||||
#else
|
||||
@@ -748,7 +748,7 @@ v3dv_DestroyImage(VkDevice _device,
|
||||
image->shadow = NULL;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
if (image->is_native_buffer_memory)
|
||||
v3dv_FreeMemory(_device,
|
||||
v3dv_device_memory_to_handle(image->planes[0].mem),
|
||||
|
||||
@@ -65,7 +65,9 @@
|
||||
#define VG(x) ((void)0)
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
#include "util/detect_os.h"
|
||||
|
||||
#if DETECT_OS_ANDROID
|
||||
#include <vndk/hardware_buffer.h>
|
||||
#include "util/u_gralloc/u_gralloc.h"
|
||||
#endif
|
||||
@@ -597,7 +599,7 @@ struct v3dv_device {
|
||||
void *device_address_mem_ctx;
|
||||
struct util_dynarray device_address_bo_list; /* Array of struct v3dv_bo * */
|
||||
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
struct u_gralloc *gralloc;
|
||||
#endif
|
||||
};
|
||||
@@ -738,7 +740,7 @@ struct v3dv_image {
|
||||
*/
|
||||
struct v3dv_image *shadow;
|
||||
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
/* Image is backed by VK_ANDROID_native_buffer, */
|
||||
bool is_native_buffer_memory;
|
||||
/* Image is backed by VK_ANDROID_external_memory_android_hardware_buffer */
|
||||
@@ -2678,7 +2680,7 @@ v3dv_update_image_layout(struct v3dv_device *device,
|
||||
bool disjoint,
|
||||
const VkImageDrmFormatModifierExplicitCreateInfoEXT *explicit_mod_info);
|
||||
|
||||
#ifdef ANDROID
|
||||
#if DETECT_OS_ANDROID
|
||||
VkResult
|
||||
v3dv_gralloc_to_drm_explicit_layout(struct u_gralloc *gralloc,
|
||||
struct u_gralloc_buffer_handle *in_hnd,
|
||||
@@ -2691,6 +2693,6 @@ v3dv_import_native_buffer_fd(VkDevice device_h,
|
||||
int dma_buf,
|
||||
const VkAllocationCallbacks *alloc,
|
||||
VkImage image_h);
|
||||
#endif /* ANDROID */
|
||||
#endif /* DETECT_OS_ANDROID */
|
||||
|
||||
#endif /* V3DV_PRIVATE_H */
|
||||
|
||||
Reference in New Issue
Block a user