Squashed commit of the following:
[mesa.git] / src / gallium / drivers / i915 / i915_state_emit.c
index a3d4e3b04e524ad55ff3aeda0a58df3fef31f83a..4d069fffa85abc780bd182be1b1362a98482961e 100644 (file)
@@ -30,6 +30,7 @@
 #include "i915_context.h"
 #include "i915_batch.h"
 #include "i915_reg.h"
+#include "i915_resource.h"
 
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
@@ -37,9 +38,9 @@
 static unsigned translate_format( enum pipe_format format )
 {
    switch (format) {
-   case PIPE_FORMAT_A8R8G8B8_UNORM:
+   case PIPE_FORMAT_B8G8R8A8_UNORM:
       return COLOR_BUF_ARGB8888;
-   case PIPE_FORMAT_R5G6B5_UNORM:
+   case PIPE_FORMAT_B5G6R5_UNORM:
       return COLOR_BUF_RGB565;
    default:
       assert(0);
@@ -50,7 +51,7 @@ static unsigned translate_format( enum pipe_format format )
 static unsigned translate_depth_format( enum pipe_format zformat )
 {
    switch (zformat) {
-   case PIPE_FORMAT_S8Z24_UNORM:
+   case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
       return DEPTH_FRMT_24_FIXED_8_OTHER;
    case PIPE_FORMAT_Z16_UNORM:
       return DEPTH_FRMT_16_FIXED;
@@ -182,7 +183,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
       
       if(i915->vbo)
          OUT_RELOC(i915->vbo,
-                   INTEL_USAGE_VERTEX,
+                   I915_USAGE_VERTEX,
                    i915->current.immediate[I915_IMMEDIATE_S0]);
       else
          /* FIXME: we should not do this */
@@ -211,8 +212,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
 
       if (cbuf_surface) {
          unsigned ctile = BUF_3D_USE_FENCE;
-         struct i915_texture *tex = (struct i915_texture *)
-                                    cbuf_surface->texture;
+         struct i915_texture *tex = i915_texture(cbuf_surface->texture);
          assert(tex);
 
          if (tex && tex->sw_tiled) {
@@ -226,7 +226,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
                    ctile);
 
          OUT_RELOC(tex->buffer,
-                   INTEL_USAGE_RENDER,
+                   I915_USAGE_RENDER,
                    cbuf_surface->offset);
       }
 
@@ -234,8 +234,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
        */
       if (depth_surface) {
          unsigned ztile = BUF_3D_USE_FENCE;
-         struct i915_texture *tex = (struct i915_texture *)
-                                    depth_surface->texture;
+         struct i915_texture *tex = i915_texture(depth_surface->texture);
          assert(tex);
 
          if (tex && tex->sw_tiled) {
@@ -244,12 +243,13 @@ i915_emit_hardware_state(struct i915_context *i915 )
 
          OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
 
+         assert(tex);
          OUT_BATCH(BUF_3D_ID_DEPTH |
                    BUF_3D_PITCH(tex->stride) |  /* pitch in bytes */
                    ztile);
 
          OUT_RELOC(tex->buffer,
-                   INTEL_USAGE_RENDER,
+                   I915_USAGE_RENDER,
                    depth_surface->offset);
       }
    
@@ -259,7 +259,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
          if (cbuf_surface)
             cformat = cbuf_surface->format;
          else
-            cformat = PIPE_FORMAT_A8R8G8B8_UNORM; /* arbitrary */
+            cformat = PIPE_FORMAT_B8G8R8A8_UNORM; /* arbitrary */
          cformat = translate_format(cformat);
 
          if (depth_surface) 
@@ -289,13 +289,14 @@ i915_emit_hardware_state(struct i915_context *i915 )
             OUT_BATCH(enabled);
             for (unit = 0; unit < I915_TEX_UNITS; unit++) {
                if (enabled & (1 << unit)) {
-                  struct intel_buffer *buf = i915->texture[unit]->buffer;
+                  struct i915_texture *texture = i915_texture(i915->fragment_sampler_views[unit]->texture);
+                  struct i915_winsys_buffer *buf = texture->buffer;
                   uint offset = 0;
                   assert(buf);
 
                   count++;
 
-                  OUT_RELOC(buf, INTEL_USAGE_SAMPLER, offset);
+                  OUT_RELOC(buf, I915_USAGE_SAMPLER, offset);
                   OUT_BATCH(i915->current.texbuffer[unit][0]); /* MS3 */
                   OUT_BATCH(i915->current.texbuffer[unit][1]); /* MS4 */
                }