diff --git a/app/src/main/cpp/skyline/gpu.cpp b/app/src/main/cpp/skyline/gpu.cpp index 609dc122..1a25b086 100644 --- a/app/src/main/cpp/skyline/gpu.cpp +++ b/app/src/main/cpp/skyline/gpu.cpp @@ -121,9 +121,19 @@ namespace skyline::gpu { vk::raii::Device GPU::CreateDevice(const vk::raii::PhysicalDevice &physicalDevice, typeof(vk::DeviceQueueCreateInfo::queueCount) &vkQueueFamilyIndex, QuirkManager &quirks) { auto properties{physicalDevice.getProperties()}; - auto features{physicalDevice.getFeatures2()}; - auto deviceExtensions{physicalDevice.enumerateDeviceExtensionProperties()}; + auto deviceFeatures2{physicalDevice.getFeatures2()}; + vk::PhysicalDeviceFeatures2 enabledFeatures2{}; // We only want to enable features we required due to potential overhead from unused features + + #define FEAT_REQ(feature) \ + if (deviceFeatures2.features.feature) \ + enabledFeatures2.features.feature = true; \ + else \ + throw exception("Vulkan device doesn't support required feature: " #feature) + + #undef FEAT_REQ + + auto deviceExtensions{physicalDevice.enumerateDeviceExtensionProperties()}; std::vector> enabledExtensions{ { // Required Extensions @@ -138,11 +148,11 @@ namespace skyline::gpu { throw exception("Cannot find Vulkan device extension: \"{}\"", requiredExtension.data()); } - quirks = QuirkManager(properties, features, deviceExtensions, enabledExtensions); + quirks = QuirkManager(properties, deviceFeatures2, enabledFeatures2, deviceExtensions, enabledExtensions); - std::vector pEnabledExtensions; + std::vector pEnabledExtensions; pEnabledExtensions.reserve(enabledExtensions.size()); - for (auto& extension : enabledExtensions) + for (auto &extension : enabledExtensions) pEnabledExtensions.push_back(extension.data()); auto queueFamilies{physicalDevice.getQueueFamilyProperties()}; @@ -181,7 +191,7 @@ namespace skyline::gpu { } return vk::raii::Device(physicalDevice, vk::DeviceCreateInfo{ - .pNext = &features, + .pNext = &enabledFeatures2, .queueCreateInfoCount = 1, .pQueueCreateInfos = &queue, .enabledExtensionCount = static_cast(pEnabledExtensions.size()), diff --git a/app/src/main/cpp/skyline/gpu/quirk_manager.cpp b/app/src/main/cpp/skyline/gpu/quirk_manager.cpp index 94e1010e..3c34b7d8 100644 --- a/app/src/main/cpp/skyline/gpu/quirk_manager.cpp +++ b/app/src/main/cpp/skyline/gpu/quirk_manager.cpp @@ -4,7 +4,7 @@ #include "quirk_manager.h" namespace skyline { - QuirkManager::QuirkManager(const vk::PhysicalDeviceProperties &properties, vk::PhysicalDeviceFeatures2 &features2, const std::vector &deviceExtensions, std::vector> &enabledExtensions) { + QuirkManager::QuirkManager(const vk::PhysicalDeviceProperties &properties, const vk::PhysicalDeviceFeatures2 &deviceFeatures2, vk::PhysicalDeviceFeatures2 &enabledFeatures2, const std::vector &deviceExtensions, std::vector> &enabledExtensions) { for (auto &extension : deviceExtensions) { #define EXT_SET(name, property) \ case util::Hash(name): \ @@ -31,13 +31,10 @@ namespace skyline { #undef EXT_SET_V } - auto deviceFeatures2{features2}; - features2 = vk::PhysicalDeviceFeatures2{}; // We only want to enable features we required due to potential overhead from unused features - - #define FEAT_SET(feature, property) \ - if (deviceFeatures2.features.feature) { \ - property = true; \ - features2.features.feature = true; \ + #define FEAT_SET(feature, property) \ + if (deviceFeatures2.features.feature) { \ + property = true; \ + enabledFeatures2.features.feature = true; \ } FEAT_SET(logicOp, supportsLogicOp) diff --git a/app/src/main/cpp/skyline/gpu/quirk_manager.h b/app/src/main/cpp/skyline/gpu/quirk_manager.h index 3b1047fb..cf2cc86b 100644 --- a/app/src/main/cpp/skyline/gpu/quirk_manager.h +++ b/app/src/main/cpp/skyline/gpu/quirk_manager.h @@ -17,7 +17,7 @@ namespace skyline { QuirkManager() = default; - QuirkManager(const vk::PhysicalDeviceProperties &properties, vk::PhysicalDeviceFeatures2 &features, const std::vector &deviceExtensions, std::vector> &enabledExtensions); + QuirkManager(const vk::PhysicalDeviceProperties &properties, const vk::PhysicalDeviceFeatures2 &deviceFeatures2, vk::PhysicalDeviceFeatures2 &enabledFeatures2, const std::vector &deviceExtensions, std::vector> &enabledExtensions); /** * @return A summary of all the GPU quirks as a human-readable string