mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-12 07:05:46 -04:00
dep: Move Vulkan loader to common
This commit is contained in:
@ -94,6 +94,8 @@ add_library(common
|
||||
vulkan/builders.h
|
||||
vulkan/context.cpp
|
||||
vulkan/context.h
|
||||
vulkan/loader.h
|
||||
vulkan/loader.cpp
|
||||
vulkan/shader_cache.cpp
|
||||
vulkan/shader_cache.h
|
||||
vulkan/shader_compiler.cpp
|
||||
@ -119,7 +121,7 @@ add_library(common
|
||||
target_include_directories(common PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
target_include_directories(common PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
target_link_libraries(common PUBLIC fmt Threads::Threads)
|
||||
target_link_libraries(common PRIVATE glad stb libchdr glslang vulkan-loader zlib minizip samplerate)
|
||||
target_link_libraries(common PRIVATE glad stb libchdr glslang zlib minizip samplerate "${CMAKE_DL_LIBS}")
|
||||
|
||||
if(WIN32)
|
||||
target_sources(common PRIVATE
|
||||
|
@ -2,7 +2,7 @@
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\fmt\include;$(SolutionDir)dep\libsamplerate\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\libcue\include;$(SolutionDir)dep\libchdr\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)dep\glslang;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\minizip\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\fmt\include;$(SolutionDir)dep\libsamplerate\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan\include;$(SolutionDir)dep\libcue\include;$(SolutionDir)dep\libchdr\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\glslang;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\minizip\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
|
@ -77,6 +77,8 @@
|
||||
<ClInclude Include="minizip_helpers.h" />
|
||||
<ClInclude Include="vulkan\builders.h" />
|
||||
<ClInclude Include="vulkan\context.h" />
|
||||
<ClInclude Include="vulkan\entry_points.h" />
|
||||
<ClInclude Include="vulkan\loader.h" />
|
||||
<ClInclude Include="vulkan\shader_cache.h" />
|
||||
<ClInclude Include="vulkan\shader_compiler.h" />
|
||||
<ClInclude Include="vulkan\staging_buffer.h" />
|
||||
@ -162,6 +164,7 @@
|
||||
<ClCompile Include="timestamp.cpp" />
|
||||
<ClCompile Include="vulkan\builders.cpp" />
|
||||
<ClCompile Include="vulkan\context.cpp" />
|
||||
<ClCompile Include="vulkan\loader.cpp" />
|
||||
<ClCompile Include="vulkan\shader_cache.cpp" />
|
||||
<ClCompile Include="vulkan\shader_compiler.cpp" />
|
||||
<ClCompile Include="vulkan\staging_buffer.cpp" />
|
||||
@ -179,6 +182,9 @@
|
||||
<ItemGroup>
|
||||
<Natvis Include="bitfield.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="vulkan\entry_points.inl" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{EE054E08-3799-4A59-A422-18259C105FFD}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
|
@ -137,6 +137,12 @@
|
||||
<ClInclude Include="http_downloader_uwp.h" />
|
||||
<ClInclude Include="http_downloader_winhttp.h" />
|
||||
<ClInclude Include="http_downloader.h" />
|
||||
<ClInclude Include="vulkan\entry_points.h">
|
||||
<Filter>vulkan</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="vulkan\loader.h">
|
||||
<Filter>vulkan</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="jit_code_buffer.cpp" />
|
||||
@ -270,6 +276,9 @@
|
||||
<ClCompile Include="http_downloader_winhttp.cpp" />
|
||||
<ClCompile Include="http_downloader.cpp" />
|
||||
<ClCompile Include="http_downloader_uwp.cpp" />
|
||||
<ClCompile Include="vulkan\loader.cpp">
|
||||
<Filter>vulkan</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include="bitfield.natvis" />
|
||||
@ -291,4 +300,9 @@
|
||||
<UniqueIdentifier>{358e11c4-34af-4169-9a66-ec66342a6a2f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="vulkan\entry_points.inl">
|
||||
<Filter>vulkan</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
#include "vulkan_loader.h"
|
||||
#include "loader.h"
|
||||
#include <array>
|
||||
|
||||
namespace Vulkan {
|
||||
|
@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../types.h"
|
||||
#include "vulkan_loader.h"
|
||||
#include "loader.h"
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
|
200
src/common/vulkan/entry_points.h
Normal file
200
src/common/vulkan/entry_points.h
Normal file
@ -0,0 +1,200 @@
|
||||
#pragma once
|
||||
|
||||
// We abuse the preprocessor here to only need to specify function names once.
|
||||
// Function names are prefixed so to not conflict with system symbols at runtime.
|
||||
#define VULKAN_MODULE_ENTRY_POINT(name, required) extern PFN_##name ds_##name;
|
||||
#define VULKAN_INSTANCE_ENTRY_POINT(name, required) extern PFN_##name ds_##name;
|
||||
#define VULKAN_DEVICE_ENTRY_POINT(name, required) extern PFN_##name ds_##name;
|
||||
#define VULKAN_DEFINE_NAME_PREFIX ds_
|
||||
#include "entry_points.inl"
|
||||
#undef VULKAN_DEFINE_NAME_PREFIX
|
||||
#undef VULKAN_DEVICE_ENTRY_POINT
|
||||
#undef VULKAN_INSTANCE_ENTRY_POINT
|
||||
#undef VULKAN_MODULE_ENTRY_POINT
|
||||
|
||||
#define vkCreateInstance ds_vkCreateInstance
|
||||
#define vkGetInstanceProcAddr ds_vkGetInstanceProcAddr
|
||||
#define vkEnumerateInstanceExtensionProperties ds_vkEnumerateInstanceExtensionProperties
|
||||
#define vkEnumerateInstanceLayerProperties ds_vkEnumerateInstanceLayerProperties
|
||||
#define vkEnumerateInstanceVersion ds_vkEnumerateInstanceVersion
|
||||
|
||||
#define vkGetDeviceProcAddr ds_vkGetDeviceProcAddr
|
||||
#define vkDestroyInstance ds_vkDestroyInstance
|
||||
#define vkEnumeratePhysicalDevices ds_vkEnumeratePhysicalDevices
|
||||
#define vkGetPhysicalDeviceFeatures ds_vkGetPhysicalDeviceFeatures
|
||||
#define vkGetPhysicalDeviceFormatProperties ds_vkGetPhysicalDeviceFormatProperties
|
||||
#define vkGetPhysicalDeviceImageFormatProperties ds_vkGetPhysicalDeviceImageFormatProperties
|
||||
#define vkGetPhysicalDeviceProperties ds_vkGetPhysicalDeviceProperties
|
||||
#define vkGetPhysicalDeviceQueueFamilyProperties ds_vkGetPhysicalDeviceQueueFamilyProperties
|
||||
#define vkGetPhysicalDeviceMemoryProperties ds_vkGetPhysicalDeviceMemoryProperties
|
||||
#define vkCreateDevice ds_vkCreateDevice
|
||||
#define vkEnumerateDeviceExtensionProperties ds_vkEnumerateDeviceExtensionProperties
|
||||
#define vkEnumerateDeviceLayerProperties ds_vkEnumerateDeviceLayerProperties
|
||||
#define vkGetPhysicalDeviceSparseImageFormatProperties ds_vkGetPhysicalDeviceSparseImageFormatProperties
|
||||
#define vkDestroySurfaceKHR ds_vkDestroySurfaceKHR
|
||||
#define vkGetPhysicalDeviceSurfaceSupportKHR ds_vkGetPhysicalDeviceSurfaceSupportKHR
|
||||
#define vkGetPhysicalDeviceSurfaceCapabilitiesKHR ds_vkGetPhysicalDeviceSurfaceCapabilitiesKHR
|
||||
#define vkGetPhysicalDeviceSurfaceFormatsKHR ds_vkGetPhysicalDeviceSurfaceFormatsKHR
|
||||
#define vkGetPhysicalDeviceSurfacePresentModesKHR ds_vkGetPhysicalDeviceSurfacePresentModesKHR
|
||||
#define vkCreateWin32SurfaceKHR ds_vkCreateWin32SurfaceKHR
|
||||
#define vkGetPhysicalDeviceWin32PresentationSupportKHR ds_vkGetPhysicalDeviceWin32PresentationSupportKHR
|
||||
#define vkCreateXlibSurfaceKHR ds_vkCreateXlibSurfaceKHR
|
||||
#define vkGetPhysicalDeviceXlibPresentationSupportKHR ds_vkGetPhysicalDeviceXlibPresentationSupportKHR
|
||||
#define vkCreateWaylandSurfaceKHR ds_vkCreateWaylandSurfaceKHR
|
||||
#define vkCreateAndroidSurfaceKHR ds_vkCreateAndroidSurfaceKHR
|
||||
#define vkCreateMacOSSurfaceMVK ds_vkCreateMacOSSurfaceMVK
|
||||
#define vkCreateMetalSurfaceEXT ds_vkCreateMetalSurfaceEXT
|
||||
|
||||
// VK_EXT_debug_utils
|
||||
#define vkCmdBeginDebugUtilsLabelEXT ds_vkCmdBeginDebugUtilsLabelEXT
|
||||
#define vkCmdEndDebugUtilsLabelEXT ds_vkCmdEndDebugUtilsLabelEXT
|
||||
#define vkCmdInsertDebugUtilsLabelEXT ds_vkCmdInsertDebugUtilsLabelEXT
|
||||
#define vkCreateDebugUtilsMessengerEXT ds_vkCreateDebugUtilsMessengerEXT
|
||||
#define vkDestroyDebugUtilsMessengerEXT ds_vkDestroyDebugUtilsMessengerEXT
|
||||
#define vkQueueBeginDebugUtilsLabelEXT ds_vkQueueBeginDebugUtilsLabelEXT
|
||||
#define vkQueueEndDebugUtilsLabelEXT ds_vkQueueEndDebugUtilsLabelEXT
|
||||
#define vkQueueInsertDebugUtilsLabelEXT ds_vkQueueInsertDebugUtilsLabelEXT
|
||||
#define vkSetDebugUtilsObjectNameEXT ds_vkSetDebugUtilsObjectNameEXT
|
||||
#define vkSetDebugUtilsObjectTagEXT ds_vkSetDebugUtilsObjectTagEXT
|
||||
#define vkSubmitDebugUtilsMessageEXT ds_vkSubmitDebugUtilsMessageEXT
|
||||
|
||||
#define vkGetPhysicalDeviceProperties2 ds_vkGetPhysicalDeviceProperties2
|
||||
#define vkGetPhysicalDeviceSurfaceCapabilities2KHR ds_vkGetPhysicalDeviceSurfaceCapabilities2KHR
|
||||
#define vkGetPhysicalDeviceDisplayPropertiesKHR ds_vkGetPhysicalDeviceDisplayPropertiesKHR
|
||||
#define vkGetPhysicalDeviceDisplayPlanePropertiesKHR ds_vkGetPhysicalDeviceDisplayPlanePropertiesKHR
|
||||
#define vkGetDisplayPlaneSupportedDisplaysKHR ds_vkGetDisplayPlaneSupportedDisplaysKHR
|
||||
#define vkGetDisplayModePropertiesKHR ds_vkGetDisplayModePropertiesKHR
|
||||
#define vkCreateDisplayModeKHR ds_vkCreateDisplayModeKHR
|
||||
#define vkGetDisplayPlaneCapabilitiesKHR ds_vkGetDisplayPlaneCapabilitiesKHR
|
||||
#define vkCreateDisplayPlaneSurfaceKHR ds_vkCreateDisplayPlaneSurfaceKHR
|
||||
|
||||
#define vkDestroyDevice ds_vkDestroyDevice
|
||||
#define vkGetDeviceQueue ds_vkGetDeviceQueue
|
||||
#define vkQueueSubmit ds_vkQueueSubmit
|
||||
#define vkQueueWaitIdle ds_vkQueueWaitIdle
|
||||
#define vkDeviceWaitIdle ds_vkDeviceWaitIdle
|
||||
#define vkAllocateMemory ds_vkAllocateMemory
|
||||
#define vkFreeMemory ds_vkFreeMemory
|
||||
#define vkMapMemory ds_vkMapMemory
|
||||
#define vkUnmapMemory ds_vkUnmapMemory
|
||||
#define vkFlushMappedMemoryRanges ds_vkFlushMappedMemoryRanges
|
||||
#define vkInvalidateMappedMemoryRanges ds_vkInvalidateMappedMemoryRanges
|
||||
#define vkGetDeviceMemoryCommitment ds_vkGetDeviceMemoryCommitment
|
||||
#define vkBindBufferMemory ds_vkBindBufferMemory
|
||||
#define vkBindImageMemory ds_vkBindImageMemory
|
||||
#define vkGetBufferMemoryRequirements ds_vkGetBufferMemoryRequirements
|
||||
#define vkGetImageMemoryRequirements ds_vkGetImageMemoryRequirements
|
||||
#define vkGetImageSparseMemoryRequirements ds_vkGetImageSparseMemoryRequirements
|
||||
#define vkQueueBindSparse ds_vkQueueBindSparse
|
||||
#define vkCreateFence ds_vkCreateFence
|
||||
#define vkDestroyFence ds_vkDestroyFence
|
||||
#define vkResetFences ds_vkResetFences
|
||||
#define vkGetFenceStatus ds_vkGetFenceStatus
|
||||
#define vkWaitForFences ds_vkWaitForFences
|
||||
#define vkCreateSemaphore ds_vkCreateSemaphore
|
||||
#define vkDestroySemaphore ds_vkDestroySemaphore
|
||||
#define vkCreateEvent ds_vkCreateEvent
|
||||
#define vkDestroyEvent ds_vkDestroyEvent
|
||||
#define vkGetEventStatus ds_vkGetEventStatus
|
||||
#define vkSetEvent ds_vkSetEvent
|
||||
#define vkResetEvent ds_vkResetEvent
|
||||
#define vkCreateQueryPool ds_vkCreateQueryPool
|
||||
#define vkDestroyQueryPool ds_vkDestroyQueryPool
|
||||
#define vkGetQueryPoolResults ds_vkGetQueryPoolResults
|
||||
#define vkCreateBuffer ds_vkCreateBuffer
|
||||
#define vkDestroyBuffer ds_vkDestroyBuffer
|
||||
#define vkCreateBufferView ds_vkCreateBufferView
|
||||
#define vkDestroyBufferView ds_vkDestroyBufferView
|
||||
#define vkCreateImage ds_vkCreateImage
|
||||
#define vkDestroyImage ds_vkDestroyImage
|
||||
#define vkGetImageSubresourceLayout ds_vkGetImageSubresourceLayout
|
||||
#define vkCreateImageView ds_vkCreateImageView
|
||||
#define vkDestroyImageView ds_vkDestroyImageView
|
||||
#define vkCreateShaderModule ds_vkCreateShaderModule
|
||||
#define vkDestroyShaderModule ds_vkDestroyShaderModule
|
||||
#define vkCreatePipelineCache ds_vkCreatePipelineCache
|
||||
#define vkDestroyPipelineCache ds_vkDestroyPipelineCache
|
||||
#define vkGetPipelineCacheData ds_vkGetPipelineCacheData
|
||||
#define vkMergePipelineCaches ds_vkMergePipelineCaches
|
||||
#define vkCreateGraphicsPipelines ds_vkCreateGraphicsPipelines
|
||||
#define vkCreateComputePipelines ds_vkCreateComputePipelines
|
||||
#define vkDestroyPipeline ds_vkDestroyPipeline
|
||||
#define vkCreatePipelineLayout ds_vkCreatePipelineLayout
|
||||
#define vkDestroyPipelineLayout ds_vkDestroyPipelineLayout
|
||||
#define vkCreateSampler ds_vkCreateSampler
|
||||
#define vkDestroySampler ds_vkDestroySampler
|
||||
#define vkCreateDescriptorSetLayout ds_vkCreateDescriptorSetLayout
|
||||
#define vkDestroyDescriptorSetLayout ds_vkDestroyDescriptorSetLayout
|
||||
#define vkCreateDescriptorPool ds_vkCreateDescriptorPool
|
||||
#define vkDestroyDescriptorPool ds_vkDestroyDescriptorPool
|
||||
#define vkResetDescriptorPool ds_vkResetDescriptorPool
|
||||
#define vkAllocateDescriptorSets ds_vkAllocateDescriptorSets
|
||||
#define vkFreeDescriptorSets ds_vkFreeDescriptorSets
|
||||
#define vkUpdateDescriptorSets ds_vkUpdateDescriptorSets
|
||||
#define vkCreateFramebuffer ds_vkCreateFramebuffer
|
||||
#define vkDestroyFramebuffer ds_vkDestroyFramebuffer
|
||||
#define vkCreateRenderPass ds_vkCreateRenderPass
|
||||
#define vkDestroyRenderPass ds_vkDestroyRenderPass
|
||||
#define vkGetRenderAreaGranularity ds_vkGetRenderAreaGranularity
|
||||
#define vkCreateCommandPool ds_vkCreateCommandPool
|
||||
#define vkDestroyCommandPool ds_vkDestroyCommandPool
|
||||
#define vkResetCommandPool ds_vkResetCommandPool
|
||||
#define vkAllocateCommandBuffers ds_vkAllocateCommandBuffers
|
||||
#define vkFreeCommandBuffers ds_vkFreeCommandBuffers
|
||||
#define vkBeginCommandBuffer ds_vkBeginCommandBuffer
|
||||
#define vkEndCommandBuffer ds_vkEndCommandBuffer
|
||||
#define vkResetCommandBuffer ds_vkResetCommandBuffer
|
||||
#define vkCmdBindPipeline ds_vkCmdBindPipeline
|
||||
#define vkCmdSetViewport ds_vkCmdSetViewport
|
||||
#define vkCmdSetScissor ds_vkCmdSetScissor
|
||||
#define vkCmdSetLineWidth ds_vkCmdSetLineWidth
|
||||
#define vkCmdSetDepthBias ds_vkCmdSetDepthBias
|
||||
#define vkCmdSetBlendConstants ds_vkCmdSetBlendConstants
|
||||
#define vkCmdSetDepthBounds ds_vkCmdSetDepthBounds
|
||||
#define vkCmdSetStencilCompareMask ds_vkCmdSetStencilCompareMask
|
||||
#define vkCmdSetStencilWriteMask ds_vkCmdSetStencilWriteMask
|
||||
#define vkCmdSetStencilReference ds_vkCmdSetStencilReference
|
||||
#define vkCmdBindDescriptorSets ds_vkCmdBindDescriptorSets
|
||||
#define vkCmdBindIndexBuffer ds_vkCmdBindIndexBuffer
|
||||
#define vkCmdBindVertexBuffers ds_vkCmdBindVertexBuffers
|
||||
#define vkCmdDraw ds_vkCmdDraw
|
||||
#define vkCmdDrawIndexed ds_vkCmdDrawIndexed
|
||||
#define vkCmdDrawIndirect ds_vkCmdDrawIndirect
|
||||
#define vkCmdDrawIndexedIndirect ds_vkCmdDrawIndexedIndirect
|
||||
#define vkCmdDispatch ds_vkCmdDispatch
|
||||
#define vkCmdDispatchIndirect ds_vkCmdDispatchIndirect
|
||||
#define vkCmdCopyBuffer ds_vkCmdCopyBuffer
|
||||
#define vkCmdCopyImage ds_vkCmdCopyImage
|
||||
#define vkCmdBlitImage ds_vkCmdBlitImage
|
||||
#define vkCmdCopyBufferToImage ds_vkCmdCopyBufferToImage
|
||||
#define vkCmdCopyImageToBuffer ds_vkCmdCopyImageToBuffer
|
||||
#define vkCmdUpdateBuffer ds_vkCmdUpdateBuffer
|
||||
#define vkCmdFillBuffer ds_vkCmdFillBuffer
|
||||
#define vkCmdClearColorImage ds_vkCmdClearColorImage
|
||||
#define vkCmdClearDepthStencilImage ds_vkCmdClearDepthStencilImage
|
||||
#define vkCmdClearAttachments ds_vkCmdClearAttachments
|
||||
#define vkCmdResolveImage ds_vkCmdResolveImage
|
||||
#define vkCmdSetEvent ds_vkCmdSetEvent
|
||||
#define vkCmdResetEvent ds_vkCmdResetEvent
|
||||
#define vkCmdWaitEvents ds_vkCmdWaitEvents
|
||||
#define vkCmdPipelineBarrier ds_vkCmdPipelineBarrier
|
||||
#define vkCmdBeginQuery ds_vkCmdBeginQuery
|
||||
#define vkCmdEndQuery ds_vkCmdEndQuery
|
||||
#define vkCmdResetQueryPool ds_vkCmdResetQueryPool
|
||||
#define vkCmdWriteTimestamp ds_vkCmdWriteTimestamp
|
||||
#define vkCmdCopyQueryPoolResults ds_vkCmdCopyQueryPoolResults
|
||||
#define vkCmdPushConstants ds_vkCmdPushConstants
|
||||
#define vkCmdBeginRenderPass ds_vkCmdBeginRenderPass
|
||||
#define vkCmdNextSubpass ds_vkCmdNextSubpass
|
||||
#define vkCmdEndRenderPass ds_vkCmdEndRenderPass
|
||||
#define vkCmdExecuteCommands ds_vkCmdExecuteCommands
|
||||
#define vkCreateSwapchainKHR ds_vkCreateSwapchainKHR
|
||||
#define vkDestroySwapchainKHR ds_vkDestroySwapchainKHR
|
||||
#define vkGetSwapchainImagesKHR ds_vkGetSwapchainImagesKHR
|
||||
#define vkAcquireNextImageKHR ds_vkAcquireNextImageKHR
|
||||
#define vkQueuePresentKHR ds_vkQueuePresentKHR
|
||||
|
||||
#ifdef SUPPORTS_VULKAN_EXCLUSIVE_FULLSCREEN
|
||||
#define vkAcquireFullScreenExclusiveModeEXT ds_vkAcquireFullScreenExclusiveModeEXT
|
||||
#define vkReleaseFullScreenExclusiveModeEXT ds_vkReleaseFullScreenExclusiveModeEXT
|
||||
#endif
|
228
src/common/vulkan/entry_points.inl
Normal file
228
src/common/vulkan/entry_points.inl
Normal file
@ -0,0 +1,228 @@
|
||||
// Copyright 2016 Dolphin Emulator Project
|
||||
// Copyright 2020 DuckStation Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the LICENSE file included.
|
||||
|
||||
// Expands the VULKAN_ENTRY_POINT macro for each function when this file is included.
|
||||
// Parameters: Function name, is required
|
||||
// VULKAN_MODULE_ENTRY_POINT is for functions in vulkan-1.dll
|
||||
// VULKAN_INSTANCE_ENTRY_POINT is for instance-specific functions.
|
||||
// VULKAN_DEVICE_ENTRY_POINT is for device-specific functions.
|
||||
|
||||
#ifdef VULKAN_MODULE_ENTRY_POINT
|
||||
|
||||
VULKAN_MODULE_ENTRY_POINT(vkCreateInstance, true)
|
||||
VULKAN_MODULE_ENTRY_POINT(vkGetInstanceProcAddr, true)
|
||||
VULKAN_MODULE_ENTRY_POINT(vkEnumerateInstanceExtensionProperties, true)
|
||||
VULKAN_MODULE_ENTRY_POINT(vkEnumerateInstanceLayerProperties, true)
|
||||
VULKAN_MODULE_ENTRY_POINT(vkEnumerateInstanceVersion, false)
|
||||
|
||||
#endif // VULKAN_MODULE_ENTRY_POINT
|
||||
|
||||
#ifdef VULKAN_INSTANCE_ENTRY_POINT
|
||||
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetDeviceProcAddr, true)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkDestroyInstance, true)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkEnumeratePhysicalDevices, true)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceFeatures, true)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceFormatProperties, true)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceImageFormatProperties, true)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceProperties, true)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceQueueFamilyProperties, true)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceMemoryProperties, true)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkCreateDevice, true)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkEnumerateDeviceExtensionProperties, true)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkEnumerateDeviceLayerProperties, true)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceSparseImageFormatProperties, true)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkDestroySurfaceKHR, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceSurfaceSupportKHR, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceSurfaceCapabilitiesKHR, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceSurfaceFormatsKHR, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceSurfacePresentModesKHR, false)
|
||||
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkCreateWin32SurfaceKHR, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceWin32PresentationSupportKHR, false)
|
||||
#endif
|
||||
|
||||
#if defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkCreateXlibSurfaceKHR, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceXlibPresentationSupportKHR, false)
|
||||
#endif
|
||||
|
||||
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkCreateWaylandSurfaceKHR, false)
|
||||
#endif
|
||||
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkCreateAndroidSurfaceKHR, false)
|
||||
#endif
|
||||
|
||||
#if defined(VK_USE_PLATFORM_MACOS_MVK)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkCreateMacOSSurfaceMVK, false)
|
||||
#endif
|
||||
|
||||
#if defined(VK_USE_PLATFORM_METAL_EXT)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkCreateMetalSurfaceEXT, false)
|
||||
#endif
|
||||
|
||||
// VK_EXT_debug_utils
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkCmdBeginDebugUtilsLabelEXT, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkCmdEndDebugUtilsLabelEXT, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkCmdInsertDebugUtilsLabelEXT, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkCreateDebugUtilsMessengerEXT, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkDestroyDebugUtilsMessengerEXT, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkQueueBeginDebugUtilsLabelEXT, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkQueueEndDebugUtilsLabelEXT, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkQueueInsertDebugUtilsLabelEXT, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkSetDebugUtilsObjectNameEXT, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkSetDebugUtilsObjectTagEXT, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkSubmitDebugUtilsMessageEXT, false)
|
||||
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceProperties2, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceSurfaceCapabilities2KHR, false)
|
||||
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceDisplayPropertiesKHR, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetPhysicalDeviceDisplayPlanePropertiesKHR, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetDisplayPlaneSupportedDisplaysKHR, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetDisplayModePropertiesKHR, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkCreateDisplayModeKHR, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkGetDisplayPlaneCapabilitiesKHR, false)
|
||||
VULKAN_INSTANCE_ENTRY_POINT(vkCreateDisplayPlaneSurfaceKHR, false)
|
||||
|
||||
#endif // VULKAN_INSTANCE_ENTRY_POINT
|
||||
|
||||
#ifdef VULKAN_DEVICE_ENTRY_POINT
|
||||
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyDevice, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkGetDeviceQueue, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkQueueSubmit, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkQueueWaitIdle, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDeviceWaitIdle, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkAllocateMemory, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkFreeMemory, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkMapMemory, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkUnmapMemory, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkFlushMappedMemoryRanges, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkInvalidateMappedMemoryRanges, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkGetDeviceMemoryCommitment, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkBindBufferMemory, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkBindImageMemory, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkGetBufferMemoryRequirements, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkGetImageMemoryRequirements, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkGetImageSparseMemoryRequirements, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkQueueBindSparse, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateFence, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyFence, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkResetFences, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkGetFenceStatus, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkWaitForFences, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateSemaphore, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroySemaphore, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateEvent, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyEvent, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkGetEventStatus, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkSetEvent, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkResetEvent, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateQueryPool, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyQueryPool, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkGetQueryPoolResults, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateBuffer, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyBuffer, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateBufferView, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyBufferView, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateImage, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyImage, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkGetImageSubresourceLayout, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateImageView, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyImageView, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateShaderModule, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyShaderModule, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreatePipelineCache, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyPipelineCache, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkGetPipelineCacheData, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkMergePipelineCaches, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateGraphicsPipelines, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateComputePipelines, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyPipeline, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreatePipelineLayout, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyPipelineLayout, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateSampler, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroySampler, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateDescriptorSetLayout, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyDescriptorSetLayout, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateDescriptorPool, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyDescriptorPool, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkResetDescriptorPool, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkAllocateDescriptorSets, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkFreeDescriptorSets, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkUpdateDescriptorSets, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateFramebuffer, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyFramebuffer, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateRenderPass, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyRenderPass, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkGetRenderAreaGranularity, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateCommandPool, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroyCommandPool, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkResetCommandPool, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkAllocateCommandBuffers, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkFreeCommandBuffers, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkBeginCommandBuffer, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkEndCommandBuffer, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkResetCommandBuffer, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdBindPipeline, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdSetViewport, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdSetScissor, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdSetLineWidth, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdSetDepthBias, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdSetBlendConstants, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdSetDepthBounds, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdSetStencilCompareMask, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdSetStencilWriteMask, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdSetStencilReference, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdBindDescriptorSets, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdBindIndexBuffer, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdBindVertexBuffers, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdDraw, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdDrawIndexed, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdDrawIndirect, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdDrawIndexedIndirect, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdDispatch, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdDispatchIndirect, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdCopyBuffer, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdCopyImage, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdBlitImage, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdCopyBufferToImage, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdCopyImageToBuffer, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdUpdateBuffer, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdFillBuffer, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdClearColorImage, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdClearDepthStencilImage, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdClearAttachments, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdResolveImage, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdSetEvent, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdResetEvent, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdWaitEvents, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdPipelineBarrier, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdBeginQuery, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdEndQuery, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdResetQueryPool, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdWriteTimestamp, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdCopyQueryPoolResults, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdPushConstants, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdBeginRenderPass, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdNextSubpass, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdEndRenderPass, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCmdExecuteCommands, true)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkCreateSwapchainKHR, false)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkDestroySwapchainKHR, false)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkGetSwapchainImagesKHR, false)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkAcquireNextImageKHR, false)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkQueuePresentKHR, false)
|
||||
|
||||
#ifdef SUPPORTS_VULKAN_EXCLUSIVE_FULLSCREEN
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkAcquireFullScreenExclusiveModeEXT, false)
|
||||
VULKAN_DEVICE_ENTRY_POINT(vkReleaseFullScreenExclusiveModeEXT, false)
|
||||
#endif
|
||||
|
||||
#endif // VULKAN_DEVICE_ENTRY_POINT
|
240
src/common/vulkan/loader.cpp
Normal file
240
src/common/vulkan/loader.cpp
Normal file
@ -0,0 +1,240 @@
|
||||
// Copyright 2016 Dolphin Emulator Project
|
||||
// Copyright 2020 DuckStation Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the LICENSE file included.
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
#include "loader.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
#define VULKAN_MODULE_ENTRY_POINT(name, required) PFN_##name ds_##name;
|
||||
#define VULKAN_INSTANCE_ENTRY_POINT(name, required) PFN_##name ds_##name;
|
||||
#define VULKAN_DEVICE_ENTRY_POINT(name, required) PFN_##name ds_##name;
|
||||
#include "entry_points.inl"
|
||||
#undef VULKAN_DEVICE_ENTRY_POINT
|
||||
#undef VULKAN_INSTANCE_ENTRY_POINT
|
||||
#undef VULKAN_MODULE_ENTRY_POINT
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
void ResetVulkanLibraryFunctionPointers()
|
||||
{
|
||||
#define VULKAN_MODULE_ENTRY_POINT(name, required) ds_##name = nullptr;
|
||||
#define VULKAN_INSTANCE_ENTRY_POINT(name, required) ds_##name = nullptr;
|
||||
#define VULKAN_DEVICE_ENTRY_POINT(name, required) ds_##name = nullptr;
|
||||
#include "entry_points.inl"
|
||||
#undef VULKAN_DEVICE_ENTRY_POINT
|
||||
#undef VULKAN_INSTANCE_ENTRY_POINT
|
||||
#undef VULKAN_MODULE_ENTRY_POINT
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
static HMODULE vulkan_module;
|
||||
static std::atomic_int vulkan_module_ref_count = {0};
|
||||
|
||||
bool LoadVulkanLibrary()
|
||||
{
|
||||
// Not thread safe if a second thread calls the loader whilst the first is still in-progress.
|
||||
if (vulkan_module)
|
||||
{
|
||||
vulkan_module_ref_count++;
|
||||
return true;
|
||||
}
|
||||
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM | WINAPI_PARTITION_GAMES)
|
||||
vulkan_module = LoadLibraryA("vulkan-1.dll");
|
||||
#else
|
||||
vulkan_module = NULL;
|
||||
#endif
|
||||
if (!vulkan_module)
|
||||
{
|
||||
std::fprintf(stderr, "Failed to load vulkan-1.dll\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool required_functions_missing = false;
|
||||
auto LoadFunction = [&](FARPROC* func_ptr, const char* name, bool is_required) {
|
||||
*func_ptr = GetProcAddress(vulkan_module, name);
|
||||
if (!(*func_ptr) && is_required)
|
||||
{
|
||||
std::fprintf(stderr, "Vulkan: Failed to load required module function %s\n", name);
|
||||
required_functions_missing = true;
|
||||
}
|
||||
};
|
||||
|
||||
#define VULKAN_MODULE_ENTRY_POINT(name, required) LoadFunction(reinterpret_cast<FARPROC*>(&name), #name, required);
|
||||
#include "entry_points.inl"
|
||||
#undef VULKAN_MODULE_ENTRY_POINT
|
||||
|
||||
if (required_functions_missing)
|
||||
{
|
||||
ResetVulkanLibraryFunctionPointers();
|
||||
FreeLibrary(vulkan_module);
|
||||
vulkan_module = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
vulkan_module_ref_count++;
|
||||
return true;
|
||||
}
|
||||
|
||||
void UnloadVulkanLibrary()
|
||||
{
|
||||
if ((--vulkan_module_ref_count) > 0)
|
||||
return;
|
||||
|
||||
ResetVulkanLibraryFunctionPointers();
|
||||
FreeLibrary(vulkan_module);
|
||||
vulkan_module = nullptr;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void* vulkan_module;
|
||||
static std::atomic_int vulkan_module_ref_count = {0};
|
||||
|
||||
bool LoadVulkanLibrary()
|
||||
{
|
||||
// Not thread safe if a second thread calls the loader whilst the first is still in-progress.
|
||||
if (vulkan_module)
|
||||
{
|
||||
vulkan_module_ref_count++;
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// Check if a path to a specific Vulkan library has been specified.
|
||||
char* libvulkan_env = getenv("LIBVULKAN_PATH");
|
||||
if (libvulkan_env)
|
||||
vulkan_module = dlopen(libvulkan_env, RTLD_NOW);
|
||||
if (!vulkan_module)
|
||||
{
|
||||
unsigned path_size = 0;
|
||||
_NSGetExecutablePath(nullptr, &path_size);
|
||||
std::string path;
|
||||
path.resize(path_size);
|
||||
if (_NSGetExecutablePath(path.data(), &path_size) == 0)
|
||||
{
|
||||
path[path_size] = 0;
|
||||
|
||||
size_t pos = path.rfind('/');
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
path.erase(pos);
|
||||
path += "/../Frameworks/libvulkan.dylib";
|
||||
vulkan_module = dlopen(path.c_str(), RTLD_NOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!vulkan_module)
|
||||
vulkan_module = dlopen("libvulkan.dylib", RTLD_NOW);
|
||||
#else
|
||||
// Names of libraries to search. Desktop should use libvulkan.so.1 or libvulkan.so.
|
||||
static const char* search_lib_names[] = {"libvulkan.so.1", "libvulkan.so"};
|
||||
for (size_t i = 0; i < sizeof(search_lib_names) / sizeof(search_lib_names[0]); i++)
|
||||
{
|
||||
vulkan_module = dlopen(search_lib_names[i], RTLD_NOW);
|
||||
if (vulkan_module)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!vulkan_module)
|
||||
{
|
||||
std::fprintf(stderr, "Failed to load or locate libvulkan.so\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool required_functions_missing = false;
|
||||
auto LoadFunction = [&](void** func_ptr, const char* name, bool is_required) {
|
||||
*func_ptr = dlsym(vulkan_module, name);
|
||||
if (!(*func_ptr) && is_required)
|
||||
{
|
||||
std::fprintf(stderr, "Vulkan: Failed to load required module function %s\n", name);
|
||||
required_functions_missing = true;
|
||||
}
|
||||
};
|
||||
|
||||
#define VULKAN_MODULE_ENTRY_POINT(name, required) LoadFunction(reinterpret_cast<void**>(&name), #name, required);
|
||||
#include "entry_points.inl"
|
||||
#undef VULKAN_MODULE_ENTRY_POINT
|
||||
|
||||
if (required_functions_missing)
|
||||
{
|
||||
ResetVulkanLibraryFunctionPointers();
|
||||
dlclose(vulkan_module);
|
||||
vulkan_module = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
vulkan_module_ref_count++;
|
||||
return true;
|
||||
}
|
||||
|
||||
void UnloadVulkanLibrary()
|
||||
{
|
||||
if ((--vulkan_module_ref_count) > 0)
|
||||
return;
|
||||
|
||||
ResetVulkanLibraryFunctionPointers();
|
||||
dlclose(vulkan_module);
|
||||
vulkan_module = nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool LoadVulkanInstanceFunctions(VkInstance instance)
|
||||
{
|
||||
bool required_functions_missing = false;
|
||||
auto LoadFunction = [&](PFN_vkVoidFunction* func_ptr, const char* name, bool is_required) {
|
||||
*func_ptr = vkGetInstanceProcAddr(instance, name);
|
||||
if (!(*func_ptr) && is_required)
|
||||
{
|
||||
std::fprintf(stderr, "Vulkan: Failed to load required instance function %s\n", name);
|
||||
required_functions_missing = true;
|
||||
}
|
||||
};
|
||||
|
||||
#define VULKAN_INSTANCE_ENTRY_POINT(name, required) \
|
||||
LoadFunction(reinterpret_cast<PFN_vkVoidFunction*>(&name), #name, required);
|
||||
#include "entry_points.inl"
|
||||
#undef VULKAN_INSTANCE_ENTRY_POINT
|
||||
|
||||
return !required_functions_missing;
|
||||
}
|
||||
|
||||
bool LoadVulkanDeviceFunctions(VkDevice device)
|
||||
{
|
||||
bool required_functions_missing = false;
|
||||
auto LoadFunction = [&](PFN_vkVoidFunction* func_ptr, const char* name, bool is_required) {
|
||||
*func_ptr = vkGetDeviceProcAddr(device, name);
|
||||
if (!(*func_ptr) && is_required)
|
||||
{
|
||||
std::fprintf(stderr, "Vulkan: Failed to load required device function %s\n", name);
|
||||
required_functions_missing = true;
|
||||
}
|
||||
};
|
||||
|
||||
#define VULKAN_DEVICE_ENTRY_POINT(name, required) \
|
||||
LoadFunction(reinterpret_cast<PFN_vkVoidFunction*>(&name), #name, required);
|
||||
#include "entry_points.inl"
|
||||
#undef VULKAN_DEVICE_ENTRY_POINT
|
||||
|
||||
return !required_functions_missing;
|
||||
}
|
||||
|
||||
} // namespace Vulkan
|
92
src/common/vulkan/loader.h
Normal file
92
src/common/vulkan/loader.h
Normal file
@ -0,0 +1,92 @@
|
||||
// Copyright 2016 Dolphin Emulator Project
|
||||
// Copyright 2020 DuckStation Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the LICENSE file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#define VK_NO_PROTOTYPES
|
||||
|
||||
#if defined(WIN32)
|
||||
|
||||
#define VK_USE_PLATFORM_WIN32_KHR
|
||||
|
||||
// vulkan.h pulls in windows.h on Windows, so we need to include our replacement header first
|
||||
#include "../windows_headers.h"
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(USE_X11)
|
||||
#define VK_USE_PLATFORM_XLIB_KHR
|
||||
#endif
|
||||
|
||||
#if defined(USE_WAYLAND)
|
||||
#define VK_USE_PLATFORM_WAYLAND_KHR
|
||||
#endif
|
||||
|
||||
#if defined(ANDROID)
|
||||
#define VK_USE_PLATFORM_ANDROID_KHR
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// #define VK_USE_PLATFORM_MACOS_MVK
|
||||
#define VK_USE_PLATFORM_METAL_EXT
|
||||
#endif
|
||||
|
||||
#include "vulkan/vulkan.h"
|
||||
|
||||
// Currently, exclusive fullscreen is only supported on Windows.
|
||||
#if defined(WIN32)
|
||||
#define SUPPORTS_VULKAN_EXCLUSIVE_FULLSCREEN 1
|
||||
#endif
|
||||
|
||||
#if defined(USE_X11)
|
||||
|
||||
// This breaks a bunch of our code. They shouldn't be #defines in the first place.
|
||||
#ifdef None
|
||||
#undef None
|
||||
#endif
|
||||
#ifdef Status
|
||||
#undef Status
|
||||
#endif
|
||||
#ifdef CursorShape
|
||||
#undef CursorShape
|
||||
#endif
|
||||
#ifdef KeyPress
|
||||
#undef KeyPress
|
||||
#endif
|
||||
#ifdef KeyRelease
|
||||
#undef KeyRelease
|
||||
#endif
|
||||
#ifdef FocusIn
|
||||
#undef FocusIn
|
||||
#endif
|
||||
#ifdef FocusOut
|
||||
#undef FocusOut
|
||||
#endif
|
||||
#ifdef FontChange
|
||||
#undef FontChange
|
||||
#endif
|
||||
#ifdef Expose
|
||||
#undef Expose
|
||||
#endif
|
||||
#ifdef Unsorted
|
||||
#undef Unsorted
|
||||
#endif
|
||||
#ifdef Bool
|
||||
#undef Bool
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include "entry_points.h"
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
bool LoadVulkanLibrary();
|
||||
bool LoadVulkanInstanceFunctions(VkInstance instance);
|
||||
bool LoadVulkanDeviceFunctions(VkDevice device);
|
||||
void UnloadVulkanLibrary();
|
||||
void ResetVulkanLibraryFunctionPointers();
|
||||
|
||||
} // namespace Vulkan
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
#include "../hash_combine.h"
|
||||
#include "../types.h"
|
||||
#include "loader.h"
|
||||
#include "shader_compiler.h"
|
||||
#include "vulkan_loader.h"
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
#include "vulkan_loader.h"
|
||||
#include "loader.h"
|
||||
#include <memory>
|
||||
|
||||
namespace Vulkan {
|
||||
|
@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../types.h"
|
||||
#include "vulkan_loader.h"
|
||||
#include "loader.h"
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "../types.h"
|
||||
#include "../window_info.h"
|
||||
#include "texture.h"
|
||||
#include "vulkan_loader.h"
|
||||
#include "loader.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
#include "vulkan_loader.h"
|
||||
#include "loader.h"
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "../string.h"
|
||||
#include "../types.h"
|
||||
#include "vulkan_loader.h"
|
||||
#include "loader.h"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstdarg>
|
||||
|
@ -120,7 +120,7 @@ set(RECOMPILER_SRCS
|
||||
|
||||
target_include_directories(core PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
target_include_directories(core PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
target_link_libraries(core PUBLIC Threads::Threads common zlib vulkan-loader)
|
||||
target_link_libraries(core PUBLIC Threads::Threads common zlib)
|
||||
target_link_libraries(core PRIVATE glad stb xxhash imgui)
|
||||
|
||||
if(WIN32)
|
||||
|
@ -9,7 +9,7 @@
|
||||
<PreprocessorDefinitions Condition="('$(Platform)'=='x64' Or '$(Platform)'=='ARM' Or '$(Platform)'=='ARM64')">WITH_RECOMPILER=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="('$(Platform)'=='x64' Or '$(Platform)'=='ARM64') And ('$(BuildingForUWP)'!='true')">WITH_MMAP_FASTMEM=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xxhash\include;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)dep\rcheevos\include;$(SolutionDir)dep\rapidjson\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xxhash\include;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\rcheevos\include;$(SolutionDir)dep\rapidjson\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories Condition="('$(BuildingForUWP)'!='true' And '$(Platform)'!='ARM64')">$(SolutionDir)dep\rainterface;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
|
||||
<AdditionalIncludeDirectories Condition="'$(Platform)'=='x64'">$(SolutionDir)dep\xbyak\xbyak;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
<ItemDefinitionGroup>
|
||||
<Lib>
|
||||
<AdditionalDependencies>$(RootBuildDir)rcheevos\rcheevos.lib;$(RootBuildDir)imgui\imgui.lib;$(RootBuildDir)stb\stb.lib;$(RootBuildDir)vulkan-loader\vulkan-loader.lib;$(RootBuildDir)xxhash\xxhash.lib;$(RootBuildDir)zlib\zlib.lib;$(RootBuildDir)common\common.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>$(RootBuildDir)rcheevos\rcheevos.lib;$(RootBuildDir)imgui\imgui.lib;$(RootBuildDir)stb\stb.lib;$(RootBuildDir)xxhash\xxhash.lib;$(RootBuildDir)zlib\zlib.lib;$(RootBuildDir)common\common.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies Condition="('$(BuildingForUWP)'!='true' And '$(Platform)'!='ARM64')">$(RootBuildDir)rainterface\rainterface.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies Condition="'$(Platform)'=='ARM64'">$(RootBuildDir)vixl\vixl.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Lib>
|
||||
|
@ -4,7 +4,7 @@ add_executable(duckstation-nogui
|
||||
nogui_host_interface.h
|
||||
)
|
||||
|
||||
target_link_libraries(duckstation-nogui PRIVATE core common imgui glad frontend-common scmversion vulkan-loader)
|
||||
target_link_libraries(duckstation-nogui PRIVATE core common imgui glad frontend-common scmversion)
|
||||
|
||||
if(USE_SDL2)
|
||||
target_sources(duckstation-nogui PRIVATE
|
||||
|
@ -139,7 +139,7 @@ qt5_add_translation(QM_FILES ${TS_FILES})
|
||||
|
||||
add_executable(duckstation-qt ${SRCS} ${QM_FILES})
|
||||
target_include_directories(duckstation-qt PRIVATE "${Qt5Gui_PRIVATE_INCLUDE_DIRS}")
|
||||
target_link_libraries(duckstation-qt PRIVATE frontend-common core common imgui glad minizip scmversion vulkan-loader Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Network)
|
||||
target_link_libraries(duckstation-qt PRIVATE frontend-common core common imgui glad minizip scmversion Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Network)
|
||||
|
||||
if(WIN32)
|
||||
# We want a Windows subsystem application not console.
|
||||
|
@ -41,7 +41,7 @@ add_library(frontend-common
|
||||
vulkan_host_display.h
|
||||
)
|
||||
|
||||
target_link_libraries(frontend-common PUBLIC core common glad vulkan-loader cubeb imgui simpleini tinyxml2 rapidjson scmversion)
|
||||
target_link_libraries(frontend-common PUBLIC core common glad cubeb imgui simpleini tinyxml2 rapidjson scmversion)
|
||||
|
||||
if(WIN32)
|
||||
target_sources(frontend-common PRIVATE
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\vulkan-loader\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>$(RootBuildDir)simpleini\simpleini.lib;$(RootBuildDir)tinyxml2\tinyxml2.lib;$(RootBuildDir)core\core.lib;$(RootBuildDir)scmversion\scmversion.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "vulkan_loader.h"
|
||||
#include "common/vulkan/loader.h"
|
||||
|
||||
// Initialization data, for ImGui_ImplVulkan_Init()
|
||||
// [Please zero-clear before use!]
|
||||
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
#include "common/vulkan/loader.h"
|
||||
#include "common/vulkan/staging_texture.h"
|
||||
#include "common/vulkan/stream_buffer.h"
|
||||
#include "common/vulkan/swap_chain.h"
|
||||
#include "common/window_info.h"
|
||||
#include "core/host_display.h"
|
||||
#include "postprocessing_chain.h"
|
||||
#include "vulkan_loader.h"
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
@ -30,9 +30,9 @@ public:
|
||||
bool HasRenderSurface() const override;
|
||||
|
||||
bool CreateRenderDevice(const WindowInfo& wi, std::string_view adapter_name, bool debug_device,
|
||||
bool threaded_presentation) override;
|
||||
bool threaded_presentation) override;
|
||||
bool InitializeRenderDevice(std::string_view shader_cache_directory, bool debug_device,
|
||||
bool threaded_presentation) override;
|
||||
bool threaded_presentation) override;
|
||||
void DestroyRenderDevice() override;
|
||||
|
||||
bool MakeRenderContextCurrent() override;
|
||||
@ -65,7 +65,7 @@ public:
|
||||
|
||||
bool Render() override;
|
||||
bool RenderScreenshot(u32 width, u32 height, std::vector<u32>* out_pixels, u32* out_stride,
|
||||
HostDisplayPixelFormat* out_format) override;
|
||||
HostDisplayPixelFormat* out_format) override;
|
||||
|
||||
static AdapterAndModeList StaticGetAdapterAndModeList(const WindowInfo* wi);
|
||||
|
||||
|
Reference in New Issue
Block a user