mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-04-29 13:55:41 -04:00
Vulkan/Context: Support specifying GPU to use
This commit is contained in:
parent
4a04800132
commit
1b5f8db2fc
@ -271,7 +271,7 @@ Context::GPUNameList Context::EnumerateGPUNames(VkInstance instance)
|
|||||||
return gpu_names;
|
return gpu_names;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Context::Create(u32 gpu_index, const WindowInfo* wi, std::unique_ptr<SwapChain>* out_swap_chain,
|
bool Context::Create(std::string_view gpu_name, const WindowInfo* wi, std::unique_ptr<SwapChain>* out_swap_chain,
|
||||||
bool enable_debug_reports, bool enable_validation_layer)
|
bool enable_debug_reports, bool enable_validation_layer)
|
||||||
{
|
{
|
||||||
AssertMsg(!g_vulkan_context, "Has no current context");
|
AssertMsg(!g_vulkan_context, "Has no current context");
|
||||||
@ -306,15 +306,28 @@ bool Context::Create(u32 gpu_index, const WindowInfo* wi, std::unique_ptr<SwapCh
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 gpu_index = 0;
|
||||||
GPUNameList gpu_names = EnumerateGPUNames(instance);
|
GPUNameList gpu_names = EnumerateGPUNames(instance);
|
||||||
for (u32 i = 0; i < gpu_names.size(); i++)
|
if (!gpu_name.empty())
|
||||||
Log_InfoPrintf("GPU %u: %s", static_cast<u32>(i), gpu_names[i].c_str());
|
|
||||||
|
|
||||||
if (gpu_index >= gpus.size())
|
|
||||||
{
|
{
|
||||||
Log_WarningPrintf("GPU index (%u) out of range (%u), using first", gpu_index, static_cast<u32>(gpus.size()));
|
for (; gpu_index < static_cast<u32>(gpu_names.size()); gpu_index++)
|
||||||
|
{
|
||||||
|
Log_InfoPrintf("GPU %u: %s", static_cast<u32>(gpu_index), gpu_names[gpu_index].c_str());
|
||||||
|
if (gpu_names[gpu_index] == gpu_name)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gpu_index == static_cast<u32>(gpu_names.size()))
|
||||||
|
{
|
||||||
|
Log_WarningPrintf("Requested GPU '%s' not found, using first (%s)", std::string(gpu_name).c_str(),
|
||||||
|
gpu_names[0].c_str());
|
||||||
gpu_index = 0;
|
gpu_index = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log_InfoPrintf("No GPU requested, using first (%s)", gpu_names[0].c_str());
|
||||||
|
}
|
||||||
|
|
||||||
VkSurfaceKHR surface = VK_NULL_HANDLE;
|
VkSurfaceKHR surface = VK_NULL_HANDLE;
|
||||||
if (enable_surface && (surface = SwapChain::CreateVulkanSurface(instance, *wi)) == VK_NULL_HANDLE)
|
if (enable_surface && (surface = SwapChain::CreateVulkanSurface(instance, *wi)) == VK_NULL_HANDLE)
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
static GPUNameList EnumerateGPUNames(VkInstance instance);
|
static GPUNameList EnumerateGPUNames(VkInstance instance);
|
||||||
|
|
||||||
// Creates a new context and sets it up as global.
|
// Creates a new context and sets it up as global.
|
||||||
static bool Create(u32 gpu_index, const WindowInfo* wi, std::unique_ptr<SwapChain>* out_swap_chain,
|
static bool Create(std::string_view gpu_name, const WindowInfo* wi, std::unique_ptr<SwapChain>* out_swap_chain,
|
||||||
bool enable_debug_reports, bool enable_validation_layer);
|
bool enable_debug_reports, bool enable_validation_layer);
|
||||||
|
|
||||||
// Destroys context.
|
// Destroys context.
|
||||||
|
@ -194,7 +194,7 @@ void VulkanHostDisplay::SetVSync(bool enabled)
|
|||||||
|
|
||||||
bool VulkanHostDisplay::CreateContextAndSwapChain(const WindowInfo& wi, bool debug_device)
|
bool VulkanHostDisplay::CreateContextAndSwapChain(const WindowInfo& wi, bool debug_device)
|
||||||
{
|
{
|
||||||
if (!Vulkan::Context::Create(0u, &wi, &m_swap_chain, debug_device, false))
|
if (!Vulkan::Context::Create({}, &wi, &m_swap_chain, debug_device, false))
|
||||||
{
|
{
|
||||||
Log_ErrorPrintf("Failed to create Vulkan context");
|
Log_ErrorPrintf("Failed to create Vulkan context");
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user