anv: stub internal android code

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

v2: Move anv_android.h include before anv_entrypoints.h (Tapani)
    Fix autotools android build (Lionel)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
This commit is contained in:
Lionel Landwerlin 2018-11-06 11:37:50 +00:00
parent f6131d4ec7
commit b43f955037
7 changed files with 80 additions and 11 deletions

View file

@ -220,6 +220,7 @@ ISL_GENERATED_FILES = \
VULKAN_FILES := \ VULKAN_FILES := \
vulkan/anv_allocator.c \ vulkan/anv_allocator.c \
vulkan/anv_android.h \
vulkan/anv_batch_chain.c \ vulkan/anv_batch_chain.c \
vulkan/anv_blorp.c \ vulkan/anv_blorp.c \
vulkan/anv_cmd_buffer.c \ vulkan/anv_cmd_buffer.c \
@ -246,6 +247,9 @@ VULKAN_FILES := \
vulkan/anv_wsi.c \ vulkan/anv_wsi.c \
vulkan/vk_format_info.h vulkan/vk_format_info.h
VULKAN_NON_ANDROID_FILES := \
vulkan/anv_android_stubs.c
VULKAN_ANDROID_FILES := \ VULKAN_ANDROID_FILES := \
vulkan/anv_android.c vulkan/anv_android.c

View file

@ -171,6 +171,8 @@ VULKAN_CPPFLAGS += \
VULKAN_CFLAGS += $(ANDROID_CFLAGS) VULKAN_CFLAGS += $(ANDROID_CFLAGS)
VULKAN_LIB_DEPS += $(ANDROID_LIBS) VULKAN_LIB_DEPS += $(ANDROID_LIBS)
VULKAN_SOURCES += $(VULKAN_ANDROID_FILES) VULKAN_SOURCES += $(VULKAN_ANDROID_FILES)
else
VULKAN_SOURCES += $(VULKAN_NON_ANDROID_FILES)
endif endif
if HAVE_PLATFORM_X11 if HAVE_PLATFORM_X11

View file

@ -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 */

View file

@ -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;
}

View file

@ -631,14 +631,12 @@ anv_CreateImage(VkDevice device,
const VkAllocationCallbacks *pAllocator, const VkAllocationCallbacks *pAllocator,
VkImage *pImage) VkImage *pImage)
{ {
#ifdef ANDROID
const VkNativeBufferANDROID *gralloc_info = const VkNativeBufferANDROID *gralloc_info =
vk_find_struct_const(pCreateInfo->pNext, NATIVE_BUFFER_ANDROID); vk_find_struct_const(pCreateInfo->pNext, NATIVE_BUFFER_ANDROID);
if (gralloc_info) if (gralloc_info)
return anv_image_from_gralloc(device, pCreateInfo, gralloc_info, return anv_image_from_gralloc(device, pCreateInfo, gralloc_info,
pAllocator, pImage); pAllocator, pImage);
#endif
return anv_image_create(device, return anv_image_create(device,
&(struct anv_image_create_info) { &(struct anv_image_create_info) {

View file

@ -76,8 +76,8 @@ struct gen_l3_config;
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <vulkan/vulkan_intel.h> #include <vulkan/vulkan_intel.h>
#include <vulkan/vk_icd.h> #include <vulkan/vk_icd.h>
#include <vulkan/vk_android_native_buffer.h>
#include "anv_android.h"
#include "anv_entrypoints.h" #include "anv_entrypoints.h"
#include "anv_extensions.h" #include "anv_extensions.h"
#include "isl/isl.h" #include "isl/isl.h"
@ -3096,14 +3096,6 @@ VkResult anv_image_create(VkDevice _device,
const VkAllocationCallbacks* alloc, const VkAllocationCallbacks* alloc,
VkImage *pImage); 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 * const struct anv_surface *
anv_image_get_surface_for_aspect_mask(const struct anv_image *image, anv_image_get_surface_for_aspect_mask(const struct anv_image *image,
VkImageAspectFlags aspect_mask); VkImageAspectFlags aspect_mask);

View file

@ -111,6 +111,8 @@ endforeach
libanv_files = files( libanv_files = files(
'anv_allocator.c', 'anv_allocator.c',
'anv_android_stubs.c',
'anv_android.h',
'anv_batch_chain.c', 'anv_batch_chain.c',
'anv_blorp.c', 'anv_blorp.c',
'anv_cmd_buffer.c', 'anv_cmd_buffer.c',