[Mesa-dev] [PATCH] i965: NULL check depth_mt to quiet static analysis.

Matt Turner mattst88 at gmail.com
Thu Jun 27 11:41:59 PDT 2013


---
I think (depth_irb == NULL) iff (depth_mt == NULL) and the same for
stencil_irb and stencil_mt. I can understand how static analysis tools
would miss this, since I haven't been able to prove it to myself
either.

 src/mesa/drivers/dri/i965/brw_misc_state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c b/src/mesa/drivers/dri/i965/brw_misc_state.c
index 7e41c84..23faee6 100644
--- a/src/mesa/drivers/dri/i965/brw_misc_state.c
+++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
@@ -586,31 +586,31 @@ brw_emit_depthbuffer(struct brw_context *brw)
    if (stencil_mt) {
       separate_stencil = stencil_mt->format == MESA_FORMAT_S8;
 
       /* Gen7 supports only separate stencil */
       assert(separate_stencil || intel->gen < 7);
    }
 
    /* If there's a packed depth/stencil bound to stencil only, we need to
     * emit the packed depth/stencil buffer packet.
     */
    if (!depth_irb && stencil_irb && !separate_stencil) {
       depth_irb = stencil_irb;
       depth_mt = stencil_mt;
    }
 
-   if (depth_irb) {
+   if (depth_irb && depth_mt) {
       /* When 3DSTATE_DEPTH_BUFFER.Separate_Stencil_Enable is set, then
        * 3DSTATE_DEPTH_BUFFER.Surface_Format is not permitted to be a packed
        * depthstencil format.
        *
        * Gens prior to 7 require that HiZ_Enable and Separate_Stencil_Enable be
        * set to the same value. Gens after 7 implicitly always set
        * Separate_Stencil_Enable; software cannot disable it.
        */
       if ((intel->gen < 7 && hiz) || intel->gen >= 7) {
          assert(!_mesa_is_format_packed_depth_stencil(depth_mt->format));
       }
 
       /* Prior to Gen7, if using separate stencil, hiz must be enabled. */
       assert(intel->gen >= 7 || !separate_stencil || hiz);
 
-- 
1.8.1.5



More information about the mesa-dev mailing list