mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-23 03:02:53 +01:00
vk: Skip feature check if extension is not supported
This commit is contained in:
parent
06a85f00d1
commit
7ad1646c2c
@ -516,6 +516,51 @@ namespace vk
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class supported_extensions
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::vector<VkExtensionProperties> m_vk_exts;
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum enumeration_class
|
||||||
|
{
|
||||||
|
instance = 0,
|
||||||
|
device = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
supported_extensions(enumeration_class _class, const char* layer_name = nullptr, physical_device* pgpu = nullptr)
|
||||||
|
{
|
||||||
|
uint32_t count;
|
||||||
|
if (_class == enumeration_class::instance)
|
||||||
|
{
|
||||||
|
if (vkEnumerateInstanceExtensionProperties(layer_name, &count, nullptr) != VK_SUCCESS)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
verify(HERE), pgpu;
|
||||||
|
if (vkEnumerateDeviceExtensionProperties(*pgpu, layer_name, &count, nullptr) != VK_SUCCESS)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_vk_exts.resize(count);
|
||||||
|
if (_class == enumeration_class::instance)
|
||||||
|
{
|
||||||
|
vkEnumerateInstanceExtensionProperties(layer_name, &count, m_vk_exts.data());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vkEnumerateDeviceExtensionProperties(*pgpu, layer_name, &count, m_vk_exts.data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_supported(const char *ext)
|
||||||
|
{
|
||||||
|
return std::any_of(m_vk_exts.cbegin(), m_vk_exts.cend(),
|
||||||
|
[&](const VkExtensionProperties& p) { return std::strcmp(p.extensionName, ext) == 0; });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class render_device
|
class render_device
|
||||||
{
|
{
|
||||||
physical_device *pgpu = nullptr;
|
physical_device *pgpu = nullptr;
|
||||||
@ -533,12 +578,20 @@ namespace vk
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VkPhysicalDeviceFloat16Int8FeaturesKHR shader_support_info{};
|
supported_extensions extension_support(supported_extensions::device, nullptr, pgpu);
|
||||||
shader_support_info.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT16_INT8_FEATURES_KHR;
|
|
||||||
|
|
||||||
VkPhysicalDeviceFeatures2 features2;
|
VkPhysicalDeviceFeatures2 features2;
|
||||||
features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
||||||
features2.pNext = &shader_support_info;
|
features2.pNext = nullptr;
|
||||||
|
|
||||||
|
VkPhysicalDeviceFloat16Int8FeaturesKHR shader_support_info{};
|
||||||
|
|
||||||
|
if (extension_support.is_supported("VK_KHR_shader_float16_int8"))
|
||||||
|
{
|
||||||
|
shader_support_info.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT16_INT8_FEATURES_KHR;
|
||||||
|
features2.pNext = &shader_support_info;
|
||||||
|
}
|
||||||
|
|
||||||
vkGetPhysicalDeviceFeatures2(*pgpu, &features2);
|
vkGetPhysicalDeviceFeatures2(*pgpu, &features2);
|
||||||
|
|
||||||
m_shader_types_support.allow_float16 = !!shader_support_info.shaderFloat16;
|
m_shader_types_support.allow_float16 = !!shader_support_info.shaderFloat16;
|
||||||
@ -566,33 +619,38 @@ namespace vk
|
|||||||
queue.queueCount = 1;
|
queue.queueCount = 1;
|
||||||
queue.pQueuePriorities = queue_priorities;
|
queue.pQueuePriorities = queue_priorities;
|
||||||
|
|
||||||
//Set up instance information
|
// Set up instance information
|
||||||
const char *requested_extensions[] =
|
std::vector<const char *>requested_extensions =
|
||||||
{
|
{
|
||||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME
|
VK_KHR_SWAPCHAIN_EXTENSION_NAME
|
||||||
};
|
};
|
||||||
|
|
||||||
//Enable hardware features manually
|
// Enable hardware features manually
|
||||||
//Currently we require:
|
// Currently we require:
|
||||||
//1. Anisotropic sampling
|
// 1. Anisotropic sampling
|
||||||
//2. DXT support
|
// 2. DXT support
|
||||||
//3. Indexable storage buffers
|
// 3. Indexable storage buffers
|
||||||
VkPhysicalDeviceFeatures available_features;
|
VkPhysicalDeviceFeatures available_features;
|
||||||
get_physical_device_features(available_features);
|
get_physical_device_features(available_features);
|
||||||
|
|
||||||
|
if (m_shader_types_support.allow_float16)
|
||||||
|
{
|
||||||
|
requested_extensions.push_back("VK_KHR_shader_float16_int8");
|
||||||
|
}
|
||||||
|
|
||||||
available_features.samplerAnisotropy = VK_TRUE;
|
available_features.samplerAnisotropy = VK_TRUE;
|
||||||
available_features.textureCompressionBC = VK_TRUE;
|
available_features.textureCompressionBC = VK_TRUE;
|
||||||
available_features.shaderStorageBufferArrayDynamicIndexing = VK_TRUE;
|
available_features.shaderStorageBufferArrayDynamicIndexing = VK_TRUE;
|
||||||
|
|
||||||
VkDeviceCreateInfo device = {};
|
VkDeviceCreateInfo device = {};
|
||||||
device.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
|
device.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
|
||||||
device.pNext = NULL;
|
device.pNext = nullptr;
|
||||||
device.queueCreateInfoCount = 1;
|
device.queueCreateInfoCount = 1;
|
||||||
device.pQueueCreateInfos = &queue;
|
device.pQueueCreateInfos = &queue;
|
||||||
device.enabledLayerCount = 0;
|
device.enabledLayerCount = 0;
|
||||||
device.ppEnabledLayerNames = nullptr; // Deprecated
|
device.ppEnabledLayerNames = nullptr; // Deprecated
|
||||||
device.enabledExtensionCount = 1;
|
device.enabledExtensionCount = (u32)requested_extensions.size();
|
||||||
device.ppEnabledExtensionNames = requested_extensions;
|
device.ppEnabledExtensionNames = requested_extensions.data();
|
||||||
device.pEnabledFeatures = &available_features;
|
device.pEnabledFeatures = &available_features;
|
||||||
|
|
||||||
VkPhysicalDeviceFloat16Int8FeaturesKHR shader_support_info{};
|
VkPhysicalDeviceFloat16Int8FeaturesKHR shader_support_info{};
|
||||||
@ -2114,29 +2172,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class supported_extensions
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::vector<VkExtensionProperties> m_vk_exts;
|
|
||||||
|
|
||||||
public:
|
|
||||||
supported_extensions()
|
|
||||||
{
|
|
||||||
uint32_t count;
|
|
||||||
if (vkEnumerateInstanceExtensionProperties(nullptr, &count, nullptr) != VK_SUCCESS)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_vk_exts.resize(count);
|
|
||||||
vkEnumerateInstanceExtensionProperties(nullptr, &count, m_vk_exts.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_supported(const char *ext)
|
|
||||||
{
|
|
||||||
return std::any_of(m_vk_exts.cbegin(), m_vk_exts.cend(),
|
|
||||||
[&](const VkExtensionProperties& p) { return std::strcmp(p.extensionName, ext) == 0; });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class context
|
class context
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -2224,7 +2259,7 @@ public:
|
|||||||
|
|
||||||
if (!fast)
|
if (!fast)
|
||||||
{
|
{
|
||||||
supported_extensions support;
|
supported_extensions support(supported_extensions::instance);
|
||||||
|
|
||||||
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
||||||
if (support.is_supported(VK_EXT_DEBUG_REPORT_EXTENSION_NAME))
|
if (support.is_supported(VK_EXT_DEBUG_REPORT_EXTENSION_NAME))
|
||||||
|
Loading…
Reference in New Issue
Block a user