diff options
-rw-r--r-- | vulkan/libvulkan/api.h | 37 | ||||
-rw-r--r-- | vulkan/libvulkan/driver.cpp | 32 | ||||
-rw-r--r-- | vulkan/libvulkan/driver.h | 123 | ||||
-rw-r--r-- | vulkan/libvulkan/driver_gen.cpp | 7 | ||||
-rw-r--r-- | vulkan/libvulkan/swapchain.cpp | 9 | ||||
-rw-r--r-- | vulkan/scripts/driver_generator.py | 7 |
6 files changed, 140 insertions, 75 deletions
diff --git a/vulkan/libvulkan/api.h b/vulkan/libvulkan/api.h index 416cba0125..2a215d7427 100644 --- a/vulkan/libvulkan/api.h +++ b/vulkan/libvulkan/api.h @@ -24,17 +24,34 @@ namespace vulkan { namespace api { -// clang-format off -VKAPI_ATTR VkResult CreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance); -VKAPI_ATTR void DestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator); -VKAPI_ATTR VkResult CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice); -VKAPI_ATTR void DestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator); -VKAPI_ATTR VkResult EnumerateInstanceLayerProperties(uint32_t* pPropertyCount, VkLayerProperties* pProperties); -VKAPI_ATTR VkResult EnumerateInstanceExtensionProperties(const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties); -VKAPI_ATTR VkResult EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkLayerProperties* pProperties); -VKAPI_ATTR VkResult EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties); +VKAPI_ATTR VkResult CreateInstance(const VkInstanceCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkInstance* pInstance); +VKAPI_ATTR void DestroyInstance(VkInstance instance, + const VkAllocationCallbacks* pAllocator); +VKAPI_ATTR VkResult CreateDevice(VkPhysicalDevice physicalDevice, + const VkDeviceCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDevice* pDevice); +VKAPI_ATTR void DestroyDevice(VkDevice device, + const VkAllocationCallbacks* pAllocator); +VKAPI_ATTR VkResult +EnumerateInstanceLayerProperties(uint32_t* pPropertyCount, + VkLayerProperties* pProperties); +VKAPI_ATTR VkResult +EnumerateInstanceExtensionProperties(const char* pLayerName, + uint32_t* pPropertyCount, + VkExtensionProperties* pProperties); +VKAPI_ATTR VkResult +EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkLayerProperties* pProperties); +VKAPI_ATTR VkResult +EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, + const char* pLayerName, + uint32_t* pPropertyCount, + VkExtensionProperties* pProperties); VKAPI_ATTR VkResult EnumerateInstanceVersion(uint32_t* pApiVersion); -// clang-format on inline InstanceData& GetData(VkInstance instance) { return driver::GetData(instance).opaque_api_data; diff --git a/vulkan/libvulkan/driver.cpp b/vulkan/libvulkan/driver.cpp index e90cb11c7d..e3fc67e35f 100644 --- a/vulkan/libvulkan/driver.cpp +++ b/vulkan/libvulkan/driver.cpp @@ -935,14 +935,14 @@ VkResult EnumerateInstanceExtensionProperties( return result; } -bool QueryPresentationProperties( +void QueryPresentationProperties( VkPhysicalDevice physicalDevice, - VkPhysicalDevicePresentationPropertiesANDROID *presentation_properties) { + VkPhysicalDevicePresentationPropertiesANDROID* presentation_properties) { // Request the android-specific presentation properties via GPDP2 - VkPhysicalDeviceProperties2KHR properties = { - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR, + VkPhysicalDeviceProperties2 properties = { + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, presentation_properties, - {} + {}, }; #pragma clang diagnostic push @@ -954,8 +954,6 @@ bool QueryPresentationProperties( presentation_properties->sharedImage = VK_FALSE; GetPhysicalDeviceProperties2(physicalDevice, &properties); - - return true; } VkResult EnumerateDeviceExtensionProperties( @@ -977,8 +975,8 @@ VkResult EnumerateDeviceExtensionProperties( } VkPhysicalDevicePresentationPropertiesANDROID presentation_properties; - if (QueryPresentationProperties(physicalDevice, &presentation_properties) && - presentation_properties.sharedImage) { + QueryPresentationProperties(physicalDevice, &presentation_properties); + if (presentation_properties.sharedImage) { loader_extensions.push_back({ VK_KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME, VK_KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION}); @@ -1337,10 +1335,10 @@ void GetDeviceQueue2(VkDevice device, if (*pQueue != VK_NULL_HANDLE) SetData(*pQueue, data); } -VKAPI_ATTR VkResult -AllocateCommandBuffers(VkDevice device, - const VkCommandBufferAllocateInfo* pAllocateInfo, - VkCommandBuffer* pCommandBuffers) { +VkResult AllocateCommandBuffers( + VkDevice device, + const VkCommandBufferAllocateInfo* pAllocateInfo, + VkCommandBuffer* pCommandBuffers) { ATRACE_CALL(); const auto& data = GetData(device); @@ -1355,10 +1353,10 @@ AllocateCommandBuffers(VkDevice device, return result; } -VKAPI_ATTR VkResult QueueSubmit(VkQueue queue, - uint32_t submitCount, - const VkSubmitInfo* pSubmits, - VkFence fence) { +VkResult QueueSubmit(VkQueue queue, + uint32_t submitCount, + const VkSubmitInfo* pSubmits, + VkFence fence) { ATRACE_CALL(); const auto& data = GetData(queue); diff --git a/vulkan/libvulkan/driver.h b/vulkan/libvulkan/driver.h index e7b4bb25bf..14c516b16b 100644 --- a/vulkan/libvulkan/driver.h +++ b/vulkan/libvulkan/driver.h @@ -103,42 +103,95 @@ struct DeviceData { bool OpenHAL(); const VkAllocationCallbacks& GetDefaultAllocator(); -bool QueryPresentationProperties( +void QueryPresentationProperties( VkPhysicalDevice physicalDevice, - VkPhysicalDevicePresentationPropertiesANDROID *presentation_properties); - -// clang-format off -VKAPI_ATTR PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* pName); -VKAPI_ATTR PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, const char* pName); -VKAPI_ATTR VkResult EnumerateInstanceExtensionProperties(const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties); - -VKAPI_ATTR VkResult EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties); - -VKAPI_ATTR VkResult CreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance); -VKAPI_ATTR void DestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator); -VKAPI_ATTR VkResult CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice); -VKAPI_ATTR void DestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult EnumeratePhysicalDevices(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices); -VKAPI_ATTR VkResult EnumeratePhysicalDeviceGroups(VkInstance instance, uint32_t* pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties); - -VKAPI_ATTR void GetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue); -VKAPI_ATTR void GetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2* pQueueInfo, VkQueue* pQueue); -VKAPI_ATTR VkResult AllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers); -VKAPI_ATTR VkResult QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence); - -VKAPI_ATTR void GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2* pFeatures); -VKAPI_ATTR void GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2* pProperties); -VKAPI_ATTR void GetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2* pFormatProperties); -VKAPI_ATTR VkResult GetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, VkImageFormatProperties2* pImageFormatProperties); -VKAPI_ATTR void GetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties2* pQueueFamilyProperties); -VKAPI_ATTR void GetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2* pMemoryProperties); -VKAPI_ATTR void GetPhysicalDeviceSparseImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo, uint32_t* pPropertyCount, VkSparseImageFormatProperties2* pProperties); - -VKAPI_ATTR void GetPhysicalDeviceExternalBufferProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, VkExternalBufferProperties* pExternalBufferProperties); -VKAPI_ATTR void GetPhysicalDeviceExternalSemaphoreProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, VkExternalSemaphoreProperties* pExternalSemaphoreProperties); -VKAPI_ATTR void GetPhysicalDeviceExternalFenceProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, VkExternalFenceProperties* pExternalFenceProperties); -// clang-format on + VkPhysicalDevicePresentationPropertiesANDROID* presentation_properties); + +VKAPI_ATTR PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, + const char* pName); +VKAPI_ATTR PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, + const char* pName); +VKAPI_ATTR VkResult +EnumerateInstanceExtensionProperties(const char* pLayerName, + uint32_t* pPropertyCount, + VkExtensionProperties* pProperties); +VKAPI_ATTR VkResult +EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, + const char* pLayerName, + uint32_t* pPropertyCount, + VkExtensionProperties* pProperties); +VKAPI_ATTR VkResult CreateInstance(const VkInstanceCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkInstance* pInstance); +VKAPI_ATTR void DestroyInstance(VkInstance instance, + const VkAllocationCallbacks* pAllocator); +VKAPI_ATTR VkResult CreateDevice(VkPhysicalDevice physicalDevice, + const VkDeviceCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDevice* pDevice); +VKAPI_ATTR void DestroyDevice(VkDevice device, + const VkAllocationCallbacks* pAllocator); +VKAPI_ATTR VkResult +EnumeratePhysicalDevices(VkInstance instance, + uint32_t* pPhysicalDeviceCount, + VkPhysicalDevice* pPhysicalDevices); +VKAPI_ATTR VkResult EnumeratePhysicalDeviceGroups( + VkInstance instance, + uint32_t* pPhysicalDeviceGroupCount, + VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties); +VKAPI_ATTR void GetDeviceQueue(VkDevice device, + uint32_t queueFamilyIndex, + uint32_t queueIndex, + VkQueue* pQueue); +VKAPI_ATTR void GetDeviceQueue2(VkDevice device, + const VkDeviceQueueInfo2* pQueueInfo, + VkQueue* pQueue); +VKAPI_ATTR VkResult +AllocateCommandBuffers(VkDevice device, + const VkCommandBufferAllocateInfo* pAllocateInfo, + VkCommandBuffer* pCommandBuffers); +VKAPI_ATTR VkResult QueueSubmit(VkQueue queue, + uint32_t submitCount, + const VkSubmitInfo* pSubmits, + VkFence fence); +VKAPI_ATTR void GetPhysicalDeviceFeatures2( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceFeatures2* pFeatures); +VKAPI_ATTR void GetPhysicalDeviceProperties2( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceProperties2* pProperties); +VKAPI_ATTR void GetPhysicalDeviceFormatProperties2( + VkPhysicalDevice physicalDevice, + VkFormat format, + VkFormatProperties2* pFormatProperties); +VKAPI_ATTR VkResult GetPhysicalDeviceImageFormatProperties2( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, + VkImageFormatProperties2* pImageFormatProperties); +VKAPI_ATTR void GetPhysicalDeviceQueueFamilyProperties2( + VkPhysicalDevice physicalDevice, + uint32_t* pQueueFamilyPropertyCount, + VkQueueFamilyProperties2* pQueueFamilyProperties); +VKAPI_ATTR void GetPhysicalDeviceMemoryProperties2( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceMemoryProperties2* pMemoryProperties); +VKAPI_ATTR void GetPhysicalDeviceSparseImageFormatProperties2( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo, + uint32_t* pPropertyCount, + VkSparseImageFormatProperties2* pProperties); +VKAPI_ATTR void GetPhysicalDeviceExternalBufferProperties( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, + VkExternalBufferProperties* pExternalBufferProperties); +VKAPI_ATTR void GetPhysicalDeviceExternalSemaphoreProperties( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, + VkExternalSemaphoreProperties* pExternalSemaphoreProperties); +VKAPI_ATTR void GetPhysicalDeviceExternalFenceProperties( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, + VkExternalFenceProperties* pExternalFenceProperties); template <typename DispatchableType> void StaticAssertDispatchable(DispatchableType) { diff --git a/vulkan/libvulkan/driver_gen.cpp b/vulkan/libvulkan/driver_gen.cpp index 6549c370b4..5f37a50a03 100644 --- a/vulkan/libvulkan/driver_gen.cpp +++ b/vulkan/libvulkan/driver_gen.cpp @@ -550,10 +550,9 @@ const ProcHook g_proc_hooks[] = { } // namespace const ProcHook* GetProcHook(const char* name) { - const auto& begin = g_proc_hooks; - const auto& end = - g_proc_hooks + sizeof(g_proc_hooks) / sizeof(g_proc_hooks[0]); - const auto hook = std::lower_bound( + auto begin = std::cbegin(g_proc_hooks); + auto end = std::cend(g_proc_hooks); + auto hook = std::lower_bound( begin, end, name, [](const ProcHook& e, const char* n) { return strcmp(e.name, n) < 0; }); return (hook < end && strcmp(hook->name, name) == 0) ? hook : nullptr; diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp index c7ff6405f1..0f791c903b 100644 --- a/vulkan/libvulkan/swapchain.cpp +++ b/vulkan/libvulkan/swapchain.cpp @@ -881,11 +881,10 @@ VkResult GetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice pdev, present_modes.push_back(VK_PRESENT_MODE_FIFO_KHR); VkPhysicalDevicePresentationPropertiesANDROID present_properties; - if (QueryPresentationProperties(pdev, &present_properties)) { - if (present_properties.sharedImage) { - present_modes.push_back(VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR); - present_modes.push_back(VK_PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR); - } + QueryPresentationProperties(pdev, &present_properties); + if (present_properties.sharedImage) { + present_modes.push_back(VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR); + present_modes.push_back(VK_PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR); } uint32_t num_modes = uint32_t(present_modes.size()); diff --git a/vulkan/scripts/driver_generator.py b/vulkan/scripts/driver_generator.py index 566e063a57..6a73023193 100644 --- a/vulkan/scripts/driver_generator.py +++ b/vulkan/scripts/driver_generator.py @@ -523,10 +523,9 @@ const ProcHook g_proc_hooks[] = { } // namespace const ProcHook* GetProcHook(const char* name) { - const auto& begin = g_proc_hooks; - const auto& end = - g_proc_hooks + sizeof(g_proc_hooks) / sizeof(g_proc_hooks[0]); - const auto hook = std::lower_bound( + auto begin = std::cbegin(g_proc_hooks); + auto end = std::cend(g_proc_hooks); + auto hook = std::lower_bound( begin, end, name, [](const ProcHook& e, const char* n) { return strcmp(e.name, n) < 0; }); return (hook < end && strcmp(hook->name, name) == 0) ? hook : nullptr; |