Loading vulkan/libvulkan/api.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -519,7 +519,11 @@ LayerChain::LayerChain(bool is_instance, get_device_proc_addr_(nullptr), driver_extensions_(nullptr), driver_extension_count_(0) { enabled_extensions_.set(driver::ProcHook::EXTENSION_CORE); // advertise the loader supported core Vulkan API version at vulkan::api for (uint32_t i = driver::ProcHook::EXTENSION_CORE_1_0; i != driver::ProcHook::EXTENSION_COUNT; ++i) { enabled_extensions_.set(i); } } LayerChain::~LayerChain() { Loading vulkan/libvulkan/code-generator.tmpl +40 −12 Original line number Diff line number Diff line Loading @@ -765,6 +765,19 @@ VK_KHR_bind_memory2 {{end}} {{/* ------------------------------------------------------------------------------ Emits the ProcHook enum for core Vulkan API verions. ------------------------------------------------------------------------------ */}} {{define "driver.GetProcHookEnum"}} {{if GetAnnotation $ "vulkan1_1"}}ProcHook::EXTENSION_CORE_1_1 {{else}}ProcHook::EXTENSION_CORE_1_0 {{end}} {{end}} {{/* ------------------------------------------------------------------------------ Emits true if a function needs a ProcHook stub. Loading @@ -778,6 +791,8 @@ VK_KHR_bind_memory2 {{if $ext}} {{if not (Macro "IsExtensionInternal" $ext)}}true{{end}} {{end}} {{if GetAnnotation $ "vulkan1_1"}}true{{end}} {{end}} {{end}} Loading @@ -801,7 +816,8 @@ VK_KHR_bind_memory2 {{TrimPrefix "VK_" $e}}, {{end}} ¶ EXTENSION_CORE, // valid bit EXTENSION_CORE_1_0, EXTENSION_CORE_1_1, EXTENSION_COUNT, EXTENSION_UNKNOWN, }; Loading Loading @@ -838,14 +854,21 @@ VK_KHR_bind_memory2 {{AssertType $ "Function"}} {{if (Macro "driver.NeedProcHookStub" $)}} {{$ext_name := Strings ("")}} {{$ext_hook := Strings ("")}} {{$ext := GetAnnotation $ "extension"}} {{$ext_name := index $ext.Arguments 0}} {{if $ext}} {{$ext_name = index $ext.Arguments 0}} {{$ext_hook = Strings ("ProcHook::") (Macro "BaseName" $ext)}} {{else}} {{$ext_name = Strings ("VK_VERSION_1_0")}} {{$ext_hook = (Macro "driver.GetProcHookEnum" $)}} {{end}} {{$base := (Macro "BaseName" $)}} VKAPI_ATTR {{Node "Type" $.Return}} checked{{$base}}({{Macro "Parameters" $}}) { {{$p0 := index $.CallParameters 0}} {{$ext_hook := Strings ("ProcHook::") (Macro "BaseName" $ext)}} if (GetData({{$p0.Name}}).hook_extensions[{{$ext_hook}}]) { {{if not (IsVoid $.Return.Type)}}return §{{end}} Loading Loading @@ -878,7 +901,7 @@ VK_KHR_bind_memory2 { "{{$.Name}}", ProcHook::GLOBAL, ProcHook::EXTENSION_CORE, {{Macro "driver.GetProcHookEnum" $}}, reinterpret_cast<PFN_vkVoidFunction>({{$base}}), nullptr, }, Loading Loading @@ -911,7 +934,7 @@ VK_KHR_bind_memory2 nullptr, {{end}} {{else}} ProcHook::EXTENSION_CORE, {{Macro "driver.GetProcHookEnum" $}}, reinterpret_cast<PFN_vkVoidFunction>({{$base}}), nullptr, {{end}} Loading @@ -934,10 +957,10 @@ VK_KHR_bind_memory2 ProcHook::DEVICE, {{$ext := GetAnnotation $ "extension"}} {{if or $ext (GetAnnotation $ "vulkan1_1")}} {{if $ext}} ProcHook::{{Macro "BaseName" $ext}}, {{if (Macro "IsExtensionInternal" $ext)}} {{if Macro "IsExtensionInternal" $ext}} nullptr, nullptr, {{else}} Loading @@ -945,7 +968,12 @@ VK_KHR_bind_memory2 reinterpret_cast<PFN_vkVoidFunction>(checked{{$base}}), {{end}} {{else}} ProcHook::EXTENSION_CORE, {{Macro "driver.GetProcHookEnum" $}}, reinterpret_cast<PFN_vkVoidFunction>({{$base}}), reinterpret_cast<PFN_vkVoidFunction>(checked{{$base}}), {{end}} {{else}} {{Macro "driver.GetProcHookEnum" $}}, reinterpret_cast<PFN_vkVoidFunction>({{$base}}), nullptr, {{end}} Loading vulkan/libvulkan/driver.cpp +44 −13 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ class CreateInfoWrapper { VkResult Validate(); void DowngradeApiVersion(); void UpgradeDeviceCoreApiVersion(uint32_t api_version); const std::bitset<ProcHook::EXTENSION_COUNT>& GetHookExtensions() const; const std::bitset<ProcHook::EXTENSION_COUNT>& GetHalExtensions() const; Loading Loading @@ -333,8 +334,12 @@ CreateInfoWrapper::CreateInfoWrapper(const VkInstanceCreateInfo& create_info, physical_dev_(VK_NULL_HANDLE), instance_info_(create_info), extension_filter_() { hook_extensions_.set(ProcHook::EXTENSION_CORE); hal_extensions_.set(ProcHook::EXTENSION_CORE); // instance core versions need to match the loader api version for (uint32_t i = ProcHook::EXTENSION_CORE_1_0; i != ProcHook::EXTENSION_COUNT; ++i) { hook_extensions_.set(i); hal_extensions_.set(i); } } CreateInfoWrapper::CreateInfoWrapper(VkPhysicalDevice physical_dev, Loading @@ -345,8 +350,9 @@ CreateInfoWrapper::CreateInfoWrapper(VkPhysicalDevice physical_dev, physical_dev_(physical_dev), dev_info_(create_info), extension_filter_() { hook_extensions_.set(ProcHook::EXTENSION_CORE); hal_extensions_.set(ProcHook::EXTENSION_CORE); // initialize with baseline core API version hook_extensions_.set(ProcHook::EXTENSION_CORE_1_0); hal_extensions_.set(ProcHook::EXTENSION_CORE_1_0); } CreateInfoWrapper::~CreateInfoWrapper() { Loading Loading @@ -545,7 +551,8 @@ void CreateInfoWrapper::FilterExtension(const char* name) { case ProcHook::ANDROID_external_memory_android_hardware_buffer: case ProcHook::ANDROID_native_buffer: case ProcHook::GOOGLE_display_timing: case ProcHook::EXTENSION_CORE: case ProcHook::EXTENSION_CORE_1_0: case ProcHook::EXTENSION_CORE_1_1: case ProcHook::EXTENSION_COUNT: // Device and meta extensions. If we ever get here it's a bug in // our code. But enumerating them lets us avoid having a default Loading Loading @@ -593,7 +600,8 @@ void CreateInfoWrapper::FilterExtension(const char* name) { case ProcHook::EXT_debug_report: case ProcHook::EXT_swapchain_colorspace: case ProcHook::ANDROID_native_buffer: case ProcHook::EXTENSION_CORE: case ProcHook::EXTENSION_CORE_1_0: case ProcHook::EXTENSION_CORE_1_1: case ProcHook::EXTENSION_COUNT: // Instance and meta extensions. If we ever get here it's a bug // in our code. But enumerating them lets us avoid having a Loading Loading @@ -641,6 +649,28 @@ void CreateInfoWrapper::DowngradeApiVersion() { } } void CreateInfoWrapper::UpgradeDeviceCoreApiVersion(uint32_t api_version) { ALOG_ASSERT(!is_instance_, "Device only API called by instance wrapper."); #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wold-style-cast" api_version ^= VK_VERSION_PATCH(api_version); #pragma clang diagnostic pop // cap the API version to the loader supported highest version if (api_version > VK_API_VERSION_1_1) api_version = VK_API_VERSION_1_1; switch (api_version) { case VK_API_VERSION_1_1: hook_extensions_.set(ProcHook::EXTENSION_CORE_1_1); hal_extensions_.set(ProcHook::EXTENSION_CORE_1_1); [[clang::fallthrough]]; case VK_API_VERSION_1_0: break; default: ALOGD("Unknown upgrade API version[%u]", api_version); break; } } VKAPI_ATTR void* DefaultAllocate(void*, size_t size, size_t alignment, Loading Loading @@ -776,7 +806,7 @@ PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* pName) { : nullptr; break; case ProcHook::DEVICE: proc = (hook->extension == ProcHook::EXTENSION_CORE) proc = (hook->extension == ProcHook::EXTENSION_CORE_1_0) ? hook->proc : hook->checked_proc; break; Loading Loading @@ -1124,6 +1154,13 @@ VkResult CreateDevice(VkPhysicalDevice physicalDevice, if (!data) return VK_ERROR_OUT_OF_HOST_MEMORY; VkPhysicalDeviceProperties properties; ATRACE_BEGIN("driver.GetPhysicalDeviceProperties"); instance_data.driver.GetPhysicalDeviceProperties(physicalDevice, &properties); ATRACE_END(); wrapper.UpgradeDeviceCoreApiVersion(properties.apiVersion); data->hook_extensions |= wrapper.GetHookExtensions(); // call into the driver Loading Loading @@ -1168,12 +1205,6 @@ VkResult CreateDevice(VkPhysicalDevice physicalDevice, return VK_ERROR_INCOMPATIBLE_DRIVER; } VkPhysicalDeviceProperties properties; ATRACE_BEGIN("driver.GetPhysicalDeviceProperties"); instance_data.driver.GetPhysicalDeviceProperties(physicalDevice, &properties); ATRACE_END(); if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU) { // Log that the app is hitting software Vulkan implementation android::GraphicsEnv::getInstance().setCpuVulkanInUse(); Loading vulkan/libvulkan/driver.h +2 −6 Original line number Diff line number Diff line Loading @@ -67,9 +67,7 @@ struct InstanceData { : opaque_api_data(), allocator(alloc), driver(), get_device_proc_addr(nullptr) { hook_extensions.set(ProcHook::EXTENSION_CORE); } get_device_proc_addr(nullptr) {} api::InstanceData opaque_api_data; Loading @@ -89,9 +87,7 @@ struct DeviceData { : opaque_api_data(), allocator(alloc), debug_report_callbacks(debug_report_callbacks_), driver() { hook_extensions.set(ProcHook::EXTENSION_CORE); } driver() {} api::DeviceData opaque_api_data; Loading vulkan/libvulkan/driver_gen.cpp +33 −16 Original line number Diff line number Diff line Loading @@ -31,6 +31,23 @@ namespace { // clang-format off VKAPI_ATTR VkResult checkedBindImageMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos) { if (GetData(device).hook_extensions[ProcHook::EXTENSION_CORE_1_1]) { return BindImageMemory2(device, bindInfoCount, pBindInfos); } else { Logger(device).Err(device, "VK_VERSION_1_0 not enabled. vkBindImageMemory2 not executed."); return VK_SUCCESS; } } VKAPI_ATTR void checkedGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2* pQueueInfo, VkQueue* pQueue) { if (GetData(device).hook_extensions[ProcHook::EXTENSION_CORE_1_1]) { GetDeviceQueue2(device, pQueueInfo, pQueue); } else { Logger(device).Err(device, "VK_VERSION_1_0 not enabled. vkGetDeviceQueue2 not executed."); } } VKAPI_ATTR VkResult checkedCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain) { if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) { return CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain); Loading Loading @@ -174,16 +191,16 @@ const ProcHook g_proc_hooks[] = { { "vkAllocateCommandBuffers", ProcHook::DEVICE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(AllocateCommandBuffers), nullptr, }, { "vkBindImageMemory2", ProcHook::DEVICE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_1, reinterpret_cast<PFN_vkVoidFunction>(BindImageMemory2), nullptr, reinterpret_cast<PFN_vkVoidFunction>(checkedBindImageMemory2), }, { "vkBindImageMemory2KHR", Loading @@ -209,14 +226,14 @@ const ProcHook g_proc_hooks[] = { { "vkCreateDevice", ProcHook::INSTANCE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(CreateDevice), nullptr, }, { "vkCreateInstance", ProcHook::GLOBAL, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(CreateInstance), nullptr, }, Loading Loading @@ -244,14 +261,14 @@ const ProcHook g_proc_hooks[] = { { "vkDestroyDevice", ProcHook::DEVICE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(DestroyDevice), nullptr, }, { "vkDestroyInstance", ProcHook::INSTANCE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(DestroyInstance), nullptr, }, Loading @@ -272,28 +289,28 @@ const ProcHook g_proc_hooks[] = { { "vkEnumerateDeviceExtensionProperties", ProcHook::INSTANCE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(EnumerateDeviceExtensionProperties), nullptr, }, { "vkEnumerateInstanceExtensionProperties", ProcHook::GLOBAL, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(EnumerateInstanceExtensionProperties), nullptr, }, { "vkEnumeratePhysicalDeviceGroups", ProcHook::INSTANCE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_1, reinterpret_cast<PFN_vkVoidFunction>(EnumeratePhysicalDeviceGroups), nullptr, }, { "vkEnumeratePhysicalDevices", ProcHook::INSTANCE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(EnumeratePhysicalDevices), nullptr, }, Loading @@ -314,28 +331,28 @@ const ProcHook g_proc_hooks[] = { { "vkGetDeviceProcAddr", ProcHook::DEVICE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(GetDeviceProcAddr), nullptr, }, { "vkGetDeviceQueue", ProcHook::DEVICE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(GetDeviceQueue), nullptr, }, { "vkGetDeviceQueue2", ProcHook::DEVICE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_1, reinterpret_cast<PFN_vkVoidFunction>(GetDeviceQueue2), nullptr, reinterpret_cast<PFN_vkVoidFunction>(checkedGetDeviceQueue2), }, { "vkGetInstanceProcAddr", ProcHook::INSTANCE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(GetInstanceProcAddr), nullptr, }, Loading Loading
vulkan/libvulkan/api.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -519,7 +519,11 @@ LayerChain::LayerChain(bool is_instance, get_device_proc_addr_(nullptr), driver_extensions_(nullptr), driver_extension_count_(0) { enabled_extensions_.set(driver::ProcHook::EXTENSION_CORE); // advertise the loader supported core Vulkan API version at vulkan::api for (uint32_t i = driver::ProcHook::EXTENSION_CORE_1_0; i != driver::ProcHook::EXTENSION_COUNT; ++i) { enabled_extensions_.set(i); } } LayerChain::~LayerChain() { Loading
vulkan/libvulkan/code-generator.tmpl +40 −12 Original line number Diff line number Diff line Loading @@ -765,6 +765,19 @@ VK_KHR_bind_memory2 {{end}} {{/* ------------------------------------------------------------------------------ Emits the ProcHook enum for core Vulkan API verions. ------------------------------------------------------------------------------ */}} {{define "driver.GetProcHookEnum"}} {{if GetAnnotation $ "vulkan1_1"}}ProcHook::EXTENSION_CORE_1_1 {{else}}ProcHook::EXTENSION_CORE_1_0 {{end}} {{end}} {{/* ------------------------------------------------------------------------------ Emits true if a function needs a ProcHook stub. Loading @@ -778,6 +791,8 @@ VK_KHR_bind_memory2 {{if $ext}} {{if not (Macro "IsExtensionInternal" $ext)}}true{{end}} {{end}} {{if GetAnnotation $ "vulkan1_1"}}true{{end}} {{end}} {{end}} Loading @@ -801,7 +816,8 @@ VK_KHR_bind_memory2 {{TrimPrefix "VK_" $e}}, {{end}} ¶ EXTENSION_CORE, // valid bit EXTENSION_CORE_1_0, EXTENSION_CORE_1_1, EXTENSION_COUNT, EXTENSION_UNKNOWN, }; Loading Loading @@ -838,14 +854,21 @@ VK_KHR_bind_memory2 {{AssertType $ "Function"}} {{if (Macro "driver.NeedProcHookStub" $)}} {{$ext_name := Strings ("")}} {{$ext_hook := Strings ("")}} {{$ext := GetAnnotation $ "extension"}} {{$ext_name := index $ext.Arguments 0}} {{if $ext}} {{$ext_name = index $ext.Arguments 0}} {{$ext_hook = Strings ("ProcHook::") (Macro "BaseName" $ext)}} {{else}} {{$ext_name = Strings ("VK_VERSION_1_0")}} {{$ext_hook = (Macro "driver.GetProcHookEnum" $)}} {{end}} {{$base := (Macro "BaseName" $)}} VKAPI_ATTR {{Node "Type" $.Return}} checked{{$base}}({{Macro "Parameters" $}}) { {{$p0 := index $.CallParameters 0}} {{$ext_hook := Strings ("ProcHook::") (Macro "BaseName" $ext)}} if (GetData({{$p0.Name}}).hook_extensions[{{$ext_hook}}]) { {{if not (IsVoid $.Return.Type)}}return §{{end}} Loading Loading @@ -878,7 +901,7 @@ VK_KHR_bind_memory2 { "{{$.Name}}", ProcHook::GLOBAL, ProcHook::EXTENSION_CORE, {{Macro "driver.GetProcHookEnum" $}}, reinterpret_cast<PFN_vkVoidFunction>({{$base}}), nullptr, }, Loading Loading @@ -911,7 +934,7 @@ VK_KHR_bind_memory2 nullptr, {{end}} {{else}} ProcHook::EXTENSION_CORE, {{Macro "driver.GetProcHookEnum" $}}, reinterpret_cast<PFN_vkVoidFunction>({{$base}}), nullptr, {{end}} Loading @@ -934,10 +957,10 @@ VK_KHR_bind_memory2 ProcHook::DEVICE, {{$ext := GetAnnotation $ "extension"}} {{if or $ext (GetAnnotation $ "vulkan1_1")}} {{if $ext}} ProcHook::{{Macro "BaseName" $ext}}, {{if (Macro "IsExtensionInternal" $ext)}} {{if Macro "IsExtensionInternal" $ext}} nullptr, nullptr, {{else}} Loading @@ -945,7 +968,12 @@ VK_KHR_bind_memory2 reinterpret_cast<PFN_vkVoidFunction>(checked{{$base}}), {{end}} {{else}} ProcHook::EXTENSION_CORE, {{Macro "driver.GetProcHookEnum" $}}, reinterpret_cast<PFN_vkVoidFunction>({{$base}}), reinterpret_cast<PFN_vkVoidFunction>(checked{{$base}}), {{end}} {{else}} {{Macro "driver.GetProcHookEnum" $}}, reinterpret_cast<PFN_vkVoidFunction>({{$base}}), nullptr, {{end}} Loading
vulkan/libvulkan/driver.cpp +44 −13 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ class CreateInfoWrapper { VkResult Validate(); void DowngradeApiVersion(); void UpgradeDeviceCoreApiVersion(uint32_t api_version); const std::bitset<ProcHook::EXTENSION_COUNT>& GetHookExtensions() const; const std::bitset<ProcHook::EXTENSION_COUNT>& GetHalExtensions() const; Loading Loading @@ -333,8 +334,12 @@ CreateInfoWrapper::CreateInfoWrapper(const VkInstanceCreateInfo& create_info, physical_dev_(VK_NULL_HANDLE), instance_info_(create_info), extension_filter_() { hook_extensions_.set(ProcHook::EXTENSION_CORE); hal_extensions_.set(ProcHook::EXTENSION_CORE); // instance core versions need to match the loader api version for (uint32_t i = ProcHook::EXTENSION_CORE_1_0; i != ProcHook::EXTENSION_COUNT; ++i) { hook_extensions_.set(i); hal_extensions_.set(i); } } CreateInfoWrapper::CreateInfoWrapper(VkPhysicalDevice physical_dev, Loading @@ -345,8 +350,9 @@ CreateInfoWrapper::CreateInfoWrapper(VkPhysicalDevice physical_dev, physical_dev_(physical_dev), dev_info_(create_info), extension_filter_() { hook_extensions_.set(ProcHook::EXTENSION_CORE); hal_extensions_.set(ProcHook::EXTENSION_CORE); // initialize with baseline core API version hook_extensions_.set(ProcHook::EXTENSION_CORE_1_0); hal_extensions_.set(ProcHook::EXTENSION_CORE_1_0); } CreateInfoWrapper::~CreateInfoWrapper() { Loading Loading @@ -545,7 +551,8 @@ void CreateInfoWrapper::FilterExtension(const char* name) { case ProcHook::ANDROID_external_memory_android_hardware_buffer: case ProcHook::ANDROID_native_buffer: case ProcHook::GOOGLE_display_timing: case ProcHook::EXTENSION_CORE: case ProcHook::EXTENSION_CORE_1_0: case ProcHook::EXTENSION_CORE_1_1: case ProcHook::EXTENSION_COUNT: // Device and meta extensions. If we ever get here it's a bug in // our code. But enumerating them lets us avoid having a default Loading Loading @@ -593,7 +600,8 @@ void CreateInfoWrapper::FilterExtension(const char* name) { case ProcHook::EXT_debug_report: case ProcHook::EXT_swapchain_colorspace: case ProcHook::ANDROID_native_buffer: case ProcHook::EXTENSION_CORE: case ProcHook::EXTENSION_CORE_1_0: case ProcHook::EXTENSION_CORE_1_1: case ProcHook::EXTENSION_COUNT: // Instance and meta extensions. If we ever get here it's a bug // in our code. But enumerating them lets us avoid having a Loading Loading @@ -641,6 +649,28 @@ void CreateInfoWrapper::DowngradeApiVersion() { } } void CreateInfoWrapper::UpgradeDeviceCoreApiVersion(uint32_t api_version) { ALOG_ASSERT(!is_instance_, "Device only API called by instance wrapper."); #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wold-style-cast" api_version ^= VK_VERSION_PATCH(api_version); #pragma clang diagnostic pop // cap the API version to the loader supported highest version if (api_version > VK_API_VERSION_1_1) api_version = VK_API_VERSION_1_1; switch (api_version) { case VK_API_VERSION_1_1: hook_extensions_.set(ProcHook::EXTENSION_CORE_1_1); hal_extensions_.set(ProcHook::EXTENSION_CORE_1_1); [[clang::fallthrough]]; case VK_API_VERSION_1_0: break; default: ALOGD("Unknown upgrade API version[%u]", api_version); break; } } VKAPI_ATTR void* DefaultAllocate(void*, size_t size, size_t alignment, Loading Loading @@ -776,7 +806,7 @@ PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* pName) { : nullptr; break; case ProcHook::DEVICE: proc = (hook->extension == ProcHook::EXTENSION_CORE) proc = (hook->extension == ProcHook::EXTENSION_CORE_1_0) ? hook->proc : hook->checked_proc; break; Loading Loading @@ -1124,6 +1154,13 @@ VkResult CreateDevice(VkPhysicalDevice physicalDevice, if (!data) return VK_ERROR_OUT_OF_HOST_MEMORY; VkPhysicalDeviceProperties properties; ATRACE_BEGIN("driver.GetPhysicalDeviceProperties"); instance_data.driver.GetPhysicalDeviceProperties(physicalDevice, &properties); ATRACE_END(); wrapper.UpgradeDeviceCoreApiVersion(properties.apiVersion); data->hook_extensions |= wrapper.GetHookExtensions(); // call into the driver Loading Loading @@ -1168,12 +1205,6 @@ VkResult CreateDevice(VkPhysicalDevice physicalDevice, return VK_ERROR_INCOMPATIBLE_DRIVER; } VkPhysicalDeviceProperties properties; ATRACE_BEGIN("driver.GetPhysicalDeviceProperties"); instance_data.driver.GetPhysicalDeviceProperties(physicalDevice, &properties); ATRACE_END(); if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU) { // Log that the app is hitting software Vulkan implementation android::GraphicsEnv::getInstance().setCpuVulkanInUse(); Loading
vulkan/libvulkan/driver.h +2 −6 Original line number Diff line number Diff line Loading @@ -67,9 +67,7 @@ struct InstanceData { : opaque_api_data(), allocator(alloc), driver(), get_device_proc_addr(nullptr) { hook_extensions.set(ProcHook::EXTENSION_CORE); } get_device_proc_addr(nullptr) {} api::InstanceData opaque_api_data; Loading @@ -89,9 +87,7 @@ struct DeviceData { : opaque_api_data(), allocator(alloc), debug_report_callbacks(debug_report_callbacks_), driver() { hook_extensions.set(ProcHook::EXTENSION_CORE); } driver() {} api::DeviceData opaque_api_data; Loading
vulkan/libvulkan/driver_gen.cpp +33 −16 Original line number Diff line number Diff line Loading @@ -31,6 +31,23 @@ namespace { // clang-format off VKAPI_ATTR VkResult checkedBindImageMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos) { if (GetData(device).hook_extensions[ProcHook::EXTENSION_CORE_1_1]) { return BindImageMemory2(device, bindInfoCount, pBindInfos); } else { Logger(device).Err(device, "VK_VERSION_1_0 not enabled. vkBindImageMemory2 not executed."); return VK_SUCCESS; } } VKAPI_ATTR void checkedGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2* pQueueInfo, VkQueue* pQueue) { if (GetData(device).hook_extensions[ProcHook::EXTENSION_CORE_1_1]) { GetDeviceQueue2(device, pQueueInfo, pQueue); } else { Logger(device).Err(device, "VK_VERSION_1_0 not enabled. vkGetDeviceQueue2 not executed."); } } VKAPI_ATTR VkResult checkedCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain) { if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) { return CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain); Loading Loading @@ -174,16 +191,16 @@ const ProcHook g_proc_hooks[] = { { "vkAllocateCommandBuffers", ProcHook::DEVICE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(AllocateCommandBuffers), nullptr, }, { "vkBindImageMemory2", ProcHook::DEVICE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_1, reinterpret_cast<PFN_vkVoidFunction>(BindImageMemory2), nullptr, reinterpret_cast<PFN_vkVoidFunction>(checkedBindImageMemory2), }, { "vkBindImageMemory2KHR", Loading @@ -209,14 +226,14 @@ const ProcHook g_proc_hooks[] = { { "vkCreateDevice", ProcHook::INSTANCE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(CreateDevice), nullptr, }, { "vkCreateInstance", ProcHook::GLOBAL, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(CreateInstance), nullptr, }, Loading Loading @@ -244,14 +261,14 @@ const ProcHook g_proc_hooks[] = { { "vkDestroyDevice", ProcHook::DEVICE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(DestroyDevice), nullptr, }, { "vkDestroyInstance", ProcHook::INSTANCE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(DestroyInstance), nullptr, }, Loading @@ -272,28 +289,28 @@ const ProcHook g_proc_hooks[] = { { "vkEnumerateDeviceExtensionProperties", ProcHook::INSTANCE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(EnumerateDeviceExtensionProperties), nullptr, }, { "vkEnumerateInstanceExtensionProperties", ProcHook::GLOBAL, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(EnumerateInstanceExtensionProperties), nullptr, }, { "vkEnumeratePhysicalDeviceGroups", ProcHook::INSTANCE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_1, reinterpret_cast<PFN_vkVoidFunction>(EnumeratePhysicalDeviceGroups), nullptr, }, { "vkEnumeratePhysicalDevices", ProcHook::INSTANCE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(EnumeratePhysicalDevices), nullptr, }, Loading @@ -314,28 +331,28 @@ const ProcHook g_proc_hooks[] = { { "vkGetDeviceProcAddr", ProcHook::DEVICE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(GetDeviceProcAddr), nullptr, }, { "vkGetDeviceQueue", ProcHook::DEVICE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(GetDeviceQueue), nullptr, }, { "vkGetDeviceQueue2", ProcHook::DEVICE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_1, reinterpret_cast<PFN_vkVoidFunction>(GetDeviceQueue2), nullptr, reinterpret_cast<PFN_vkVoidFunction>(checkedGetDeviceQueue2), }, { "vkGetInstanceProcAddr", ProcHook::INSTANCE, ProcHook::EXTENSION_CORE, ProcHook::EXTENSION_CORE_1_0, reinterpret_cast<PFN_vkVoidFunction>(GetInstanceProcAddr), nullptr, }, Loading