SDL
SDL copied to clipboard
testffmpeg doesn't set dma_buf format modifiers
Hi,
The SDL testffmpeg.c program renders corrupted output for me:
This is on Linux, with an Intel Arc A310 GPU. The problem is that the DRM surface is using the "Intel Tile 4 layout":
/*
* Intel Tile 4 layout
*
* This is a tiled layout using 4KB tiles in a row-major layout. It has the same
* shape as Tile Y at two granularities: 4KB (128B x 32) and 64B (16B x 4). It
* only differs from Tile Y at the 256B granularity in between. At this
* granularity, Tile Y has a shape of 16B x 32 rows, but this tiling has a shape
* of 64B x 8 rows.
*/
#define I915_FORMAT_MOD_4_TILED fourcc_mod_code(INTEL, 9)
I was able to get testffmpeg to work on my system by propagating the DRM format modifier from the AVDRMObjectDescriptor
to eglCreateImage()
:
diff --git a/test/testffmpeg.c b/test/testffmpeg.c
index d1b8e0901..4bde9562f 100644
--- a/test/testffmpeg.c
+++ b/test/testffmpeg.c
@@ -625,6 +625,8 @@ static SDL_bool GetTextureForDRMFrame(AVFrame *frame, SDL_Texture **texture)
EGL_DMA_BUF_PLANE0_FD_EXT, object->fd,
EGL_DMA_BUF_PLANE0_OFFSET_EXT, plane->offset,
EGL_DMA_BUF_PLANE0_PITCH_EXT, plane->pitch,
+ EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, (object->format_modifier >> 0) & 0xFFFFFFFF,
+ EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT, (object->format_modifier >> 32) & 0xFFFFFFFF,
EGL_NONE
};
EGLImage pImage = eglCreateImage(display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, img_attr);
Technically, I guess this also requires checking for the presence of the EGL_EXT_image_dma_buf_import_modifiers
extension.