From bca60c4eec2e156a018c66aa5076d6ae7bbe5bed Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 7 Sep 2022 11:20:51 +0200 Subject: [PATCH] render/vulkan: improve format logging --- render/vulkan/pixel_format.c | 55 +++++++++++++++++++++--------------- render/vulkan/vulkan.c | 1 + 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/render/vulkan/pixel_format.c b/render/vulkan/pixel_format.c index a152f4674..c93e10f9b 100644 --- a/render/vulkan/pixel_format.c +++ b/render/vulkan/pixel_format.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "render/vulkan.h" // Reversed endianess of shm and vulkan format names @@ -134,9 +135,7 @@ static bool query_modifier_support(struct wlr_vk_device *dev, for (unsigned i = 0u; i < modp.drmFormatModifierCount; ++i) { VkDrmFormatModifierPropertiesEXT m = modp.pDrmFormatModifierProperties[i]; - wlr_log(WLR_DEBUG, " modifier: 0x%"PRIx64 ": features 0x%"PRIx32", %d planes", - m.drmFormatModifier, m.drmFormatModifierTilingFeatures, - m.drmFormatModifierPlaneCount); + const char *render_status, *texture_status; // check that specific modifier for render usage if ((m.drmFormatModifierTilingFeatures & render_features) == render_features) { @@ -151,7 +150,7 @@ static bool query_modifier_support(struct wlr_vk_device *dev, res); } - wlr_log(WLR_DEBUG, " >> rendering: format not supported"); + render_status = "✗ render (unsupported format)"; } else if (emp->externalMemoryFeatures & VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT) { unsigned c = props->render_mod_count; @@ -170,12 +169,12 @@ static bool query_modifier_support(struct wlr_vk_device *dev, wlr_drm_format_set_add(&dev->dmabuf_render_formats, props->format.drm_format, m.drmFormatModifier); - wlr_log(WLR_DEBUG, " >> rendering: supported"); + render_status = "✓ render"; } else { - wlr_log(WLR_DEBUG, " >> rendering: importing not supported"); + render_status = "✗ render (import not supported)"; } } else { - wlr_log(WLR_DEBUG, " >> rendering: format features not supported"); + render_status = "✗ render (missing required features)"; } // check that specific modifier for texture usage @@ -191,7 +190,7 @@ static bool query_modifier_support(struct wlr_vk_device *dev, res); } - wlr_log(WLR_DEBUG, " >> dmatex: format not supported"); + texture_status = "✗ texture (unsupported format)"; } else if (emp->externalMemoryFeatures & VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT) { unsigned c = props->texture_mod_count; @@ -210,13 +209,20 @@ static bool query_modifier_support(struct wlr_vk_device *dev, wlr_drm_format_set_add(&dev->dmabuf_texture_formats, props->format.drm_format, m.drmFormatModifier); - wlr_log(WLR_DEBUG, " >> dmatex: supported"); + texture_status = "✓ texture"; } else { - wlr_log(WLR_DEBUG, " >> dmatex: importing not supported"); + texture_status = "✗ texture (import not supported)"; } } else { - wlr_log(WLR_DEBUG, " >> dmatex: format features not supported"); + texture_status = "✗ texture (missing required features)"; } + + char *modifier_name = drmGetFormatModifierName(m.drmFormatModifier); + wlr_log(WLR_DEBUG, " DMA-BUF modifier %s " + "(0x%016"PRIX64", %"PRIu32" planes): %s %s", + modifier_name ? modifier_name : "", m.drmFormatModifier, + m.drmFormatModifierPlaneCount, texture_status, render_status); + free(modifier_name); } free(modp.pDrmFormatModifierProperties); @@ -225,11 +231,13 @@ static bool query_modifier_support(struct wlr_vk_device *dev, void vulkan_format_props_query(struct wlr_vk_device *dev, const struct wlr_vk_format *format) { - - wlr_log(WLR_DEBUG, "vulkan: Checking support for format %.4s (0x%" PRIx32 ")", - (const char *)&format->drm_format, format->drm_format); VkResult res; + char *format_name = drmGetFormatName(format->drm_format); + wlr_log(WLR_DEBUG, " %s (0x%08"PRIX32")", + format_name ? format_name : "", format->drm_format); + free(format_name); + // get general features and modifiers VkFormatProperties2 fmtp = {0}; fmtp.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2; @@ -254,13 +262,8 @@ void vulkan_format_props_query(struct wlr_vk_device *dev, struct wlr_vk_format_props props = {0}; props.format = *format; - wlr_log(WLR_DEBUG, " drmFormatModifierCount: %d", modp.drmFormatModifierCount); - if (modp.drmFormatModifierCount > 0) { - add_fmt_props |= query_modifier_support(dev, &props, - modp.drmFormatModifierCount, fmti); - } - // non-dmabuf texture properties + const char *shm_texture_status; if ((fmtp.formatProperties.optimalTilingFeatures & tex_features) == tex_features) { fmti.pNext = NULL; ifmtp.pNext = NULL; @@ -275,14 +278,14 @@ void vulkan_format_props_query(struct wlr_vk_device *dev, res); } - wlr_log(WLR_DEBUG, " >> shmtex: format not supported"); + shm_texture_status = "✗ texture (unsupported format)"; } else { VkExtent3D me = ifmtp.imageFormatProperties.maxExtent; props.max_extent.width = me.width; props.max_extent.height = me.height; props.features = fmtp.formatProperties.optimalTilingFeatures; - wlr_log(WLR_DEBUG, " >> shmtex: supported"); + shm_texture_status = "✓ texture"; dev->shm_formats[dev->shm_format_count] = format->drm_format; ++dev->shm_format_count; @@ -290,7 +293,13 @@ void vulkan_format_props_query(struct wlr_vk_device *dev, add_fmt_props = true; } } else { - wlr_log(WLR_DEBUG, " >> shmtex: format features not supported"); + shm_texture_status = "✗ texture (missing required features)"; + } + wlr_log(WLR_DEBUG, " Shared memory: %s", shm_texture_status); + + if (modp.drmFormatModifierCount > 0) { + add_fmt_props |= query_modifier_support(dev, &props, + modp.drmFormatModifierCount, fmti); } if (add_fmt_props) { diff --git a/render/vulkan/vulkan.c b/render/vulkan/vulkan.c index d5ff5feba..133ba8a95 100644 --- a/render/vulkan/vulkan.c +++ b/render/vulkan/vulkan.c @@ -511,6 +511,7 @@ struct wlr_vk_device *vulkan_device_create(struct wlr_vk_instance *ini, goto error; } + wlr_log(WLR_DEBUG, "Supported Vulkan formats:"); for (unsigned i = 0u; i < max_fmts; ++i) { vulkan_format_props_query(dev, &fmts[i]); }