Mesa (main): gallium/dri: Add Y21x formats

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 21 02:07:16 UTC 2021


Module: Mesa
Branch: main
Commit: 2fdd9b86043e358d60eaa3e8fc80d2a3994d9456
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2fdd9b86043e358d60eaa3e8fc80d2a3994d9456

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Fri Mar 12 12:45:58 2021 -0800

gallium/dri: Add Y21x formats

v2: Add all the Y21x tests to the A530 expected fail list.  All of the
YUV image import tests fail on this platform, and nobody has been able
to investigate why.

v3: Update the comment describing the zeroed bits in Y212.  Suggested by
Emma.

v4: Add all Y21x test to the rpi3 expected fail list.

Reviewed-by: Emma Anholt <emma at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9610>

---

 src/broadcom/ci/piglit-vc4-rpi3-fails.txt          |  3 +++
 .../freedreno/ci/piglit-freedreno-a530-fails.txt   |  3 +++
 src/gallium/frontends/dri/dri_helpers.c            | 23 +++++++++++++++++++++-
 src/mesa/state_tracker/st_atom_sampler.c           |  3 +++
 src/mesa/state_tracker/st_atom_texture.c           | 11 +++++++++++
 src/mesa/state_tracker/st_cb_eglimage.c            | 16 +++++++++++++++
 src/mesa/state_tracker/st_program.h                |  3 +++
 src/mesa/state_tracker/st_sampler_view.c           |  5 +++++
 8 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/src/broadcom/ci/piglit-vc4-rpi3-fails.txt b/src/broadcom/ci/piglit-vc4-rpi3-fails.txt
index f2cb3178cd6..43cbe70cd4a 100644
--- a/src/broadcom/ci/piglit-vc4-rpi3-fails.txt
+++ b/src/broadcom/ci/piglit-vc4-rpi3-fails.txt
@@ -268,6 +268,9 @@ spec at ext_image_dma_buf_import@ext_image_dma_buf_import-export,Fail
 spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_p010,Fail
 spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_p012,Fail
 spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_p016,Fail
+spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y210,Fail
+spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y212,Fail
+spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y216,Fail
 spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y410,Fail
 spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y412,Fail
 spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y416,Fail
diff --git a/src/gallium/drivers/freedreno/ci/piglit-freedreno-a530-fails.txt b/src/gallium/drivers/freedreno/ci/piglit-freedreno-a530-fails.txt
index e7a7abf48c5..3a15fd3de11 100644
--- a/src/gallium/drivers/freedreno/ci/piglit-freedreno-a530-fails.txt
+++ b/src/gallium/drivers/freedreno/ci/piglit-freedreno-a530-fails.txt
@@ -224,6 +224,9 @@ spec at ext_image_dma_buf_import@ext_image_dma_buf_import-export,Fail
 spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_p010,Fail
 spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_p012,Fail
 spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_p016,Fail
+spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y210,Fail
+spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y212,Fail
+spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y216,Fail
 spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y412,Fail
 spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_y416,Fail
 spec at ext_image_dma_buf_import@ext_image_dma_buf_import-sample_uyvy,Fail
