i915g: Switch to state atoms
authorJakob Bornecrantz <wallbraker@gmail.com>
Fri, 11 Jun 2010 23:34:54 +0000 (01:34 +0200)
committerJakob Bornecrantz <wallbraker@gmail.com>
Tue, 22 Jun 2010 18:04:55 +0000 (20:04 +0200)
src/gallium/drivers/i915/i915_state.h
src/gallium/drivers/i915/i915_state_derived.c
src/gallium/drivers/i915/i915_state_dynamic.c
src/gallium/drivers/i915/i915_state_immediate.c
src/gallium/drivers/i915/i915_state_sampler.c

index 86c6b0027d5f84e3c590e3876e52f0bc171cd367..7795046f06d966c766eaa6227a81959555a7aaa6 100644 (file)
@@ -35,16 +35,21 @@ struct i915_context;
 
 
 struct i915_tracked_state {
+   const char *name;
+   void (*update)(struct i915_context *);
    unsigned dirty;
-   void (*update)( struct i915_context * );
 };
 
-void i915_update_immediate( struct i915_context *i915 );
-void i915_update_dynamic( struct i915_context *i915 );
-void i915_update_derived( struct i915_context *i915 );
-void i915_update_samplers( struct i915_context *i915 );
-void i915_update_textures(struct i915_context *i915);
+extern struct i915_tracked_state i915_update_vertex_layout;
 
-void i915_emit_hardware_state( struct i915_context *i915 );
+extern struct i915_tracked_state i915_hw_samplers;
+extern struct i915_tracked_state i915_hw_sampler_views;
+extern struct i915_tracked_state i915_hw_immediate;
+extern struct i915_tracked_state i915_hw_dynamic;
+extern struct i915_tracked_state i915_hw_fs;
+extern struct i915_tracked_state i915_hw_framebuffer;
+
+void i915_update_derived(struct i915_context *i915);
+void i915_emit_hardware_state(struct i915_context *i915);
 
 #endif
index 4da46772b5d8e049b806214b37e3b58c54474a97..5ebda94f6c4ed8bdde13050813e5f808237f9557 100644 (file)
 
 
 
-/**
+/***********************************************************************
  * Determine the hardware vertex layout.
  * Depends on vertex/fragment shader state.
  */
-static void calculate_vertex_layout( struct i915_context *i915 )
+static void calculate_vertex_layout(struct i915_context *i915)
 {
    const struct i915_fragment_shader *fs = i915->fs;
    const enum interp_mode colorInterp = i915->rasterizer->color_interp;
@@ -146,37 +146,68 @@ static void calculate_vertex_layout( struct i915_context *i915 )
    }
 }
 
+struct i915_tracked_state i915_update_vertex_layout = {
+   "vertex_layout",
+   calculate_vertex_layout,
+   I915_NEW_RASTERIZER | I915_NEW_FS | I915_NEW_VS
+};
 
 
 
-/* Hopefully this will remain quite simple, otherwise need to pull in
- * something like the state tracker mechanism.
+/***********************************************************************
+ * Update fragment state
  */
-void i915_update_derived( struct i915_context *i915 )
+static void update_fs(struct i915_context *i915)
 {
-   if (i915->dirty & (I915_NEW_RASTERIZER | I915_NEW_FS | I915_NEW_VS))
-      calculate_vertex_layout( i915 );
-
-   if (i915->dirty & (I915_NEW_SAMPLER | I915_NEW_SAMPLER_VIEW))
-      i915_update_samplers(i915);
-
-   if (i915->dirty & I915_NEW_SAMPLER_VIEW)
-      i915_update_textures(i915);
+   i915->hardware_dirty |= I915_HW_PROGRAM; /* XXX right? */
+}
 
-   if (i915->dirty)
-      i915_update_immediate( i915 );
+struct i915_tracked_state i915_hw_fs = {
+   "fs",
+   update_fs,
+   I915_NEW_FS
+};
 
-   if (i915->dirty)
-      i915_update_dynamic( i915 );
 
-   if (i915->dirty & I915_NEW_FS) {
-      i915->hardware_dirty |= I915_HW_PROGRAM; /* XXX right? */
-   }
 
