st/mesa: add a second pipeline for compute
[mesa.git] / src / mesa / state_tracker / st_atom.c
index 0676b087eea78e4f91e6702ac087b99baee69d42..2d89512e8542c3d1eae62fb9505cf4cbca3aa7a5 100644 (file)
@@ -38,9 +38,9 @@
 
 
 /**
- * This is used to initialize st->atoms[].
+ * This is used to initialize st->render_atoms[].
  */
-static const struct st_tracked_state *atoms[] =
+static const struct st_tracked_state *render_atoms[] =
 {
    &st_update_depth_stencil_alpha,
    &st_update_clip,
@@ -80,6 +80,11 @@ static const struct st_tracked_state *atoms[] =
    &st_bind_tes_atomics,
    &st_bind_fs_atomics,
    &st_bind_gs_atomics,
+   &st_bind_vs_ssbos,
+   &st_bind_tcs_ssbos,
+   &st_bind_tes_ssbos,
+   &st_bind_fs_ssbos,
+   &st_bind_gs_ssbos,
    &st_update_pixel_transfer,
    &st_update_tess,
 
@@ -88,6 +93,15 @@ static const struct st_tracked_state *atoms[] =
 };
 
 
+/**
+ * This is used to initialize st->compute_atoms[].
+ */
+static const struct st_tracked_state *compute_atoms[] =
+{
+   /* will be updated in the next commit */
+};
+
+
 void st_init_atoms( struct st_context *st )
 {
    /* no-op */
@@ -173,20 +187,41 @@ static void check_attrib_edgeflag(struct st_context *st)
  * Update all derived state:
  */
 
-void st_validate_state( struct st_context *st )
+void st_validate_state( struct st_context *st, enum st_pipeline pipeline )
 {
-   struct st_state_flags *state = &st->dirty;
+   const struct st_tracked_state **atoms;
+   struct st_state_flags *state;
+   GLuint num_atoms;
    GLuint i;
 
+   /* Get pipeline state. */
+   switch (pipeline) {
+    case ST_PIPELINE_RENDER:
+      atoms     = render_atoms;
+      num_atoms = ARRAY_SIZE(render_atoms);
+      state     = &st->dirty;
+      break;
+   case ST_PIPELINE_COMPUTE:
+      atoms     = compute_atoms;
+      num_atoms = ARRAY_SIZE(compute_atoms);
+      state     = &st->dirty_cp;
+      break;
+   default:
+      unreachable("Invalid pipeline specified");
+   }
+
    /* Get Mesa driver state. */
    st->dirty.st |= st->ctx->NewDriverState;
+   st->dirty_cp.st |= st->ctx->NewDriverState;
    st->ctx->NewDriverState = 0;
 
-   check_attrib_edgeflag(st);
+   if (pipeline == ST_PIPELINE_RENDER) {
+      check_attrib_edgeflag(st);
 
-   check_program_state( st );
+      check_program_state(st);
 
-   st_manager_validate_framebuffers(st);
+      st_manager_validate_framebuffers(st);
+   }
 
    if (state->st == 0 && state->mesa == 0)
       return;
@@ -206,7 +241,7 @@ void st_validate_state( struct st_context *st )
       memset(&examined, 0, sizeof(examined));
       prev = *state;
 
-      for (i = 0; i < ARRAY_SIZE(atoms); i++) {         
+      for (i = 0; i < num_atoms; i++) {
         const struct st_tracked_state *atom = atoms[i];
         struct st_state_flags generated;
         
@@ -237,7 +272,7 @@ void st_validate_state( struct st_context *st )
 
    }
    else {
-      for (i = 0; i < ARRAY_SIZE(atoms); i++) {         
+      for (i = 0; i < num_atoms; i++) {
         if (check_state(state, &atoms[i]->dirty))
            atoms[i]->update( st );
       }