intel: Use Mesa core's renderbuffer accessors for depth.
authorEric Anholt <eric@anholt.net>
Fri, 15 Apr 2011 18:58:58 +0000 (11:58 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 18 Apr 2011 18:19:54 +0000 (11:19 -0700)
Since we're using GTT mappings now (no manual detiling), there's
really nothing special to accessing these buffers, other than needing
the new RowStride field of gl_renderbuffer to accomodate padding.

Reduces the driver size by 2.7kb, and improves glean depthStencil
performance 3-10x (!)

Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/drivers/dri/intel/intel_span.c
src/mesa/main/renderbuffer.c

index 1f41518535c05f787acde9d55c067ebbf21129d2..37a561aacdf699be9fbd084bc12b906550deebf8 100644 (file)
@@ -30,6 +30,7 @@
 #include "main/macros.h"
 #include "main/mtypes.h"
 #include "main/colormac.h"
+#include "main/renderbuffer.h"
 
 #include "intel_buffers.h"
 #include "intel_fbo.h"
@@ -134,36 +135,6 @@ intel_set_span_functions(struct intel_context *intel,
 #define TAG2(x,y) intel_##x##y##_RG1616
 #include "spantmp2.h"
 
-#define LOCAL_DEPTH_VARS                                               \
-   struct intel_renderbuffer *irb = intel_renderbuffer(rb);            \
-   const GLint yScale = rb->Name ? 1 : -1;                             \
-   const GLint yBias = rb->Name ? 0 : rb->Height - 1;                  \
-   int minx = 0, miny = 0;                                             \
-   int maxx = rb->Width;                                               \
-   int maxy = rb->Height;                                              \
-   int pitch = irb->region->pitch * irb->region->cpp;                  \
-   void *buf = irb->region->buffer->virtual;                           \
-   (void)buf; (void)pitch; /* unused for non-gttmap. */                        \
-
-#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
-
-/* z16 depthbuffer functions. */
-#define VALUE_TYPE GLushort
-#define WRITE_DEPTH(_x, _y, d) \
-   (*(uint16_t *)(irb->region->buffer->virtual + NO_TILE(_x, _y)) = d)
-#define READ_DEPTH(d, _x, _y) \
-   d = *(uint16_t *)(irb->region->buffer->virtual + NO_TILE(_x, _y))
-#define TAG(x) intel_##x##_z16
-#include "depthtmp.h"
-
-/* z24_s8 and z24_x8 depthbuffer functions. */
-#define VALUE_TYPE GLuint
-#define WRITE_DEPTH(_x, _y, d) \
-   (*(uint32_t *)(irb->region->buffer->virtual + NO_TILE(_x, _y)) = d)
-#define READ_DEPTH(d, _x, _y) \
-   d = *(uint32_t *)(irb->region->buffer->virtual + NO_TILE(_x, _y))
-#define TAG(x) intel_##x##_z24_s8
-#include "depthtmp.h"
 
 void
 intel_renderbuffer_map(struct intel_context *intel, struct gl_renderbuffer *rb)
@@ -175,6 +146,15 @@ intel_renderbuffer_map(struct intel_context *intel, struct gl_renderbuffer *rb)
 
    drm_intel_gem_bo_map_gtt(irb->region->buffer);
 
+   rb->Data = irb->region->buffer->virtual;
+   rb->RowStride = irb->region->pitch;
+
+   /* Flip orientation if it's the window system buffer */
+   if (!rb->Name) {
+      rb->Data += rb->RowStride * (irb->region->height - 1) * irb->region->cpp;
+      rb->RowStride = -rb->RowStride;
+   }
+
    intel_set_span_functions(intel, rb);
 }
 
@@ -191,6 +171,8 @@ intel_renderbuffer_unmap(struct intel_context *intel,
 
    rb->GetRow = NULL;
    rb->PutRow = NULL;
+   rb->Data = NULL;
+   rb->RowStride = 0;
 }
 
 /**
@@ -371,9 +353,9 @@ static span_init_func intel_span_init_funcs[MESA_FORMAT_COUNT] =
    [MESA_FORMAT_XRGB8888] = intel_InitPointers_xRGB8888,
    [MESA_FORMAT_ARGB8888] = intel_InitPointers_ARGB8888,
    [MESA_FORMAT_SARGB8] = intel_InitPointers_ARGB8888,
-   [MESA_FORMAT_Z16] = intel_InitDepthPointers_z16,
-   [MESA_FORMAT_X8_Z24] = intel_InitDepthPointers_z24_s8,
-   [MESA_FORMAT_S8_Z24] = intel_InitDepthPointers_z24_s8,
+   [MESA_FORMAT_Z16] = _mesa_set_renderbuffer_accessors,
+   [MESA_FORMAT_X8_Z24] = _mesa_set_renderbuffer_accessors,
+   [MESA_FORMAT_S8_Z24] = _mesa_set_renderbuffer_accessors,
    [MESA_FORMAT_R8] = intel_InitPointers_R8,
    [MESA_FORMAT_RG88] = intel_InitPointers_RG88,
    [MESA_FORMAT_R16] = intel_InitPointers_R16,
index de01cfc695141692574ef0e0453fbbc2d5eb796b..b2e2e84963be9187575c0a767a7af9820dbf75c9 100644 (file)
@@ -1011,6 +1011,7 @@ _mesa_set_renderbuffer_accessors(struct gl_renderbuffer *rb)
 
    case MESA_FORMAT_Z32:
    case MESA_FORMAT_X8_Z24:
+   case MESA_FORMAT_Z24_X8:
       rb->DataType = GL_UNSIGNED_INT;
       rb->GetPointer = get_pointer_uint;
       rb->GetRow = get_row_uint;
@@ -1023,6 +1024,7 @@ _mesa_set_renderbuffer_accessors(struct gl_renderbuffer *rb)
       break;
 
    case MESA_FORMAT_Z24_S8:
+   case MESA_FORMAT_S8_Z24:
       rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
       rb->GetPointer = get_pointer_uint;
       rb->GetRow = get_row_uint;