+/***********************************************************************
+ * Update framebuffer state
+ */
+static void update_framebuffer(struct i915_context *i915)
+{
    /* HW emit currently references framebuffer state directly:
     */
-   if (i915->dirty & I915_NEW_FRAMEBUFFER)
-      i915->hardware_dirty |= I915_HW_STATIC;
+   i915->hardware_dirty |= I915_HW_STATIC;
+}
+
+struct i915_tracked_state i915_hw_framebuffer = {
+   "framebuffer",
+   update_framebuffer,
+   I915_NEW_FRAMEBUFFER
+};
+
+
+
+/***********************************************************************
+ */
+static struct i915_tracked_state *atoms[] = {
+   &i915_update_vertex_layout,
+   &i915_hw_samplers,
+   &i915_hw_sampler_views,
+   &i915_hw_immediate,
+   &i915_hw_dynamic,
+   &i915_hw_fs,
+   &i915_hw_framebuffer,
+   NULL,
+};
+
+void i915_update_derived(struct i915_context *i915)
+{
+   int i;
+
+   for (i = 0; atoms[i]; i++)
+      if (atoms[i]->dirty & i915->dirty)
+         atoms[i]->update(i915);
 
    i915->dirty = 0;
 }
index 7a66a3e08723666d5cb42d32018eadcc938755b2..d63d4a98ddc41d181c4ee2459faa41ce7f7d465c 100644 (file)
@@ -86,8 +86,9 @@ static void upload_MODES4(struct i915_context *i915)
 }
 
 const struct i915_tracked_state i915_upload_MODES4 = {
-   I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL,
-   upload_MODES4
+   "MODES4",
+   upload_MODES4,
+   I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL
 };
 
 
@@ -111,8 +112,9 @@ static void upload_BFO(struct i915_context *i915)
 }
 
 const struct i915_tracked_state i915_upload_BFO = {
-   I915_NEW_DEPTH_STENCIL,
-   upload_BFO
+   "BFO",
+   upload_BFO,
+   I915_NEW_DEPTH_STENCIL
 };
 
 
@@ -144,8 +146,9 @@ static void upload_BLENDCOLOR(struct i915_context *i915)
 }
 
 const struct i915_tracked_state i915_upload_BLENDCOLOR = {
-   I915_NEW_BLEND,
-   upload_BLENDCOLOR
+   "BLENDCOLOR",
+   upload_BLENDCOLOR,
+   I915_NEW_BLEND
 };
 
 
@@ -163,8 +166,9 @@ static void upload_IAB(struct i915_context *i915)
 }
 
 const struct i915_tracked_state i915_upload_IAB = {
-   I915_NEW_BLEND,
-   upload_IAB
+   "IAB",
+   upload_IAB,
+   I915_NEW_BLEND
 };
 
 
@@ -180,8 +184,9 @@ static void upload_DEPTHSCALE(struct i915_context *i915)
 }
 
 const struct i915_tracked_state i915_upload_DEPTHSCALE = {
-   I915_NEW_RASTERIZER,
-   upload_DEPTHSCALE
+   "DEPTHSCALE",
+   upload_DEPTHSCALE,
+   I915_NEW_RASTERIZER
 };
 
 
@@ -234,8 +239,9 @@ static void upload_STIPPLE(struct i915_context *i915)
 }
 
 const struct i915_tracked_state i915_upload_STIPPLE = {
-   I915_NEW_RASTERIZER | I915_NEW_STIPPLE,
-   upload_STIPPLE
+   "STIPPLE",
+   upload_STIPPLE,
+   I915_NEW_RASTERIZER | I915_NEW_STIPPLE
 };
 
 
@@ -281,8 +287,9 @@ static void upload_SCISSOR_RECT(struct i915_context *i915)
 }
 
 const struct i915_tracked_state i915_upload_SCISSOR_RECT = {
-   I915_NEW_SCISSOR,
-   upload_SCISSOR_RECT
+   "SCISSOR RECT",
+   upload_SCISSOR_RECT,
+   I915_NEW_SCISSOR
 };
 
 
@@ -303,7 +310,7 @@ static const struct i915_tracked_state *atoms[] = {
 /* These will be dynamic indirect state commands, but for now just end
  * up on the batch buffer with everything else.
  */
-void i915_update_dynamic(struct i915_context *i915)
+static void update_dynamic(struct i915_context *i915)
 {
    int i;
 
@@ -311,3 +318,9 @@ void i915_update_dynamic(struct i915_context *i915)
       if (i915->dirty & atoms[i]->dirty)
          atoms[i]->update(i915);
 }
+
+struct i915_tracked_state i915_hw_dynamic = {
+   "dynamic",
+   update_dynamic,
+   ~0 /* all state atoms, becuase we do internal checking */
+};
index fb7fa8f80e0038b6947db536c4baae84c675fb22..f9ade7077f245a1a9493758168803dbee778702a 100644 (file)
@@ -79,8 +79,9 @@ static void upload_S0S1(struct i915_context *i915)
 }
 
 const struct i915_tracked_state i915_upload_S0S1 = {
-   I915_NEW_VBO | I915_NEW_VERTEX_FORMAT,
-   upload_S0S1
+   "imm S0 S1",
+   upload_S0S1,
+   I915_NEW_VBO | I915_NEW_VERTEX_FORMAT
 };
 
 
