Discussion:
[PATCH v1 1/3] dri: Add UYVY as available format UYVY is diffrent with YUYV in byte order. YUYV is already declared in dri_interface.h, this CL add the difinitions for UYVY. Drivers can add UYVY as supported format
(too old to reply)
Johnson Lin
2017-06-16 06:24:51 UTC
Permalink
Raw Message
---
include/GL/internal/dri_interface.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index fc2d4bbe22ef..6992da16d5f8 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1211,6 +1211,7 @@ struct __DRIdri2ExtensionRec {
#define __DRI_IMAGE_FOURCC_NV12 0x3231564e
#define __DRI_IMAGE_FOURCC_NV16 0x3631564e
#define __DRI_IMAGE_FOURCC_YUYV 0x56595559
+#define __DRI_IMAGE_FOURCC_UYVY 0x59565955

#define __DRI_IMAGE_FOURCC_YVU410 0x39555659
#define __DRI_IMAGE_FOURCC_YVU411 0x31315659
@@ -1224,7 +1225,7 @@ struct __DRIdri2ExtensionRec {
* RGB and RGBA are may be usable directly as images but its still
* recommended to call fromPlanar with plane == 0.
*
- * Y_U_V, Y_UV and Y_XUXV all requires call to fromPlanar to create
+ * Y_U_V, Y_UV,Y_XUXV and Y_UXVX all requires call to fromPlanar to create
* usable sub-images, sampling from images return raw YUV data and
* color conversion needs to be done in the shader.
*
@@ -1236,6 +1237,7 @@ struct __DRIdri2ExtensionRec {
#define __DRI_IMAGE_COMPONENTS_Y_U_V 0x3003
#define __DRI_IMAGE_COMPONENTS_Y_UV 0x3004
#define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005
+#define __DRI_IMAGE_COMPONENTS_Y_UXVX 0x3008
#define __DRI_IMAGE_COMPONENTS_R 0x3006
#define __DRI_IMAGE_COMPONENTS_RG 0x3007
--
1.9.1
Johnson Lin
2017-06-16 06:24:52 UTC
Permalink
Raw Message
---
src/compiler/nir/nir.h | 1 +
src/compiler/nir/nir_lower_tex.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index ab7ba14303b7..1b4e47058d4d 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2449,6 +2449,7 @@ typedef struct nir_lower_tex_options {
unsigned lower_y_uv_external;
unsigned lower_y_u_v_external;
unsigned lower_yx_xuxv_external;
+ unsigned lower_xy_uxvx_external;

/**
* To emulate certain texture wrap modes, this can be used
diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c
index 4ef81955513e..5593f9890b28 100644
--- a/src/compiler/nir/nir_lower_tex.c
+++ b/src/compiler/nir/nir_lower_tex.c
@@ -301,6 +301,18 @@ lower_yx_xuxv_external(nir_builder *b, nir_tex_instr *tex)
nir_channel(b, xuxv, 3));
}

+static void lower_xy_uxvx_external(nir_builder *b, nir_tex_instr *tex) {
+ b->cursor = nir_after_instr(&tex->instr);
+
+ nir_ssa_def *y = sample_plane(b, tex, 0);
+ nir_ssa_def *uxvx = sample_plane(b, tex, 1);
+
+ convert_yuv_to_rgb(b, tex,
+ nir_channel(b, y, 1),
+ nir_channel(b, uxvx, 2),
+ nir_channel(b, uxvx, 0));
+}
+
/*
* Emits a textureLod operation used to replace an existing
* textureGrad instruction.
@@ -760,6 +772,10 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
progress = true;
}

+ if ((1 << tex->texture_index) & options->lower_xy_uxvx_external) {
+ lower_xy_uxvx_external(b, tex);
+ progress = true;
+ }

if (sat_mask) {
saturate_src(b, tex, sat_mask);
--
1.9.1
Kristian H. Kristensen
2017-06-16 17:57:47 UTC
Permalink
Raw Message
Post by Johnson Lin
---
src/compiler/nir/nir.h | 1 +
src/compiler/nir/nir_lower_tex.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index ab7ba14303b7..1b4e47058d4d 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2449,6 +2449,7 @@ typedef struct nir_lower_tex_options {
unsigned lower_y_uv_external;
unsigned lower_y_u_v_external;
unsigned lower_yx_xuxv_external;
+ unsigned lower_xy_uxvx_external;
/**
* To emulate certain texture wrap modes, this can be used
diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c
index 4ef81955513e..5593f9890b28 100644
--- a/src/compiler/nir/nir_lower_tex.c
+++ b/src/compiler/nir/nir_lower_tex.c
@@ -301,6 +301,18 @@ lower_yx_xuxv_external(nir_builder *b, nir_tex_instr *tex)
nir_channel(b, xuxv, 3));
}
+static void lower_xy_uxvx_external(nir_builder *b, nir_tex_instr *tex) {
+ b->cursor = nir_after_instr(&tex->instr);
+
+ nir_ssa_def *y = sample_plane(b, tex, 0);
+ nir_ssa_def *uxvx = sample_plane(b, tex, 1);
+
+ convert_yuv_to_rgb(b, tex,
+ nir_channel(b, y, 1),
+ nir_channel(b, uxvx, 2),
+ nir_channel(b, uxvx, 0));
This looks like it's swapping U and V channels.
Post by Johnson Lin
+}
+
/*
* Emits a textureLod operation used to replace an existing
* textureGrad instruction.
@@ -760,6 +772,10 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
progress = true;
}
+ if ((1 << tex->texture_index) & options->lower_xy_uxvx_external) {
+ lower_xy_uxvx_external(b, tex);
+ progress = true;
+ }
if (sat_mask) {
saturate_src(b, tex, sat_mask);
--
1.9.1
_______________________________________________
mesa-dev mailing list
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Johnson Lin
2017-06-16 06:24:53 UTC
Permalink
Raw Message
---
src/intel/compiler/brw_compiler.h | 1 +
src/intel/compiler/brw_nir.c | 1 +
src/mesa/drivers/dri/i915/intel_screen.c | 7 +++++--
src/mesa/drivers/dri/i965/brw_wm.c | 7 +++++++
src/mesa/drivers/dri/i965/intel_screen.c | 7 +++++--
5 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h
index 78873744ce5f..3f383403883c 100644
--- a/src/intel/compiler/brw_compiler.h
+++ b/src/intel/compiler/brw_compiler.h
@@ -168,6 +168,7 @@ struct brw_sampler_prog_key_data {
uint32_t y_u_v_image_mask;
uint32_t y_uv_image_mask;
uint32_t yx_xuxv_image_mask;
+ uint32_t xy_uxvx_image_mask;
};

/**
diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c
index de8f519b4e10..49d3cf365647 100644
--- a/src/intel/compiler/brw_nir.c
+++ b/src/intel/compiler/brw_nir.c
@@ -770,6 +770,7 @@ brw_nir_apply_sampler_key(nir_shader *nir,
tex_options.lower_y_uv_external = key_tex->y_uv_image_mask;
tex_options.lower_y_u_v_external = key_tex->y_u_v_image_mask;
tex_options.lower_yx_xuxv_external = key_tex->yx_xuxv_image_mask;
+ tex_options.lower_xy_uxvx_external = key_tex->xy_uxvx_image_mask;

if (nir_lower_tex(nir, &tex_options)) {
nir_validate_shader(nir);
diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c
index cba5434b5e1b..03f79e242c67 100644
--- a/src/mesa/drivers/dri/i915/intel_screen.c
+++ b/src/mesa/drivers/dri/i915/intel_screen.c
@@ -227,16 +227,19 @@ static struct intel_image_format intel_image_formats[] = {
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
{ 1, 1, 0, __DRI_IMAGE_FORMAT_GR88, 2 } } },

- /* For YUYV buffers, we set up two overlapping DRI images and treat
+ /* For YUYV&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 the R component, while
- * plane 1 is ARGB and samples YUYV clusters and places pairs and
+ * plane 1 is ARGB and samples YUYV/UYVY clusters and places pairs and
* places U into the G component and V into A. This lets the
* texture sampler interpolate the Y components correctly when
* sampling from plane 0, and interpolate U and V correctly when
* sampling from plane 1. */
{ __DRI_IMAGE_FOURCC_YUYV, __DRI_IMAGE_COMPONENTS_Y_XUXV, 2,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88, 2 },
+ { 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } },
+ { __DRI_IMAGE_FOURCC_UYVY, __DRI_IMAGE_COMPONENTS_Y_UXVX, 2,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88, 2 },
{ 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } }
};

diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 0f075a11f756..a8ec1f5c2368 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -270,6 +270,10 @@ brw_debug_recompile_sampler_key(struct brw_context *brw,
found |= key_debug(brw, "yx_xuxv image bound",
old_key->yx_xuxv_image_mask,
key->yx_xuxv_image_mask);
+ found |= key_debug(brw, "xy_uxvx image bound",
+ old_key->xy_uxvx_image_mask,
+ key->xy_uxvx_image_mask);
+

for (unsigned int i = 0; i < MAX_SAMPLERS; i++) {
found |= key_debug(brw, "textureGather workarounds",
@@ -412,6 +416,9 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
case __DRI_IMAGE_COMPONENTS_Y_XUXV:
key->yx_xuxv_image_mask |= 1 << s;
break;
+ case __DRI_IMAGE_COMPONENTS_Y_UXVX:
+ key->xy_uxvx_image_mask |= 1 << s;
+ break;
default:
break;
}
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 83b8a24509a4..4258e54e78ca 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -278,16 +278,19 @@ static struct intel_image_format intel_image_formats[] = {
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
{ 1, 1, 0, __DRI_IMAGE_FORMAT_GR88, 2 } } },

- /* For YUYV buffers, we set up two overlapping DRI images and treat
+ /* For YUYV&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 the R component, while
- * plane 1 is ARGB and samples YUYV clusters and places pairs and
+ * plane 1 is ARGB and samples YUYV/UYVY clusters and places pairs and
* places U into the G component and V into A. This lets the
* texture sampler interpolate the Y components correctly when
* sampling from plane 0, and interpolate U and V correctly when
* sampling from plane 1. */
{ __DRI_IMAGE_FOURCC_YUYV, __DRI_IMAGE_COMPONENTS_Y_XUXV, 2,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88, 2 },
+ { 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } },
+ { __DRI_IMAGE_FOURCC_UYVY, __DRI_IMAGE_COMPONENTS_Y_UXVX, 2,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88, 2 },
{ 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } }
};
--
1.9.1
Kristian H. Kristensen
2017-06-16 19:53:31 UTC
Permalink
Raw Message
Johnson Lin <***@intel.com> writes:

