+ brw_store_register_mem64(brw, bo, GEN6_SO_NUM_PRIMS_WRITTEN,
+ idx * sizeof(uint64_t));
+ }
+}
+
+static void
+write_xfb_overflow_streams(struct gl_context *ctx,
+ struct brw_bo *bo, int stream, int count,
+ int idx)
+{
+ struct brw_context *brw = brw_context(ctx);
+ const struct gen_device_info *devinfo = &brw->screen->devinfo;
+
+ brw_emit_mi_flush(brw);
+
+ for (int i = 0; i < count; i++) {
+ int w_idx = 4 * i + idx;
+ int g_idx = 4 * i + idx + 2;
+
+ if (devinfo->gen >= 7) {
+ brw_store_register_mem64(brw, bo,
+ GEN7_SO_NUM_PRIMS_WRITTEN(stream + i),
+ g_idx * sizeof(uint64_t));
+ brw_store_register_mem64(brw, bo,
+ GEN7_SO_PRIM_STORAGE_NEEDED(stream + i),
+ w_idx * sizeof(uint64_t));
+ } else {
+ brw_store_register_mem64(brw, bo,
+ GEN6_SO_NUM_PRIMS_WRITTEN,
+ g_idx * sizeof(uint64_t));
+ brw_store_register_mem64(brw, bo,
+ GEN6_SO_PRIM_STORAGE_NEEDED,
+ w_idx * sizeof(uint64_t));
+ }
+ }
+}
+
+static bool
+check_xfb_overflow_streams(uint64_t *results, int count)
+{
+ bool overflow = false;
+
+ for (int i = 0; i < count; i++) {
+ uint64_t *result_i = &results[4 * i];
+
+ if ((result_i[3] - result_i[2]) != (result_i[1] - result_i[0])) {
+ overflow = true;
+ break;
+ }