i965: Ensure that all necessary state is re-emitted if we run out of aperture.
authorPaul Berry <stereotype441@gmail.com>
Sat, 11 Jan 2014 02:56:14 +0000 (18:56 -0800)
committerPaul Berry <stereotype441@gmail.com>
Mon, 13 Jan 2014 17:44:39 +0000 (09:44 -0800)
Prior to this patch, if we ran out of aperture space during
brw_try_draw_prims(), we would rewind the batch buffer pointer
(potentially throwing some state that may have been emitted by
brw_upload_state()), flush the batch, and then try again.  However, we
wouldn't reset the dirty bits to the state they had before the call to
brw_upload_state().  As a result, when we tried again, there was a
danger that we wouldn't re-emit all the necessary state.  (Note: prior
to the introduction of hardware contexts, this wasn't a problem
because flushing the batch forced all state to be re-emitted).

This patch fixes the problem by leaving the dirty bits set at the end
of brw_upload_state(); we only clear them after we have determined
that we don't need to rewind the batch buffer.

Cc: 10.0 9.2 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_draw.c
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/brw_state_upload.c

index b898cd305d31c261548742423921d674600a51b5..ec56a2107de16ba6802ed9b17e104cf9c64b1d3b 100644 (file)
@@ -499,6 +499,12 @@ retry:
            }
         }
       }
+
+      /* Now that we know we haven't run out of aperture space, we can safely
+       * reset the dirty bits.
+       */
+      if (brw->state.dirty.brw)
+         brw_clear_dirty_bits(brw);
    }
 
    if (brw->always_flush_batch)
index a148125a9eed9adc6dce4a0d9eafbba297ed4126..e9428fbe956e7fe0c2bcb9a949028f53732c5203 100644 (file)
@@ -143,6 +143,7 @@ brw_depthbuffer_format(struct brw_context *brw);
  * brw_state.c
  */
 void brw_upload_state(struct brw_context *brw);
+void brw_clear_dirty_bits(struct brw_context *brw);
 void brw_init_state(struct brw_context *brw);
 void brw_destroy_state(struct brw_context *brw);
 
index 1eb3a7951192b355c0a635702acfdbce34a62cee..7490df46b846ce25737dce8f6263a5d0dd82ba71 100644 (file)
@@ -573,6 +573,20 @@ void brw_upload_state(struct brw_context *brw)
         fprintf(stderr, "\n");
       }
    }
+}
+
 
+/**
+ * Clear dirty bits to account for the fact that the state emitted by
+ * brw_upload_state() has been committed to the hardware.  This is a separate
+ * call from brw_upload_state() because it's possible that after the call to
+ * brw_upload_state(), we will discover that we've run out of aperture space,
+ * and need to rewind the batch buffer to the state it had before the
+ * brw_upload_state() call.
+ */
+void
+brw_clear_dirty_bits(struct brw_context *brw)
+{
+   struct brw_state_flags *state = &brw->state.dirty;
    memset(state, 0, sizeof(*state));
 }