diff --git a/src/gallium/frontends/dri/dri_helpers.c b/src/gallium/frontends/dri/dri_helpers.c
index bff99d8bdce..4170a4c9533 100644
--- a/src/gallium/frontends/dri/dri_helpers.c
+++ b/src/gallium/frontends/dri/dri_helpers.c
@@ -580,7 +580,28 @@ static const struct dri2_format_mapping dri2_format_table[] = {
       { DRM_FORMAT_UYVY,          __DRI_IMAGE_FORMAT_NONE,
         __DRI_IMAGE_COMPONENTS_Y_UXVX,    PIPE_FORMAT_UYVY, 2,
         { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88 },
-          { 0, 1, 0, __DRI_IMAGE_FORMAT_ABGR8888 } } }
+          { 0, 1, 0, __DRI_IMAGE_FORMAT_ABGR8888 } } },
+
+      /* The Y21x formats work in a similar fashion to the YUYV and UYVY
+       * formats.
+       */
+      { DRM_FORMAT_Y210,          __DRI_IMAGE_FORMAT_NONE,
+        __DRI_IMAGE_COMPONENTS_Y_XUXV,    PIPE_FORMAT_Y210, 2,
+        { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR1616 },
+          { 0, 1, 0, __DRI_IMAGE_FORMAT_ABGR16161616 } } },
+      /* Y212 is an unusual format.  It has the same layout as Y216 (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_Y212,          __DRI_IMAGE_FORMAT_NONE,
+        __DRI_IMAGE_COMPONENTS_Y_XUXV,    PIPE_FORMAT_Y212, 2,
+        { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR1616 },
+          { 0, 1, 0, __DRI_IMAGE_FORMAT_ABGR16161616 } } },
+      { DRM_FORMAT_Y216,          __DRI_IMAGE_FORMAT_NONE,
+        __DRI_IMAGE_COMPONENTS_Y_XUXV,    PIPE_FORMAT_Y216, 2,
+        { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR1616 },
+          { 0, 1, 0, __DRI_IMAGE_FORMAT_ABGR16161616 } } },
 };
 
 const struct dri2_format_mapping *
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index fa68acccfcf..6810a98fc1c 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -358,6 +358,9 @@ update_shader_samplers(struct st_context *st,
       case PIPE_FORMAT_P010:
       case PIPE_FORMAT_P012:
       case PIPE_FORMAT_P016:
+      case PIPE_FORMAT_Y210:
+      case PIPE_FORMAT_Y212:
+      case PIPE_FORMAT_Y216:
       case PIPE_FORMAT_YUYV:
       case PIPE_FORMAT_UYVY:
          /* we need one additional sampler: */
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index f42cac58856..eafccfe87ca 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -238,6 +238,17 @@ update_textures(struct st_context *st,
          sampler_views[extra] =
                pipe->create_sampler_view(pipe, stObj->pt->next, &tmpl);
          break;
+      case PIPE_FORMAT_Y210:
+      case PIPE_FORMAT_Y212:
+      case PIPE_FORMAT_Y216:
+         /* we need one additional R16G16B16A16 view: */
+         tmpl.format = PIPE_FORMAT_R16G16B16A16_UNORM;
+         tmpl.swizzle_b = PIPE_SWIZZLE_Z;
+         tmpl.swizzle_a = PIPE_SWIZZLE_W;
+         extra = u_bit_scan(&free_slots);
+         sampler_views[extra] =
+               pipe->create_sampler_view(pipe, stObj->pt->next, &tmpl);
+         break;
       default:
          break;
       }
diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c
index 79bd7f6b0a0..c613ad333bc 100644
--- a/src/mesa/state_tracker/st_cb_eglimage.c
+++ b/src/mesa/state_tracker/st_cb_eglimage.c
@@ -79,6 +79,16 @@ is_format_supported(struct pipe_screen *screen, enum pipe_format format,
                                                  PIPE_TEXTURE_2D, nr_samples,
                                                  nr_storage_samples, usage);
          break;
+      case PIPE_FORMAT_Y210:
+      case PIPE_FORMAT_Y212:
+      case PIPE_FORMAT_Y216:
+         supported = screen->is_format_supported(screen, PIPE_FORMAT_R16G16_UNORM,
+                                                 PIPE_TEXTURE_2D, nr_samples,
+                                                 nr_storage_samples, usage) &&
+                     screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_UNORM,
+                                                 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,
@@ -294,6 +304,12 @@ st_bind_egl_image(struct gl_context *ctx,
          texFormat = MESA_FORMAT_R_UNORM16;
          texObj->RequiredTextureImageUnits = 2;
          break;
+      case PIPE_FORMAT_Y210:
+      case PIPE_FORMAT_Y212:
+      case PIPE_FORMAT_Y216:
+         texFormat = MESA_FORMAT_RG_UNORM16;
+         texObj->RequiredTextureImageUnits = 2;
+         break;
       case PIPE_FORMAT_Y410:
          texFormat = MESA_FORMAT_B10G10R10A2_UNORM;
          internalFormat = GL_RGBA;
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
index dcd51dcae8b..7cff5cc64ae 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -95,6 +95,9 @@ st_get_external_sampler_key(struct st_context *st, struct gl_program *prog)
          key.lower_iyuv |= (1 << unit);
          break;
       case PIPE_FORMAT_YUYV:
+      case PIPE_FORMAT_Y210:
+      case PIPE_FORMAT_Y212:
+      case PIPE_FORMAT_Y216:
          key.lower_yx_xuxv |= (1 << unit);
          break;
       case PIPE_FORMAT_UYVY:
diff --git a/src/mesa/state_tracker/st_sampler_view.c b/src/mesa/state_tracker/st_sampler_view.c
index 353b2bb9417..3e5bf387718 100644
--- a/src/mesa/state_tracker/st_sampler_view.c
+++ b/src/mesa/state_tracker/st_sampler_view.c
@@ -511,6 +511,11 @@ get_sampler_view_format(struct st_context *st,
    case PIPE_FORMAT_P016:
       format = PIPE_FORMAT_R16_UNORM;
       break;
+   case PIPE_FORMAT_Y210:
+   case PIPE_FORMAT_Y212:
+   case PIPE_FORMAT_Y216:
+      format = PIPE_FORMAT_R16G16_UNORM;
+      break;
    case PIPE_FORMAT_Y410:
       format = PIPE_FORMAT_R10G10B10A2_UNORM;
       break;



More information about the mesa-commit mailing list