mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 04:45:58 +01:00
render/vulkan: improve format logging
This commit is contained in:
parent
b5a474189e
commit
bca60c4eec
2 changed files with 33 additions and 23 deletions
|
@ -2,6 +2,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <xf86drm.h>
|
||||
#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 : "<unknown>", 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 : "<unknown>", 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) {
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue