i965: Combine the two WM pull constant tracked state atoms.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 1 Nov 2011 23:19:39 +0000 (16:19 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 11 Nov 2011 06:51:19 +0000 (22:51 -0800)
These were only split for historical reasons: brw_wm_constants used to
be the "prepare" step, while brw_wm_constant_surface was "emit".  Now
that both happen at emit time, it makes sense to combine them.

Call the newly combined state atom "brw_wm_pull_constants" to indicate
help distinguish it from the Gen6+ atoms that handle push constants.

Finally, remove the BRW_NEW_WM_CONSTBUF dirty bit entirely now that it's
never flagged nor used.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/brw_state_upload.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c

index f8e6f81d7cf55c59ed59a1db271c28c17825ee27..c889e54021ff5448f726e5251024bf6ce8298d03 100644 (file)
@@ -142,7 +142,6 @@ enum brw_state_id {
    BRW_STATE_NR_VS_SURFACES,
    BRW_STATE_INDEX_BUFFER,
    BRW_STATE_VS_CONSTBUF,
-   BRW_STATE_WM_CONSTBUF,
    BRW_STATE_PROGRAM_CACHE,
    BRW_STATE_STATE_BASE_ADDRESS,
 };
@@ -171,7 +170,6 @@ enum brw_state_id {
 /** \see brw.state.depth_region */
 #define BRW_NEW_INDEX_BUFFER           (1 << BRW_STATE_INDEX_BUFFER)
 #define BRW_NEW_VS_CONSTBUF            (1 << BRW_STATE_VS_CONSTBUF)
-#define BRW_NEW_WM_CONSTBUF            (1 << BRW_STATE_WM_CONSTBUF)
 #define BRW_NEW_PROGRAM_CACHE          (1 << BRW_STATE_PROGRAM_CACHE)
 #define BRW_NEW_STATE_BASE_ADDRESS     (1 << BRW_STATE_STATE_BASE_ADDRESS)
 
index 635718891f062e3c189dbbe213c54d842e97e6d1..3979206b3fb1c9356e1bf9dfb2e61b0a15aeeae5 100644 (file)
@@ -42,7 +42,7 @@ extern const struct brw_tracked_state brw_check_fallback;
 extern const struct brw_tracked_state brw_clip_prog;
 extern const struct brw_tracked_state brw_clip_unit;
 extern const struct brw_tracked_state brw_vs_constants;
-extern const struct brw_tracked_state brw_wm_constants;
+extern const struct brw_tracked_state brw_wm_pull_constants;
 extern const struct brw_tracked_state brw_constant_buffer;
 extern const struct brw_tracked_state brw_curbe_offsets;
 extern const struct brw_tracked_state brw_invarient_state;
@@ -69,7 +69,6 @@ extern const struct brw_tracked_state brw_vs_unit;
 extern const struct brw_tracked_state brw_wm_input_sizes;
 extern const struct brw_tracked_state brw_wm_prog;
 extern const struct brw_tracked_state brw_wm_samplers;
-extern const struct brw_tracked_state brw_wm_constant_surface;
 extern const struct brw_tracked_state brw_wm_surfaces;
 extern const struct brw_tracked_state brw_wm_binding_table;
 extern const struct brw_tracked_state brw_wm_unit;
index 40563ec64d7d403552b7f5f5469e4e89132e0fdc..d3bc5e0f440a9de9780694b1e794d9fecc3d1b47 100644 (file)
@@ -64,10 +64,9 @@ static const struct brw_tracked_state *gen4_atoms[] =
    &brw_cc_unit,
 
    &brw_vs_constants, /* Before vs_surfaces and constant_buffer */
-   &brw_wm_constants, /* Before wm_surfaces and constant_buffer */
+   &brw_wm_pull_constants, /* Before brw_wm_binding_table */
 
    &brw_vs_surfaces,           /* must do before unit */
-   &brw_wm_constant_surface,   /* must do before wm surfaces/bind bo */
    &brw_wm_surfaces,           /* must do before samplers and unit */
    &brw_wm_binding_table,
    &brw_wm_samplers,
@@ -134,12 +133,11 @@ static const struct brw_tracked_state *gen6_atoms[] =
    &gen6_cc_state_pointers,
 
    &brw_vs_constants, /* Before vs_surfaces and constant_buffer */
-   &brw_wm_constants, /* Before wm_surfaces and constant_buffer */
+   &brw_wm_pull_constants,  /* Before brw_wm_binding_table */
    &gen6_vs_push_constants, /* Before vs_state */
    &gen6_wm_push_constants, /* Before wm_state */
 
    &brw_vs_surfaces,           /* must do before unit */
-   &brw_wm_constant_surface,   /* must do before wm surfaces/bind bo */
    &brw_wm_surfaces,           /* must do before samplers and unit */
    &brw_wm_binding_table,
 
@@ -199,12 +197,11 @@ const struct brw_tracked_state *gen7_atoms[] =
    &gen7_depth_stencil_state_pointer,
 
    &brw_vs_constants, /* Before vs_surfaces and constant_buffer */
-   &brw_wm_constants, /* Before wm_surfaces and constant_buffer */
+   &brw_wm_pull_constants,  /* Before brw_wm_binding_table */
    &gen6_vs_push_constants, /* Before vs_state */
    &gen6_wm_push_constants, /* Before wm_surfaces and constant_buffer */
 
    &brw_vs_surfaces,           /* must do before unit */
-   &brw_wm_constant_surface,   /* must do before wm surfaces/bind bo */
    &brw_wm_surfaces,           /* must do before samplers and unit */
    &brw_wm_binding_table,
 
@@ -358,7 +355,6 @@ static struct dirty_bit_map brw_bits[] = {
    DEFINE_BIT(BRW_NEW_VERTICES),
    DEFINE_BIT(BRW_NEW_BATCH),
    DEFINE_BIT(BRW_NEW_VS_CONSTBUF),
-   DEFINE_BIT(BRW_NEW_WM_CONSTBUF),
    DEFINE_BIT(BRW_NEW_VS_BINDING_TABLE),
    DEFINE_BIT(BRW_NEW_GS_BINDING_TABLE),
    DEFINE_BIT(BRW_NEW_PS_BINDING_TABLE),
index cca1d48439c8580775cc5684fef53216594d0279..1bce06c1eae849d3831ab9c3f7c2d5b41632d050 100644 (file)
@@ -362,18 +362,21 @@ brw_upload_wm_pull_constants(struct brw_context *brw)
    /* BRW_NEW_FRAGMENT_PROGRAM */
    struct brw_fragment_program *fp =
       (struct brw_fragment_program *) brw->fragment_program;
+   struct gl_program_parameter_list *params = fp->program.Base.Parameters;
    const int size = brw->wm.prog_data->nr_pull_params * sizeof(float);
+   const int surf_index = SURF_INDEX_FRAG_CONST_BUFFER;
    float *constants;
    unsigned int i;
 
-   _mesa_load_state_parameters(ctx, fp->program.Base.Parameters);
+   _mesa_load_state_parameters(ctx, params);
 
    /* CACHE_NEW_WM_PROG */
    if (brw->wm.prog_data->nr_pull_params == 0) {
       if (brw->wm.const_bo) {
         drm_intel_bo_unreference(brw->wm.const_bo);
         brw->wm.const_bo = NULL;
-        brw->state.dirty.brw |= BRW_NEW_WM_CONSTBUF;
+        brw->wm.surf_offset[surf_index] = 0;
+        brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
       }
       return;
    }
@@ -391,61 +394,22 @@ brw_upload_wm_pull_constants(struct brw_context *brw)
    }
    drm_intel_gem_bo_unmap_gtt(brw->wm.const_bo);
 
-   brw->state.dirty.brw |= BRW_NEW_WM_CONSTBUF;
+   intel->vtbl.create_constant_surface(brw, brw->wm.const_bo,
+                                      params->NumParameters,
+                                      &brw->wm.surf_offset[surf_index]);
+
+   brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
 }
 
-const struct brw_tracked_state brw_wm_constants = {
+const struct brw_tracked_state brw_wm_pull_constants = {
    .dirty = {
       .mesa = (_NEW_PROGRAM_CONSTANTS),
-      .brw = (BRW_NEW_FRAGMENT_PROGRAM),
+      .brw = (BRW_NEW_BATCH | BRW_NEW_FRAGMENT_PROGRAM),
       .cache = CACHE_NEW_WM_PROG,
    },
    .emit = brw_upload_wm_pull_constants,
 };
 
-/**
- * Updates surface / buffer for fragment shader constant buffer, if
- * one is required.
- *
- * This consumes the state updates for the constant buffer, and produces
- * BRW_NEW_WM_SURFACES to get picked up by brw_prepare_wm_surfaces for
- * inclusion in the binding table.
- */
-static void upload_wm_constant_surface(struct brw_context *brw )
-{
-   GLuint surf = SURF_INDEX_FRAG_CONST_BUFFER;
-   struct brw_fragment_program *fp =
-      (struct brw_fragment_program *) brw->fragment_program;
-   const struct gl_program_parameter_list *params =
-      fp->program.Base.Parameters;
-
-   /* If there's no constant buffer, then no surface BO is needed to point at
-    * it.
-    */
-   if (brw->wm.const_bo == 0) {
-      if (brw->wm.surf_offset[surf]) {
-        brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
-        brw->wm.surf_offset[surf] = 0;
-      }
-      return;
-   }
-
-   brw->intel.vtbl.create_constant_surface(brw, brw->wm.const_bo,
-                                          params->NumParameters,
-                                          &brw->wm.surf_offset[surf]);
-   brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
-}
-
-const struct brw_tracked_state brw_wm_constant_surface = {
-   .dirty = {
-      .mesa = 0,
-      .brw = (BRW_NEW_WM_CONSTBUF |
-             BRW_NEW_BATCH),
-      .cache = 0
-   },
-   .emit = upload_wm_constant_surface,
-};
-
 static void
 brw_update_null_renderbuffer_surface(struct brw_context *brw, unsigned int unit)
 {