[Mesa-dev] [PATCH 3/3] i965: Support rendering to RGBX formats in general.

Kenneth Graunke kenneth at whitecape.org
Tue Mar 25 18:01:28 PDT 2014


Previously, we supported rendering to B8G8R8X8_UNORM by overriding the
rendering format to B8G8R8A8_UNORM.  However, we didn't support any
other formats, such as R8G8B8X8_UNORM.

This patch adds format overrides for all other RGBX formats, making them
renderable (assuming the equivalent RGBA format is renderable).

Being able to render to more formats is helpful because it means that
BLORP and Meta can accelerate operations on those formats.

This makes various Piglit fbo-*-formats tests change from 'skip' to
'pass' for GL_RGB10, GL_RGB12, and GL_RGB16 internal formats, as
they're now supported and work properly.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_surface_formats.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_surface_formats.c b/src/mesa/drivers/dri/i965/brw_surface_formats.c
index 3f64881..b1ea340 100644
--- a/src/mesa/drivers/dri/i965/brw_surface_formats.c
+++ b/src/mesa/drivers/dri/i965/brw_surface_formats.c
@@ -543,7 +543,15 @@ brw_init_surface_formats(struct brw_context *brw)
       const struct surface_format_info *rinfo, *tinfo;
       bool is_integer = _mesa_is_format_integer_color(format);
 
-      render = texture = brw_format_for_mesa_format(format);
+      texture = brw_format_for_mesa_format(format);
+      /* Our hardware can't natively render to RGBX formats, so we convert
+       * them to the equivalent RGBA format when rendering.  When sampling,
+       * we use the original RGBX format, so the sampler will return 1.0 for
+       * the alpha channel, as required.  We also override blend functions
+       * to use GL_ONE instead of GL_DST_ALPHA and GL_ZERO instead of
+       * GL_ONE_MINUS_DST_ALPHA.  (See brw_fix_xRGB_alpha.)
+       */
+      render = brw_format_for_mesa_format(_mesa_format_x_to_a(format));
       tinfo = &surface_formats[texture];
 
       /* The value of BRW_SURFACEFORMAT_R32G32B32A32_FLOAT is 0, so don't skip
@@ -571,16 +579,6 @@ brw_init_surface_formats(struct brw_context *brw)
       case BRW_SURFACEFORMAT_L16_FLOAT:
 	 render = BRW_SURFACEFORMAT_R16_FLOAT;
 	 break;
-      case BRW_SURFACEFORMAT_B8G8R8X8_UNORM:
-	 /* XRGB is handled as ARGB because the chips in this family
-	  * cannot render to XRGB targets.  This means that we have to
-	  * mask writes to alpha (ala glColorMask) and reconfigure the
-	  * alpha blending hardware to use GL_ONE (or GL_ZERO) for
-	  * cases where GL_DST_ALPHA (or GL_ONE_MINUS_DST_ALPHA) is
-	  * used.
-	  */
-	 render = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
-	 break;
       }
 
       rinfo = &surface_formats[render];
-- 
1.9.0



More information about the mesa-dev mailing list