mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-20 19:54:19 +01:00
[dxvk] Move getInstanceExtensions platform logic to wsi.
This ensures that all of the WSI backend logic is in one place rather than two.
This commit is contained in:
parent
4055a92856
commit
529129c332
@ -1,17 +1,21 @@
|
||||
#include "../dxvk_platform_exts.h"
|
||||
#include "dxvk_platform_exts.h"
|
||||
#include "../wsi/wsi_platform.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
DxvkPlatformExts DxvkPlatformExts::s_instance;
|
||||
|
||||
std::string_view DxvkPlatformExts::getName() {
|
||||
return "Win32 WSI";
|
||||
return "Platform WSI";
|
||||
}
|
||||
|
||||
|
||||
DxvkNameSet DxvkPlatformExts::getInstanceExtensions() {
|
||||
std::vector<const char *> extensionNames = wsi::getInstanceExtensions();
|
||||
|
||||
DxvkNameSet names;
|
||||
names.add(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
|
||||
for (const char* name : extensionNames)
|
||||
names.add(name);
|
||||
|
||||
return names;
|
||||
}
|
||||
@ -33,4 +37,4 @@ namespace dxvk {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -89,6 +89,7 @@ dxvk_src = [
|
||||
'dxvk_options.cpp',
|
||||
'dxvk_pipelayout.cpp',
|
||||
'dxvk_pipemanager.cpp',
|
||||
'dxvk_platform_exts.cpp',
|
||||
'dxvk_presenter.cpp',
|
||||
'dxvk_queue.cpp',
|
||||
'dxvk_resource.cpp',
|
||||
@ -117,20 +118,6 @@ if platform == 'windows'
|
||||
]
|
||||
endif
|
||||
|
||||
if dxvk_wsi == 'win32'
|
||||
dxvk_src += [
|
||||
'platform/dxvk_win32_exts.cpp'
|
||||
]
|
||||
elif dxvk_wsi == 'sdl2'
|
||||
dxvk_src += [
|
||||
'platform/dxvk_sdl2_exts.cpp'
|
||||
]
|
||||
elif dxvk_wsi == 'glfw'
|
||||
dxvk_src += [
|
||||
'platform/dxvk_glfw_exts.cpp'
|
||||
]
|
||||
endif
|
||||
|
||||
dxvk_extra_deps = [ dependency('threads') ]
|
||||
if platform == 'linux'
|
||||
dxvk_extra_deps += [ cpp.find_library('dl', required: false) ]
|
||||
|
@ -1,49 +0,0 @@
|
||||
#include "../dxvk_platform_exts.h"
|
||||
|
||||
#include "../../vulkan/vulkan_loader.h"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
DxvkPlatformExts DxvkPlatformExts::s_instance;
|
||||
|
||||
std::string_view DxvkPlatformExts::getName() {
|
||||
return "GLFW WSI";
|
||||
}
|
||||
|
||||
DxvkNameSet DxvkPlatformExts::getInstanceExtensions() {
|
||||
if (!glfwVulkanSupported())
|
||||
throw DxvkError(str::format("GLFW WSI: Vulkan is not supported in any capacity!"));
|
||||
|
||||
uint32_t extensionCount = 0;
|
||||
const char** extensionArray = glfwGetRequiredInstanceExtensions(&extensionCount);
|
||||
|
||||
if (extensionCount == 0)
|
||||
throw DxvkError(str::format("GLFW WSI: Failed to get required instance extensions"));
|
||||
|
||||
DxvkNameSet names;
|
||||
for (uint32_t i = 0; i < extensionCount; ++i) {
|
||||
names.add(extensionArray[i]);
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
DxvkNameSet DxvkPlatformExts::getDeviceExtensions(
|
||||
uint32_t adapterId) {
|
||||
return DxvkNameSet();
|
||||
}
|
||||
|
||||
|
||||
void DxvkPlatformExts::initInstanceExtensions() {
|
||||
//Nothing needs to be done here on GLFW
|
||||
}
|
||||
|
||||
|
||||
void DxvkPlatformExts::initDeviceExtensions(
|
||||
const DxvkInstance* instance) {
|
||||
//Nothing needs to be done here on GLFW
|
||||
}
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
#include "../dxvk_platform_exts.h"
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_vulkan.h>
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
DxvkPlatformExts DxvkPlatformExts::s_instance;
|
||||
|
||||
std::string_view DxvkPlatformExts::getName() {
|
||||
return "SDL2 WSI";
|
||||
}
|
||||
|
||||
|
||||
DxvkNameSet DxvkPlatformExts::getInstanceExtensions() {
|
||||
SDL_Vulkan_LoadLibrary(nullptr);
|
||||
|
||||
uint32_t extensionCount = 0;
|
||||
if (!SDL_Vulkan_GetInstanceExtensions(nullptr, &extensionCount, nullptr))
|
||||
throw DxvkError(str::format("SDL2 WSI: Failed to get instance extension count. ", SDL_GetError()));
|
||||
|
||||
auto extensionNames = std::vector<const char *>(extensionCount);
|
||||
if (!SDL_Vulkan_GetInstanceExtensions(nullptr, &extensionCount, extensionNames.data()))
|
||||
throw DxvkError(str::format("SDL2 WSI: Failed to get instance extensions. ", SDL_GetError()));
|
||||
|
||||
DxvkNameSet names;
|
||||
for (const char* name : extensionNames)
|
||||
names.add(name);
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
DxvkNameSet DxvkPlatformExts::getDeviceExtensions(
|
||||
uint32_t adapterId) {
|
||||
return DxvkNameSet();
|
||||
}
|
||||
|
||||
|
||||
void DxvkPlatformExts::initInstanceExtensions() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DxvkPlatformExts::initDeviceExtensions(
|
||||
const DxvkInstance* instance) {
|
||||
|
||||
}
|
||||
|
||||
}
|
25
src/wsi/glfw/wsi_platform_glfw.cpp
Normal file
25
src/wsi/glfw/wsi_platform_glfw.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "wsi_platform_glfw.h"
|
||||
#include "../../util/util_error.h"
|
||||
#include "../../util/util_string.h"
|
||||
|
||||
namespace dxvk::wsi {
|
||||
|
||||
std::vector<const char *> getInstanceExtensions() {
|
||||
if (!glfwVulkanSupported())
|
||||
throw DxvkError(str::format("GLFW WSI: Vulkan is not supported in any capacity!"));
|
||||
|
||||
uint32_t extensionCount = 0;
|
||||
const char** extensionArray = glfwGetRequiredInstanceExtensions(&extensionCount);
|
||||
|
||||
if (extensionCount == 0)
|
||||
throw DxvkError(str::format("GLFW WSI: Failed to get required instance extensions"));
|
||||
|
||||
std::vector<const char *> names(extensionCount);
|
||||
for (uint32_t i = 0; i < extensionCount; ++i) {
|
||||
names.push_back(extensionArray[i]);
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
}
|
@ -5,16 +5,19 @@ wsi_common_src = [
|
||||
|
||||
wsi_win32_src = [
|
||||
'win32/wsi_monitor_win32.cpp',
|
||||
'win32/wsi_platform_win32.cpp',
|
||||
'win32/wsi_window_win32.cpp',
|
||||
]
|
||||
|
||||
wsi_sdl2_src = [
|
||||
'sdl2/wsi_monitor_sdl2.cpp',
|
||||
'sdl2/wsi_platform_sdl2.cpp',
|
||||
'sdl2/wsi_window_sdl2.cpp',
|
||||
]
|
||||
|
||||
wsi_glfw_src = [
|
||||
'glfw/wsi_monitor_glfw.cpp',
|
||||
'glfw/wsi_platform_glfw.cpp',
|
||||
'glfw/wsi_window_glfw.cpp',
|
||||
]
|
||||
|
||||
|
23
src/wsi/sdl2/wsi_platform_sdl2.cpp
Normal file
23
src/wsi/sdl2/wsi_platform_sdl2.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include "wsi_platform_sdl2.h"
|
||||
#include "../../util/util_error.h"
|
||||
#include "../../util/util_string.h"
|
||||
|
||||
#include <SDL2/SDL_vulkan.h>
|
||||
|
||||
namespace dxvk::wsi {
|
||||
|
||||
std::vector<const char *> getInstanceExtensions() {
|
||||
SDL_Vulkan_LoadLibrary(nullptr);
|
||||
|
||||
uint32_t extensionCount = 0;
|
||||
if (!SDL_Vulkan_GetInstanceExtensions(nullptr, &extensionCount, nullptr))
|
||||
throw DxvkError(str::format("SDL2 WSI: Failed to get instance extension count. ", SDL_GetError()));
|
||||
|
||||
auto extensionNames = std::vector<const char *>(extensionCount);
|
||||
if (!SDL_Vulkan_GetInstanceExtensions(nullptr, &extensionCount, extensionNames.data()))
|
||||
throw DxvkError(str::format("SDL2 WSI: Failed to get instance extensions. ", SDL_GetError()));
|
||||
|
||||
return extensionNames;
|
||||
}
|
||||
|
||||
}
|
9
src/wsi/win32/wsi_platform_win32.cpp
Normal file
9
src/wsi/win32/wsi_platform_win32.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "wsi_platform_win32.h"
|
||||
|
||||
namespace dxvk::wsi {
|
||||
|
||||
std::vector<const char *> getInstanceExtensions() {
|
||||
return { VK_KHR_WIN32_SURFACE_EXTENSION_NAME };
|
||||
}
|
||||
|
||||
}
|
@ -8,9 +8,12 @@
|
||||
#include "glfw/wsi_platform_glfw.h"
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace dxvk::wsi {
|
||||
|
||||
void init();
|
||||
void quit();
|
||||
std::vector<const char *> getInstanceExtensions();
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user