Commit b1444c9c authored by Bas Nieuwenhuizen's avatar Bas Nieuwenhuizen Committed by Bas Nieuwenhuizen

radv: Implement VK_ANDROID_native_buffer.

Passes
  dEQP-VK.api.smoke.*
  dEQP-VK.wsi.android.*

with android-cts-7.1_r12 .

Unlike the initial anv implementation this does
use syncobjs instead of waiting on the CPU.

This is missing meson build coverage for now.

One possible todo is that linux 4.15 now has a
sycall that allows us to export amdgpu fence to
a sync_file, which allows us not to force all
fences and semaphores to use syncobjs. However,
I had trouble with my kernel crashing regularly
with NULL pointers, and I'm not sure how beneficial
it is in the first place given that intel uses
syncobjs for all fences if available.
Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
parent a3e241ed
......@@ -99,6 +99,13 @@ VULKAN_LIB_DEPS += \
$(WAYLAND_CLIENT_LIBS)
endif
if HAVE_PLATFORM_ANDROID
AM_CPPFLAGS += $(ANDROID_CPPFLAGS)
AM_CFLAGS += $(ANDROID_CFLAGS)
VULKAN_LIB_DEPS += $(ANDROID_LIBS)
VULKAN_SOURCES += $(VULKAN_ANDROID_FILES)
endif
noinst_LTLIBRARIES = libvulkan_common.la
libvulkan_common_la_SOURCES = $(VULKAN_SOURCES)
......
......@@ -69,6 +69,9 @@ VULKAN_FILES := \
vk_format.h \
$(RADV_WS_AMDGPU_FILES)
VULKAN_ANDROID_FILES := \
radv_android.c
VULKAN_WSI_WAYLAND_FILES := \
radv_wsi_wayland.c
......
......@@ -31,10 +31,10 @@ radv_entrypoints = custom_target(
radv_extensions_c = custom_target(
'radv_extensions.c',
input : ['radv_extensions.py', vk_api_xml],
input : ['radv_extensions.py', vk_api_xml, vk_android_native_buffer_xml],
output : ['radv_extensions.c'],
command : [
prog_python2, '@INPUT0@', '--xml', '@INPUT1@', '--out', '@OUTPUT@',
prog_python2, '@INPUT0@', '--xml', '@INPUT1@', '--xml', '@INPUT2@', '--out', '@OUTPUT@',
],
)
......
This diff is collapsed.
......@@ -1108,6 +1108,9 @@ VkResult radv_CreateDevice(
/* Disabled and not implemented for now. */
device->dfsm_allowed = device->pbb_allowed && false;
#ifdef ANDROID
device->always_use_syncobj = device->physical_device->rad_info.has_syncobj_wait_for_submit;
#endif
#if HAVE_LLVM < 0x0400
device->llvm_supports_spill = false;
......@@ -2679,7 +2682,7 @@ VkResult radv_CreateFence(
fence->submitted = false;
fence->signalled = !!(pCreateInfo->flags & VK_FENCE_CREATE_SIGNALED_BIT);
fence->temp_syncobj = 0;
if (handleTypes) {
if (device->always_use_syncobj || handleTypes) {
int ret = device->ws->create_syncobj(device->ws, &fence->syncobj);
if (ret) {
vk_free2(&device->alloc, pAllocator, fence);
......@@ -2855,7 +2858,7 @@ VkResult radv_CreateSemaphore(
sem->temp_syncobj = 0;
/* create a syncobject if we are going to export this semaphore */
if (handleTypes) {
if (device->always_use_syncobj || handleTypes) {
assert (device->physical_device->rad_info.has_syncobj);
int ret = device->ws->create_syncobj(device->ws, &sem->syncobj);
if (ret) {
......
......@@ -1147,6 +1147,15 @@ radv_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 radv_image_from_gralloc(device, pCreateInfo, gralloc_info,
pAllocator, pImage);
#endif
const struct wsi_image_create_info *wsi_info =
vk_find_struct_const(pCreateInfo->pNext, WSI_IMAGE_CREATE_INFO_MESA);
bool scanout = wsi_info && wsi_info->scanout;
......@@ -1173,6 +1182,9 @@ radv_DestroyImage(VkDevice _device, VkImage _image,
if (image->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT)
device->ws->buffer_destroy(image->bo);
if (image->owned_memory != VK_NULL_HANDLE)
radv_FreeMemory(_device, image->owned_memory, pAllocator);
vk_free2(&device->alloc, pAllocator, image);
}
......
......@@ -70,6 +70,7 @@ typedef uint32_t xcb_window_t;
#include <vulkan/vulkan.h>
#include <vulkan/vulkan_intel.h>
#include <vulkan/vk_icd.h>
#include <vulkan/vk_android_native_buffer.h>
#include "radv_entrypoints.h"
......@@ -587,6 +588,7 @@ struct radv_device {
int queue_count[RADV_MAX_QUEUE_FAMILIES];
struct radeon_winsys_cs *empty_cs[RADV_MAX_QUEUE_FAMILIES];
bool always_use_syncobj;
bool llvm_supports_spill;
bool has_distributed_tess;
bool pbb_allowed;
......@@ -1374,6 +1376,9 @@ struct radv_image {
struct radv_cmask_info cmask;
uint64_t clear_value_offset;
uint64_t dcc_pred_offset;
/* For VK_ANDROID_native_buffer, the WSI image owns the memory, */
VkDeviceMemory owned_memory;
};
/* Whether the image has a htile that is known consistent with the contents of
......@@ -1468,6 +1473,13 @@ VkResult radv_image_create(VkDevice _device,
const VkAllocationCallbacks* alloc,
VkImage *pImage);
VkResult
radv_image_from_gralloc(VkDevice device_h,
const VkImageCreateInfo *base_info,
const VkNativeBufferANDROID *gralloc_info,
const VkAllocationCallbacks *alloc,
VkImage *out_image_h);
void radv_image_view_init(struct radv_image_view *view,
struct radv_device *device,
const VkImageViewCreateInfo* pCreateInfo);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment