From: David Stevens Date: Thu, 30 Jul 2020 09:44:41 +0000 (+0900) Subject: i965/i915: Add colorspace support to YUV sampling X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6c11a7994dd8937035f4f9e49b63dd18b015bce6;p=mesa.git i965/i915: Add colorspace support to YUV sampling Reviewed-by: Lionel Landwerlin Reviewed-by: Rob Clark Part-of: --- diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h index d5ec740225e..ccbb5cc6409 100644 --- a/src/intel/compiler/brw_compiler.h +++ b/src/intel/compiler/brw_compiler.h @@ -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]; diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c index aac9c0d7aa5..9a6914f92f2 100644 --- a/src/intel/compiler/brw_nir.c +++ b/src/intel/compiler/brw_nir.c @@ -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, diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index 3bee666cec8..44d59603477 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -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; + } } } diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c index b1f86a6ba71..c0a4a9c2ca9 100644 --- a/src/mesa/drivers/dri/i965/intel_tex_image.c +++ b/src/mesa/drivers/dri/i965/intel_tex_image.c @@ -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 ? diff --git a/src/mesa/drivers/dri/i965/intel_tex_obj.h b/src/mesa/drivers/dri/i965/intel_tex_obj.h index 526f5ceb478..7338ec2821c 100644 --- a/src/mesa/drivers/dri/i965/intel_tex_obj.h +++ b/src/mesa/drivers/dri/i965/intel_tex_obj.h @@ -63,6 +63,7 @@ struct intel_texture_object mesa_format _Format; const struct intel_image_format *planar_format; + unsigned int yuv_color_space; };