17ec681f3Smrg/* 27ec681f3Smrg * Copyright 2015 The Android Open Source Project 37ec681f3Smrg * 47ec681f3Smrg * Licensed under the Apache License, Version 2.0 (the "License"); 57ec681f3Smrg * you may not use this file except in compliance with the License. 67ec681f3Smrg * You may obtain a copy of the License at 77ec681f3Smrg * 87ec681f3Smrg * http://www.apache.org/licenses/LICENSE-2.0 97ec681f3Smrg * 107ec681f3Smrg * Unless required by applicable law or agreed to in writing, software 117ec681f3Smrg * distributed under the License is distributed on an "AS IS" BASIS, 127ec681f3Smrg * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 137ec681f3Smrg * See the License for the specific language governing permissions and 147ec681f3Smrg * limitations under the License. 157ec681f3Smrg */ 167ec681f3Smrg 177ec681f3Smrg#ifndef ANDROID_HWVULKAN_H 187ec681f3Smrg#define ANDROID_HWVULKAN_H 197ec681f3Smrg 207ec681f3Smrg#include <hardware/hardware.h> 217ec681f3Smrg#include <vulkan/vulkan.h> 227ec681f3Smrg 237ec681f3Smrg__BEGIN_DECLS 247ec681f3Smrg 257ec681f3Smrg#define HWVULKAN_HARDWARE_MODULE_ID "vulkan" 267ec681f3Smrg 277ec681f3Smrg#define HWVULKAN_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) 287ec681f3Smrg#define HWVULKAN_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, 0) 297ec681f3Smrg 307ec681f3Smrg#define HWVULKAN_DEVICE_0 "vk0" 317ec681f3Smrg 327ec681f3Smrgtypedef struct hwvulkan_module_t { 337ec681f3Smrg struct hw_module_t common; 347ec681f3Smrg} hwvulkan_module_t; 357ec681f3Smrg 367ec681f3Smrg/* Dispatchable Vulkan object handles must be pointers, which must point to 377ec681f3Smrg * instances of hwvulkan_dispatch_t (potentially followed by additional 387ec681f3Smrg * implementation-defined data). On return from the creation function, the 397ec681f3Smrg * 'magic' field must contain HWVULKAN_DISPATCH_MAGIC; the loader will overwrite 407ec681f3Smrg * the 'vtbl' field. 417ec681f3Smrg * 427ec681f3Smrg * NOTE: The magic value and the layout of hwvulkan_dispatch_t match the LunarG 437ec681f3Smrg * loader used on platforms, to avoid pointless annoying differences for 447ec681f3Smrg * multi-platform drivers. Don't change them without a good reason. If there is 457ec681f3Smrg * an opportunity to change it, using a magic value that doesn't leave the 467ec681f3Smrg * upper 32-bits zero on 64-bit platforms would be nice. 477ec681f3Smrg */ 487ec681f3Smrg#define HWVULKAN_DISPATCH_MAGIC 0x01CDC0DE 497ec681f3Smrgtypedef union { 507ec681f3Smrg uintptr_t magic; 517ec681f3Smrg const void* vtbl; 527ec681f3Smrg} hwvulkan_dispatch_t; 537ec681f3Smrg 547ec681f3Smrg/* A hwvulkan_device_t corresponds to an ICD on other systems. Currently there 557ec681f3Smrg * can only be one on a system (HWVULKAN_DEVICE_0). It is opened once per 567ec681f3Smrg * process when the Vulkan API is first used; the hw_device_t::close() function 577ec681f3Smrg * is never called. Any non-trivial resource allocation should be done when 587ec681f3Smrg * the VkInstance is created rather than when the hwvulkan_device_t is opened. 597ec681f3Smrg */ 607ec681f3Smrgtypedef struct hwvulkan_device_t { 617ec681f3Smrg struct hw_device_t common; 627ec681f3Smrg 637ec681f3Smrg PFN_vkEnumerateInstanceExtensionProperties 647ec681f3Smrg EnumerateInstanceExtensionProperties; 657ec681f3Smrg PFN_vkCreateInstance CreateInstance; 667ec681f3Smrg PFN_vkGetInstanceProcAddr GetInstanceProcAddr; 677ec681f3Smrg} hwvulkan_device_t; 687ec681f3Smrg 697ec681f3Smrg__END_DECLS 707ec681f3Smrg 717ec681f3Smrg#endif // ANDROID_HWVULKAN_H 72