Set to force the use of dedicated GPU #324
|
@ -1,4 +1,4 @@
|
||||||
Start Maximized: true
|
Start Maximized: true
|
||||||
Working Scene ID: 97402985
|
Working Scene ID: 97402985
|
||||||
Window Size: {x: 1920, y: 1080}
|
Window Size: {x: 1920, y: 1013}
|
||||||
Style: 0
|
Style: 0
|
|
@ -10,6 +10,7 @@ namespace SHADE
|
||||||
enum class SH_PHYSICAL_DEVICE_TYPE
|
enum class SH_PHYSICAL_DEVICE_TYPE
|
||||||
{
|
{
|
||||||
BEST,
|
BEST,
|
||||||
|
DEDICATED,
|
||||||
};
|
};
|
||||||
|
|
||||||
class SHVkPhysicalDevice
|
class SHVkPhysicalDevice
|
||||||
|
|
|
@ -160,9 +160,31 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return bestDevice;
|
return bestDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vk::PhysicalDevice SHVkPhysicalDeviceLibrary::GetFirstDedicatedDevice(uint32_t apiVersion /*= SHVulkanAPIVersion::V_1_2*/)
|
||||||
|
{
|
||||||
|
if (!queried || physicalDevices.empty())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
for (auto const& device : physicalDevices)
|
||||||
|
{
|
||||||
|
// Check for API version and device type. Ignore if queried device doesn't support version passed in
|
||||||
|
if (device.getProperties().apiVersion < static_cast<uint32_t>(apiVersion))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//VkDeviceSize biggestDeviceHeapSize = device.getMemoryProperties().;
|
||||||
|
if (device.getProperties().deviceType == vk::PhysicalDeviceType::eDiscreteGpu)
|
||||||
|
return device;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
|
|
||||||
|
@ -181,10 +203,10 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
SHLOG_TRACE("Successfully queried Physical Devices:");
|
SHLOG_INFO("Successfully queried Physical Devices:");
|
||||||
for (auto const& device : physicalDevices)
|
for (auto const& device : physicalDevices)
|
||||||
{
|
{
|
||||||
SHLOG_TRACE(std::string_view (std::string("\t-") + GetDeviceTypeName(device.getProperties().deviceType) + device.getProperties().deviceName.operator std::string()));
|
SHLOG_INFO(std::string_view (std::string("\t-") + GetDeviceTypeName(device.getProperties().deviceType) + device.getProperties().deviceName.operator std::string()));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace SHADE
|
||||||
static void QueryPhysicalDevices(bool printInfo) noexcept;
|
static void QueryPhysicalDevices(bool printInfo) noexcept;
|
||||||
//static std::vector<std::shared_ptr<SHPhysicalDevice>> GetDevicesByType(VkPhysicalDeviceType gpuType, SHVulkanAPIVersion apiVersion = SHVulkanAPIVersion::V_1_2) noexcept;
|
//static std::vector<std::shared_ptr<SHPhysicalDevice>> GetDevicesByType(VkPhysicalDeviceType gpuType, SHVulkanAPIVersion apiVersion = SHVulkanAPIVersion::V_1_2) noexcept;
|
||||||
static vk::PhysicalDevice GetBestDevice(uint32_t apiVersion = VK_API_VERSION_1_3);
|
static vk::PhysicalDevice GetBestDevice(uint32_t apiVersion = VK_API_VERSION_1_3);
|
||||||
|
static vk::PhysicalDevice GetFirstDedicatedDevice(uint32_t apiVersion = VK_API_VERSION_1_3);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,6 +213,8 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
case SH_PHYSICAL_DEVICE_TYPE::BEST:
|
case SH_PHYSICAL_DEVICE_TYPE::BEST:
|
||||||
return resourceManager.Create<SHVkPhysicalDevice>(SHVkPhysicalDeviceLibrary::GetBestDevice());
|
return resourceManager.Create<SHVkPhysicalDevice>(SHVkPhysicalDeviceLibrary::GetBestDevice());
|
||||||
|
case SH_PHYSICAL_DEVICE_TYPE::DEDICATED:
|
||||||
|
return resourceManager.Create<SHVkPhysicalDevice>(SHVkPhysicalDeviceLibrary::GetFirstDedicatedDevice());
|
||||||
default:
|
default:
|
||||||
return resourceManager.Create<SHVkPhysicalDevice>(SHVkPhysicalDeviceLibrary::GetBestDevice());
|
return resourceManager.Create<SHVkPhysicalDevice>(SHVkPhysicalDeviceLibrary::GetBestDevice());
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace SHADE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get Physical Device
|
// Get Physical Device
|
||||||
physicalDevice = SHVkInstance::CreatePhysicalDevice(SH_PHYSICAL_DEVICE_TYPE::BEST);
|
physicalDevice = SHVkInstance::CreatePhysicalDevice(SH_PHYSICAL_DEVICE_TYPE::DEDICATED);
|
||||||
if (!physicalDevice->GetVkPhysicalDevice())
|
if (!physicalDevice->GetVkPhysicalDevice())
|
||||||
{
|
{
|
||||||
throw std::runtime_error("[Graphics System] No supported Vulkan 1.3 compatible GPU was detected!");
|
throw std::runtime_error("[Graphics System] No supported Vulkan 1.3 compatible GPU was detected!");
|
||||||
|
|
Loading…
Reference in New Issue