etnaviv 16-bit DMA buffer import
I'm trying to use 16-bit depth grayscale buffers with etnaviv. There's an issue where I can't import a previously allocated DMA buffer.
The code I use for the import:
EGLint const attrs[] = {
EGL_WIDTH, (int)pixelSize.width,
EGL_HEIGHT, (int)pixelSize.height,
EGL_LINUX_DRM_FOURCC_EXT, (int)format.get_fourcc(),
EGL_DMA_BUF_PLANE0_FD_EXT, fd,
EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
EGL_DMA_BUF_PLANE0_PITCH_EXT, (int)pixelSize.width * bytes_per_pixel,
EGL_NONE,
};
auto eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR");
auto image = eglCreateImageKHR (
egl.display,
EGL_NO_CONTEXT,
EGL_LINUX_DMA_BUF_EXT,
NULL,
attrs
);
eglCreateImageKHR will always fail. The reason is that the fourcc is R16
, and it gets converted internally into PIPE_FORMAT_R16_UNORM
via dri2_get_mapping_by_fourcc
in dri2_create_image_from_fd
. The vivante hardware doesn't seem to support 16-bit unorm types, so it is guaranteed to fail.
Vivante does support PIPE_FORMAT_R16_UINT
at least in some hardware versions, but there's currently no way to request a buffer of this type.
Should PIPE_FORMAT_R16_UNORM
be unconditionally converted into PIPE_FORMAT_R16_UINT
for importing? Both satisfy user's fourcc request for a R16 type.