[Mesa-dev] [PATCH 04/16] i965/hsw: Adjust uploading default color for stencil surfaces

Jordan Justen jordan.l.justen at intel.com
Wed Aug 24 23:54:56 UTC 2016


Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 src/mesa/drivers/dri/i965/brw_sampler_state.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_sampler_state.c b/src/mesa/drivers/dri/i965/brw_sampler_state.c
index 9f56c81..8ad34b8 100644
--- a/src/mesa/drivers/dri/i965/brw_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sampler_state.c
@@ -281,7 +281,10 @@ upload_default_color(struct brw_context *brw,
       memset(sdc, 0, 20 * 4);
       sdc = &sdc[16];
 
-      int bits_per_channel = _mesa_get_format_bits(format, GL_RED_BITS);
+      int bits_per_channel =
+         _mesa_get_format_bits(format,
+                               format == MESA_FORMAT_S_UINT8 ?
+                               GL_STENCIL_BITS : GL_RED_BITS);
 
       /* From the Haswell PRM, "Command Reference: Structures", Page 36:
        * "If any color channel is missing from the surface format,
@@ -290,8 +293,9 @@ upload_default_color(struct brw_context *brw,
        *  be programmed as 1."
        */
       unsigned c[4] = { 0, 0, 0, 1 };
+      bool is_color = _mesa_is_format_color_format(format);
       for (int i = 0; i < 4; i++) {
-         if (_mesa_format_has_color_component(format, i))
+         if (is_color ? _mesa_format_has_color_component(format, i) : i == 0)
             c[i] = color.ui[i];
       }
 
-- 
2.8.0.rc3



More information about the mesa-dev mailing list