mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-11-29 19:24:10 +01:00
[dxvk] Skip CPU adapters if GPUs are present
Because some games try (and fail) to run on Lavapipe despite it already being the lowest priority device in the list.
This commit is contained in:
parent
c51080068e
commit
94674ac45e
@ -2,7 +2,8 @@
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
DxvkDeviceFilter::DxvkDeviceFilter() {
|
||||
DxvkDeviceFilter::DxvkDeviceFilter(DxvkDeviceFilterFlags flags)
|
||||
: m_flags(flags) {
|
||||
m_matchDeviceName = env::getEnvVar("DXVK_FILTER_DEVICE_NAME");
|
||||
|
||||
if (m_matchDeviceName.size() != 0)
|
||||
@ -16,11 +17,23 @@ namespace dxvk {
|
||||
|
||||
|
||||
bool DxvkDeviceFilter::testAdapter(const VkPhysicalDeviceProperties& properties) const {
|
||||
if (properties.apiVersion < VK_MAKE_VERSION(1, 1, 0)) {
|
||||
Logger::warn(str::format("Skipping Vulkan 1.0 adapter: ", properties.deviceName));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_flags.test(DxvkDeviceFilterFlag::MatchDeviceName)) {
|
||||
if (std::string(properties.deviceName).find(m_matchDeviceName) == std::string::npos)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_flags.test(DxvkDeviceFilterFlag::SkipCpuDevices)) {
|
||||
if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU) {
|
||||
Logger::warn(str::format("Skipping CPU adapter: ", properties.deviceName));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ namespace dxvk {
|
||||
*/
|
||||
enum class DxvkDeviceFilterFlag {
|
||||
MatchDeviceName = 0,
|
||||
SkipCpuDevices = 1,
|
||||
};
|
||||
|
||||
using DxvkDeviceFilterFlags = Flags<DxvkDeviceFilterFlag>;
|
||||
@ -30,7 +31,7 @@ namespace dxvk {
|
||||
|
||||
public:
|
||||
|
||||
DxvkDeviceFilter();
|
||||
DxvkDeviceFilter(DxvkDeviceFilterFlags flags);
|
||||
~DxvkDeviceFilter();
|
||||
|
||||
/**
|
||||
|
@ -154,8 +154,6 @@ namespace dxvk {
|
||||
|
||||
|
||||
std::vector<Rc<DxvkAdapter>> DxvkInstance::queryAdapters() {
|
||||
DxvkDeviceFilter filter;
|
||||
|
||||
uint32_t numAdapters = 0;
|
||||
if (m_vki->vkEnumeratePhysicalDevices(m_vki->instance(), &numAdapters, nullptr) != VK_SUCCESS)
|
||||
throw DxvkError("DxvkInstance::enumAdapters: Failed to enumerate adapters");
|
||||
@ -163,15 +161,22 @@ namespace dxvk {
|
||||
std::vector<VkPhysicalDevice> adapters(numAdapters);
|
||||
if (m_vki->vkEnumeratePhysicalDevices(m_vki->instance(), &numAdapters, adapters.data()) != VK_SUCCESS)
|
||||
throw DxvkError("DxvkInstance::enumAdapters: Failed to enumerate adapters");
|
||||
|
||||
std::vector<Rc<DxvkAdapter>> result;
|
||||
for (uint32_t i = 0; i < numAdapters; i++) {
|
||||
VkPhysicalDeviceProperties deviceProperties;
|
||||
m_vki->vkGetPhysicalDeviceProperties(adapters[i], &deviceProperties);
|
||||
|
||||
if (deviceProperties.apiVersion < VK_MAKE_VERSION(1, 1, 0))
|
||||
Logger::warn(str::format("Skipping Vulkan 1.0 adapter: ", deviceProperties.deviceName));
|
||||
else if (filter.testAdapter(deviceProperties))
|
||||
std::vector<VkPhysicalDeviceProperties> deviceProperties(numAdapters);
|
||||
DxvkDeviceFilterFlags filterFlags = 0;
|
||||
|
||||
for (uint32_t i = 0; i < numAdapters; i++) {
|
||||
m_vki->vkGetPhysicalDeviceProperties(adapters[i], &deviceProperties[i]);
|
||||
|
||||
if (deviceProperties[i].deviceType != VK_PHYSICAL_DEVICE_TYPE_CPU)
|
||||
filterFlags.set(DxvkDeviceFilterFlag::SkipCpuDevices);
|
||||
}
|
||||
|
||||
DxvkDeviceFilter filter(filterFlags);
|
||||
std::vector<Rc<DxvkAdapter>> result;
|
||||
|
||||
for (uint32_t i = 0; i < numAdapters; i++) {
|
||||
if (filter.testAdapter(deviceProperties[i]))
|
||||
result.push_back(new DxvkAdapter(m_vki, adapters[i]));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user