[Mesa-dev] [PATCH 10/13] i965: Clean up code for VS pull constant surface creation.

Eric Anholt eric at anholt.net
Wed Nov 9 10:33:21 PST 2011


On Tue,  8 Nov 2011 14:32:09 -0800, Kenneth Graunke <kenneth at whitecape.org> wrote:
> Like for the WM pull constants, we can merge the former prepare/emit
> stages into one tracked state atom.  Furthermore, the code that used to
> handle the binding table was removed in the last commit, leaving some
> rather silly looking short functions that can easily be folded in.
> 
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>

> -   &brw_vs_constants, /* Before vs_surfaces and constant_buffer */
> -   &brw_wm_pull_constants,  /* Before brw_wm_binding_table */
> +   /* Pull constants must be before brw_binding_table */
> +   &brw_vs_pull_constants,
> +   &brw_wm_pull_constants,
> +
>     &gen6_vs_push_constants, /* Before vs_state */
>     &gen6_wm_push_constants, /* Before wm_state */
>  
> -   &brw_vs_surfaces,		/* must do before unit */
>     &brw_renderbuffer_surfaces,  /* must do before unit */
>     &brw_texture_surfaces,       /* must do before unit */
>     &brw_binding_table,

I think the pull constants atoms should live down with the rest of the
surfaces.

> -/**
> - * Update the surface state for a VS constant buffer.
> - *
> - * Sets brw->vs.surf_bo[surf] and brw->vp->const_buffer.
> - */
> -static void
> -brw_update_vs_constant_surface( struct gl_context *ctx,
> -                                GLuint surf)
> -{
> -   struct brw_context *brw = brw_context(ctx);
> -   struct intel_context *intel = &brw->intel;
> -   struct brw_vertex_program *vp =
> -      (struct brw_vertex_program *) brw->vertex_program;
> -   const struct gl_program_parameter_list *params = vp->program.Base.Parameters;
> -
> -   /* If there's no constant buffer, then no surface BO is needed to point at
> -    * it.
> -    */
> -   if (brw->vs.const_bo == NULL) {
> -      brw->bind.surf_offset[surf] = 0;
> -      return;
> -   }
>  
> +   const int surf = SURF_INDEX_VERT_CONST_BUFFER;
>     intel->vtbl.create_constant_surface(brw, brw->vs.const_bo,
>  				       params->NumParameters,
>  				       &brw->bind.surf_offset[surf]);

> -const struct brw_tracked_state brw_vs_surfaces = {
> +const struct brw_tracked_state brw_vs_pull_constants = {
>     .dirty = {
> -      .mesa = 0,
> -      .brw = (BRW_NEW_VS_CONSTBUF |
> -	      BRW_NEW_BATCH),
> -      .cache = 0
> +      .mesa = (_NEW_PROGRAM_CONSTANTS),
> +      .brw = (BRW_NEW_VERTEX_PROGRAM),
> +      .cache = CACHE_NEW_VS_PROG,
>     },
> -   .emit = brw_upload_vs_surfaces,
> +   .emit = brw_upload_vs_pull_constants,
>  };

Looks like BRW_NEW_BATCH got misplaced, which is required since you're
uploading state batch data (create_constant_surface()).

Hmm.  You know, I ought to add some debug code that checks that
!bo_references(intel->batch.bo, old_batch_bo).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20111109/53e7b222/attachment-0001.pgp>


More information about the mesa-dev mailing list