Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7b994a0 authored by Jesse Hall's avatar Jesse Hall
Browse files

vulkan: Implement vk_ext_khr_*swapchain extensions

Change-Id: I46312c9ba1332e0a5b8ac4c1b5608f0465c3962c
(cherry picked from commit e5ca41cb11212bbfbd608eddb92d794e12e1528e)
parent b1352bce
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -22,10 +22,12 @@ LOCAL_CFLAGS += -Weverything -Werror -Wno-padded -Wno-undef
LOCAL_CPPFLAGS := -std=c++1y \
	-Wno-c++98-compat-pedantic \
	-Wno-exit-time-destructors \
	-Wno-c99-extensions
	-Wno-c99-extensions \
	-Wno-zero-length-array

LOCAL_C_INCLUDES := \
	frameworks/native/vulkan/include
	frameworks/native/vulkan/include \
	system/core/libsync/include

LOCAL_SRC_FILES := \
	entry.cpp \
@@ -34,7 +36,7 @@ LOCAL_SRC_FILES := \
	swapchain.cpp
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk

LOCAL_SHARED_LIBRARIES := libhardware liblog
LOCAL_SHARED_LIBRARIES := libhardware liblog libsync

LOCAL_MODULE := libvulkan
include $(BUILD_SHARED_LIBRARY)
+36 −0
Original line number Diff line number Diff line
@@ -89,6 +89,9 @@ inline const InstanceVtbl* GetVtbl(VkPhysicalDevice physicalDevice) {
inline const DeviceVtbl* GetVtbl(VkDevice device) {
    return *reinterpret_cast<DeviceVtbl**>(device);
}
inline const DeviceVtbl* GetVtbl(VkQueue queue) {
    return *reinterpret_cast<DeviceVtbl**>(queue);
}

void* DefaultAlloc(void*, size_t size, size_t alignment, VkSystemAllocType) {
    return memalign(alignment, size);
@@ -577,4 +580,37 @@ VkResult DestroyDevice(VkDevice drv_device) {
    return VK_SUCCESS;
}

void* AllocDeviceMem(VkDevice device,
                     size_t size,
                     size_t align,
                     VkSystemAllocType type) {
    const VkAllocCallbacks* alloc_cb =
        static_cast<Device*>(GetVtbl(device)->device)->alloc;
    return alloc_cb->pfnAlloc(alloc_cb->pUserData, size, align, type);
}

void FreeDeviceMem(VkDevice device, void* ptr) {
    const VkAllocCallbacks* alloc_cb =
        static_cast<Device*>(GetVtbl(device)->device)->alloc;
    alloc_cb->pfnFree(alloc_cb->pUserData, ptr);
}

const DeviceVtbl& GetDriverVtbl(VkDevice device) {
    // TODO(jessehall): This actually returns the API-level vtbl for the
    // device, not the driver entry points. Given the current use -- getting
    // the driver's private swapchain-related functions -- that works, but is
    // misleading and likely to cause bugs. Fix as part of separating the
    // loader->driver interface from the app->loader interface.
    return static_cast<Device*>(GetVtbl(device)->device)->vtbl_storage;
}

const DeviceVtbl& GetDriverVtbl(VkQueue queue) {
    // TODO(jessehall): This actually returns the API-level vtbl for the
    // device, not the driver entry points. Given the current use -- getting
    // the driver's private swapchain-related functions -- that works, but is
    // misleading and likely to cause bugs. Fix as part of separating the
    // loader->driver interface from the app->loader interface.
    return static_cast<Device*>(GetVtbl(queue)->device)->vtbl_storage;
}

}  // namespace vulkan
+13 −5
Original line number Diff line number Diff line
@@ -234,6 +234,14 @@ VkResult CreateCommandBuffer(VkDevice device,
                             VkCmdBuffer* out_cmdbuf);
VkResult DestroyDevice(VkDevice drv_device);

void* AllocDeviceMem(VkDevice device,
                     size_t size,
                     size_t align,
                     VkSystemAllocType type);
void FreeDeviceMem(VkDevice device, void* ptr);
const DeviceVtbl& GetDriverVtbl(VkDevice device);
const DeviceVtbl& GetDriverVtbl(VkQueue queue);

// -----------------------------------------------------------------------------
// get_proc_addr.cpp

@@ -272,14 +280,14 @@ VkResult GetSurfacePresentModesKHR(VkDevice device,
                                   VkPresentModeKHR* modes);
VkResult CreateSwapchainKHR(VkDevice device,
                            const VkSwapchainCreateInfoKHR* create_info,
                            VkSwapchainKHR* swapchain);
VkResult DestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain);
                            VkSwapchainKHR* swapchain_handle);
VkResult DestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain_handle);
VkResult GetSwapchainImagesKHR(VkDevice device,
                               VkSwapchainKHR swapchain,
                               VkSwapchainKHR swapchain_handle,
                               uint32_t* count,
                               VkImage* image);
                               VkImage* images);
VkResult AcquireNextImageKHR(VkDevice device,
                             VkSwapchainKHR swapchain,
                             VkSwapchainKHR swapchain_handle,
                             uint64_t timeout,
                             VkSemaphore semaphore,
                             uint32_t* image_index);
+553 −30

File changed.

Preview size limit exceeded, changes collapsed.

+11 −13
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ VkResult CreateInstance(const VkInstanceCreateInfo* create_info,
                        VkInstance* out_instance) {
    // Assume the loader provided alloc callbacks even if the app didn't.
    ALOG_ASSERT(
        !create_info->pAllocCb,
        create_info->pAllocCb,
        "Missing alloc callbacks, loader or app should have provided them");

    VkInstance_T* instance =
@@ -695,6 +695,16 @@ VkResult CreateShaderModule(VkDevice device,
    return VK_SUCCESS;
}

VkResult ImportNativeFenceANDROID(VkDevice, VkSemaphore, int fence) {
    close(fence);
    return VK_SUCCESS;
}

VkResult QueueSignalNativeFenceANDROID(VkQueue, int* fence) {
    *fence = -1;
    return VK_SUCCESS;
}

// -----------------------------------------------------------------------------
// No-op entrypoints

@@ -785,7 +795,6 @@ VkResult BindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem,
}

VkResult BindImageMemory(VkDevice device, VkImage image, VkDeviceMemory mem, VkDeviceSize memOffset) {
    ALOGV("TODO: vk%s", __FUNCTION__);
    return VK_SUCCESS;
}

@@ -841,7 +850,6 @@ VkResult QueueSignalSemaphore(VkQueue queue, VkSemaphore semaphore) {
}

VkResult QueueWaitSemaphore(VkQueue queue, VkSemaphore semaphore) {
    ALOGV("TODO: vk%s", __FUNCTION__);
    return VK_SUCCESS;
}

@@ -1123,16 +1131,6 @@ void CmdEndRenderPass(VkCmdBuffer cmdBuffer) {
void CmdExecuteCommands(VkCmdBuffer cmdBuffer, uint32_t cmdBuffersCount, const VkCmdBuffer* pCmdBuffers) {
}

VkResult ImportNativeFenceANDROID(VkDevice device, VkSemaphore semaphore, int nativeFenceFd) {
    ALOGV("TODO: vk%s", __FUNCTION__);
    return VK_SUCCESS;
}

VkResult QueueSignalNativeFenceANDROID(VkQueue queue, int* pNativeFenceFd) {
    ALOGV("TODO: vk%s", __FUNCTION__);
    return VK_SUCCESS;
}

#pragma clang diagnostic pop
// clang-format on