Some basic state - blend and ztest sort of work.
authorKeith Whitwell <keith@tungstengraphics.com>
Thu, 9 Aug 2007 15:43:44 +0000 (16:43 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Thu, 9 Aug 2007 15:44:22 +0000 (16:44 +0100)
src/mesa/pipe/i915simple/Makefile
src/mesa/pipe/i915simple/i915_context.h
src/mesa/pipe/i915simple/i915_prim_emit.c
src/mesa/pipe/i915simple/i915_state.h
src/mesa/pipe/i915simple/i915_state_derived.c
src/mesa/pipe/i915simple/i915_state_emit.c

index 93d9c6c..1adffbb 100644 (file)
@@ -15,6 +15,7 @@ DRIVER_SOURCES = \
        i915_debug_fp.c \
        i915_regions.c \
        i915_state.c \
+       i915_state_immediate.c \
        i915_state_derived.c \
        i915_state_emit.c \
        i915_state_fragprog.c \
index c298f0f..0f0728c 100644 (file)
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
 
+
+
+#define I915_TEX_UNITS 8
+
+#define I915_DYNAMIC_MODES4       0
+#define I915_DYNAMIC_DEPTHSCALE_0 1 /* just the header */
+#define I915_DYNAMIC_DEPTHSCALE_1 2 
+#define I915_DYNAMIC_IAB          3
+#define I915_DYNAMIC_BC_0         4 /* just the header */
+#define I915_DYNAMIC_BC_1         5
+#define I915_DYNAMIC_BFO_0        6 
+#define I915_DYNAMIC_BFO_1        7
+#define I915_DYNAMIC_STP_0        8 
+#define I915_DYNAMIC_STP_1        9 
+#define I915_DYNAMIC_SC_0         10 
+#define I915_DYNAMIC_SC_1         11 
+#define I915_DYNAMIC_SC_2         12 
+#define I915_DYNAMIC_SC_3         13 
+#define I915_MAX_DYNAMIC          14
+
+
+#define I915_IMMEDIATE_S0         0
+#define I915_IMMEDIATE_S1         1
+#define I915_IMMEDIATE_S2         2
+#define I915_IMMEDIATE_S3         3
+#define I915_IMMEDIATE_S4         4
+#define I915_IMMEDIATE_S5         5
+#define I915_IMMEDIATE_S6         6
+#define I915_IMMEDIATE_S7         7
+#define I915_MAX_IMMEDIATE        8
+
+/* These must mach the order of LI0_STATE_* bits, as they will be used
+ * to generate hardware packets:
+ */
+#define I915_CACHE_STATIC         0 
+#define I915_CACHE_DYNAMIC        1 /* handled specially */
+#define I915_CACHE_SAMPLER        2
+#define I915_CACHE_MAP            3
+#define I915_CACHE_PROGRAM        4
+#define I915_CACHE_CONSTANTS      5
+#define I915_MAX_CACHE            6
+
+
+struct i915_cache_context;
+
+/* Use to calculate differences between state emitted to hardware and
+ * current driver-calculated state.  
+ */
+struct i915_state 
+{
+   GLuint immediate[I915_MAX_IMMEDIATE];
+   
+   GLuint id;                  /* track lost context events */
+};
+
+
+
 struct i915_context
 {
    struct pipe_context pipe; 
@@ -56,13 +113,19 @@ struct i915_context
    struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS];
    struct pipe_viewport_state viewport;
    GLuint dirty;
-   GLuint hw_dirty;
 
    GLuint *batch_start;
 
+   struct i915_state current;
+   GLuint hardware_dirty;
+   
+
+
    struct pipe_scissor_state cliprect;
 };
 
+/* A flag for each state_tracker state object:
+ */
 #define I915_NEW_VIEWPORT      0x1
 #define I915_NEW_SETUP         0x2
 #define I915_NEW_FS            0x4
@@ -77,6 +140,16 @@ struct i915_context
 #define I915_NEW_TEXTURE     0x800
 #define I915_NEW_STENCIL    0x1000
 
+/* Driver's internally generated state flags:
+ */
+#define I915_NEW_VERTEX_FORMAT    0x10000
+
+
+/* Dirty flags for hardware emit
+ */
+#define I915_HW_INDIRECT          (1<<0)
+#define I915_HW_IMMEDIATE         (1<<1)
+
 
 /***********************************************************************
  * i915_prim_emit.c: 
index a1e0e85..708fc41 100644 (file)
@@ -123,7 +123,7 @@ emit_prim( struct draw_stage *stage,
    if (i915->dirty)
       i915_update_derived( i915 );
 
-   if (i915->hw_dirty)
+   if (i915->hardware_dirty)
       i915_emit_hardware_state( i915 );
 
    ptr = winsys->batch_start( winsys, nr * vertex_size, 0 );
index c9b9f15..e26e8f6 100644 (file)
@@ -33,6 +33,7 @@
 
 struct i915_context;
 
+void i915_update_immediate( struct i915_context *i915 );
 void i915_update_derived( struct i915_context *i915 );
 
 void i915_emit_hardware_state( struct i915_context *i915 );
index f1f798b..32b8b6c 100644 (file)
@@ -183,7 +183,12 @@ void i915_update_derived( struct i915_context *i915 )
       compute_cliprect(i915);
 
    if (i915->dirty)
-      i915->hw_dirty = 1;
+      i915_update_immediate( i915 );
+
+   /* HW emit currently references framebuffer state directly:
+    */
+   if (i915->dirty & I915_NEW_FRAMEBUFFER)
+      i915->hardware_dirty = 1;
 
    i915->dirty = 0;
 }
index 3b2ab47..1a50470 100644 (file)
@@ -151,10 +151,10 @@ i915_emit_hardware_state(struct i915_context *i915 )
                I1_LOAD_S(6) | 
                (3));
       
-      OUT_BATCH(0xffffffff);
-      OUT_BATCH(0x00902440); //      OUT_BATCH(S4_VFMT_XYZ | S4_VFMT_COLOR);
-      OUT_BATCH(0x00000002);
-      OUT_BATCH(0x00020216); // OUT_BATCH( S6_COLOR_WRITE_ENABLE | (2 << S6_TRISTRIP_PV_SHIFT));
+      OUT_BATCH(i915->current.immediate[I915_IMMEDIATE_S2]);
+      OUT_BATCH(i915->current.immediate[I915_IMMEDIATE_S4]);
+      OUT_BATCH(i915->current.immediate[I915_IMMEDIATE_S5]);
+      OUT_BATCH(i915->current.immediate[I915_IMMEDIATE_S6]);
    }
 
    {
@@ -264,6 +264,6 @@ i915_emit_hardware_state(struct i915_context *i915 )
    }
 
 
-   i915->hw_dirty = 0;
+   i915->hardware_dirty = 0;
 }