Mesa (master): i965/hsw: Adjust uploading default color for stencil surfaces

Jordan Justen jljusten at kemper.freedesktop.org
Fri Aug 26 17:50:31 UTC 2016


Module: Mesa
Branch: master
Commit: b82bb98441609579c753351295a9f5317b572604
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b82bb98441609579c753351295a9f5317b572604

Author: Jordan Justen <jordan.l.justen at intel.com>
Date:   Mon Aug 22 22:47:50 2016 -0700

i965/hsw: Adjust uploading default color for stencil surfaces

v2:
 * has_component (Ken); const bits_per_channel (Topi)

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/mesa/drivers/dri/i965/brw_sampler_state.c | 17 +++++++++++++++--
 1 file changed, 15 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..0eed8f9 100644
--- a/src/mesa/drivers/dri/i965/brw_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sampler_state.c
@@ -196,6 +196,16 @@ wrap_mode_needs_border_color(unsigned wrap_mode)
           wrap_mode == GEN8_TEXCOORDMODE_HALF_BORDER;
 }
 
+static bool
+has_component(mesa_format format, int i)
+{
+   if (_mesa_is_format_color_format(format))
+      return _mesa_format_has_color_component(format, i);
+
+   /* depth and stencil have only one component */
+   return i == 0;
+}
+
 /**
  * Upload SAMPLER_BORDER_COLOR_STATE.
  */
@@ -281,7 +291,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);
+      const 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,
@@ -291,7 +304,7 @@ upload_default_color(struct brw_context *brw,
        */
       unsigned c[4] = { 0, 0, 0, 1 };
       for (int i = 0; i < 4; i++) {
-         if (_mesa_format_has_color_component(format, i))
+         if (has_component(format, i))
             c[i] = color.ui[i];
       }
 




More information about the mesa-commit mailing list