diff options
| author | Charles Giessen <charles@lunarg.com> | 2021-06-21 14:14:41 -0600 |
|---|---|---|
| committer | Charles Giessen <46324611+charles-lunarg@users.noreply.github.com> | 2021-06-28 15:28:36 -0600 |
| commit | aaebda90a9a86b9170d18685f17e2df10a6371fd (patch) | |
| tree | e3faec2dcd9693c50e25288d897a0d972879874d | |
| parent | 8926213dd0088f91e4be9bbe770a5b11b1316897 (diff) | |
| download | usermoji-aaebda90a9a86b9170d18685f17e2df10a6371fd.tar.xz | |
vulkaninfo: Fix image format query arguments
The VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT and
VK_IMAGE_CREATE_SPARSE_BINDING_BIT were swapped, causing erroneous output
and validation messages.
Change-Id: Iff61c379f66aedb14e27e7f422516e1469274248
| -rw-r--r-- | vulkaninfo/vulkaninfo.h | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/vulkaninfo/vulkaninfo.h b/vulkaninfo/vulkaninfo.h index 509c1fdb..9a74b9fb 100644 --- a/vulkaninfo/vulkaninfo.h +++ b/vulkaninfo/vulkaninfo.h @@ -1350,11 +1350,10 @@ util::trivial_optional<VkDeviceGroupPresentCapabilitiesKHR> GetGroupCapabilities const VkFormat color_format = VK_FORMAT_R8G8B8A8_UNORM; struct ImageTypeSupport { - enum class Type { regular, sparse, transient } type = Type::regular; - bool supported = false; - uint32_t memoryTypeBits = 0; + enum class Type { regular, sparse, transient } type; + uint32_t memoryTypeBits; - bool Compatible(uint32_t memtype_bit) { return supported && (memoryTypeBits & memtype_bit); } + bool Compatible(uint32_t memtype_bit) { return memoryTypeBits & memtype_bit; } }; struct ImageTypeFormatInfo { @@ -1385,8 +1384,8 @@ VkImageCreateInfo GetImageCreateInfo(VkImageCreateFlags flags, VkFormat format, VK_IMAGE_LAYOUT_UNDEFINED}; } -ImageTypeSupport FillImageTypeSupport(AppInstance &inst, VkPhysicalDevice phys_device, VkDevice device, - ImageTypeSupport::Type img_type, VkImageCreateInfo image_ci) { +util::trivial_optional<ImageTypeSupport> FillImageTypeSupport(AppInstance &inst, VkPhysicalDevice phys_device, VkDevice device, + ImageTypeSupport::Type img_type, VkImageCreateInfo image_ci) { VkImageFormatProperties img_props; VkResult res = inst.dll.fp_vkGetPhysicalDeviceImageFormatProperties( phys_device, image_ci.format, image_ci.imageType, image_ci.tiling, image_ci.usage, image_ci.flags, &img_props); @@ -1394,7 +1393,6 @@ ImageTypeSupport FillImageTypeSupport(AppInstance &inst, VkPhysicalDevice phys_d if (res == VK_SUCCESS) { ImageTypeSupport img_type_support{}; img_type_support.type = img_type; - img_type_support.supported = true; VkImage dummy_img; res = inst.dll.fp_vkCreateImage(device, &image_ci, nullptr, &dummy_img); @@ -1407,7 +1405,7 @@ ImageTypeSupport FillImageTypeSupport(AppInstance &inst, VkPhysicalDevice phys_d inst.dll.fp_vkDestroyImage(device, dummy_img, nullptr); return img_type_support; } else if (res == VK_ERROR_FORMAT_NOT_SUPPORTED) { - return {}; // default initialization has supported being false + return {}; // return empty optional } THROW_VK_ERR("vkGetPhysicalDeviceImageFormatProperties", res); return {}; @@ -1565,9 +1563,10 @@ struct AppGpu { } VkImageCreateInfo image_ci_regular = GetImageCreateInfo(0, format, tiling, 0); - VkImageCreateInfo image_ci_transient = - GetImageCreateInfo(VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, format, tiling, 0); - VkImageCreateInfo image_ci_sparse = GetImageCreateInfo(0, format, tiling, VK_IMAGE_CREATE_SPARSE_BINDING_BIT); + VkImageCreateInfo image_ci_transient = GetImageCreateInfo( + 0, format, tiling, VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); + VkImageCreateInfo image_ci_sparse = + GetImageCreateInfo(VK_IMAGE_CREATE_SPARSE_BINDING_BIT, format, tiling, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); if (tiling == VK_IMAGE_TILING_LINEAR) { if (format == color_format) { @@ -1588,22 +1587,22 @@ struct AppGpu { } } - auto image_ts_regular = + auto image_ts_regular_ret = FillImageTypeSupport(inst, phys_device, dev, ImageTypeSupport::Type::regular, image_ci_regular); - if (image_ts_regular.supported) { - image_type_format_info.type_support.push_back(image_ts_regular); + if (image_ts_regular_ret) { + image_type_format_info.type_support.push_back(image_ts_regular_ret.value()); } - auto image_ts_transient = + auto image_ts_transient_ret = FillImageTypeSupport(inst, phys_device, dev, ImageTypeSupport::Type::transient, image_ci_transient); - if (image_ts_transient.supported) { - image_type_format_info.type_support.push_back(image_ts_transient); + if (image_ts_transient_ret) { + image_type_format_info.type_support.push_back(image_ts_transient_ret.value()); } if (enabled_features.sparseBinding) { - auto image_ts_sparse = + auto image_ts_sparse_ret = FillImageTypeSupport(inst, phys_device, dev, ImageTypeSupport::Type::sparse, image_ci_sparse); - if (image_ts_sparse.supported) { - image_type_format_info.type_support.push_back(image_ts_sparse); + if (image_ts_sparse_ret) { + image_type_format_info.type_support.push_back(image_ts_sparse_ret.value()); } } image_type_infos.formats.push_back(image_type_format_info); |
