|
|
|
@ -38,6 +38,9 @@ constexpr std::array Depth16UnormS8_UINT{
|
|
|
|
|
|
|
|
|
|
constexpr std::array REQUIRED_EXTENSIONS{
|
|
|
|
|
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
|
|
|
|
VK_KHR_MAINTENANCE1_EXTENSION_NAME,
|
|
|
|
|
VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME,
|
|
|
|
|
VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME,
|
|
|
|
|
VK_KHR_16BIT_STORAGE_EXTENSION_NAME,
|
|
|
|
|
VK_KHR_8BIT_STORAGE_EXTENSION_NAME,
|
|
|
|
|
VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME,
|
|
|
|
@ -187,10 +190,10 @@ std::unordered_map<VkFormat, VkFormatProperties> GetFormatProperties(
|
|
|
|
|
|
|
|
|
|
} // Anonymous namespace
|
|
|
|
|
|
|
|
|
|
VKDevice::VKDevice(VkInstance instance, vk::PhysicalDevice physical, VkSurfaceKHR surface,
|
|
|
|
|
const vk::InstanceDispatch& dld)
|
|
|
|
|
: dld{dld}, physical{physical}, properties{physical.GetProperties()},
|
|
|
|
|
format_properties{GetFormatProperties(physical, dld)} {
|
|
|
|
|
VKDevice::VKDevice(VkInstance instance_, u32 instance_version_, vk::PhysicalDevice physical_,
|
|
|
|
|
VkSurfaceKHR surface, const vk::InstanceDispatch& dld_)
|
|
|
|
|
: dld{dld_}, physical{physical_}, properties{physical.GetProperties()},
|
|
|
|
|
instance_version{instance_version_}, format_properties{GetFormatProperties(physical, dld)} {
|
|
|
|
|
SetupFamilies(surface);
|
|
|
|
|
SetupFeatures();
|
|
|
|
|
}
|
|
|
|
@ -597,20 +600,6 @@ bool VKDevice::IsSuitable(vk::PhysicalDevice physical, VkSurfaceKHR surface) {
|
|
|
|
|
|
|
|
|
|
std::vector<const char*> VKDevice::LoadExtensions() {
|
|
|
|
|
std::vector<const char*> extensions;
|
|
|
|
|
const auto Test = [&](const VkExtensionProperties& extension,
|
|
|
|
|
std::optional<std::reference_wrapper<bool>> status, const char* name,
|
|
|
|
|
bool push) {
|
|
|
|
|
if (extension.extensionName != std::string_view(name)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (push) {
|
|
|
|
|
extensions.push_back(name);
|
|
|
|
|
}
|
|
|
|
|
if (status) {
|
|
|
|
|
status->get() = true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extensions.reserve(7 + REQUIRED_EXTENSIONS.size());
|
|
|
|
|
extensions.insert(extensions.begin(), REQUIRED_EXTENSIONS.begin(), REQUIRED_EXTENSIONS.end());
|
|
|
|
|
|
|
|
|
@ -619,28 +608,36 @@ std::vector<const char*> VKDevice::LoadExtensions() {
|
|
|
|
|
bool has_ext_transform_feedback{};
|
|
|
|
|
bool has_ext_custom_border_color{};
|
|
|
|
|
bool has_ext_extended_dynamic_state{};
|
|
|
|
|
for (const auto& extension : physical.EnumerateDeviceExtensionProperties()) {
|
|
|
|
|
Test(extension, nv_viewport_swizzle, VK_NV_VIEWPORT_SWIZZLE_EXTENSION_NAME, true);
|
|
|
|
|
Test(extension, khr_uniform_buffer_standard_layout,
|
|
|
|
|
for (const VkExtensionProperties& extension : physical.EnumerateDeviceExtensionProperties()) {
|
|
|
|
|
const auto test = [&](std::optional<std::reference_wrapper<bool>> status, const char* name,
|
|
|
|
|
bool push) {
|
|
|
|
|
if (extension.extensionName != std::string_view(name)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (push) {
|
|
|
|
|
extensions.push_back(name);
|
|
|
|
|
}
|
|
|
|
|
if (status) {
|
|
|
|
|
status->get() = true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
test(nv_viewport_swizzle, VK_NV_VIEWPORT_SWIZZLE_EXTENSION_NAME, true);
|
|
|
|
|
test(khr_uniform_buffer_standard_layout,
|
|
|
|
|
VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME, true);
|
|
|
|
|
Test(extension, has_khr_shader_float16_int8, VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME,
|
|
|
|
|
false);
|
|
|
|
|
Test(extension, ext_depth_range_unrestricted,
|
|
|
|
|
VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME, true);
|
|
|
|
|
Test(extension, ext_index_type_uint8, VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME, true);
|
|
|
|
|
Test(extension, ext_shader_viewport_index_layer,
|
|
|
|
|
VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, true);
|
|
|
|
|
Test(extension, has_ext_subgroup_size_control, VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME,
|
|
|
|
|
false);
|
|
|
|
|
Test(extension, has_ext_transform_feedback, VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME,
|
|
|
|
|
false);
|
|
|
|
|
Test(extension, has_ext_custom_border_color, VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME,
|
|
|
|
|
false);
|
|
|
|
|
Test(extension, has_ext_extended_dynamic_state,
|
|
|
|
|
VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME, false);
|
|
|
|
|
test(has_khr_shader_float16_int8, VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME, false);
|
|
|
|
|
test(ext_depth_range_unrestricted, VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME, true);
|
|
|
|
|
test(ext_index_type_uint8, VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME, true);
|
|
|
|
|
test(ext_shader_viewport_index_layer, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME,
|
|
|
|
|
true);
|
|
|
|
|
test(has_ext_transform_feedback, VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME, false);
|
|
|
|
|
test(has_ext_custom_border_color, VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME, false);
|
|
|
|
|
test(has_ext_extended_dynamic_state, VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME, false);
|
|
|
|
|
if (instance_version >= VK_API_VERSION_1_1) {
|
|
|
|
|
test(has_ext_subgroup_size_control, VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME, false);
|
|
|
|
|
}
|
|
|
|
|
if (Settings::values.renderer_debug) {
|
|
|
|
|
Test(extension, nv_device_diagnostics_config,
|
|
|
|
|
VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME, true);
|
|
|
|
|
test(nv_device_diagnostics_config, VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME,
|
|
|
|
|
true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|