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

Commit 04f4f474 authored by Jesse Hall's avatar Jesse Hall
Browse files

vulkan: initial loader and null driver

Change-Id: Id5ebb5f01e61e9b114990f49c64c88fbbb7b730e
(cherry picked from commit 4df205cdfc61e66de774ba50be9ef59a08cf88bb)
parent f09c6b1f
Loading
Loading
Loading
Loading

vulkan/.clang-format

0 → 100644
+2 −0
Original line number Diff line number Diff line
BasedOnStyle: Chromium
IndentWidth: 4
+21 −0
Original line number Diff line number Diff line
@@ -199,3 +199,24 @@
    {{Global $d.Name $d.Expression}}
  {{end}}
{{end}}


{{/*
-------------------------------------------------------------------------------
  Given a function, return "Global", "Instance", or "Device" depending on which
  dispatch table the function belongs to.
-------------------------------------------------------------------------------
*/}}
{{define "Vtbl#VkInstance"      }}Instance{{end}}
{{define "Vtbl#VkPhysicalDevice"}}Instance{{end}}
{{define "Vtbl#VkDevice"        }}Device{{end}}
{{define "Vtbl#VkQueue"         }}Device{{end}}
{{define "Vtbl#VkCmdBuffer"     }}Device{{end}}
{{define "Vtbl_Default"         }}Global{{end}}
{{define "Vtbl"}}
  {{AssertType $ "Function"}}

  {{range $i, $p := $.CallParameters}}
    {{if not $i}}{{Node "Vtbl" $p}}{{end}}
  {{end}}
{{end}}
+71 −0
Original line number Diff line number Diff line
/*
 * Copyright 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_HWVULKAN_H
#define ANDROID_HWVULKAN_H

#include <hardware/hardware.h>
#include <vulkan/vulkan.h>

__BEGIN_DECLS

#define HWVULKAN_HARDWARE_MODULE_ID "vulkan"

#define HWVULKAN_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1)
#define HWVULKAN_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, 0)

#define HWVULKAN_DEVICE_0 "vk0"

typedef struct hwvulkan_module_t {
    struct hw_module_t common;
} hwvulkan_module_t;

/* Dispatchable Vulkan object handles must be pointers, which must point to
 * instances of hwvulkan_dispatch_t (potentially followed by additional
 * implementation-defined data). On return from the creation function, the
 * 'magic' field must contain HWVULKAN_DISPATCH_MAGIC; the loader will overwrite
 * the 'vtbl' field.
 */
#if defined(__LP64__)
#define HWVULKAN_DISPATCH_MAGIC UINT64_C(0xCA11AB1E00C0DE00)
#elif defined(__ILP32__)
#define HWVULKAN_DISPATCH_MAGIC UINT32_C(0xCA11AB1E)
#else
#error "unknown pointer size?!"
#endif

typedef union {
    uintptr_t magic;
    const void* vtbl;
} hwvulkan_dispatch_t;

/* A hwvulkan_device_t corresponds to an ICD on other systems. Currently there
 * can only be one on a system (HWVULKAN_DEVICE_0). It is opened once per
 * process when the Vulkan API is first used; the hw_device_t::close() function
 * is never called. Any non-trivial resource allocation should be done when
 * the VkInstance is created rather than when the hwvulkan_device_t is opened.
 */
typedef struct hwvulkan_device_t {
    struct hw_device_t common;

    PFN_vkGetGlobalExtensionProperties GetGlobalExtensionProperties;
    PFN_vkCreateInstance CreateInstance;
    PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
} hwvulkan_device_t;

__END_DECLS

#endif  // ANDROID_HWVULKAN_H
+90 −0
Original line number Diff line number Diff line
//
// File: vk_platform.h
//
/*
** Copyright (c) 2014-2015 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE 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
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/


#ifndef __VK_PLATFORM_H__
#define __VK_PLATFORM_H__

#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus

/*
***************************************************************************************************
*   Platform-specific directives and type declarations
***************************************************************************************************
*/

#if defined(_WIN32)
    // On Windows, VKAPI should equate to the __stdcall convention
    #define VKAPI   __stdcall
#elif defined(__GNUC__)
    // On other platforms using GCC, VKAPI stays undefined
    #define VKAPI
#else
    // Unsupported Platform!
    #error "Unsupported OS Platform detected!"
#endif

#include <stddef.h>

#if !defined(VK_NO_STDINT_H)
    #if defined(_MSC_VER) && (_MSC_VER < 1600)
        typedef signed   __int8  int8_t;
        typedef unsigned __int8  uint8_t;
        typedef signed   __int16 int16_t;
        typedef unsigned __int16 uint16_t;
        typedef signed   __int32 int32_t;
        typedef unsigned __int32 uint32_t;
        typedef signed   __int64 int64_t;
        typedef unsigned __int64 uint64_t;
    #else
        #include <stdint.h>
    #endif
#endif // !defined(VK_NO_STDINT_H)

typedef uint64_t   VkDeviceSize;
typedef uint32_t   VkBool32;

typedef uint32_t   VkSampleMask;
typedef uint32_t   VkFlags;

#if (UINTPTR_MAX >= UINT64_MAX)
    #define VK_UINTPTRLEAST64_MAX UINTPTR_MAX

    typedef uintptr_t VkUintPtrLeast64;
#else
    #define VK_UINTPTRLEAST64_MAX UINT64_MAX

    typedef uint64_t  VkUintPtrLeast64;
#endif

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus

#endif // __VK_PLATFORM_H__
+3054 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading