Vulkan: Fix device selection in the SDL path

This commit is contained in:
Henrik Rydgård committed 2020-06-27 10:12:58 +02:00
1 parent 3b980eb442
commit f6cc10f532
4 files changed
+14 -4

No files matched your search

+2 -1
View File
@@ -619,7 +619,8 @@ bool VulkanContext::EnableDeviceExtension(const char *extension) {
VkResult VulkanContext::CreateDevice() {
if (!init_error_.empty() || physical_device_ < 0) {
ELOG("Vulkan init failed: %s", init_error_.c_str());
// Forgot to call ChooseDevice?
ELOG("Vulkan init of physical device %d failed: %s", physical_device_, init_error_.c_str());
return VK_ERROR_INITIALIZATION_FAILED;
}
+1
View File
@@ -413,6 +413,7 @@ bool VulkanMayBeAvailable() {
case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU:
case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU:
case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU:
ILOG("VulkanMayBeAvailable: Found usable device: '%s'", props.deviceName);
anyGood = true;
break;
default:
+1 -1
View File
@@ -793,7 +793,7 @@ int main(int argc, char *argv[]) {
g_Config.bFullScreen = fullscreen;
// Hide/Show cursor correctly toggling fullscreen
if (lastUIState == UISTATE_INGAME && fullscreen && !g_Config.bShowTouchControls) {
if (lastUIState == UISTATE_INGAME && fullscreen && !g_Config.bShowTouchControls && !g_Config.bShowDeveloperMenu) {
SDL_ShowCursor(SDL_DISABLE);
} else if (lastUIState != UISTATE_INGAME || !fullscreen) {
SDL_ShowCursor(SDL_ENABLE);
+10 -2
View File
@@ -56,7 +56,15 @@ bool SDLVulkanGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode,
vulkan_ = nullptr;
return false;
}
vulkan_->ChooseDevice(vulkan_->GetBestPhysicalDevice());
int deviceNum = vulkan_->GetPhysicalDeviceByName(g_Config.sVulkanDevice);
if (deviceNum < 0) {
deviceNum = vulkan_->GetBestPhysicalDevice();
if (!g_Config.sVulkanDevice.empty())
g_Config.sVulkanDevice = vulkan_->GetPhysicalDeviceProperties(deviceNum).properties.deviceName;
}
vulkan_->ChooseDevice(deviceNum);
if (vulkan_->CreateDevice() != VK_SUCCESS) {
*error_message = vulkan_->InitError();
delete vulkan_;
@@ -65,7 +73,7 @@ bool SDLVulkanGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode,
}
SDL_SysWMinfo sys_info{};
SDL_VERSION(&sys_info.version); //Set SDL version
SDL_VERSION(&sys_info.version); // Set SDL version
if (!SDL_GetWindowWMInfo(window, &sys_info)) {
fprintf(stderr, "Error getting SDL window wm info: %s\n", SDL_GetError());
exit(1);