From d98344f99b5a91fbaee1bc42345f412861d75e8a Mon Sep 17 00:00:00 2001 From: DrChat Date: Mon, 18 Dec 2017 15:47:52 -0600 Subject: [PATCH] [Vulkan] Log down strings when an invalid usage flag is specified. --- src/xenia/gpu/vulkan/texture_cache.cc | 11 +++++--- src/xenia/ui/vulkan/vulkan_swap_chain.cc | 3 ++- src/xenia/ui/vulkan/vulkan_util.cc | 32 +++++++++++++++++++++++- src/xenia/ui/vulkan/vulkan_util.h | 3 ++- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/xenia/gpu/vulkan/texture_cache.cc b/src/xenia/gpu/vulkan/texture_cache.cc index c2d88a894..7983efdd2 100644 --- a/src/xenia/gpu/vulkan/texture_cache.cc +++ b/src/xenia/gpu/vulkan/texture_cache.cc @@ -271,10 +271,13 @@ TextureCache::Texture* TextureCache::AllocateTexture( if ((props.optimalTilingFeatures & required_flags) != required_flags) { // Texture needs conversion on upload to a native format. XELOGE( - "Texture Cache: Invalid usage flag specified on format %s (vk %d) " - "(0x%.8X != 0x%.8X)", - texture_info.format_info()->name, format, - (props.optimalTilingFeatures & required_flags), required_flags); + "Texture Cache: Invalid usage flag specified on format %s (%s)\n\t" + "(requested: %s)", + texture_info.format_info()->name, ui::vulkan::to_string(format), + ui::vulkan::to_flags_string( + static_cast(required_flags & + ~props.optimalTilingFeatures)) + .c_str()); assert_always(); } diff --git a/src/xenia/ui/vulkan/vulkan_swap_chain.cc b/src/xenia/ui/vulkan/vulkan_swap_chain.cc index 45bd4cdb0..87a07b42d 100644 --- a/src/xenia/ui/vulkan/vulkan_swap_chain.cc +++ b/src/xenia/ui/vulkan/vulkan_swap_chain.cc @@ -156,7 +156,8 @@ bool VulkanSwapChain::Initialize(VkSurfaceKHR surface) { XELOGVK(" presentMode = %s", to_string(create_info.presentMode)); XELOGVK(" clipped = %s", create_info.clipped ? "true" : "false"); XELOGVK(" imageColorSpace = %s", to_string(create_info.imageColorSpace)); - auto image_usage_flags_str = to_flags_string(create_info.imageUsage); + auto image_usage_flags_str = to_flags_string( + static_cast(create_info.imageUsage)); XELOGVK(" imageUsageFlags = %s", image_usage_flags_str.c_str()); XELOGVK(" imageSharingMode = %s", to_string(create_info.imageSharingMode)); XELOGVK(" queueFamilyCount = %u", create_info.queueFamilyIndexCount); diff --git a/src/xenia/ui/vulkan/vulkan_util.cc b/src/xenia/ui/vulkan/vulkan_util.cc index 9a853c13f..9c0a4238a 100644 --- a/src/xenia/ui/vulkan/vulkan_util.cc +++ b/src/xenia/ui/vulkan/vulkan_util.cc @@ -296,7 +296,7 @@ const char* to_string(VkResult result) { } } -std::string to_flags_string(VkImageUsageFlags flags) { +std::string to_flags_string(VkImageUsageFlagBits flags) { std::string result; #define OR_FLAG(f) \ if (flags & f) { \ @@ -317,6 +317,36 @@ std::string to_flags_string(VkImageUsageFlags flags) { return result; } +std::string to_flags_string(VkFormatFeatureFlagBits flags) { + std::string result; +#define OR_FLAG(f) \ + if (flags & f) { \ + if (!result.empty()) { \ + result += " | "; \ + } \ + result += #f; \ + } + OR_FLAG(VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT); + OR_FLAG(VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT); + OR_FLAG(VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT); + OR_FLAG(VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT); + OR_FLAG(VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT); + OR_FLAG(VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT); + OR_FLAG(VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT); + OR_FLAG(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); + OR_FLAG(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT); + OR_FLAG(VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT); + OR_FLAG(VK_FORMAT_FEATURE_BLIT_SRC_BIT); + OR_FLAG(VK_FORMAT_FEATURE_BLIT_DST_BIT); + OR_FLAG(VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT); + OR_FLAG(VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG); + OR_FLAG(VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR); + OR_FLAG(VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR); + OR_FLAG(VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT); +#undef OR_FLAG + return result; +} + std::string to_flags_string(VkSurfaceTransformFlagBitsKHR flags) { std::string result; #define OR_FLAG(f) \ diff --git a/src/xenia/ui/vulkan/vulkan_util.h b/src/xenia/ui/vulkan/vulkan_util.h index f5475edd8..d876e7722 100644 --- a/src/xenia/ui/vulkan/vulkan_util.h +++ b/src/xenia/ui/vulkan/vulkan_util.h @@ -65,7 +65,8 @@ const char* to_string(VkPhysicalDeviceType type); const char* to_string(VkSharingMode sharing_mode); const char* to_string(VkResult result); -std::string to_flags_string(VkImageUsageFlags flags); +std::string to_flags_string(VkImageUsageFlagBits flags); +std::string to_flags_string(VkFormatFeatureFlagBits flags); std::string to_flags_string(VkSurfaceTransformFlagBitsKHR flags); const char* to_string(VkColorSpaceKHR color_space);