Commit a62dbc66 authored by Pekka Paalanen's avatar Pekka Paalanen Committed by Jonas Ådahl

renderer/native: Debug print chosen secondary FB format

Print the pixel format chosen for an output on a secondary GPU for
debugging. Knowing the format can aid in debugging e.g. red/blue channel
swaps and CPU copy performance issues.

This adds a DRM format printing helper in meta-crtc-kms.h. This header
is included in most native backend files making it widely available,
while DRM formats are specific to the native backend. It could be shared
with Wayland bits, DRM format codes are used there too.

The helper makes the pixel format much more readable than a "%x".

parent 442dcc78
......@@ -30,6 +30,11 @@
#include "backends/meta-backend-private.h"
#include "backends/native/meta-gpu-kms.h"
/* added in libdrm 2.4.95 */
......@@ -52,6 +57,39 @@ typedef struct _MetaCrtcKms
GHashTable *formats_modifiers;
} MetaCrtcKms;
* meta_drm_format_to_string:
* @tmp: temporary buffer
* @drm_format: DRM fourcc pixel format
* Returns a pointer to a string naming the given pixel format,
* usually a pointer to the temporary buffer but not always.
* Invalid formats may return nonsense names.
* When calling this, allocate one MetaDrmFormatBuf on the stack to
* be used as the temporary buffer.
const char *
meta_drm_format_to_string (MetaDrmFormatBuf *tmp,
uint32_t drm_format)
int i;
if (drm_format == DRM_FORMAT_INVALID)
return "INVALID";
G_STATIC_ASSERT (sizeof (tmp->s) == 5);
for (i = 0; i < 4; i++)
char c = (drm_format >> (i * 8)) & 0xff;
tmp->s[i] = g_ascii_isgraph (c) ? c : '.';
tmp->s[i] = 0;
return tmp->s;
meta_crtc_kms_is_transform_handled (MetaCrtc *crtc,
MetaMonitorTransform transform)
......@@ -30,6 +30,15 @@
#include "backends/meta-crtc.h"
#include "backends/native/meta-gpu-kms.h"
typedef struct _MetaDrmFormatBuf
char s[5];
} MetaDrmFormatBuf;
const char *
meta_drm_format_to_string (MetaDrmFormatBuf *tmp,
uint32_t format);
gboolean meta_crtc_kms_is_transform_handled (MetaCrtc *crtc,
MetaMonitorTransform transform);
......@@ -803,6 +803,7 @@ init_secondary_gpu_state_cpu_copy_mode (MetaRendererNative *renderer_nat
int width, height;
unsigned int i;
uint32_t drm_format;
MetaDrmFormatBuf tmp;
drm_format = pick_secondary_gpu_framebuffer_format_for_cpu (onscreen,
META_GPU (gpu_kms));
......@@ -816,6 +817,12 @@ init_secondary_gpu_state_cpu_copy_mode (MetaRendererNative *renderer_nat
width = cogl_framebuffer_get_width (framebuffer);
height = cogl_framebuffer_get_height (framebuffer);
g_debug ("Secondary GPU %s using DRM format '%s' (0x%x) for a %dx%d output.",
meta_gpu_kms_get_file_path (gpu_kms),
meta_drm_format_to_string (&tmp, drm_format),
width, height);
secondary_gpu_state = g_new0 (MetaOnscreenNativeSecondaryGpuState, 1);
secondary_gpu_state->renderer_gpu_data = renderer_gpu_data;
secondary_gpu_state->gpu_kms = gpu_kms;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment