[Mesa-dev] [PATCH 1/2] anv: stub internal android code

Lionel Landwerlin lionel.g.landwerlin at intel.com
Tue Nov 6 11:37:50 UTC 2018


This reduces the amount of #ifdef ANDROID we'll have to have inside
the driver. Potentially offering better coverage of the android
extensions.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
 src/intel/Makefile.sources           |  4 +++
 src/intel/Makefile.vulkan.am         |  3 ++-
 src/intel/vulkan/anv_android.h       | 37 ++++++++++++++++++++++++++++
 src/intel/vulkan/anv_android_stubs.c | 34 +++++++++++++++++++++++++
 src/intel/vulkan/anv_image.c         |  2 --
 src/intel/vulkan/anv_private.h       | 10 +-------
 src/intel/vulkan/meson.build         |  2 ++
 7 files changed, 80 insertions(+), 12 deletions(-)
 create mode 100644 src/intel/vulkan/anv_android.h
 create mode 100644 src/intel/vulkan/anv_android_stubs.c

diff --git a/src/intel/Makefile.sources b/src/intel/Makefile.sources
index d10c4511734..4da887f7ed2 100644
--- a/src/intel/Makefile.sources
+++ b/src/intel/Makefile.sources
@@ -220,6 +220,7 @@ ISL_GENERATED_FILES = \
 
 VULKAN_FILES := \
 	vulkan/anv_allocator.c \
+	vulkan/anv_android.h \
 	vulkan/anv_batch_chain.c \
 	vulkan/anv_blorp.c \
 	vulkan/anv_cmd_buffer.c \
@@ -246,6 +247,9 @@ VULKAN_FILES := \
 	vulkan/anv_wsi.c \
 	vulkan/vk_format_info.h
 
+VULKAN_NON_ANDROID_FILES := \
+	vulkan/anv_android_stubs.c
+
 VULKAN_ANDROID_FILES := \
 	vulkan/anv_android.c
 
diff --git a/src/intel/Makefile.vulkan.am b/src/intel/Makefile.vulkan.am
index 49108bbf946..f06280e7557 100644
--- a/src/intel/Makefile.vulkan.am
+++ b/src/intel/Makefile.vulkan.am
@@ -144,7 +144,8 @@ vulkan_libanv_gen11_la_SOURCES = $(VULKAN_GEN11_FILES)
 
 VULKAN_SOURCES = \
 	$(VULKAN_GENERATED_FILES) \
-	$(VULKAN_FILES)
+	$(VULKAN_FILES) \
+	$(VULKAN_NON_ANDROID_FILES)
 
 VULKAN_LIB_DEPS = \
 	vulkan/libvulkan_common.la \
diff --git a/src/intel/vulkan/anv_android.h b/src/intel/vulkan/anv_android.h
new file mode 100644
index 00000000000..a27c364471b
--- /dev/null
+++ b/src/intel/vulkan/anv_android.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef ANV_ANDROID_H
+#define ANV_ANDROID_H
+
+#include <vulkan/vulkan.h>
+#include <vulkan/vulkan_android.h>
+#include <vulkan/vk_android_native_buffer.h>
+
+VkResult anv_image_from_gralloc(VkDevice device_h,
+                                const VkImageCreateInfo *base_info,
+                                const VkNativeBufferANDROID *gralloc_info,
+                                const VkAllocationCallbacks *alloc,
+                                VkImage *pImage);
+
+#endif /* ANV_ANDROID_H */
diff --git a/src/intel/vulkan/anv_android_stubs.c b/src/intel/vulkan/anv_android_stubs.c
new file mode 100644
index 00000000000..a6fe5a5e6b3
--- /dev/null
+++ b/src/intel/vulkan/anv_android_stubs.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "anv_android.h"
+
+VkResult
+anv_image_from_gralloc(VkDevice device_h,
+                       const VkImageCreateInfo *base_info,
+                       const VkNativeBufferANDROID *gralloc_info,
+                       const VkAllocationCallbacks *alloc,
+                       VkImage *pImage)
+{
+   return VK_ERROR_EXTENSION_NOT_PRESENT;
+}
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index e89ce012be7..fdb13c2938a 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -631,14 +631,12 @@ anv_CreateImage(VkDevice device,
                 const VkAllocationCallbacks *pAllocator,
                 VkImage *pImage)
 {
-#ifdef ANDROID
    const VkNativeBufferANDROID *gralloc_info =
       vk_find_struct_const(pCreateInfo->pNext, NATIVE_BUFFER_ANDROID);
 
    if (gralloc_info)
       return anv_image_from_gralloc(device, pCreateInfo, gralloc_info,
                                     pAllocator, pImage);
-#endif
 
    return anv_image_create(device,
       &(struct anv_image_create_info) {
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index d8a08d9d67f..2ae03b51b98 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -76,10 +76,10 @@ struct gen_l3_config;
 #include <vulkan/vulkan.h>
 #include <vulkan/vulkan_intel.h>
 #include <vulkan/vk_icd.h>
-#include <vulkan/vk_android_native_buffer.h>
 
 #include "anv_entrypoints.h"
 #include "anv_extensions.h"
+#include "anv_android.h"
 #include "isl/isl.h"
 
 #include "common/gen_debug.h"
@@ -3096,14 +3096,6 @@ VkResult anv_image_create(VkDevice _device,
                           const VkAllocationCallbacks* alloc,
                           VkImage *pImage);
 
-#ifdef ANDROID
-VkResult anv_image_from_gralloc(VkDevice device_h,
-                                const VkImageCreateInfo *base_info,
-                                const VkNativeBufferANDROID *gralloc_info,
-                                const VkAllocationCallbacks *alloc,
-                                VkImage *pImage);
-#endif
-
 const struct anv_surface *
 anv_image_get_surface_for_aspect_mask(const struct anv_image *image,
                                       VkImageAspectFlags aspect_mask);
diff --git a/src/intel/vulkan/meson.build b/src/intel/vulkan/meson.build
index b08b84fe2f0..b9834867407 100644
--- a/src/intel/vulkan/meson.build
+++ b/src/intel/vulkan/meson.build
@@ -111,6 +111,8 @@ endforeach
 
 libanv_files = files(
   'anv_allocator.c',
+  'anv_android_stubs.c',
+  'anv_android.h',
   'anv_batch_chain.c',
   'anv_blorp.c',
   'anv_cmd_buffer.c',
-- 
2.19.1



More information about the mesa-dev mailing list