OSDN Git Service

gallium: remove support for separate depth/stencil buffers. Always combined now.
authorBrian <brian.paul@tungstengraphics.com>
Wed, 23 Jan 2008 22:45:52 +0000 (15:45 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Wed, 23 Jan 2008 22:45:52 +0000 (15:45 -0700)
14 files changed:
src/mesa/pipe/i915simple/i915_state_emit.c
src/mesa/pipe/i965simple/brw_misc_state.c
src/mesa/pipe/p_state.h
src/mesa/pipe/softpipe/sp_clear.c
src/mesa/pipe/softpipe/sp_context.c
src/mesa/pipe/softpipe/sp_context.h
src/mesa/pipe/softpipe/sp_flush.c
src/mesa/pipe/softpipe/sp_quad.c
src/mesa/pipe/softpipe/sp_quad_depth_test.c
src/mesa/pipe/softpipe/sp_quad_stencil.c
src/mesa/pipe/softpipe/sp_state_surface.c
src/mesa/pipe/xlib/fakeglx.c
src/mesa/state_tracker/st_atom_framebuffer.c
src/mesa/state_tracker/st_cb_drawpixels.c

index 09bf1fa..8598eac 100644 (file)
@@ -74,14 +74,9 @@ framebuffer_size(const struct pipe_framebuffer_state *fb,
       *height = fb->cbufs[0]->height;
       return TRUE;
    }
-   else if (fb->zbuf) {
-      *width = fb->zbuf->width;
-      *height = fb->zbuf->height;
-      return TRUE;
-   }
-   else if (fb->sbuf) {
-      *width = fb->sbuf->width;
-      *height = fb->sbuf->height;
+   else if (fb->zsbuf) {
+      *width = fb->zsbuf->width;
+      *height = fb->zsbuf->height;
       return TRUE;
    }
    else {
@@ -209,7 +204,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
    if (i915->hardware_dirty & I915_HW_STATIC)
    {
       struct pipe_surface *cbuf_surface = i915->framebuffer.cbufs[0];
-      struct pipe_surface *depth_surface = i915->framebuffer.zbuf;
+      struct pipe_surface *depth_surface = i915->framebuffer.zsbuf;
 
       if (cbuf_surface) {
         unsigned pitch = (cbuf_surface->pitch * cbuf_surface->cpp);
@@ -251,7 +246,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
          cformat = translate_format(cformat);
 
         if (depth_surface) 
-           zformat = translate_depth_format( i915->framebuffer.zbuf->format );
+           zformat = translate_depth_format( i915->framebuffer.zsbuf->format );
 
         OUT_BATCH(_3DSTATE_DST_BUF_VARS_CMD);
         OUT_BATCH(DSTORG_HORT_BIAS(0x8) | /* .5 */
index 13b3b16..3b7f36d 100644 (file)
@@ -211,7 +211,7 @@ const struct brw_tracked_state brw_psp_urb_cbs = {
  */
 static void upload_depthbuffer(struct brw_context *brw)
 {
-   struct pipe_surface *depth_surface = brw->attribs.FrameBuffer.zbuf;
+   struct pipe_surface *depth_surface = brw->attribs.FrameBuffer.zsbuf;
 
    BEGIN_BATCH(5, INTEL_BATCH_NO_CLIPRECTS);
    OUT_BATCH(CMD_DEPTH_BUFFER << 16 | (5 - 2));
index 46328d2..146a479 100644 (file)
@@ -202,8 +202,7 @@ struct pipe_framebuffer_state
    unsigned num_cbufs;
    struct pipe_surface *cbufs[PIPE_MAX_COLOR_BUFS];
 
-   struct pipe_surface *zbuf;      /**< Z buffer */
-   struct pipe_surface *sbuf;      /**< Stencil buffer */
+   struct pipe_surface *zsbuf;      /**< Z/stencil buffer */
 };
 
 
index 5b38571..571f64b 100644 (file)
@@ -53,24 +53,19 @@ softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
    softpipe_update_derived(softpipe); /* not needed?? */
 #endif
 
-#if TILE_CLEAR_OPTIMIZATION
-   if (ps == sp_tile_cache_get_surface(softpipe->zbuf_cache)) {
-      sp_tile_cache_clear(softpipe->zbuf_cache, clearValue);
+   if (ps == sp_tile_cache_get_surface(softpipe->zsbuf_cache)) {
+      sp_tile_cache_clear(softpipe->zsbuf_cache, clearValue);
       return;
    }
 
    for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) {
       if (ps == sp_tile_cache_get_surface(softpipe->cbuf_cache[i])) {
          sp_tile_cache_clear(softpipe->cbuf_cache[i], clearValue);
-         return;
       }
    }
-#endif
 
+#if !TILE_CLEAR_OPTIMIZATION
    /* non-cached surface */
    pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
-
-#if 0
-   sp_clear_tile_cache(ps, clearValue);
 #endif
 }
index 81436c6..8dadd9a 100644 (file)
@@ -82,9 +82,7 @@ softpipe_map_surfaces(struct softpipe_context *sp)
       sp_tile_cache_map_surfaces(sp->cbuf_cache[i]);
    }
 
-   sp_tile_cache_map_surfaces(sp->zbuf_cache);
-
-   sp_tile_cache_map_surfaces(sp->sbuf_cache);
+   sp_tile_cache_map_surfaces(sp->zsbuf_cache);
 }
 
 
@@ -98,16 +96,12 @@ softpipe_unmap_surfaces(struct softpipe_context *sp)
 
    for (i = 0; i < sp->framebuffer.num_cbufs; i++)
       sp_flush_tile_cache(sp, sp->cbuf_cache[i]);
-   sp_flush_tile_cache(sp, sp->zbuf_cache);
-   sp_flush_tile_cache(sp, sp->sbuf_cache);
+   sp_flush_tile_cache(sp, sp->zsbuf_cache);
 
    for (i = 0; i < sp->framebuffer.num_cbufs; i++) {
       sp_tile_cache_unmap_surfaces(sp->cbuf_cache[i]);
    }
-
-   sp_tile_cache_unmap_surfaces(sp->zbuf_cache);
-
-   sp_tile_cache_unmap_surfaces(sp->sbuf_cache);
+   sp_tile_cache_unmap_surfaces(sp->zsbuf_cache);
 }
 
 
@@ -134,8 +128,7 @@ static void softpipe_destroy( struct pipe_context *pipe )
 
    for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
       sp_destroy_tile_cache(softpipe->cbuf_cache[i]);
-   sp_destroy_tile_cache(softpipe->zbuf_cache);
-   sp_destroy_tile_cache(softpipe->sbuf_cache_sep);
+   sp_destroy_tile_cache(softpipe->zsbuf_cache);
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
       sp_destroy_tile_cache(softpipe->tex_cache[i]);
@@ -298,9 +291,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
     */
    for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
       softpipe->cbuf_cache[i] = sp_create_tile_cache();
-   softpipe->zbuf_cache = sp_create_tile_cache();
-   softpipe->sbuf_cache_sep = sp_create_tile_cache();
-   softpipe->sbuf_cache = softpipe->sbuf_cache_sep; /* initial value */
+   softpipe->zsbuf_cache = sp_create_tile_cache();
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
       softpipe->tex_cache[i] = sp_create_tile_cache();
index 4ce0410..daf7dd5 100644 (file)
@@ -131,11 +131,7 @@ struct softpipe_context {
    uint current_cbuf;      /**< current color buffer being written to */
 
    struct softpipe_tile_cache *cbuf_cache[PIPE_MAX_COLOR_BUFS];
-   struct softpipe_tile_cache *zbuf_cache;
-   /** Stencil buffer cache, for stencil separate from Z */
-   struct softpipe_tile_cache *sbuf_cache_sep;
-   /** This either points to zbuf_cache or sbuf_cache_sep */
-   struct softpipe_tile_cache *sbuf_cache;
+   struct softpipe_tile_cache *zsbuf_cache;
 
    struct softpipe_tile_cache *tex_cache[PIPE_MAX_SAMPLERS];
 
index 47b1180..ec6bb4a 100644 (file)
@@ -59,11 +59,8 @@ softpipe_flush( struct pipe_context *pipe,
       if (softpipe->cbuf_cache[i])
          sp_flush_tile_cache(softpipe, softpipe->cbuf_cache[i]);
 
-   if (softpipe->zbuf_cache)
-      sp_flush_tile_cache(softpipe, softpipe->zbuf_cache);
-
-   if (softpipe->sbuf_cache)
-      sp_flush_tile_cache(softpipe, softpipe->sbuf_cache);
+   if (softpipe->zsbuf_cache)
+      sp_flush_tile_cache(softpipe, softpipe->zsbuf_cache);
 
    /* Need this call for hardware buffers before swapbuffers.
     *
index a10c9c3..6bd468a 100644 (file)
@@ -48,7 +48,7 @@ sp_build_depth_stencil(
       sp_push_quad_first( sp, sp->quad.stencil_test );
    }
    else if (sp->depth_stencil->depth.enabled &&
-            sp->framebuffer.zbuf) {
+            sp->framebuffer.zsbuf) {
       sp_push_quad_first( sp, sp->quad.depth_test );
    }
 }
@@ -58,7 +58,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
 {
    boolean  early_depth_test =
                sp->depth_stencil->depth.enabled &&
-               sp->framebuffer.zbuf &&
+               sp->framebuffer.zsbuf &&
                !sp->depth_stencil->alpha.enabled &&
                sp->fs->shader.output_semantic_name[0] != TGSI_SEMANTIC_POSITION;
 
index 1b8a296..a9a0754 100644 (file)
@@ -53,14 +53,14 @@ void
 sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
 {
    struct softpipe_context *softpipe = qs->softpipe;
-   struct pipe_surface *ps = softpipe->framebuffer.zbuf;
+   struct pipe_surface *ps = softpipe->framebuffer.zsbuf;
    const enum pipe_format format = ps->format;
    unsigned bzzzz[QUAD_SIZE];  /**< Z values fetched from depth buffer */
    unsigned qzzzz[QUAD_SIZE];  /**< Z values from the quad */
    unsigned zmask = 0;
    unsigned j;
    struct softpipe_cached_tile *tile
-      = sp_get_cached_tile(softpipe, softpipe->zbuf_cache, quad->x0, quad->y0);
+      = sp_get_cached_tile(softpipe, softpipe->zsbuf_cache, quad->x0, quad->y0);
 
    assert(ps); /* shouldn't get here if there's no zbuffer */
 
index 3374088..92a0da0 100644 (file)
@@ -201,12 +201,12 @@ static void
 stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
 {
    struct softpipe_context *softpipe = qs->softpipe;
-   struct pipe_surface *ps = softpipe->framebuffer.sbuf;
+   struct pipe_surface *ps = softpipe->framebuffer.zsbuf;
    unsigned func, zFailOp, zPassOp, failOp;
    ubyte ref, wrtMask, valMask;
    ubyte stencilVals[QUAD_SIZE];
    struct softpipe_cached_tile *tile
-      = sp_get_cached_tile(softpipe, softpipe->sbuf_cache, quad->x0, quad->y0);
+      = sp_get_cached_tile(softpipe, softpipe->zsbuf_cache, quad->x0, quad->y0);
    uint j;
    uint face = quad->facing;
 
index 4a9a28c..e2c6893 100644 (file)
@@ -65,17 +65,18 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
    sp->framebuffer.num_cbufs = fb->num_cbufs;
 
    /* zbuf changing? */
-   if (sp->framebuffer.zbuf != fb->zbuf) {
+   if (sp->framebuffer.zsbuf != fb->zsbuf) {
       /* flush old */
-      sp_flush_tile_cache(sp, sp->zbuf_cache);
+      sp_flush_tile_cache(sp, sp->zsbuf_cache);
 
       /* assign new */
-      sp->framebuffer.zbuf = fb->zbuf;
+      sp->framebuffer.zsbuf = fb->zsbuf;
 
       /* update cache */
-      sp_tile_cache_set_surface(sp->zbuf_cache, fb->zbuf);
+      sp_tile_cache_set_surface(sp->zsbuf_cache, fb->zsbuf);
    }
 
+#if 0
    /* XXX combined depth/stencil here */
 
    /* sbuf changing? */
@@ -98,6 +99,7 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
          sp_tile_cache_set_surface(sp->sbuf_cache, fb->sbuf);
       }
    }
+#endif
 
    sp->dirty |= SP_NEW_FRAMEBUFFER;
 }
index 6965ee0..902a755 100644 (file)
@@ -419,7 +419,7 @@ static XMesaVisual
 create_glx_visual( Display *dpy, XVisualInfo *visinfo )
 {
    int vislevel;
-   GLint zBits = default_depth_bits();
+   GLint zBits = 24; /*default_depth_bits();*/
    GLint accBits = default_accum_bits();
    GLboolean alphaFlag = default_alpha_bits() > 0;
 
@@ -1289,7 +1289,7 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
          double_flag = GL_TRUE;
          if (vis->depth > 8)
             rgb_flag = GL_TRUE;
-         depth_size = default_depth_bits();
+         depth_size = 24; /*default_depth_bits();*/
          stencil_size = STENCIL_BITS;
          /* XXX accum??? */
       }
@@ -1336,7 +1336,9 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
        * largest depth buffer size, which is 32bits/value.  Instead, we
        * return 16 to maintain performance with earlier versions of Mesa.
        */
-      if (depth_size > 24)
+      if (stencil_size > 0)
+         depth_size = 24;  /* if Z and stencil, always use 24+8 format */
+      else if (depth_size > 24)
          depth_size = 32;
       else if (depth_size > 16)
          depth_size = 24;
index aec51f5..3e58d49 100644 (file)
@@ -65,14 +65,15 @@ update_framebuffer_state( struct st_context *st )
    if (strb) {
       strb = st_renderbuffer(strb->Base.Wrapped);
       assert(strb->surface);
-      framebuffer.zbuf = strb->surface;
+      framebuffer.zsbuf = strb->surface;
    }
-
-   strb = st_renderbuffer(fb->Attachment[BUFFER_STENCIL].Renderbuffer);
-   if (strb) {
-      strb = st_renderbuffer(strb->Base.Wrapped);
-      assert(strb->surface);
-      framebuffer.sbuf = strb->surface;
+   else {
+      strb = st_renderbuffer(fb->Attachment[BUFFER_STENCIL].Renderbuffer);
+      if (strb) {
+         strb = st_renderbuffer(strb->Base.Wrapped);
+         assert(strb->surface);
+         framebuffer.zsbuf = strb->surface;
+      }
    }
 
    /* XXX: The memcmp is insufficient for eliminating redundant state changes,
index eaa88d3..6b44cba 100644 (file)
@@ -848,7 +848,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
 {
    struct st_context *st = ctx->st;
    struct pipe_context *pipe = st->pipe;
-   struct pipe_surface *ps = st->state.framebuffer.sbuf;
+   struct pipe_surface *ps = st->state.framebuffer.zsbuf;
    const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0;
    GLint skipPixels;
    ubyte *stmap;
@@ -940,13 +940,13 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
    st_validate_state(st);
 
    if (format == GL_DEPTH_COMPONENT) {
-      ps = st->state.framebuffer.zbuf;
+      ps = st->state.framebuffer.zsbuf;
       stfp = make_fragment_shader_z(ctx->st);
       stvp = make_vertex_shader(ctx->st, GL_TRUE);
       color = ctx->Current.RasterColor;
    }
    else if (format == GL_STENCIL_INDEX) {
-      ps = st->state.framebuffer.sbuf;
+      ps = st->state.framebuffer.zsbuf;
       /* XXX special case - can't use texture map */
       color = NULL;
    }