diff --git a/base/vulkanandroid.cpp b/base/vulkanandroid.cpp index 0a503c9e..7c0ce23c 100644 --- a/base/vulkanandroid.cpp +++ b/base/vulkanandroid.cpp @@ -121,161 +121,167 @@ PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR; void *libVulkan; -// Dynamically load Vulkan library and base function pointers -bool loadVulkanLibrary() -{ - __android_log_print(ANDROID_LOG_INFO, "vulkanandroid", "Loading libvulkan.so...\n"); - - // Load vulkan library - libVulkan = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL); - if (!libVulkan) +namespace vks +{ + namespace android { - __android_log_print(ANDROID_LOG_INFO, "vulkanandroid", "Could not load vulkan library : %s!\n", dlerror()); - return false; + // Dynamically load Vulkan library and base function pointers + bool loadVulkanLibrary() + { + __android_log_print(ANDROID_LOG_INFO, "vulkanandroid", "Loading libvulkan.so...\n"); + + // Load vulkan library + libVulkan = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL); + if (!libVulkan) + { + __android_log_print(ANDROID_LOG_INFO, "vulkanandroid", "Could not load vulkan library : %s!\n", dlerror()); + return false; + } + + // Load base function pointers + vkEnumerateInstanceExtensionProperties = reinterpret_cast(dlsym(libVulkan, "vkEnumerateInstanceExtensionProperties")); + vkEnumerateInstanceLayerProperties = reinterpret_cast(dlsym(libVulkan, "vkEnumerateInstanceLayerProperties")); + vkCreateInstance = reinterpret_cast(dlsym(libVulkan, "vkCreateInstance")); + vkGetInstanceProcAddr = reinterpret_cast(dlsym(libVulkan, "vkGetInstanceProcAddr")); + vkGetDeviceProcAddr = reinterpret_cast(dlsym(libVulkan, "vkGetDeviceProcAddr")); + + return true; + } + + // Load instance based Vulkan function pointers + void loadVulkanFunctions(VkInstance instance) + { + __android_log_print(ANDROID_LOG_INFO, "vulkanandroid", "Loading instance based function pointers...\n"); + + vkEnumeratePhysicalDevices = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkEnumeratePhysicalDevices")); + vkGetPhysicalDeviceProperties = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceProperties")); + vkEnumerateDeviceLayerProperties = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkEnumerateDeviceLayerProperties")); + vkEnumerateDeviceExtensionProperties = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkEnumerateDeviceExtensionProperties")); + vkGetPhysicalDeviceQueueFamilyProperties = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceQueueFamilyProperties")); + vkGetPhysicalDeviceFeatures = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceFeatures")); + vkCreateDevice = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateDevice")); + vkGetPhysicalDeviceFormatProperties = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceFormatProperties")); + vkGetPhysicalDeviceMemoryProperties = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceMemoryProperties")); + + vkCmdPipelineBarrier = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdPipelineBarrier")); + vkCreateShaderModule = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateShaderModule")); + + vkCreateBuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateBuffer")); + vkGetBufferMemoryRequirements = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetBufferMemoryRequirements")); + vkMapMemory = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkMapMemory")); + vkUnmapMemory = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkUnmapMemory")); + vkFlushMappedMemoryRanges = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkFlushMappedMemoryRanges")); + vkInvalidateMappedMemoryRanges = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkInvalidateMappedMemoryRanges")); + vkBindBufferMemory = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkBindBufferMemory")); + vkDestroyBuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyBuffer")); + + vkAllocateMemory = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkAllocateMemory")); + vkFreeMemory = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkFreeMemory")); + vkCreateRenderPass = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateRenderPass")); + vkCmdBeginRenderPass = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdBeginRenderPass")); + vkCmdEndRenderPass = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdEndRenderPass")); + vkCmdNextSubpass = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdNextSubpass")); + vkCmdExecuteCommands = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdExecuteCommands")); + + vkCreateImage = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateImage")); + vkGetImageMemoryRequirements = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetImageMemoryRequirements")); + vkCreateImageView = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateImageView")); + vkDestroyImageView = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyImageView")); + vkBindImageMemory = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkBindImageMemory")); + vkGetImageSubresourceLayout = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetImageSubresourceLayout")); + vkCmdCopyImage = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdCopyImage")); + vkCmdBlitImage = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdBlitImage")); + vkDestroyImage = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyImage")); + + vkCmdClearAttachments = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdClearAttachments")); + + vkCmdCopyBuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdCopyBuffer")); + vkCmdCopyBufferToImage = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdCopyBufferToImage")); + + vkCreateSampler = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateSampler")); + vkDestroySampler = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroySampler"));; + + vkCreateSemaphore = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateSemaphore")); + vkDestroySemaphore = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroySemaphore")); + + vkCreateFence = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateFence")); + vkDestroyFence = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyFence")); + vkWaitForFences = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkWaitForFences")); + vkResetFences = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkResetFences"));; + + vkCreateCommandPool = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateCommandPool")); + vkDestroyCommandPool = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyCommandPool"));; + + vkAllocateCommandBuffers = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkAllocateCommandBuffers")); + vkBeginCommandBuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkBeginCommandBuffer")); + vkEndCommandBuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkEndCommandBuffer")); + + vkGetDeviceQueue = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetDeviceQueue")); + vkQueueSubmit = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkQueueSubmit")); + vkQueueWaitIdle = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkQueueWaitIdle")); + + vkDeviceWaitIdle = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDeviceWaitIdle")); + + vkCreateFramebuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateFramebuffer")); + + vkCreatePipelineCache = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreatePipelineCache")); + vkCreatePipelineLayout = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreatePipelineLayout")); + vkCreateGraphicsPipelines = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateGraphicsPipelines")); + vkCreateComputePipelines = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateComputePipelines")); + + vkCreateDescriptorPool = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateDescriptorPool")); + vkCreateDescriptorSetLayout = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateDescriptorSetLayout")); + + vkAllocateDescriptorSets = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkAllocateDescriptorSets")); + vkUpdateDescriptorSets = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkUpdateDescriptorSets")); + + vkCmdBindDescriptorSets = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdBindDescriptorSets")); + vkCmdBindPipeline = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdBindPipeline")); + vkCmdBindVertexBuffers = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdBindVertexBuffers")); + vkCmdBindIndexBuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdBindIndexBuffer")); + + vkCmdSetViewport = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdSetViewport")); + vkCmdSetScissor = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdSetScissor")); + vkCmdSetLineWidth = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdSetLineWidth")); + vkCmdSetDepthBias = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdSetDepthBias")); + vkCmdPushConstants = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdPushConstants"));; + + vkCmdDrawIndexed = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdDrawIndexed")); + vkCmdDraw = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdDraw")); + vkCmdDrawIndexedIndirect = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdDrawIndexedIndirect")); + vkCmdDrawIndirect = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdDrawIndirect")); + vkCmdDispatch = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdDispatch")); + + vkDestroyPipeline = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyPipeline")); + vkDestroyPipelineLayout = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyPipelineLayout"));; + vkDestroyDescriptorSetLayout = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyDescriptorSetLayout")); + vkDestroyDevice = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyDevice")); + vkDestroyInstance = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyInstance")); + vkDestroyDescriptorPool = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyDescriptorPool")); + vkFreeCommandBuffers = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkFreeCommandBuffers")); + vkDestroyRenderPass = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyRenderPass")); + vkDestroyFramebuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyFramebuffer")); + vkDestroyShaderModule = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyShaderModule")); + vkDestroyPipelineCache = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyPipelineCache")); + + vkCreateQueryPool = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateQueryPool")); + vkDestroyQueryPool = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyQueryPool")); + vkGetQueryPoolResults = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetQueryPoolResults")); + + vkCmdBeginQuery = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdBeginQuery")); + vkCmdEndQuery = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdEndQuery")); + vkCmdResetQueryPool = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdResetQueryPool")); + vkCmdCopyQueryPoolResults = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdCopyQueryPoolResults")); + + vkCreateAndroidSurfaceKHR = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateAndroidSurfaceKHR")); + vkDestroySurfaceKHR = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroySurfaceKHR")); + } + + void freeVulkanLibrary() + { + dlclose(libVulkan); + } } - - // Load base function pointers - vkEnumerateInstanceExtensionProperties = reinterpret_cast(dlsym(libVulkan, "vkEnumerateInstanceExtensionProperties")); - vkEnumerateInstanceLayerProperties = reinterpret_cast(dlsym(libVulkan, "vkEnumerateInstanceLayerProperties")); - vkCreateInstance = reinterpret_cast(dlsym(libVulkan, "vkCreateInstance")); - vkGetInstanceProcAddr = reinterpret_cast(dlsym(libVulkan, "vkGetInstanceProcAddr")); - vkGetDeviceProcAddr = reinterpret_cast(dlsym(libVulkan, "vkGetDeviceProcAddr")); - - return true; -} - -// Load instance based Vulkan function pointers -void loadVulkanFunctions(VkInstance instance) -{ - __android_log_print(ANDROID_LOG_INFO, "vulkanandroid", "Loading instance based function pointers...\n"); - - vkEnumeratePhysicalDevices = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkEnumeratePhysicalDevices")); - vkGetPhysicalDeviceProperties = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceProperties")); - vkEnumerateDeviceLayerProperties = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkEnumerateDeviceLayerProperties")); - vkEnumerateDeviceExtensionProperties = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkEnumerateDeviceExtensionProperties")); - vkGetPhysicalDeviceQueueFamilyProperties = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceQueueFamilyProperties")); - vkGetPhysicalDeviceFeatures = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceFeatures")); - vkCreateDevice = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateDevice")); - vkGetPhysicalDeviceFormatProperties = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceFormatProperties")); - vkGetPhysicalDeviceMemoryProperties = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceMemoryProperties")); - - vkCmdPipelineBarrier = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdPipelineBarrier")); - vkCreateShaderModule = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateShaderModule")); - - vkCreateBuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateBuffer")); - vkGetBufferMemoryRequirements = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetBufferMemoryRequirements")); - vkMapMemory = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkMapMemory")); - vkUnmapMemory = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkUnmapMemory")); - vkFlushMappedMemoryRanges = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkFlushMappedMemoryRanges")); - vkInvalidateMappedMemoryRanges = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkInvalidateMappedMemoryRanges")); - vkBindBufferMemory = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkBindBufferMemory")); - vkDestroyBuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyBuffer")); - - vkAllocateMemory = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkAllocateMemory")); - vkFreeMemory = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkFreeMemory")); - vkCreateRenderPass = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateRenderPass")); - vkCmdBeginRenderPass = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdBeginRenderPass")); - vkCmdEndRenderPass = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdEndRenderPass")); - vkCmdNextSubpass = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdNextSubpass")); - vkCmdExecuteCommands = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdExecuteCommands")); - - vkCreateImage = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateImage")); - vkGetImageMemoryRequirements = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetImageMemoryRequirements")); - vkCreateImageView = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateImageView")); - vkDestroyImageView = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyImageView")); - vkBindImageMemory = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkBindImageMemory")); - vkGetImageSubresourceLayout = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetImageSubresourceLayout")); - vkCmdCopyImage = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdCopyImage")); - vkCmdBlitImage = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdBlitImage")); - vkDestroyImage = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyImage")); - - vkCmdClearAttachments = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdClearAttachments")); - - vkCmdCopyBuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdCopyBuffer")); - vkCmdCopyBufferToImage = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdCopyBufferToImage")); - - vkCreateSampler = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateSampler")); - vkDestroySampler = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroySampler"));; - - vkCreateSemaphore = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateSemaphore")); - vkDestroySemaphore = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroySemaphore")); - - vkCreateFence = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateFence")); - vkDestroyFence = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyFence")); - vkWaitForFences = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkWaitForFences")); - vkResetFences = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkResetFences"));; - - vkCreateCommandPool = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateCommandPool")); - vkDestroyCommandPool = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyCommandPool"));; - - vkAllocateCommandBuffers = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkAllocateCommandBuffers")); - vkBeginCommandBuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkBeginCommandBuffer")); - vkEndCommandBuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkEndCommandBuffer")); - - vkGetDeviceQueue = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetDeviceQueue")); - vkQueueSubmit = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkQueueSubmit")); - vkQueueWaitIdle = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkQueueWaitIdle")); - - vkDeviceWaitIdle = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDeviceWaitIdle")); - - vkCreateFramebuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateFramebuffer")); - - vkCreatePipelineCache = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreatePipelineCache")); - vkCreatePipelineLayout = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreatePipelineLayout")); - vkCreateGraphicsPipelines = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateGraphicsPipelines")); - vkCreateComputePipelines = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateComputePipelines")); - - vkCreateDescriptorPool = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateDescriptorPool")); - vkCreateDescriptorSetLayout = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateDescriptorSetLayout")); - - vkAllocateDescriptorSets = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkAllocateDescriptorSets")); - vkUpdateDescriptorSets = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkUpdateDescriptorSets")); - - vkCmdBindDescriptorSets = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdBindDescriptorSets")); - vkCmdBindPipeline = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdBindPipeline")); - vkCmdBindVertexBuffers = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdBindVertexBuffers")); - vkCmdBindIndexBuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdBindIndexBuffer")); - - vkCmdSetViewport = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdSetViewport")); - vkCmdSetScissor = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdSetScissor")); - vkCmdSetLineWidth = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdSetLineWidth")); - vkCmdSetDepthBias = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdSetDepthBias")); - vkCmdPushConstants = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdPushConstants"));; - - vkCmdDrawIndexed = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdDrawIndexed")); - vkCmdDraw = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdDraw")); - vkCmdDrawIndexedIndirect = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdDrawIndexedIndirect")); - vkCmdDrawIndirect = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdDrawIndirect")); - vkCmdDispatch = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdDispatch")); - - vkDestroyPipeline = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyPipeline")); - vkDestroyPipelineLayout = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyPipelineLayout"));; - vkDestroyDescriptorSetLayout = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyDescriptorSetLayout")); - vkDestroyDevice = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyDevice")); - vkDestroyInstance = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyInstance")); - vkDestroyDescriptorPool = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyDescriptorPool")); - vkFreeCommandBuffers = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkFreeCommandBuffers")); - vkDestroyRenderPass = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyRenderPass")); - vkDestroyFramebuffer = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyFramebuffer")); - vkDestroyShaderModule = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyShaderModule")); - vkDestroyPipelineCache = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyPipelineCache")); - - vkCreateQueryPool = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateQueryPool")); - vkDestroyQueryPool = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroyQueryPool")); - vkGetQueryPoolResults = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkGetQueryPoolResults")); - - vkCmdBeginQuery = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdBeginQuery")); - vkCmdEndQuery = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdEndQuery")); - vkCmdResetQueryPool = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdResetQueryPool")); - vkCmdCopyQueryPoolResults = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCmdCopyQueryPoolResults")); - - vkCreateAndroidSurfaceKHR = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkCreateAndroidSurfaceKHR")); - vkDestroySurfaceKHR = reinterpret_cast(vkGetInstanceProcAddr(instance, "vkDestroySurfaceKHR")); -} - -void freeVulkanLibrary() -{ - dlclose(libVulkan); } #endif diff --git a/base/vulkanandroid.h b/base/vulkanandroid.h index 828a8ce6..afde52c5 100644 --- a/base/vulkanandroid.h +++ b/base/vulkanandroid.h @@ -151,9 +151,15 @@ extern PFN_vkCmdCopyQueryPoolResults vkCmdCopyQueryPoolResults; extern PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR; extern PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR; -bool loadVulkanLibrary(); -void loadVulkanFunctions(VkInstance instance); -void freeVulkanLibrary(); +namespace vks +{ + namespace android + { + bool loadVulkanLibrary(); + void loadVulkanFunctions(VkInstance instance); + void freeVulkanLibrary(); + } +} #endif diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 8baa27bf..1f26a8ad 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -645,7 +645,7 @@ VulkanExampleBase::VulkanExampleBase(bool enableValidation) #if defined(__ANDROID__) // Vulkan library is loaded dynamically on Android - bool libLoaded = loadVulkanLibrary(); + bool libLoaded = vks::android::loadVulkanLibrary(); assert(libLoaded); #elif defined(_DIRECT2DISPLAY) @@ -746,7 +746,7 @@ void VulkanExampleBase::initVulkan() } #if defined(__ANDROID__) - loadVulkanFunctions(instance); + vks::android::loadVulkanFunctions(instance); #endif // If requested, we enable the default validation layers for debugging