i965/i915: Add colorspace support to YUV sampling
authorDavid Stevens <stevensd@chromium.org>
Thu, 30 Jul 2020 09:44:41 +0000 (18:44 +0900)
committerMarge Bot <eric+marge@anholt.net>
Fri, 31 Jul 2020 07:27:03 +0000 (07:27 +0000)
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6122>

src/intel/compiler/brw_compiler.h
src/intel/compiler/brw_nir.c
src/mesa/drivers/dri/i965/brw_wm.c
src/mesa/drivers/dri/i965/intel_tex_image.c
src/mesa/drivers/dri/i965/intel_tex_obj.h

index d5ec740225eee26454a2c14576fecdef117002e5..ccbb5cc640903e87ab68642868250ae87cf183bf 100644 (file)
@@ -210,6 +210,8 @@ struct brw_sampler_prog_key_data {
    uint32_t xy_uxvx_image_mask;
    uint32_t ayuv_image_mask;
    uint32_t xyuv_image_mask;
+   uint32_t bt709_mask;
+   uint32_t bt2020_mask;
 
    /* Scale factor for each texture. */
    float scale_factors[32];
index aac9c0d7aa5edb80856406b12c33adc0e65a0ace..9a6914f92f257e57f0d5dd615ed64f19e11eacd6 100644 (file)
@@ -1073,6 +1073,8 @@ brw_nir_apply_sampler_key(nir_shader *nir,
    tex_options.lower_xy_uxvx_external = key_tex->xy_uxvx_image_mask;
    tex_options.lower_ayuv_external = key_tex->ayuv_image_mask;
    tex_options.lower_xyuv_external = key_tex->xyuv_image_mask;
+   tex_options.bt709_external = key_tex->bt709_mask;
+   tex_options.bt2020_external = key_tex->bt2020_mask;
 
    /* Setup array of scaling factors for each texture. */
    memcpy(&tex_options.scale_factors, &key_tex->scale_factors,
index 3bee666cec8ac5d9bf12e07abb23a97d58161e36..44d59603477914f4efb884d6690a2bc5e7df2017 100644 (file)
@@ -323,6 +323,17 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
             default:
                break;
             }
+
+            switch (intel_tex->yuv_color_space) {
+            case __DRI_YUV_COLOR_SPACE_ITU_REC709:
+              key->bt709_mask |= 1 << s;
+              break;
+            case __DRI_YUV_COLOR_SPACE_ITU_REC2020:
+              key->bt2020_mask |= 1 << s;
+              break;
+            default:
+              break;
+            }
          }
 
       }
index b1f86a6ba7197c6e0e649c8ab1b3c038d2964932..c0a4a9c2ca9163364830fe1201266f37c393a35c 100644 (file)
@@ -634,6 +634,7 @@ intel_image_target_texture(struct gl_context *ctx, GLenum target,
 
    struct intel_texture_object *intel_texobj = intel_texture_object(texObj);
    intel_texobj->planar_format = image->planar_format;
+   intel_texobj->yuv_color_space = image->yuv_color_space;
 
    GLenum internal_format =
       image->internal_format != 0 ?
index 526f5ceb47804bd6ace567df7a0ffaeae1cc9ff9..7338ec2821c82dbd56f8f2a451cc890ec744fe69 100644 (file)
@@ -63,6 +63,7 @@ struct intel_texture_object
    mesa_format _Format;
 
    const struct intel_image_format *planar_format;
+   unsigned int yuv_color_space;
 };