From 53fc6ba9302ed62401b64962adcb1c157817b518 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 12 Mar 2021 23:01:15 -0800 Subject: [PATCH] mesa: Add R8G8_R8B8 and G8R8_B8R8 formats These aren't real formats. They cannot be used with RenderbufferObjects, Textures, or anything else visible through the GL API. The only purpose is to support YUYV textures imported through EGL_image_external. There is hardware that can sample from this subsampled format, but the hardware does not do the colorspace conversion automatically. v2: Treat these formats as compressed. This is a lie, but it seems to be a less egregious lie than what I was doing before. It also passes 'ninja test'. Reviewed-by: Emma Anholt Part-of: --- src/mesa/main/format_info.py | 2 ++ src/mesa/main/format_parser.py | 5 +++-- src/mesa/main/formats.c | 2 ++ src/mesa/main/formats.csv | 3 +++ src/mesa/main/formats.h | 2 ++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/format_info.py b/src/mesa/main/format_info.py index 42c236c..edc0324 100644 --- a/src/mesa/main/format_info.py +++ b/src/mesa/main/format_info.py @@ -128,6 +128,8 @@ def get_channel_bits(fmat, chan_name): return bits if fmat.has_channel(chan_name) else 0 elif fmat.layout == 'atc': return 8 if fmat.has_channel(chan_name) else 0 + elif fmat.layout == 'other' and ('RG_RB' in fmat.name or 'GR_BR' in fmat.name): + return 8 if fmat.has_channel(chan_name) else 0 else: assert False else: diff --git a/src/mesa/main/format_parser.py b/src/mesa/main/format_parser.py index c0d73c9..3b1cb54 100644 --- a/src/mesa/main/format_parser.py +++ b/src/mesa/main/format_parser.py @@ -518,7 +518,7 @@ def _get_datatype(type, size): else: assert False -def _parse_channels(fields, layout, colorspace, swizzle): +def _parse_channels(fields): channels = [] for field in fields: if not field: @@ -569,6 +569,7 @@ def parse(filename): swizzle = Swizzle(fields[9]) except: sys.exit("error parsing swizzle for format " + name) - channels = _parse_channels(fields[5:9], layout, colorspace, swizzle) + + channels = _parse_channels(fields[5:9]) yield Format(name, layout, block_width, block_height, block_depth, channels, swizzle, colorspace) diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index ac00a21..9cd026f 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -1024,6 +1024,8 @@ _mesa_uncompressed_format_to_type_and_comps(mesa_format format, case MESA_FORMAT_YCBCR: case MESA_FORMAT_YCBCR_REV: + case MESA_FORMAT_RG_RB_UNORM8: + case MESA_FORMAT_GR_BR_UNORM8: *datatype = GL_UNSIGNED_SHORT; *comps = 2; return; diff --git a/src/mesa/main/formats.csv b/src/mesa/main/formats.csv index e2b54e9..21cdea2 100644 --- a/src/mesa/main/formats.csv +++ b/src/mesa/main/formats.csv @@ -93,6 +93,9 @@ MESA_FORMAT_A2R10G10B10_UNORM , packed, 1, 1, 1, un2 , un10, un10, u MESA_FORMAT_YCBCR , other , 1, 1, 1, x16 , , , , xyzw, yuv MESA_FORMAT_YCBCR_REV , other , 1, 1, 1, x16 , , , , xyzw, yuv +MESA_FORMAT_RG_RB_UNORM8 , other , 2, 1, 1, x16 , , , , xyz1, rgb +MESA_FORMAT_GR_BR_UNORM8 , other , 2, 1, 1, x16 , , , , xyz1, rgb + # Array normalized formats MESA_FORMAT_A_UNORM8 , array , 1, 1, 1, un8 , , , , 000x, rgb MESA_FORMAT_A_UNORM16 , array , 1, 1, 1, un16, , , , 000x, rgb diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index 29c1308..508c9c3 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -385,6 +385,8 @@ typedef enum pipe_format mesa_format; #define MESA_FORMAT_A2R10G10B10_UNORM PIPE_FORMAT_A2R10G10B10_UNORM #define MESA_FORMAT_YCBCR PIPE_FORMAT_UYVY #define MESA_FORMAT_YCBCR_REV PIPE_FORMAT_YUYV +#define MESA_FORMAT_RG_RB_UNORM8 PIPE_FORMAT_R8G8_R8B8_UNORM +#define MESA_FORMAT_GR_BR_UNORM8 PIPE_FORMAT_G8R8_B8R8_UNORM #define MESA_FORMAT_A_UNORM8 PIPE_FORMAT_A8_UNORM #define MESA_FORMAT_A_UNORM16 PIPE_FORMAT_A16_UNORM #define MESA_FORMAT_L_UNORM8 PIPE_FORMAT_L8_UNORM -- 2.7.4