i915: Use the new draw vbuf interface
[mesa.git] / src / gallium / drivers / i915simple / i915_state_emit.c
index 6bbaac4e34c3dc999f6c6201142251f4b811935c..6558cf1c3e5bb90a5afa2f9c9375d346e88d9927 100644 (file)
@@ -115,7 +115,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
 #endif
    
    if(!BEGIN_BATCH(dwords, relocs)) {
-      FLUSH_BATCH();
+      FLUSH_BATCH(NULL);
       assert(BEGIN_BATCH(dwords, relocs));
    }
 
@@ -211,33 +211,51 @@ i915_emit_hardware_state(struct i915_context *i915 )
       struct pipe_surface *depth_surface = i915->framebuffer.zsbuf;
 
       if (cbuf_surface) {
-        unsigned pitch = (cbuf_surface->pitch * cbuf_surface->cpp);
+        unsigned cpitch = cbuf_surface->stride;
+        unsigned ctile = BUF_3D_USE_FENCE;
+         struct i915_texture *tex = (struct i915_texture *)
+                                    cbuf_surface->texture;
+         struct pipe_buffer *buffer = tex->buffer;
+         assert(tex);
+
+        if (tex && tex->tiled) {
+           ctile = BUF_3D_TILED_SURFACE;
+        }
 
         OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
 
-        OUT_BATCH(BUF_3D_ID_COLOR_BACK | 
-                  BUF_3D_PITCH(pitch) |  /* pitch in bytes */
-                  BUF_3D_USE_FENCE);
+        OUT_BATCH(BUF_3D_ID_COLOR_BACK |
+                  BUF_3D_PITCH(cpitch) |  /* pitch in bytes */
+                  ctile);
 
-        OUT_RELOC(cbuf_surface->buffer,
+        OUT_RELOC(tex->buffer,
                   I915_BUFFER_ACCESS_WRITE,
-                  0);
+                  cbuf_surface->offset);
       }
 
       /* What happens if no zbuf??
        */
       if (depth_surface) {
-        unsigned zpitch = (depth_surface->pitch * depth_surface->cpp);
-                        
+        unsigned zpitch = depth_surface->stride;
+        unsigned ztile = BUF_3D_USE_FENCE;
+         struct i915_texture *tex = (struct i915_texture *)
+                                    depth_surface->texture;
+         struct pipe_buffer *buffer = tex->buffer;
+         assert(tex);
+
+        if (tex && tex->tiled) {
+           ztile = BUF_3D_TILED_SURFACE;
+        }
+
         OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
 
         OUT_BATCH(BUF_3D_ID_DEPTH |
                   BUF_3D_PITCH(zpitch) |  /* pitch in bytes */
-                  BUF_3D_USE_FENCE);
+                  ztile);
 
-        OUT_RELOC(depth_surface->buffer,
+        OUT_RELOC(tex->buffer,
                   I915_BUFFER_ACCESS_WRITE,
-                  0);
+                  depth_surface->offset);
       }
    
       {
@@ -267,12 +285,6 @@ i915_emit_hardware_state(struct i915_context *i915 )
       /* 2 + I915_TEX_UNITS*3 dwords, I915_TEX_UNITS relocs */
       if (i915->hardware_dirty & (I915_HW_MAP | I915_HW_SAMPLER))
       {
-        /* XXX: we were refering to sampler state
-         * (current.sampler_enable_nr) below, but only checking
-         * I915_HW_MAP above.  Should probably calculate the enabled
-         * flags separately - but there will be further rework of
-         * state so perhaps not necessary yet.
-         */
          const uint nr = i915->current.sampler_enable_nr;
          if (nr) {
             const uint enabled = i915->current.sampler_enable_flags;
@@ -382,6 +394,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
    {
       uint w, h;
       boolean k = framebuffer_size(&i915->framebuffer, &w, &h);
+      (void)k;
       assert(k);
 
       OUT_BATCH(_3DSTATE_DRAW_RECT_CMD);