intel: Add an interface for saving/restoring the batchbuffer state.
authorEric Anholt <eric@anholt.net>
Sat, 22 Oct 2011 02:01:17 +0000 (19:01 -0700)
committerEric Anholt <eric@anholt.net>
Sat, 29 Oct 2011 19:15:56 +0000 (12:15 -0700)
This will be used to avoid the prepare() step in the i965 driver's
state setup.  Instead, we can just speculatively emit the primitive
into the batchbuffer, then check if the batch is too big, rollback and
flush, and replay the primitive.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Paul Berry <stereotype441@gmail.com>
configure.ac
src/mesa/drivers/dri/intel/intel_batchbuffer.c
src/mesa/drivers/dri/intel/intel_batchbuffer.h
src/mesa/drivers/dri/intel/intel_context.h

index 29da959e229c338b31baa290be2d5f607d96aeea..30b3b96c30e944a5474728d0150718c061096393 100644 (file)
@@ -24,7 +24,7 @@ USER_CXXFLAGS="$CXXFLAGS"
 dnl Versions for external dependencies
 LIBDRM_REQUIRED=2.4.24
 LIBDRM_RADEON_REQUIRED=2.4.24
-LIBDRM_INTEL_REQUIRED=2.4.24
+LIBDRM_INTEL_REQUIRED=2.4.27
 LIBDRM_NOUVEAU_REQUIRED=0.6
 DRI2PROTO_REQUIRED=2.6
 GLPROTO_REQUIRED=1.4.14
index 38cdeda8f49ea57fb6f66e049a256fbf76a42a00..2d99eeca5e0bc0edf8c051d3b77e97e1d69e8403 100644 (file)
@@ -87,6 +87,27 @@ intel_batchbuffer_reset(struct intel_context *intel)
    intel->batch.used = 0;
 }
 
+void
+intel_batchbuffer_save_state(struct intel_context *intel)
+{
+   intel->batch.saved.used = intel->batch.used;
+   intel->batch.saved.reloc_count =
+      drm_intel_gem_bo_get_reloc_count(intel->batch.bo);
+}
+
+void
+intel_batchbuffer_reset_to_saved(struct intel_context *intel)
+{
+   drm_intel_gem_bo_clear_relocs(intel->batch.bo, intel->batch.saved.reloc_count);
+
+   intel->batch.used = intel->batch.saved.used;
+
+   /* Cached batch state is dead, since we just cleared some unknown part of the
+    * batchbuffer.  Assume that the caller resets any other state necessary.
+    */
+   clear_cache(intel);
+}
+
 void
 intel_batchbuffer_free(struct intel_context *intel)
 {
index 0b2e5ea34daa1a0e7782118b47ec86b103fb137d..228c32df53cc78b43cb22937a9c4cffcf6f718f7 100644 (file)
@@ -12,6 +12,8 @@
 void intel_batchbuffer_init(struct intel_context *intel);
 void intel_batchbuffer_reset(struct intel_context *intel);
 void intel_batchbuffer_free(struct intel_context *intel);
+void intel_batchbuffer_save_state(struct intel_context *intel);
+void intel_batchbuffer_reset_to_saved(struct intel_context *intel);
 
 void _intel_batchbuffer_flush(struct intel_context *intel,
                              const char *file, int line);
index 938112af81dc368db484555fe0eba1550a4b32c9..47e53d9e38a49a2457d57988112a21bf4c818ccc 100644 (file)
@@ -210,6 +210,11 @@ struct intel_context
 
       uint32_t state_batch_offset;
       bool is_blit;
+
+      struct {
+        uint16_t used;
+        int reloc_count;
+      } saved;
    } batch;
 
    drm_intel_bo *first_post_swapbuffers_batch;