[Mesa-dev] [PATCH 7/7] i965: Split BeginTransformFeedback hook into Gen6 and Gen7+ variants.
Paul Berry
stereotype441 at gmail.com
Tue May 21 07:53:37 PDT 2013
On 20 May 2013 15:54, Kenneth Graunke <kenneth at whitecape.org> wrote:
> Most of the work in BeginTransformFeedback is only necessary on Gen6.
> We may as well just skip it on Gen7+.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> Cc: Eric Anholt <eric at anholt.net>
> Cc: Paul Berry <stereotype441 at gmail.com>
> ---
> src/mesa/drivers/dri/i965/brw_context.c | 8 +++---
> src/mesa/drivers/dri/i965/brw_context.h | 3 +++
> src/mesa/drivers/dri/i965/gen6_sol.c | 41
> +++++++++++-------------------
> src/mesa/drivers/dri/i965/gen7_sol_state.c | 17 +++++++++++++
> 4 files changed, 40 insertions(+), 29 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c
> b/src/mesa/drivers/dri/i965/brw_context.c
> index 405580f..56c42ba 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -94,12 +94,14 @@ static void brwInitDriverFunctions(struct intel_screen
> *screen,
> gen4_init_queryobj_functions(functions);
>
> functions->QuerySamplesForFormat = brw_query_samples_for_format;
> - functions->BeginTransformFeedback = brw_begin_transform_feedback;
>
> - if (screen->gen >= 7)
> + if (screen->gen >= 7) {
> + functions->BeginTransformFeedback = gen7_begin_transform_feedback;
> functions->EndTransformFeedback = gen7_end_transform_feedback;
> - else
> + } else {
> + functions->BeginTransformFeedback = brw_begin_transform_feedback;
> functions->EndTransformFeedback = brw_end_transform_feedback;
> + }
>
> if (screen->gen >= 6)
> functions->GetSamplePosition = gen6_get_sample_position;
> diff --git a/src/mesa/drivers/dri/i965/brw_context.h
> b/src/mesa/drivers/dri/i965/brw_context.h
> index be49078..60b713d 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.h
> +++ b/src/mesa/drivers/dri/i965/brw_context.h
> @@ -1228,6 +1228,9 @@ brw_end_transform_feedback(struct gl_context *ctx,
>
> /* gen7_sol_state.c */
> void
> +gen7_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
> + struct gl_transform_feedback_object *obj);
> +void
> gen7_end_transform_feedback(struct gl_context *ctx,
> struct gl_transform_feedback_object *obj);
>
> diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c
> b/src/mesa/drivers/dri/i965/gen6_sol.c
> index cdd6e74..8e197a1 100644
> --- a/src/mesa/drivers/dri/i965/gen6_sol.c
> +++ b/src/mesa/drivers/dri/i965/gen6_sol.c
> @@ -152,36 +152,25 @@ brw_begin_transform_feedback(struct gl_context *ctx,
> GLenum mode,
> = _mesa_compute_max_transform_feedback_vertices(xfb_obj,
> linked_xfb_info);
>
> - if (intel->gen == 6) {
>
Can we replace this with "assert(intel->gen == 6)" just to document that
this is a Gen6-only function now?
With that change, the series is:
Reviewed-by: Paul Berry <stereotype441 at gmail.com>
> - /* Initialize the SVBI 0 register to zero and set the maximum
> index. */
> + /* Initialize the SVBI 0 register to zero and set the maximum index. */
> + BEGIN_BATCH(4);
> + OUT_BATCH(_3DSTATE_GS_SVB_INDEX << 16 | (4 - 2));
> + OUT_BATCH(0); /* SVBI 0 */
> + OUT_BATCH(0); /* starting index */
> + OUT_BATCH(max_index);
> + ADVANCE_BATCH();
> +
> + /* Initialize the rest of the unused streams to sane values.
> Otherwise,
> + * they may indicate that there is no room to write data and prevent
> + * anything from happening at all.
> + */
> + for (int i = 1; i < 4; i++) {
> BEGIN_BATCH(4);
> OUT_BATCH(_3DSTATE_GS_SVB_INDEX << 16 | (4 - 2));
> - OUT_BATCH(0); /* SVBI 0 */
> + OUT_BATCH(i << SVB_INDEX_SHIFT);
> OUT_BATCH(0); /* starting index */
> - OUT_BATCH(max_index);
> + OUT_BATCH(0xffffffff);
> ADVANCE_BATCH();
> -
> - /* Initialize the rest of the unused streams to sane values.
> Otherwise,
> - * they may indicate that there is no room to write data and prevent
> - * anything from happening at all.
> - */
> - for (int i = 1; i < 4; i++) {
> - BEGIN_BATCH(4);
> - OUT_BATCH(_3DSTATE_GS_SVB_INDEX << 16 | (4 - 2));
> - OUT_BATCH(i << SVB_INDEX_SHIFT);
> - OUT_BATCH(0); /* starting index */
> - OUT_BATCH(0xffffffff);
> - ADVANCE_BATCH();
> - }
> - } else if (intel->gen >= 7) {
> - /* Reset the SOL buffer offset register. */
> - for (int i = 0; i < 4; i++) {
> - BEGIN_BATCH(3);
> - OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2));
> - OUT_BATCH(GEN7_SO_WRITE_OFFSET(i));
> - OUT_BATCH(0);
> - ADVANCE_BATCH();
> - }
> }
> }
>
> diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c
> b/src/mesa/drivers/dri/i965/gen7_sol_state.c
> index 2c4b7f9..8dfac01 100644
> --- a/src/mesa/drivers/dri/i965/gen7_sol_state.c
> +++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c
> @@ -254,6 +254,23 @@ const struct brw_tracked_state gen7_sol_state = {
> };
>
> void
> +gen7_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
> + struct gl_transform_feedback_object *obj)
> +{
> + struct brw_context *brw = brw_context(ctx);
> + struct intel_context *intel = &brw->intel;
> +
> + /* Reset the SOL buffer offset register. */
> + for (int i = 0; i < 4; i++) {
> + BEGIN_BATCH(3);
> + OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2));
> + OUT_BATCH(GEN7_SO_WRITE_OFFSET(i));
> + OUT_BATCH(0);
> + ADVANCE_BATCH();
> + }
> +}
> +
> +void
> gen7_end_transform_feedback(struct gl_context *ctx,
> struct gl_transform_feedback_object *obj)
> {
> --
> 1.8.2.3
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130521/7434abf7/attachment.html>
More information about the mesa-dev
mailing list