mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-18 06:47:31 -04:00
Merge branch 'drm-fmt-desc' into 'master'
render/pixel-format: add get_drm_{format,modifier}_description
See merge request wlroots/wlroots!4113
This commit is contained in:
commit
8a1f69ebfb
6 changed files with 68 additions and 32 deletions
|
|
@ -25,4 +25,7 @@ bool pixel_format_info_check_stride(const struct wlr_pixel_format_info *info,
|
||||||
uint32_t convert_wl_shm_format_to_drm(enum wl_shm_format fmt);
|
uint32_t convert_wl_shm_format_to_drm(enum wl_shm_format fmt);
|
||||||
enum wl_shm_format convert_drm_format_to_wl_shm(uint32_t fmt);
|
enum wl_shm_format convert_drm_format_to_wl_shm(uint32_t fmt);
|
||||||
|
|
||||||
|
char *get_drm_format_description(uint32_t format);
|
||||||
|
char *get_drm_modifier_description(uint64_t modifier);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "render/allocator/gbm.h"
|
#include "render/allocator/gbm.h"
|
||||||
#include "render/drm_format_set.h"
|
#include "render/drm_format_set.h"
|
||||||
|
#include "render/pixel_format.h"
|
||||||
|
|
||||||
static const struct wlr_buffer_impl buffer_impl;
|
static const struct wlr_buffer_impl buffer_impl;
|
||||||
|
|
||||||
|
|
@ -139,15 +140,13 @@ static struct wlr_gbm_buffer *create_buffer(struct wlr_gbm_allocator *alloc,
|
||||||
buffer->dmabuf.modifier = fallback_modifier;
|
buffer->dmabuf.modifier = fallback_modifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *format_name = drmGetFormatName(buffer->dmabuf.format);
|
char *format_desc = get_drm_format_description(buffer->dmabuf.format);
|
||||||
char *modifier_name = drmGetFormatModifierName(buffer->dmabuf.modifier);
|
char *modifier_desc = get_drm_modifier_description(buffer->dmabuf.modifier);
|
||||||
wlr_log(WLR_DEBUG, "Allocated %dx%d GBM buffer "
|
wlr_log(WLR_DEBUG, "Allocated %dx%d GBM buffer with format %s, modifier %s",
|
||||||
"with format %s (0x%08"PRIX32"), modifier %s (0x%016"PRIX64")",
|
|
||||||
buffer->base.width, buffer->base.height,
|
buffer->base.width, buffer->base.height,
|
||||||
format_name ? format_name : "<unknown>", buffer->dmabuf.format,
|
format_desc, modifier_desc);
|
||||||
modifier_name ? modifier_name : "<unknown>", buffer->dmabuf.modifier);
|
free(format_desc);
|
||||||
free(format_name);
|
free(modifier_desc);
|
||||||
free(modifier_name);
|
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
15
render/egl.c
15
render/egl.c
|
|
@ -11,6 +11,7 @@
|
||||||
#include <wlr/util/region.h>
|
#include <wlr/util/region.h>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
#include "render/egl.h"
|
#include "render/egl.h"
|
||||||
|
#include "render/pixel_format.h"
|
||||||
#include "util/env.h"
|
#include "util/env.h"
|
||||||
|
|
||||||
static enum wlr_log_importance egl_log_importance_to_wlr(EGLint type) {
|
static enum wlr_log_importance egl_log_importance_to_wlr(EGLint type) {
|
||||||
|
|
@ -100,10 +101,9 @@ static int get_egl_dmabuf_modifiers(struct wlr_egl *egl, EGLint format,
|
||||||
uint64_t **modifiers, EGLBoolean **external_only);
|
uint64_t **modifiers, EGLBoolean **external_only);
|
||||||
|
|
||||||
static void log_modifier(uint64_t modifier, bool external_only) {
|
static void log_modifier(uint64_t modifier, bool external_only) {
|
||||||
char *mod_name = drmGetFormatModifierName(modifier);
|
char *mod_desc = get_drm_modifier_description(modifier);
|
||||||
wlr_log(WLR_DEBUG, " %s (0x%016"PRIX64"): ✓ texture %s render",
|
wlr_log(WLR_DEBUG, " %s: ✓ texture %s render", mod_desc, external_only ? "✗" : "✓");
|
||||||
mod_name ? mod_name : "<unknown>", modifier, external_only ? "✗" : "✓");
|
free(mod_desc);
|
||||||
free(mod_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_dmabuf_formats(struct wlr_egl *egl) {
|
static void init_dmabuf_formats(struct wlr_egl *egl) {
|
||||||
|
|
@ -166,10 +166,9 @@ static void init_dmabuf_formats(struct wlr_egl *egl) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wlr_log_get_verbosity() >= WLR_DEBUG) {
|
if (wlr_log_get_verbosity() >= WLR_DEBUG) {
|
||||||
char *fmt_name = drmGetFormatName(fmt);
|
char *fmt_desc = get_drm_format_description(fmt);
|
||||||
wlr_log(WLR_DEBUG, " %s (0x%08"PRIX32")",
|
wlr_log(WLR_DEBUG, " %s", fmt_desc);
|
||||||
fmt_name ? fmt_name : "<unknown>", fmt);
|
free(fmt_desc);
|
||||||
free(fmt_name);
|
|
||||||
|
|
||||||
log_modifier(DRM_FORMAT_MOD_INVALID, false);
|
log_modifier(DRM_FORMAT_MOD_INVALID, false);
|
||||||
if (modifiers_len == 0) {
|
if (modifiers_len == 0) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <drm_fourcc.h>
|
#include <drm_fourcc.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
#include <xf86drm.h>
|
||||||
#include "render/pixel_format.h"
|
#include "render/pixel_format.h"
|
||||||
|
|
||||||
static const struct wlr_pixel_format_info pixel_format_info[] = {
|
static const struct wlr_pixel_format_info pixel_format_info[] = {
|
||||||
|
|
@ -211,3 +214,38 @@ bool pixel_format_info_check_stride(const struct wlr_pixel_format_info *fmt,
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *format_str(const char *fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
int len = vsnprintf(NULL, 0, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
if (len < 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *str = malloc(len + 1);
|
||||||
|
if (str == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
vsnprintf(str, len + 1, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *get_drm_format_description(uint32_t format) {
|
||||||
|
char *name = drmGetFormatName(format);
|
||||||
|
char *str = format_str("%s (0x%08"PRIX32")", name ? name : "<unknown>", format);
|
||||||
|
free(name);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *get_drm_modifier_description(uint64_t modifier) {
|
||||||
|
char *name = drmGetFormatModifierName(modifier);
|
||||||
|
char *str = format_str("%s (0x%016"PRIX64")", name ? name : "<unknown>", modifier);
|
||||||
|
free(name);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include <xf86drm.h>
|
#include "render/pixel_format.h"
|
||||||
#include "render/vulkan.h"
|
#include "render/vulkan.h"
|
||||||
|
|
||||||
static const struct wlr_vk_format formats[] = {
|
static const struct wlr_vk_format formats[] = {
|
||||||
|
|
@ -333,12 +333,10 @@ static bool query_modifier_support(struct wlr_vk_device *dev,
|
||||||
snprintf(texture_status, sizeof(texture_status), "✓ texture");
|
snprintf(texture_status, sizeof(texture_status), "✓ texture");
|
||||||
}
|
}
|
||||||
|
|
||||||
char *modifier_name = drmGetFormatModifierName(m.drmFormatModifier);
|
char *modifier_desc = get_drm_modifier_description(m.drmFormatModifier);
|
||||||
wlr_log(WLR_DEBUG, " DMA-BUF modifier %s "
|
wlr_log(WLR_DEBUG, " DMA-BUF modifier %s: %"PRIu32" planes, %s %s",
|
||||||
"(0x%016"PRIX64", %"PRIu32" planes): %s %s",
|
modifier_desc, m.drmFormatModifierPlaneCount, texture_status, render_status);
|
||||||
modifier_name ? modifier_name : "<unknown>", m.drmFormatModifier,
|
free(modifier_desc);
|
||||||
m.drmFormatModifierPlaneCount, texture_status, render_status);
|
|
||||||
free(modifier_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(modp.pDrmFormatModifierProperties);
|
free(modp.pDrmFormatModifierProperties);
|
||||||
|
|
@ -353,10 +351,9 @@ void vulkan_format_props_query(struct wlr_vk_device *dev,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *format_name = drmGetFormatName(format->drm);
|
char *format_desc = get_drm_format_description(format->drm);
|
||||||
wlr_log(WLR_DEBUG, " %s (0x%08"PRIX32")",
|
wlr_log(WLR_DEBUG, " %s", format_desc);
|
||||||
format_name ? format_name : "<unknown>", format->drm);
|
free(format_desc);
|
||||||
free(format_name);
|
|
||||||
|
|
||||||
VkDrmFormatModifierPropertiesListEXT modp = {
|
VkDrmFormatModifierPropertiesListEXT modp = {
|
||||||
.sType = VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT,
|
.sType = VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT,
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#include <wlr/render/allocator.h>
|
#include <wlr/render/allocator.h>
|
||||||
#include <wlr/render/swapchain.h>
|
#include <wlr/render/swapchain.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include <xf86drm.h>
|
|
||||||
|
|
||||||
#include "render/drm_format_set.h"
|
#include "render/drm_format_set.h"
|
||||||
|
#include "render/pixel_format.h"
|
||||||
#include "types/wlr_output.h"
|
#include "types/wlr_output.h"
|
||||||
|
|
||||||
static struct wlr_swapchain *create_swapchain(struct wlr_output *output,
|
static struct wlr_swapchain *create_swapchain(struct wlr_output *output,
|
||||||
|
|
@ -24,10 +24,10 @@ static struct wlr_swapchain *create_swapchain(struct wlr_output *output,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *format_name = drmGetFormatName(format->format);
|
char *format_desc = get_drm_format_description(format->format);
|
||||||
wlr_log(WLR_DEBUG, "Choosing primary buffer format %s (0x%08"PRIX32") for output '%s'",
|
wlr_log(WLR_DEBUG, "Choosing primary buffer format %s for output '%s'",
|
||||||
format_name ? format_name : "<unknown>", format->format, output->name);
|
format_desc, output->name);
|
||||||
free(format_name);
|
free(format_desc);
|
||||||
|
|
||||||
if (!allow_modifiers && (format->len != 1 || format->modifiers[0] != DRM_FORMAT_MOD_LINEAR)) {
|
if (!allow_modifiers && (format->len != 1 || format->modifiers[0] != DRM_FORMAT_MOD_LINEAR)) {
|
||||||
if (!wlr_drm_format_has(format, DRM_FORMAT_MOD_INVALID)) {
|
if (!wlr_drm_format_has(format, DRM_FORMAT_MOD_INVALID)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue