gallium/dri: Add Y41x formats

v2: Don't leak __DRI_IMAGE_FOURCC_RGBA16161616 to applications.

v3: Fix typo in __DRI_IMAGE_FOURCC_RGBA16161616 table entry.

v4: Add the Y412 and Y416 tests to the A530 expected fail list.  Many
YUV image import tests fail on this platform, and nobody has been able
to investigate why.

v5: Update the comment describing the zeroed bits in Y412.  Suggested by
Emma.

v6: Add all Y41x test to the rpi3 expected fail list.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9610>
This commit is contained in:
Ian Romanick 2021-03-10 20:55:08 -08:00 committed by Marge Bot
parent 410c94926c
commit 3c4c03cd13
8 changed files with 67 additions and 3 deletions

View File

@ -1366,6 +1366,7 @@ struct __DRIdri2ExtensionRec {
#define __DRI_IMAGE_FORMAT_XBGR16161616F 0x1014
#define __DRI_IMAGE_FORMAT_ABGR16161616F 0x1015
#define __DRI_IMAGE_FORMAT_SXRGB8 0x1016
#define __DRI_IMAGE_FORMAT_ABGR16161616 0x1017
#define __DRI_IMAGE_USE_SHARE 0x0001
#define __DRI_IMAGE_USE_SCANOUT 0x0002
@ -1395,6 +1396,7 @@ struct __DRIdri2ExtensionRec {
#define __DRI_IMAGE_FOURCC_SARGB8888 0x83324258
#define __DRI_IMAGE_FOURCC_SABGR8888 0x84324258
#define __DRI_IMAGE_FOURCC_SXRGB8888 0x85324258
#define __DRI_IMAGE_FOURCC_RGBA16161616 0x38344152 /* fourcc_code('R', 'A', '4', '8' ) */
/**
* Queryable on images created by createImageFromNames.

View File

@ -269,6 +269,8 @@ spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_p010,Fail
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_p012,Fail
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_p016,Fail
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y410,Fail
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y412,Fail
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y416,Fail
spec@ext_occlusion_query_boolean@any-samples,Fail
spec@ext_packed_depth_stencil@depth_stencil texture,Fail
spec@ext_packed_depth_stencil@fbo-depthstencil-gl_depth24_stencil8-clear,Fail

View File

@ -224,6 +224,8 @@ spec@ext_image_dma_buf_import@ext_image_dma_buf_import-export,Fail
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_p010,Fail
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_p012,Fail
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_p016,Fail
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y412,Fail
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y416,Fail
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_uyvy,Fail
spec@ext_image_dma_buf_import@ext_image_dma_buf_import-sample_yuyv,Fail
spec@ext_packed_depth_stencil@fbo-clear-formats,Fail

View File

@ -418,6 +418,9 @@ static const struct dri2_format_mapping dri2_format_table[] = {
{ DRM_FORMAT_XBGR16161616F, __DRI_IMAGE_FORMAT_XBGR16161616F,
__DRI_IMAGE_COMPONENTS_RGB, PIPE_FORMAT_R16G16B16X16_FLOAT, 1,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_XBGR16161616F } } },
{ __DRI_IMAGE_FOURCC_RGBA16161616, __DRI_IMAGE_FORMAT_ABGR16161616,
__DRI_IMAGE_COMPONENTS_RGBA, PIPE_FORMAT_R16G16B16A16_UNORM, 1,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_ABGR16161616 } } },
{ DRM_FORMAT_ARGB2101010, __DRI_IMAGE_FORMAT_ARGB2101010,
__DRI_IMAGE_COMPONENTS_RGBA, PIPE_FORMAT_B10G10R10A2_UNORM, 1,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_ARGB2101010 } } },
@ -546,6 +549,22 @@ static const struct dri2_format_mapping dri2_format_table[] = {
__DRI_IMAGE_COMPONENTS_XYUV, PIPE_FORMAT_XYUV, 1,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_XBGR8888 } } },
{ DRM_FORMAT_Y410, __DRI_IMAGE_FORMAT_ABGR2101010,
__DRI_IMAGE_COMPONENTS_AYUV, PIPE_FORMAT_Y410, 1,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_ABGR2101010 } } },
/* Y412 is an unusual format. It has the same layout as Y416 (i.e.,
* 16-bits of physical storage per channel), but the low 4 bits of each
* component are unused padding. The writer is supposed to write zeros
* to these bits.
*/
{ DRM_FORMAT_Y412, __DRI_IMAGE_FORMAT_ABGR16161616,
__DRI_IMAGE_COMPONENTS_AYUV, PIPE_FORMAT_Y412, 1,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_ABGR16161616 } } },
{ DRM_FORMAT_Y416, __DRI_IMAGE_FORMAT_ABGR16161616,
__DRI_IMAGE_COMPONENTS_AYUV, PIPE_FORMAT_Y416, 1,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_ABGR16161616 } } },
/* For YUYV and UYVY buffers, we set up two overlapping DRI images
* and treat them as planar buffers in the compositors.
* Plane 0 is GR88 and samples YU or YV pairs and places Y into
@ -628,9 +647,12 @@ dri2_query_dma_buf_formats(__DRIscreen *_screen, int max, int *formats,
const struct dri2_format_mapping *map = &dri2_format_table[i];
/* The sRGB format is not a real FourCC as defined by drm_fourcc.h, so we
* must not leak it out to clients.
* must not leak it out to clients. The RGBA16161616 format isn't
* real either, but at some point it could be. Don't leak it out form
* now.
*/
if (dri2_format_table[i].dri_fourcc == __DRI_IMAGE_FOURCC_SARGB8888)
if (dri2_format_table[i].dri_fourcc == __DRI_IMAGE_FOURCC_SARGB8888 ||
dri2_format_table[i].dri_fourcc == __DRI_IMAGE_FOURCC_RGBA16161616)
continue;
if (pscreen->is_format_supported(pscreen, map->pipe_format,

View File

@ -79,6 +79,17 @@ is_format_supported(struct pipe_screen *screen, enum pipe_format format,
PIPE_TEXTURE_2D, nr_samples,
nr_storage_samples, usage);
break;
case PIPE_FORMAT_Y410:
supported = screen->is_format_supported(screen, PIPE_FORMAT_R10G10B10A2_UNORM,
PIPE_TEXTURE_2D, nr_samples,
nr_storage_samples, usage);
break;
case PIPE_FORMAT_Y412:
case PIPE_FORMAT_Y416:
supported = screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_UNORM,
PIPE_TEXTURE_2D, nr_samples,
nr_storage_samples, usage);
break;
case PIPE_FORMAT_YUYV:
supported = screen->is_format_supported(screen, PIPE_FORMAT_RG88_UNORM,
PIPE_TEXTURE_2D, nr_samples,
@ -283,6 +294,17 @@ st_bind_egl_image(struct gl_context *ctx,
texFormat = MESA_FORMAT_R_UNORM16;
texObj->RequiredTextureImageUnits = 2;
break;
case PIPE_FORMAT_Y410:
texFormat = MESA_FORMAT_B10G10R10A2_UNORM;
internalFormat = GL_RGBA;
texObj->RequiredTextureImageUnits = 1;
break;
case PIPE_FORMAT_Y412:
case PIPE_FORMAT_Y416:
texFormat = MESA_FORMAT_RGBA_UNORM16;
internalFormat = GL_RGBA;
texObj->RequiredTextureImageUnits = 1;
break;
case PIPE_FORMAT_IYUV:
texFormat = MESA_FORMAT_R_UNORM8;
texObj->RequiredTextureImageUnits = 3;

View File

@ -1455,7 +1455,7 @@ st_create_fp_variant(struct st_context *st,
if (unlikely(key->external.lower_nv12 || key->external.lower_iyuv ||
key->external.lower_xy_uxvx || key->external.lower_yx_xuxv ||
key->external.lower_ayuv || key->external.lower_xyuv ||
key->external.lower_yuv)) {
key->external.lower_yuv || key->external.lower_y41x)) {
st_nir_lower_samplers(st->screen, state.ir.nir,
stfp->shader_program, &stfp->Base);
@ -1468,6 +1468,7 @@ st_create_fp_variant(struct st_context *st,
options.lower_ayuv_external = key->external.lower_ayuv;
options.lower_xyuv_external = key->external.lower_xyuv;
options.lower_yuv_external = key->external.lower_yuv;
options.lower_y41x_external = key->external.lower_y41x;
NIR_PASS_V(state.ir.nir, nir_lower_tex, &options);
finalize = true;
need_lower_tex_src_plane = true;

View File

@ -58,6 +58,7 @@ struct st_external_sampler_key
GLuint lower_ayuv;
GLuint lower_xyuv;
GLuint lower_yuv;
GLuint lower_y41x;
};
static inline struct st_external_sampler_key
@ -105,6 +106,11 @@ st_get_external_sampler_key(struct st_context *st, struct gl_program *prog)
case PIPE_FORMAT_XYUV:
key.lower_xyuv |= (1 << unit);
break;
case PIPE_FORMAT_Y410:
case PIPE_FORMAT_Y412:
case PIPE_FORMAT_Y416:
key.lower_y41x |= (1 << unit);
break;
default:
printf("mesa: st_get_external_sampler_key: unhandled pipe format %u\n",
format);

View File

@ -511,6 +511,13 @@ get_sampler_view_format(struct st_context *st,
case PIPE_FORMAT_P016:
format = PIPE_FORMAT_R16_UNORM;
break;
case PIPE_FORMAT_Y410:
format = PIPE_FORMAT_R10G10B10A2_UNORM;
break;
case PIPE_FORMAT_Y412:
case PIPE_FORMAT_Y416:
format = PIPE_FORMAT_R16G16B16A16_UNORM;
break;
case PIPE_FORMAT_YUYV:
case PIPE_FORMAT_UYVY:
format = PIPE_FORMAT_R8G8_UNORM;