vk_device.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. // Copyright 2018 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <bitset>
  5. #include <chrono>
  6. #include <cstdlib>
  7. #include <optional>
  8. #include <set>
  9. #include <string_view>
  10. #include <thread>
  11. #include <vector>
  12. #include "common/assert.h"
  13. #include "core/settings.h"
  14. #include "video_core/renderer_vulkan/declarations.h"
  15. #include "video_core/renderer_vulkan/vk_device.h"
  16. namespace Vulkan {
  17. namespace {
  18. namespace Alternatives {
  19. constexpr std::array Depth24UnormS8Uint = {vk::Format::eD32SfloatS8Uint,
  20. vk::Format::eD16UnormS8Uint, vk::Format{}};
  21. constexpr std::array Depth16UnormS8Uint = {vk::Format::eD24UnormS8Uint,
  22. vk::Format::eD32SfloatS8Uint, vk::Format{}};
  23. } // namespace Alternatives
  24. template <typename T>
  25. void SetNext(void**& next, T& data) {
  26. *next = &data;
  27. next = &data.pNext;
  28. }
  29. template <typename T>
  30. T GetFeatures(vk::PhysicalDevice physical, const vk::DispatchLoaderDynamic& dldi) {
  31. vk::PhysicalDeviceFeatures2 features;
  32. T extension_features;
  33. features.pNext = &extension_features;
  34. physical.getFeatures2(&features, dldi);
  35. return extension_features;
  36. }
  37. template <typename T>
  38. T GetProperties(vk::PhysicalDevice physical, const vk::DispatchLoaderDynamic& dldi) {
  39. vk::PhysicalDeviceProperties2 properties;
  40. T extension_properties;
  41. properties.pNext = &extension_properties;
  42. physical.getProperties2(&properties, dldi);
  43. return extension_properties;
  44. }
  45. constexpr const vk::Format* GetFormatAlternatives(vk::Format format) {
  46. switch (format) {
  47. case vk::Format::eD24UnormS8Uint:
  48. return Alternatives::Depth24UnormS8Uint.data();
  49. case vk::Format::eD16UnormS8Uint:
  50. return Alternatives::Depth16UnormS8Uint.data();
  51. default:
  52. return nullptr;
  53. }
  54. }
  55. vk::FormatFeatureFlags GetFormatFeatures(vk::FormatProperties properties, FormatType format_type) {
  56. switch (format_type) {
  57. case FormatType::Linear:
  58. return properties.linearTilingFeatures;
  59. case FormatType::Optimal:
  60. return properties.optimalTilingFeatures;
  61. case FormatType::Buffer:
  62. return properties.bufferFeatures;
  63. default:
  64. return {};
  65. }
  66. }
  67. } // Anonymous namespace
  68. VKDevice::VKDevice(const vk::DispatchLoaderDynamic& dldi, vk::PhysicalDevice physical,
  69. vk::SurfaceKHR surface)
  70. : physical{physical}, properties{physical.getProperties(dldi)},
  71. format_properties{GetFormatProperties(dldi, physical)} {
  72. SetupFamilies(dldi, surface);
  73. SetupFeatures(dldi);
  74. }
  75. VKDevice::~VKDevice() = default;
  76. bool VKDevice::Create(const vk::DispatchLoaderDynamic& dldi, vk::Instance instance) {
  77. const auto queue_cis = GetDeviceQueueCreateInfos();
  78. const std::vector extensions = LoadExtensions(dldi);
  79. vk::PhysicalDeviceFeatures2 features2;
  80. void** next = &features2.pNext;
  81. auto& features = features2.features;
  82. features.vertexPipelineStoresAndAtomics = true;
  83. features.independentBlend = true;
  84. features.depthClamp = true;
  85. features.samplerAnisotropy = true;
  86. features.largePoints = true;
  87. features.multiViewport = true;
  88. features.depthBiasClamp = true;
  89. features.geometryShader = true;
  90. features.tessellationShader = true;
  91. features.fragmentStoresAndAtomics = true;
  92. features.shaderImageGatherExtended = true;
  93. features.shaderStorageImageWriteWithoutFormat = true;
  94. features.textureCompressionASTC_LDR = is_optimal_astc_supported;
  95. vk::PhysicalDevice16BitStorageFeaturesKHR bit16_storage;
  96. bit16_storage.uniformAndStorageBuffer16BitAccess = true;
  97. SetNext(next, bit16_storage);
  98. vk::PhysicalDevice8BitStorageFeaturesKHR bit8_storage;
  99. bit8_storage.uniformAndStorageBuffer8BitAccess = true;
  100. SetNext(next, bit8_storage);
  101. vk::PhysicalDeviceFloat16Int8FeaturesKHR float16_int8;
  102. if (is_float16_supported) {
  103. float16_int8.shaderFloat16 = true;
  104. SetNext(next, float16_int8);
  105. } else {
  106. LOG_INFO(Render_Vulkan, "Device doesn't support float16 natively");
  107. }
  108. vk::PhysicalDeviceUniformBufferStandardLayoutFeaturesKHR std430_layout;
  109. if (khr_uniform_buffer_standard_layout) {
  110. std430_layout.uniformBufferStandardLayout = true;
  111. SetNext(next, std430_layout);
  112. } else {
  113. LOG_INFO(Render_Vulkan, "Device doesn't support packed UBOs");
  114. }
  115. vk::PhysicalDeviceIndexTypeUint8FeaturesEXT index_type_uint8;
  116. if (ext_index_type_uint8) {
  117. index_type_uint8.indexTypeUint8 = true;
  118. SetNext(next, index_type_uint8);
  119. } else {
  120. LOG_INFO(Render_Vulkan, "Device doesn't support uint8 indexes");
  121. }
  122. if (!ext_depth_range_unrestricted) {
  123. LOG_INFO(Render_Vulkan, "Device doesn't support depth range unrestricted");
  124. }
  125. vk::DeviceCreateInfo device_ci({}, static_cast<u32>(queue_cis.size()), queue_cis.data(), 0,
  126. nullptr, static_cast<u32>(extensions.size()), extensions.data(),
  127. nullptr);
  128. device_ci.pNext = &features2;
  129. vk::Device dummy_logical;
  130. if (physical.createDevice(&device_ci, nullptr, &dummy_logical, dldi) != vk::Result::eSuccess) {
  131. LOG_CRITICAL(Render_Vulkan, "Logical device failed to be created!");
  132. return false;
  133. }
  134. dld.init(instance, dldi.vkGetInstanceProcAddr, dummy_logical, dldi.vkGetDeviceProcAddr);
  135. logical = UniqueDevice(
  136. dummy_logical, vk::ObjectDestroy<vk::NoParent, vk::DispatchLoaderDynamic>(nullptr, dld));
  137. CollectTelemetryParameters();
  138. graphics_queue = logical->getQueue(graphics_family, 0, dld);
  139. present_queue = logical->getQueue(present_family, 0, dld);
  140. return true;
  141. }
  142. vk::Format VKDevice::GetSupportedFormat(vk::Format wanted_format,
  143. vk::FormatFeatureFlags wanted_usage,
  144. FormatType format_type) const {
  145. if (IsFormatSupported(wanted_format, wanted_usage, format_type)) {
  146. return wanted_format;
  147. }
  148. // The wanted format is not supported by hardware, search for alternatives
  149. const vk::Format* alternatives = GetFormatAlternatives(wanted_format);
  150. if (alternatives == nullptr) {
  151. UNREACHABLE_MSG("Format={} with usage={} and type={} has no defined alternatives and host "
  152. "hardware does not support it",
  153. vk::to_string(wanted_format), vk::to_string(wanted_usage),
  154. static_cast<u32>(format_type));
  155. return wanted_format;
  156. }
  157. std::size_t i = 0;
  158. for (vk::Format alternative = alternatives[0]; alternative != vk::Format{};
  159. alternative = alternatives[++i]) {
  160. if (!IsFormatSupported(alternative, wanted_usage, format_type)) {
  161. continue;
  162. }
  163. LOG_WARNING(Render_Vulkan,
  164. "Emulating format={} with alternative format={} with usage={} and type={}",
  165. static_cast<u32>(wanted_format), static_cast<u32>(alternative),
  166. static_cast<u32>(wanted_usage), static_cast<u32>(format_type));
  167. return alternative;
  168. }
  169. // No alternatives found, panic
  170. UNREACHABLE_MSG("Format={} with usage={} and type={} is not supported by the host hardware and "
  171. "doesn't support any of the alternatives",
  172. static_cast<u32>(wanted_format), static_cast<u32>(wanted_usage),
  173. static_cast<u32>(format_type));
  174. return wanted_format;
  175. }
  176. void VKDevice::ReportLoss() const {
  177. LOG_CRITICAL(Render_Vulkan, "Device loss occured!");
  178. // Wait some time to let the log flush
  179. std::this_thread::sleep_for(std::chrono::seconds{1});
  180. if (!nv_device_diagnostic_checkpoints) {
  181. return;
  182. }
  183. [[maybe_unused]] const std::vector data = graphics_queue.getCheckpointDataNV(dld);
  184. // Catch here in debug builds (or with optimizations disabled) the last graphics pipeline to be
  185. // executed. It can be done on a debugger by evaluating the expression:
  186. // *(VKGraphicsPipeline*)data[0]
  187. }
  188. bool VKDevice::IsOptimalAstcSupported(const vk::PhysicalDeviceFeatures& features,
  189. const vk::DispatchLoaderDynamic& dldi) const {
  190. // Disable for now to avoid converting ASTC twice.
  191. return false;
  192. static constexpr std::array astc_formats = {
  193. vk::Format::eAstc4x4SrgbBlock, vk::Format::eAstc8x8SrgbBlock,
  194. vk::Format::eAstc8x5SrgbBlock, vk::Format::eAstc5x4SrgbBlock,
  195. vk::Format::eAstc5x5UnormBlock, vk::Format::eAstc5x5SrgbBlock,
  196. vk::Format::eAstc10x8UnormBlock, vk::Format::eAstc10x8SrgbBlock,
  197. vk::Format::eAstc6x6UnormBlock, vk::Format::eAstc6x6SrgbBlock,
  198. vk::Format::eAstc10x10UnormBlock, vk::Format::eAstc10x10SrgbBlock,
  199. vk::Format::eAstc12x12UnormBlock, vk::Format::eAstc12x12SrgbBlock,
  200. vk::Format::eAstc8x6UnormBlock, vk::Format::eAstc8x6SrgbBlock,
  201. vk::Format::eAstc6x5UnormBlock, vk::Format::eAstc6x5SrgbBlock};
  202. if (!features.textureCompressionASTC_LDR) {
  203. return false;
  204. }
  205. const auto format_feature_usage{
  206. vk::FormatFeatureFlagBits::eSampledImage | vk::FormatFeatureFlagBits::eBlitSrc |
  207. vk::FormatFeatureFlagBits::eBlitDst | vk::FormatFeatureFlagBits::eTransferSrc |
  208. vk::FormatFeatureFlagBits::eTransferDst};
  209. for (const auto format : astc_formats) {
  210. const auto format_properties{physical.getFormatProperties(format, dldi)};
  211. if (!(format_properties.optimalTilingFeatures & format_feature_usage)) {
  212. return false;
  213. }
  214. }
  215. return true;
  216. }
  217. bool VKDevice::IsFormatSupported(vk::Format wanted_format, vk::FormatFeatureFlags wanted_usage,
  218. FormatType format_type) const {
  219. const auto it = format_properties.find(wanted_format);
  220. if (it == format_properties.end()) {
  221. UNIMPLEMENTED_MSG("Unimplemented format query={}", vk::to_string(wanted_format));
  222. return true;
  223. }
  224. const auto supported_usage = GetFormatFeatures(it->second, format_type);
  225. return (supported_usage & wanted_usage) == wanted_usage;
  226. }
  227. bool VKDevice::IsSuitable(const vk::DispatchLoaderDynamic& dldi, vk::PhysicalDevice physical,
  228. vk::SurfaceKHR surface) {
  229. bool is_suitable = true;
  230. constexpr std::array required_extensions = {
  231. VK_KHR_SWAPCHAIN_EXTENSION_NAME,
  232. VK_KHR_16BIT_STORAGE_EXTENSION_NAME,
  233. VK_KHR_8BIT_STORAGE_EXTENSION_NAME,
  234. VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME,
  235. VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
  236. VK_EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME,
  237. VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME,
  238. };
  239. std::bitset<required_extensions.size()> available_extensions{};
  240. for (const auto& prop : physical.enumerateDeviceExtensionProperties(nullptr, dldi)) {
  241. for (std::size_t i = 0; i < required_extensions.size(); ++i) {
  242. if (available_extensions[i]) {
  243. continue;
  244. }
  245. available_extensions[i] =
  246. required_extensions[i] == std::string_view{prop.extensionName};
  247. }
  248. }
  249. if (!available_extensions.all()) {
  250. for (std::size_t i = 0; i < required_extensions.size(); ++i) {
  251. if (available_extensions[i]) {
  252. continue;
  253. }
  254. LOG_ERROR(Render_Vulkan, "Missing required extension: {}", required_extensions[i]);
  255. is_suitable = false;
  256. }
  257. }
  258. bool has_graphics{}, has_present{};
  259. const auto queue_family_properties = physical.getQueueFamilyProperties(dldi);
  260. for (u32 i = 0; i < static_cast<u32>(queue_family_properties.size()); ++i) {
  261. const auto& family = queue_family_properties[i];
  262. if (family.queueCount == 0) {
  263. continue;
  264. }
  265. has_graphics |=
  266. (family.queueFlags & vk::QueueFlagBits::eGraphics) != static_cast<vk::QueueFlagBits>(0);
  267. has_present |= physical.getSurfaceSupportKHR(i, surface, dldi) != 0;
  268. }
  269. if (!has_graphics || !has_present) {
  270. LOG_ERROR(Render_Vulkan, "Device lacks a graphics and present queue");
  271. is_suitable = false;
  272. }
  273. // TODO(Rodrigo): Check if the device matches all requeriments.
  274. const auto properties{physical.getProperties(dldi)};
  275. const auto& limits{properties.limits};
  276. constexpr u32 required_ubo_size = 65536;
  277. if (limits.maxUniformBufferRange < required_ubo_size) {
  278. LOG_ERROR(Render_Vulkan, "Device UBO size {} is too small, {} is required",
  279. limits.maxUniformBufferRange, required_ubo_size);
  280. is_suitable = false;
  281. }
  282. constexpr u32 required_num_viewports = 16;
  283. if (limits.maxViewports < required_num_viewports) {
  284. LOG_INFO(Render_Vulkan, "Device number of viewports {} is too small, {} is required",
  285. limits.maxViewports, required_num_viewports);
  286. is_suitable = false;
  287. }
  288. const auto features{physical.getFeatures(dldi)};
  289. const std::array feature_report = {
  290. std::make_pair(features.vertexPipelineStoresAndAtomics, "vertexPipelineStoresAndAtomics"),
  291. std::make_pair(features.independentBlend, "independentBlend"),
  292. std::make_pair(features.depthClamp, "depthClamp"),
  293. std::make_pair(features.samplerAnisotropy, "samplerAnisotropy"),
  294. std::make_pair(features.largePoints, "largePoints"),
  295. std::make_pair(features.multiViewport, "multiViewport"),
  296. std::make_pair(features.depthBiasClamp, "depthBiasClamp"),
  297. std::make_pair(features.geometryShader, "geometryShader"),
  298. std::make_pair(features.tessellationShader, "tessellationShader"),
  299. std::make_pair(features.fragmentStoresAndAtomics, "fragmentStoresAndAtomics"),
  300. std::make_pair(features.shaderImageGatherExtended, "shaderImageGatherExtended"),
  301. std::make_pair(features.shaderStorageImageWriteWithoutFormat,
  302. "shaderStorageImageWriteWithoutFormat"),
  303. };
  304. for (const auto& [supported, name] : feature_report) {
  305. if (supported) {
  306. continue;
  307. }
  308. LOG_ERROR(Render_Vulkan, "Missing required feature: {}", name);
  309. is_suitable = false;
  310. }
  311. if (!is_suitable) {
  312. LOG_ERROR(Render_Vulkan, "{} is not suitable", properties.deviceName);
  313. }
  314. return is_suitable;
  315. }
  316. std::vector<const char*> VKDevice::LoadExtensions(const vk::DispatchLoaderDynamic& dldi) {
  317. std::vector<const char*> extensions;
  318. const auto Test = [&](const vk::ExtensionProperties& extension,
  319. std::optional<std::reference_wrapper<bool>> status, const char* name,
  320. bool push) {
  321. if (extension.extensionName != std::string_view(name)) {
  322. return;
  323. }
  324. if (push) {
  325. extensions.push_back(name);
  326. }
  327. if (status) {
  328. status->get() = true;
  329. }
  330. };
  331. extensions.reserve(13);
  332. extensions.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
  333. extensions.push_back(VK_KHR_16BIT_STORAGE_EXTENSION_NAME);
  334. extensions.push_back(VK_KHR_8BIT_STORAGE_EXTENSION_NAME);
  335. extensions.push_back(VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME);
  336. extensions.push_back(VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME);
  337. extensions.push_back(VK_EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME);
  338. extensions.push_back(VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME);
  339. [[maybe_unused]] const bool nsight =
  340. std::getenv("NVTX_INJECTION64_PATH") || std::getenv("NSIGHT_LAUNCHED");
  341. bool khr_shader_float16_int8{};
  342. bool ext_subgroup_size_control{};
  343. for (const auto& extension : physical.enumerateDeviceExtensionProperties(nullptr, dldi)) {
  344. Test(extension, khr_uniform_buffer_standard_layout,
  345. VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME, true);
  346. Test(extension, khr_shader_float16_int8, VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME, false);
  347. Test(extension, ext_depth_range_unrestricted,
  348. VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME, true);
  349. Test(extension, ext_index_type_uint8, VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME, true);
  350. Test(extension, ext_shader_viewport_index_layer,
  351. VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, true);
  352. Test(extension, ext_subgroup_size_control, VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME,
  353. false);
  354. if (Settings::values.renderer_debug) {
  355. Test(extension, nv_device_diagnostic_checkpoints,
  356. VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME, true);
  357. }
  358. }
  359. if (khr_shader_float16_int8) {
  360. is_float16_supported =
  361. GetFeatures<vk::PhysicalDeviceFloat16Int8FeaturesKHR>(physical, dldi).shaderFloat16;
  362. extensions.push_back(VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME);
  363. }
  364. if (ext_subgroup_size_control) {
  365. const auto features =
  366. GetFeatures<vk::PhysicalDeviceSubgroupSizeControlFeaturesEXT>(physical, dldi);
  367. const auto properties =
  368. GetProperties<vk::PhysicalDeviceSubgroupSizeControlPropertiesEXT>(physical, dldi);
  369. is_warp_potentially_bigger = properties.maxSubgroupSize > GuestWarpSize;
  370. if (features.subgroupSizeControl && properties.minSubgroupSize <= GuestWarpSize &&
  371. properties.maxSubgroupSize >= GuestWarpSize) {
  372. extensions.push_back(VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME);
  373. guest_warp_stages = properties.requiredSubgroupSizeStages;
  374. }
  375. } else {
  376. is_warp_potentially_bigger = true;
  377. }
  378. return extensions;
  379. }
  380. void VKDevice::SetupFamilies(const vk::DispatchLoaderDynamic& dldi, vk::SurfaceKHR surface) {
  381. std::optional<u32> graphics_family_, present_family_;
  382. const auto queue_family_properties = physical.getQueueFamilyProperties(dldi);
  383. for (u32 i = 0; i < static_cast<u32>(queue_family_properties.size()); ++i) {
  384. if (graphics_family_ && present_family_)
  385. break;
  386. const auto& queue_family = queue_family_properties[i];
  387. if (queue_family.queueCount == 0)
  388. continue;
  389. if (queue_family.queueFlags & vk::QueueFlagBits::eGraphics)
  390. graphics_family_ = i;
  391. if (physical.getSurfaceSupportKHR(i, surface, dldi))
  392. present_family_ = i;
  393. }
  394. ASSERT(graphics_family_ && present_family_);
  395. graphics_family = *graphics_family_;
  396. present_family = *present_family_;
  397. }
  398. void VKDevice::SetupFeatures(const vk::DispatchLoaderDynamic& dldi) {
  399. const auto supported_features{physical.getFeatures(dldi)};
  400. is_optimal_astc_supported = IsOptimalAstcSupported(supported_features, dldi);
  401. }
  402. void VKDevice::CollectTelemetryParameters() {
  403. const auto driver = GetProperties<vk::PhysicalDeviceDriverPropertiesKHR>(physical, dld);
  404. driver_id = driver.driverID;
  405. vendor_name = driver.driverName;
  406. const auto extensions = physical.enumerateDeviceExtensionProperties(nullptr, dld);
  407. reported_extensions.reserve(std::size(extensions));
  408. for (const auto& extension : extensions) {
  409. reported_extensions.push_back(extension.extensionName);
  410. }
  411. }
  412. std::vector<vk::DeviceQueueCreateInfo> VKDevice::GetDeviceQueueCreateInfos() const {
  413. static const float QUEUE_PRIORITY = 1.0f;
  414. std::set<u32> unique_queue_families = {graphics_family, present_family};
  415. std::vector<vk::DeviceQueueCreateInfo> queue_cis;
  416. for (u32 queue_family : unique_queue_families)
  417. queue_cis.push_back({{}, queue_family, 1, &QUEUE_PRIORITY});
  418. return queue_cis;
  419. }
  420. std::unordered_map<vk::Format, vk::FormatProperties> VKDevice::GetFormatProperties(
  421. const vk::DispatchLoaderDynamic& dldi, vk::PhysicalDevice physical) {
  422. static constexpr std::array formats{vk::Format::eA8B8G8R8UnormPack32,
  423. vk::Format::eA8B8G8R8UintPack32,
  424. vk::Format::eA8B8G8R8SnormPack32,
  425. vk::Format::eA8B8G8R8SrgbPack32,
  426. vk::Format::eB5G6R5UnormPack16,
  427. vk::Format::eA2B10G10R10UnormPack32,
  428. vk::Format::eA1R5G5B5UnormPack16,
  429. vk::Format::eR32G32B32A32Sfloat,
  430. vk::Format::eR32G32B32A32Uint,
  431. vk::Format::eR32G32Sfloat,
  432. vk::Format::eR32G32Uint,
  433. vk::Format::eR16G16B16A16Uint,
  434. vk::Format::eR16G16B16A16Unorm,
  435. vk::Format::eR16G16Unorm,
  436. vk::Format::eR16G16Snorm,
  437. vk::Format::eR16G16Sfloat,
  438. vk::Format::eR16Unorm,
  439. vk::Format::eR8G8B8A8Srgb,
  440. vk::Format::eR8G8Unorm,
  441. vk::Format::eR8G8Snorm,
  442. vk::Format::eR8Unorm,
  443. vk::Format::eR8Uint,
  444. vk::Format::eB10G11R11UfloatPack32,
  445. vk::Format::eR32Sfloat,
  446. vk::Format::eR32Uint,
  447. vk::Format::eR16Sfloat,
  448. vk::Format::eR16G16B16A16Sfloat,
  449. vk::Format::eB8G8R8A8Unorm,
  450. vk::Format::eR4G4B4A4UnormPack16,
  451. vk::Format::eD32Sfloat,
  452. vk::Format::eD16Unorm,
  453. vk::Format::eD16UnormS8Uint,
  454. vk::Format::eD24UnormS8Uint,
  455. vk::Format::eD32SfloatS8Uint,
  456. vk::Format::eBc1RgbaUnormBlock,
  457. vk::Format::eBc2UnormBlock,
  458. vk::Format::eBc3UnormBlock,
  459. vk::Format::eBc4UnormBlock,
  460. vk::Format::eBc5UnormBlock,
  461. vk::Format::eBc5SnormBlock,
  462. vk::Format::eBc7UnormBlock,
  463. vk::Format::eBc6HUfloatBlock,
  464. vk::Format::eBc6HSfloatBlock,
  465. vk::Format::eBc1RgbaSrgbBlock,
  466. vk::Format::eBc3SrgbBlock,
  467. vk::Format::eBc7SrgbBlock,
  468. vk::Format::eAstc4x4SrgbBlock,
  469. vk::Format::eAstc8x8SrgbBlock,
  470. vk::Format::eAstc8x5SrgbBlock,
  471. vk::Format::eAstc5x4SrgbBlock,
  472. vk::Format::eAstc5x5UnormBlock,
  473. vk::Format::eAstc5x5SrgbBlock,
  474. vk::Format::eAstc10x8UnormBlock,
  475. vk::Format::eAstc10x8SrgbBlock,
  476. vk::Format::eAstc6x6UnormBlock,
  477. vk::Format::eAstc6x6SrgbBlock,
  478. vk::Format::eAstc10x10UnormBlock,
  479. vk::Format::eAstc10x10SrgbBlock,
  480. vk::Format::eAstc12x12UnormBlock,
  481. vk::Format::eAstc12x12SrgbBlock,
  482. vk::Format::eAstc8x6UnormBlock,
  483. vk::Format::eAstc8x6SrgbBlock,
  484. vk::Format::eAstc6x5UnormBlock,
  485. vk::Format::eAstc6x5SrgbBlock,
  486. vk::Format::eE5B9G9R9UfloatPack32};
  487. std::unordered_map<vk::Format, vk::FormatProperties> format_properties;
  488. for (const auto format : formats) {
  489. format_properties.emplace(format, physical.getFormatProperties(format, dldi));
  490. }
  491. return format_properties;
  492. }
  493. } // namespace Vulkan