[Mesa-dev] [PATCH 5/9] i965: Implement Pause/ResumeTransformfeedback driver hooks on Gen7+.
Kenneth Graunke
kenneth at whitecape.org
Fri Oct 18 08:09:33 CEST 2013
The ARB_transform_feedback2 extension introduces the ability to pause
and resume transform feedback sessions. Although only one can be active
at a time, it's possible to switch between multiple transform feedback
objects while paused.
In order to facilitate this, we need to save/restore the SO_WRITE_OFFSET
registers so that after resuming, the GPU continues writing where it
left off.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/mesa/drivers/dri/i965/brw_context.c | 2 ++
src/mesa/drivers/dri/i965/brw_context.h | 9 +++++++
src/mesa/drivers/dri/i965/gen6_sol.c | 5 ++++
src/mesa/drivers/dri/i965/gen7_sol_state.c | 40 ++++++++++++++++++++++++++++++
4 files changed, 56 insertions(+)
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index fbfbce3..dbff04a 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -256,6 +256,8 @@ brw_init_driver_functions(struct brw_context *brw,
if (brw->gen >= 7) {
functions->BeginTransformFeedback = gen7_begin_transform_feedback;
functions->EndTransformFeedback = gen7_end_transform_feedback;
+ functions->PauseTransformFeedback = gen7_pause_transform_feedback;
+ functions->ResumeTransformFeedback = gen7_resume_transform_feedback;
} else {
functions->BeginTransformFeedback = brw_begin_transform_feedback;
functions->EndTransformFeedback = brw_end_transform_feedback;
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index f55d41b..02d2b9f 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -876,6 +876,9 @@ struct intel_batchbuffer {
struct brw_transform_feedback_object {
struct gl_transform_feedback_object base;
+
+ /** A buffer to hold SO_WRITE_OFFSET(n) values while paused. */
+ drm_intel_bo *offset_bo;
};
/**
@@ -1573,6 +1576,12 @@ gen7_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
void
gen7_end_transform_feedback(struct gl_context *ctx,
struct gl_transform_feedback_object *obj);
+void
+gen7_pause_transform_feedback(struct gl_context *ctx,
+ struct gl_transform_feedback_object *obj);
+void
+gen7_resume_transform_feedback(struct gl_context *ctx,
+ struct gl_transform_feedback_object *obj);
/* brw_blorp_blit.cpp */
GLbitfield
diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c
index ffecfc8..fb801fe 100644
--- a/src/mesa/drivers/dri/i965/gen6_sol.c
+++ b/src/mesa/drivers/dri/i965/gen6_sol.c
@@ -141,6 +141,9 @@ brw_new_transform_feedback(struct gl_context *ctx, GLuint name)
CALLOC_STRUCT(brw_transform_feedback_object);
struct gl_transform_feedback_object *obj = &brw_obj->base;
+ brw_obj->offset_bo =
+ drm_intel_bo_alloc(brw->bufmgr, "transform feedback offsets", 16, 4096);
+
obj->Name = name;
obj->RefCount = 1;
obj->EverBound = GL_FALSE;
@@ -159,6 +162,8 @@ brw_delete_transform_feedback(struct gl_context *ctx,
_mesa_reference_buffer_object(ctx, &obj->Buffers[i], NULL);
}
+ drm_intel_bo_unreference(brw_obj->offset_bo);
+
free(brw_obj);
}
diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c b/src/mesa/drivers/dri/i965/gen7_sol_state.c
index 504d9e7..c7fe4f6 100644
--- a/src/mesa/drivers/dri/i965/gen7_sol_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c
@@ -273,3 +273,43 @@ gen7_end_transform_feedback(struct gl_context *ctx,
intel_batchbuffer_emit_mi_flush(brw);
}
+
+void
+gen7_pause_transform_feedback(struct gl_context *ctx,
+ struct gl_transform_feedback_object *obj)
+{
+ struct brw_context *brw = brw_context(ctx);
+ struct brw_transform_feedback_object *brw_obj =
+ (struct brw_transform_feedback_object *) obj;
+
+ /* Save the SOL buffer offset register values. */
+ for (int i = 0; i < 4; i++) {
+ BEGIN_BATCH(3);
+ OUT_BATCH(MI_STORE_REGISTER_MEM | (3 - 2));
+ OUT_BATCH(GEN7_SO_WRITE_OFFSET(i));
+ OUT_RELOC(brw_obj->offset_bo,
+ I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+ i * sizeof(uint32_t));
+ ADVANCE_BATCH();
+ }
+}
+
+void
+gen7_resume_transform_feedback(struct gl_context *ctx,
+ struct gl_transform_feedback_object *obj)
+{
+ struct brw_context *brw = brw_context(ctx);
+ struct brw_transform_feedback_object *brw_obj =
+ (struct brw_transform_feedback_object *) obj;
+
+ /* Reload the SOL buffer offset registers. */
+ for (int i = 0; i < 4; i++) {
+ BEGIN_BATCH(3);
+ OUT_BATCH(GEN7_MI_LOAD_REGISTER_MEM | (3 - 2));
+ OUT_BATCH(GEN7_SO_WRITE_OFFSET(i));
+ OUT_RELOC(brw_obj->offset_bo,
+ I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+ i * sizeof(uint32_t));
+ ADVANCE_BATCH();
+ }
+}
--
1.8.3.2
More information about the mesa-dev
mailing list