1*61046927SAndroid Build Coastguard Worker /* 2*61046927SAndroid Build Coastguard Worker * Copyright 2015 The Android Open Source Project 3*61046927SAndroid Build Coastguard Worker * 4*61046927SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*61046927SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*61046927SAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*61046927SAndroid Build Coastguard Worker * 8*61046927SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*61046927SAndroid Build Coastguard Worker * 10*61046927SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*61046927SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*61046927SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*61046927SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*61046927SAndroid Build Coastguard Worker * limitations under the License. 15*61046927SAndroid Build Coastguard Worker */ 16*61046927SAndroid Build Coastguard Worker 17*61046927SAndroid Build Coastguard Worker #ifndef ANDROID_HWVULKAN_H 18*61046927SAndroid Build Coastguard Worker #define ANDROID_HWVULKAN_H 19*61046927SAndroid Build Coastguard Worker 20*61046927SAndroid Build Coastguard Worker #include <hardware/hardware.h> 21*61046927SAndroid Build Coastguard Worker #include <vulkan/vulkan.h> 22*61046927SAndroid Build Coastguard Worker 23*61046927SAndroid Build Coastguard Worker __BEGIN_DECLS 24*61046927SAndroid Build Coastguard Worker 25*61046927SAndroid Build Coastguard Worker #define HWVULKAN_HARDWARE_MODULE_ID "vulkan" 26*61046927SAndroid Build Coastguard Worker 27*61046927SAndroid Build Coastguard Worker #define HWVULKAN_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) 28*61046927SAndroid Build Coastguard Worker #define HWVULKAN_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, 0) 29*61046927SAndroid Build Coastguard Worker 30*61046927SAndroid Build Coastguard Worker #define HWVULKAN_DEVICE_0 "vk0" 31*61046927SAndroid Build Coastguard Worker 32*61046927SAndroid Build Coastguard Worker typedef struct hwvulkan_module_t { 33*61046927SAndroid Build Coastguard Worker struct hw_module_t common; 34*61046927SAndroid Build Coastguard Worker } hwvulkan_module_t; 35*61046927SAndroid Build Coastguard Worker 36*61046927SAndroid Build Coastguard Worker /* Dispatchable Vulkan object handles must be pointers, which must point to 37*61046927SAndroid Build Coastguard Worker * instances of hwvulkan_dispatch_t (potentially followed by additional 38*61046927SAndroid Build Coastguard Worker * implementation-defined data). On return from the creation function, the 39*61046927SAndroid Build Coastguard Worker * 'magic' field must contain HWVULKAN_DISPATCH_MAGIC; the loader will overwrite 40*61046927SAndroid Build Coastguard Worker * the 'vtbl' field. 41*61046927SAndroid Build Coastguard Worker * 42*61046927SAndroid Build Coastguard Worker * NOTE: The magic value and the layout of hwvulkan_dispatch_t match the LunarG 43*61046927SAndroid Build Coastguard Worker * loader used on platforms, to avoid pointless annoying differences for 44*61046927SAndroid Build Coastguard Worker * multi-platform drivers. Don't change them without a good reason. If there is 45*61046927SAndroid Build Coastguard Worker * an opportunity to change it, using a magic value that doesn't leave the 46*61046927SAndroid Build Coastguard Worker * upper 32-bits zero on 64-bit platforms would be nice. 47*61046927SAndroid Build Coastguard Worker */ 48*61046927SAndroid Build Coastguard Worker #define HWVULKAN_DISPATCH_MAGIC 0x01CDC0DE 49*61046927SAndroid Build Coastguard Worker typedef union { 50*61046927SAndroid Build Coastguard Worker uintptr_t magic; 51*61046927SAndroid Build Coastguard Worker const void* vtbl; 52*61046927SAndroid Build Coastguard Worker } hwvulkan_dispatch_t; 53*61046927SAndroid Build Coastguard Worker 54*61046927SAndroid Build Coastguard Worker /* A hwvulkan_device_t corresponds to an ICD on other systems. Currently there 55*61046927SAndroid Build Coastguard Worker * can only be one on a system (HWVULKAN_DEVICE_0). It is opened once per 56*61046927SAndroid Build Coastguard Worker * process when the Vulkan API is first used; the hw_device_t::close() function 57*61046927SAndroid Build Coastguard Worker * is never called. Any non-trivial resource allocation should be done when 58*61046927SAndroid Build Coastguard Worker * the VkInstance is created rather than when the hwvulkan_device_t is opened. 59*61046927SAndroid Build Coastguard Worker */ 60*61046927SAndroid Build Coastguard Worker typedef struct hwvulkan_device_t { 61*61046927SAndroid Build Coastguard Worker struct hw_device_t common; 62*61046927SAndroid Build Coastguard Worker 63*61046927SAndroid Build Coastguard Worker PFN_vkEnumerateInstanceExtensionProperties 64*61046927SAndroid Build Coastguard Worker EnumerateInstanceExtensionProperties; 65*61046927SAndroid Build Coastguard Worker PFN_vkCreateInstance CreateInstance; 66*61046927SAndroid Build Coastguard Worker PFN_vkGetInstanceProcAddr GetInstanceProcAddr; 67*61046927SAndroid Build Coastguard Worker } hwvulkan_device_t; 68*61046927SAndroid Build Coastguard Worker 69*61046927SAndroid Build Coastguard Worker __END_DECLS 70*61046927SAndroid Build Coastguard Worker 71*61046927SAndroid Build Coastguard Worker #endif // ANDROID_HWVULKAN_H 72