Theoretically, we could use it to support UYVY and YUY2 *textures* as well, but it would still require converting from YUV to RGB after sampling.
Signed-off-by: Chip Davis cdavis@codeweavers.com --- dlls/wined3d/arb_program_shader.c | 14 ++++++++++++-- dlls/wined3d/glsl_shader.c | 10 ++++++++++ dlls/wined3d/utils.c | 8 ++++++++ 3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 36c920dc6e0..961d7acf131 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -6951,7 +6951,7 @@ static void arbfp_blitter_destroy(struct wined3d_blitter *blitter, struct wined3 heap_free(arbfp_blitter); }
-static void gen_packed_yuv_read(struct wined3d_string_buffer *buffer, +static void gen_packed_yuv_read(struct wined3d_string_buffer *buffer, const struct wined3d_gl_info *gl_info, const struct arbfp_blit_type *type, char *luminance) { char chroma; @@ -6972,6 +6972,16 @@ static void gen_packed_yuv_read(struct wined3d_string_buffer *buffer, if (type->res_type == WINED3D_GL_RES_TYPE_TEX_RECT) texinstr = "TEX";
+ if (gl_info->supported[APPLE_RGB_422]) + { + /* In this case, things are much simpler. The only thing we have to do here + * is YUV-RGB conversion. */ + shader_addline(buffer, "TEX luminance, fragment.texcoord[0], texture[0], %s\n", tex); + shader_addline(buffer, "MOV chroma.xy, luminance.xz\n"); + shader_addline(buffer, "MOV luminance.%c, luminance.y\n", *luminance); + return; + } + /* First we have to read the chroma values. This means we need at least two pixels(no filtering), * or 4 pixels(with filtering). To get the unmodified chromas, we have to rid ourselves of the * filtering when we sample the texture. @@ -7479,7 +7489,7 @@ static GLuint gen_yuv_shader(const struct wined3d_gl_info *gl_info, const struct { case COMPLEX_FIXUP_UYVY: case COMPLEX_FIXUP_YUY2: - gen_packed_yuv_read(&buffer, type, &luminance_component); + gen_packed_yuv_read(&buffer, gl_info, type, &luminance_component); break;
case COMPLEX_FIXUP_YV12: diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index c7feff85efb..207ba892e24 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -12499,6 +12499,16 @@ static void gen_packed_yuv_read(struct wined3d_string_buffer *buffer,
tex = needs_legacy_glsl_syntax(gl_info) ? tex_type : "";
+ if (gl_info->supported[APPLE_RGB_422]) + { + /* In this case, things are much simpler. The only thing we have to do here + * is YUV-RGB conversion. */ + shader_addline(buffer, " vec3 yuv = vec3(texture%s(sampler, out_texcoord.xy));\n", tex); + shader_addline(buffer, " luminance = yuv.y;\n"); + shader_addline(buffer, " chroma = yuv.xz;\n"); + return; + } + /* First we have to read the chroma values. This means we need at least * two pixels (no filtering), or 4 pixels (with filtering). To get the * unmodified chroma, we have to rid ourselves of the filtering when we diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index dec7eecd7ee..b50813db3a1 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -1312,6 +1312,10 @@ static const struct wined3d_format_texture_info format_texture_info[] = * Macs, so probably the endianness differs. This could be tested as soon as we have a Windows and MacOS on a big * endian machine */ + {WINED3DFMT_UYVY, GL_RGB_RAW_422_APPLE, GL_RGB_RAW_422_APPLE, 0, + GL_RGB_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, 0, + WINED3DFMT_FLAG_FILTERING, + APPLE_RGB_422, NULL}, {WINED3DFMT_UYVY, GL_RG8, GL_RG8, 0, GL_RG, GL_UNSIGNED_BYTE, 0, WINED3DFMT_FLAG_FILTERING, @@ -1324,6 +1328,10 @@ static const struct wined3d_format_texture_info format_texture_info[] = GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, 0, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_FILTERING, APPLE_YCBCR_422, NULL}, + {WINED3DFMT_YUY2, GL_RGB_RAW_422_APPLE, GL_RGB_RAW_422_APPLE, 0, + GL_RGB_422_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE, 0, + WINED3DFMT_FLAG_FILTERING, + APPLE_RGB_422, NULL}, {WINED3DFMT_YUY2, GL_RG8, GL_RG8, 0, GL_RG, GL_UNSIGNED_BYTE, 0, WINED3DFMT_FLAG_FILTERING,
On Tue, 14 Apr 2020 at 08:18, Chip Davis cdavis@codeweavers.com wrote:
@@ -12499,6 +12499,16 @@ static void gen_packed_yuv_read(struct wined3d_string_buffer *buffer,
tex = needs_legacy_glsl_syntax(gl_info) ? tex_type : "";
- if (gl_info->supported[APPLE_RGB_422])
- {
/* In this case, things are much simpler. The only thing we have to do here
* is YUV-RGB conversion. */
shader_addline(buffer, " vec3 yuv = vec3(texture%s(sampler, out_texcoord.xy));\n", tex);
shader_addline(buffer, " luminance = yuv.y;\n");
shader_addline(buffer, " chroma = yuv.xz;\n");
return;
- }
It seems arbitrary to reuse COMPLEX_FIXUP_UYVY/COMPLEX_FIXUP_YUY2 for this.