Commit subject is too long. Make it a brief summary under 72 characters
wide. Explain further, if necessary in commit body.

See https://chris.beams.io/posts/git-commit/ for a good guide and
rationale.
Post by Johnson Lin
---
src/intel/compiler/brw_compiler.h | 1 +
src/intel/compiler/brw_nir.c | 1 +
src/mesa/drivers/dri/i915/intel_screen.c | 7 +++++--
src/mesa/drivers/dri/i965/brw_wm.c | 7 +++++++
src/mesa/drivers/dri/i965/intel_screen.c | 7 +++++--
5 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h
index 78873744ce5f..3f383403883c 100644
--- a/src/intel/compiler/brw_compiler.h
+++ b/src/intel/compiler/brw_compiler.h
@@ -168,6 +168,7 @@ struct brw_sampler_prog_key_data {
uint32_t y_u_v_image_mask;
uint32_t y_uv_image_mask;
uint32_t yx_xuxv_image_mask;
+ uint32_t xy_uxvx_image_mask;
};
/**
diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c
index de8f519b4e10..49d3cf365647 100644
--- a/src/intel/compiler/brw_nir.c
+++ b/src/intel/compiler/brw_nir.c
@@ -770,6 +770,7 @@ brw_nir_apply_sampler_key(nir_shader *nir,
tex_options.lower_y_uv_external = key_tex->y_uv_image_mask;
tex_options.lower_y_u_v_external = key_tex->y_u_v_image_mask;
tex_options.lower_yx_xuxv_external = key_tex->yx_xuxv_image_mask;
+ tex_options.lower_xy_uxvx_external = key_tex->xy_uxvx_image_mask;
if (nir_lower_tex(nir, &tex_options)) {
nir_validate_shader(nir);
diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c
index cba5434b5e1b..03f79e242c67 100644
--- a/src/mesa/drivers/dri/i915/intel_screen.c
+++ b/src/mesa/drivers/dri/i915/intel_screen.c
@@ -227,16 +227,19 @@ static struct intel_image_format intel_image_formats[] = {
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
{ 1, 1, 0, __DRI_IMAGE_FORMAT_GR88, 2 } } },
- /* For YUYV buffers, we set up two overlapping DRI images and treat
+ /* For YUYV&UYVY buffers, we set up two overlapping DRI images and treat
I would just say "For YUYV-style buffers...", implying the various
swizzled versions.
Post by Johnson Lin
* them as planar buffers in the compositors. Plane 0 is GR88 and
* samples YU or YV pairs and places Y into the R component, while
- * plane 1 is ARGB and samples YUYV clusters and places pairs and
+ * plane 1 is ARGB and samples YUYV/UYVY clusters and places pairs and
* places U into the G component and V into A. This lets the
* texture sampler interpolate the Y components correctly when
* sampling from plane 0, and interpolate U and V correctly when
* sampling from plane 1. */
{ __DRI_IMAGE_FOURCC_YUYV, __DRI_IMAGE_COMPONENTS_Y_XUXV, 2,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88, 2 },
+ { 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } },
+ { __DRI_IMAGE_FOURCC_UYVY, __DRI_IMAGE_COMPONENTS_Y_UXVX, 2,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88, 2 },
{ 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } }
};
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 0f075a11f756..a8ec1f5c2368 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -270,6 +270,10 @@ brw_debug_recompile_sampler_key(struct brw_context *brw,
found |= key_debug(brw, "yx_xuxv image bound",
old_key->yx_xuxv_image_mask,
key->yx_xuxv_image_mask);
+ found |= key_debug(brw, "xy_uxvx image bound",
+ old_key->xy_uxvx_image_mask,
+ key->xy_uxvx_image_mask);
+
for (unsigned int i = 0; i < MAX_SAMPLERS; i++) {
found |= key_debug(brw, "textureGather workarounds",
@@ -412,6 +416,9 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
key->yx_xuxv_image_mask |= 1 << s;
break;
+ key->xy_uxvx_image_mask |= 1 << s;
+ break;
break;
}
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 83b8a24509a4..4258e54e78ca 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -278,16 +278,19 @@ static struct intel_image_format intel_image_formats[] = {
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 },
{ 1, 1, 0, __DRI_IMAGE_FORMAT_GR88, 2 } } },
- /* For YUYV buffers, we set up two overlapping DRI images and treat
+ /* For YUYV&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 the R component, while
- * plane 1 is ARGB and samples YUYV clusters and places pairs and
+ * plane 1 is ARGB and samples YUYV/UYVY clusters and places pairs and
* places U into the G component and V into A. This lets the
* texture sampler interpolate the Y components correctly when
* sampling from plane 0, and interpolate U and V correctly when
* sampling from plane 1. */
{ __DRI_IMAGE_FOURCC_YUYV, __DRI_IMAGE_COMPONENTS_Y_XUXV, 2,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88, 2 },
+ { 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } },
+ { __DRI_IMAGE_FOURCC_UYVY, __DRI_IMAGE_COMPONENTS_Y_UXVX, 2,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88, 2 },
{ 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } }
};
--
1.9.1
_______________________________________________
mesa-dev mailing list
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Loading...