mesa: add/update comments in _mesa_copy_buffer_subdata()
[mesa.git] / src / mesa / drivers / dri / i965 / brw_state_batch.c
index 213c7a38d8c732ac637e6f167eb200315af75f82..81d034ce822770c8209347db2d0db0e52d2afad4 100644 (file)
 #include "brw_state.h"
 #include "intel_batchbuffer.h"
 #include "main/imports.h"
+#include "glsl/ralloc.h"
+
+static void
+brw_track_state_batch(struct brw_context *brw,
+                     enum state_struct_type type,
+                     uint32_t offset,
+                     int size)
+{
+   struct intel_batchbuffer *batch = &brw->intel.batch;
+
+   if (!brw->state_batch_list) {
+      /* Our structs are always aligned to at least 32 bytes, so
+       * our array doesn't need to be any larger
+       */
+      brw->state_batch_list = ralloc_size(brw, sizeof(*brw->state_batch_list) *
+                                         batch->bo->size / 32);
+   }
+
+   brw->state_batch_list[brw->state_batch_count].offset = offset;
+   brw->state_batch_list[brw->state_batch_count].size = size;
+   brw->state_batch_list[brw->state_batch_count].type = type;
+   brw->state_batch_count++;
+}
 
 /**
  * Allocates a block of space in the batchbuffer for indirect state.
@@ -49,6 +72,7 @@
  */
 void *
 brw_state_batch(struct brw_context *brw,
+               enum state_struct_type type,
                int size,
                int alignment,
                uint32_t *out_offset)
@@ -71,6 +95,9 @@ brw_state_batch(struct brw_context *brw,
 
    batch->state_batch_offset = offset;
 
+   if (unlikely(INTEL_DEBUG & DEBUG_BATCH))
+      brw_track_state_batch(brw, type, offset, size);
+
    *out_offset = offset;
    return batch->map + (offset>>2);
 }