@@ -115,8 +116,9 @@ static void upload_S2S4(struct i915_context *i915)
 }
 
 const struct i915_tracked_state i915_upload_S2S4 = {
-   I915_NEW_RASTERIZER | I915_NEW_VERTEX_FORMAT,
-   upload_S2S4
+   "imm S2 S4",
+   upload_S2S4,
+   I915_NEW_RASTERIZER | I915_NEW_VERTEX_FORMAT
 };
 
 
@@ -152,8 +154,9 @@ static void upload_S5(struct i915_context *i915)
 }
 
 const struct i915_tracked_state i915_upload_S5 = {
-   (I915_NEW_DEPTH_STENCIL | I915_NEW_BLEND | I915_NEW_RASTERIZER),
-   upload_S5
+   "imm S5",
+   upload_S5,
+   I915_NEW_DEPTH_STENCIL | I915_NEW_BLEND | I915_NEW_RASTERIZER
 };
 
 
@@ -184,8 +187,9 @@ static void upload_S6(struct i915_context *i915)
 }
 
 const struct i915_tracked_state i915_upload_S6 = {
-   I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL | I915_NEW_FRAMEBUFFER,
-   upload_S6
+   "imm s6",
+   upload_S6,
+   I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL | I915_NEW_FRAMEBUFFER
 };
 
 
@@ -207,8 +211,9 @@ static void upload_S7(struct i915_context *i915)
 }
 
 const struct i915_tracked_state i915_upload_S7 = {
-   I915_NEW_RASTERIZER,
-   upload_S7
+   "imm S7",
+   upload_S7,
+   I915_NEW_RASTERIZER
 };
 
 
@@ -223,7 +228,7 @@ static const struct i915_tracked_state *atoms[] = {
    &i915_upload_S7
 };
 
-void i915_update_immediate(struct i915_context *i915)
+static void update_immediate(struct i915_context *i915)
 {
    int i;
 
@@ -231,3 +236,9 @@ void i915_update_immediate(struct i915_context *i915)
       if (i915->dirty & atoms[i]->dirty)
          atoms[i]->update(i915);
 }
+
+struct i915_tracked_state i915_hw_immediate = {
+   "immediate",
+   update_immediate,
+   ~0 /* all state atoms, becuase we do internal checking */
+};
index 8d2f16b80d342d8756687985dfd01f0761ff87bc..941259eb76611cecfd7b07bf09d246a0166e627d 100644 (file)
@@ -140,7 +140,7 @@ static void update_sampler(struct i915_context *i915,
    state[1] |= (unit << SS3_TEXTUREMAP_INDEX_SHIFT);
 }
 
-void i915_update_samplers(struct i915_context *i915)
+static void update_samplers(struct i915_context *i915)
 {
    uint unit;
 
@@ -173,6 +173,11 @@ void i915_update_samplers(struct i915_context *i915)
    i915->hardware_dirty |= I915_HW_SAMPLER | I915_HW_MAP;
 }
 
+struct i915_tracked_state i915_hw_samplers = {
+   "sampler_views",
+   update_samplers,
+   I915_NEW_SAMPLER | I915_NEW_SAMPLER_VIEW
+};
 
 
 
@@ -291,7 +296,7 @@ static void update_texture(struct i915_context *i915,
        | ((depth - 1) << MS4_VOLUME_DEPTH_SHIFT));
 }
 
-void i915_update_textures(struct i915_context *i915)
+static void update_textures(struct i915_context *i915)
 {
    uint unit;
 
@@ -312,3 +317,9 @@ void i915_update_textures(struct i915_context *i915)
 
    i915->hardware_dirty |= I915_HW_MAP;
 }
+
+struct i915_tracked_state i915_hw_sampler_views = {
+   "sampler_views",
+   update_textures,
+   I915_NEW_SAMPLER_VIEW
+};