Mesa (master): intel: Use Mesa core's renderbuffer accessors for depth.

Eric Anholt anholt at kemper.freedesktop.org
Mon Apr 18 11:21:16 PDT 2011


Module: Mesa
Branch: master
Commit: 0778fdb002b000e241b042ad65b6da6dd8480454
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0778fdb002b000e241b042ad65b6da6dd8480454

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Apr 15 11:58:58 2011 -0700

intel: Use Mesa core's renderbuffer accessors for depth.

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 at vmware.com>

---

 src/mesa/drivers/dri/intel/intel_span.c |   48 +++++++++---------------------
 src/mesa/main/renderbuffer.c            |    2 +
 2 files changed, 17 insertions(+), 33 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c
index 1f41518..37a561a 100644
--- a/src/mesa/drivers/dri/intel/intel_span.c
+++ b/src/mesa/drivers/dri/intel/intel_span.c
@@ -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,
diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c
index de01cfc..b2e2e84 100644
--- a/src/mesa/main/renderbuffer.c
+++ b/src/mesa/main/renderbuffer.c
@@ -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;



More information about the mesa-commit mailing list