Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1
authorBen Skeggs <skeggsb@gmail.com>
Sat, 1 Mar 2008 15:35:17 +0000 (02:35 +1100)
committerBen Skeggs <skeggsb@gmail.com>
Sat, 1 Mar 2008 15:35:17 +0000 (02:35 +1100)
15 files changed:
src/gallium/auxiliary/draw/draw_aaline.c
src/gallium/auxiliary/draw/draw_aapoint.c
src/gallium/auxiliary/draw/draw_pstipple.c
src/gallium/auxiliary/draw/draw_unfilled.c
src/gallium/auxiliary/draw/draw_validate.c
src/gallium/auxiliary/draw/draw_wide_line.c
src/gallium/auxiliary/draw/draw_wide_point.c
src/gallium/auxiliary/util/p_tile.c
src/gallium/auxiliary/util/p_tile.h
src/gallium/drivers/softpipe/SConscript
src/gallium/include/pipe/p_context.h
src/mesa/state_tracker/st_atom_texture.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_gen_mipmap.c

index 51140388f0983771205163cd11fe7ead6639e15d..7660e56fe662fc22b8d44cfffb8da09d803dc540 100644 (file)
@@ -691,35 +691,11 @@ draw_aaline_stage(struct draw_context *draw)
 }
 
 
-/*
- * XXX temporary? solution to mapping a pipe_context to a aaline_stage.
- */
-
-#define MAX_CONTEXTS 10
-
-static struct pipe_context *Pipe[MAX_CONTEXTS];
-static struct aaline_stage *Stage[MAX_CONTEXTS];
-static uint NumContexts;
-
-static void
-add_aa_pipe_context(struct pipe_context *pipe, struct aaline_stage *aa)
-{
-   assert(NumContexts < MAX_CONTEXTS);
-   Pipe[NumContexts] = pipe;
-   Stage[NumContexts] = aa;
-   NumContexts++;
-}
-
 static struct aaline_stage *
 aaline_stage_from_pipe(struct pipe_context *pipe)
 {
-   uint i;
-   for (i = 0; i < NumContexts; i++) {
-      if (Pipe[i] == pipe)
-         return Stage[i];
-   }
-   assert(0);
-   return NULL;
+   struct draw_context *draw = (struct draw_context *) pipe->draw;
+   return aaline_stage(draw->pipeline.aaline);
 }
 
 
@@ -802,6 +778,8 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
 {
    struct aaline_stage *aaline;
 
+   pipe->draw = (void *) draw;
+
    /*
     * Create / install AA line drawing / prim stage
     */
@@ -830,6 +808,4 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
 
    pipe->bind_sampler_state = aaline_bind_sampler_state;
    pipe->set_sampler_texture = aaline_set_sampler_texture;
-
-   add_aa_pipe_context(pipe, aaline);
 }
index d48a416899fa4c04b902ceb85909247d0006588c..70f696475fcf5db99fcacfaf9a1f156fe4835ae6 100644 (file)
@@ -762,35 +762,11 @@ draw_aapoint_stage(struct draw_context *draw)
 }
 
 
-/*
- * XXX temporary? solution to mapping a pipe_context to a aapoint_stage.
- */
-
-#define MAX_CONTEXTS 10
-
-static struct pipe_context *Pipe[MAX_CONTEXTS];
-static struct aapoint_stage *Stage[MAX_CONTEXTS];
-static uint NumContexts;
-
-static void
-add_aa_pipe_context(struct pipe_context *pipe, struct aapoint_stage *aa)
-{
-   assert(NumContexts < MAX_CONTEXTS);
-   Pipe[NumContexts] = pipe;
-   Stage[NumContexts] = aa;
-   NumContexts++;
-}
-
 static struct aapoint_stage *
 aapoint_stage_from_pipe(struct pipe_context *pipe)
 {
-   uint i;
-   for (i = 0; i < NumContexts; i++) {
-      if (Pipe[i] == pipe)
-         return Stage[i];
-   }
-   assert(0);
-   return NULL;
+   struct draw_context *draw = (struct draw_context *) pipe->draw;
+   return aapoint_stage(draw->pipeline.aapoint);
 }
 
 
@@ -850,6 +826,8 @@ draw_install_aapoint_stage(struct draw_context *draw,
 {
    struct aapoint_stage *aapoint;
 
+   pipe->draw = (void *) draw;
+
    /*
     * Create / install AA point drawing / prim stage
     */
@@ -868,6 +846,4 @@ draw_install_aapoint_stage(struct draw_context *draw,
    pipe->create_fs_state = aapoint_create_fs_state;
    pipe->bind_fs_state = aapoint_bind_fs_state;
    pipe->delete_fs_state = aapoint_delete_fs_state;
-
-   add_aa_pipe_context(pipe, aapoint);
 }
index f6200aa82012fb2914b39b910096f9e41142cf03..2cfeb813b30794a069fb4beaad3e0daecd18de99 100644 (file)
@@ -559,35 +559,11 @@ draw_pstip_stage(struct draw_context *draw)
 }
 
 
-/*
- * XXX temporary? solution to mapping a pipe_context to a pstip_stage.
- */
-
-#define MAX_CONTEXTS 10
-
-static struct pipe_context *Pipe[MAX_CONTEXTS];
-static struct pstip_stage *Stage[MAX_CONTEXTS];
-static uint NumContexts;
-
-static void
-add_pstip_pipe_context(struct pipe_context *pipe, struct pstip_stage *pstip)
-{
-   assert(NumContexts < MAX_CONTEXTS);
-   Pipe[NumContexts] = pipe;
-   Stage[NumContexts] = pstip;
-   NumContexts++;
-}
-
 static struct pstip_stage *
 pstip_stage_from_pipe(struct pipe_context *pipe)
 {
-   uint i;
-   for (i = 0; i < NumContexts; i++) {
-      if (Pipe[i] == pipe)
-         return Stage[i];
-   }
-   assert(0);
-   return NULL;
+   struct draw_context *draw = (struct draw_context *) pipe->draw;
+   return pstip_stage(draw->pipeline.pstipple);
 }
 
 
@@ -686,6 +662,8 @@ draw_install_pstipple_stage(struct draw_context *draw,
 {
    struct pstip_stage *pstip;
 
+   pipe->draw = (void *) draw;
+
    /*
     * Create / install AA line drawing / prim stage
     */
@@ -716,6 +694,4 @@ draw_install_pstipple_stage(struct draw_context *draw,
    pipe->bind_sampler_state = pstip_bind_sampler_state;
    pipe->set_sampler_texture = pstip_set_sampler_texture;
    pipe->set_polygon_stipple = pstip_set_polygon_stipple;
-
-   add_pstip_pipe_context(pipe, pstip);
 }
index 8777cfdfc861b39ab00c2098faa93787e403d26a..4d718d514c6f7e06be30d7e7deb9d832052aa2ac 100644 (file)
@@ -101,9 +101,9 @@ static void lines( struct draw_stage *stage,
    assert(((header->edgeflags & 0x4) >> 2) == header->v[2]->edgeflag);
 #endif
 
+   if (header->edgeflags & 0x4) line( stage, v2, v0 );
    if (header->edgeflags & 0x1) line( stage, v0, v1 );
    if (header->edgeflags & 0x2) line( stage, v1, v2 );
-   if (header->edgeflags & 0x4) line( stage, v2, v0 );
 }
 
 
index 084eee9b6e9ace87969f345a35ee104a0fdb6c78..b43295b5860b91e0d92c73300878203546b38db9 100644 (file)
@@ -84,6 +84,7 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
    if (wide_lines) {
       draw->pipeline.wide_line->next = next;
       next = draw->pipeline.wide_line;
+      precalc_flat = 1;
    }
 
    if (wide_points || draw->rasterizer->point_sprite) {
index 946a983f0085b39c79150d818ffb4846d09a935a..9a168ce8bdc6f66d4633733014bddc89c1af5266 100644 (file)
@@ -86,7 +86,10 @@ static void wideline_line( struct draw_stage *stage,
 
    const float dx = FABSF(pos0[0] - pos2[0]);
    const float dy = FABSF(pos0[1] - pos2[1]);
-   
+
+   /* small tweak to meet GL specification */
+   const float bias = 0.125f;
+
    /*
     * Draw wide line as a quad (two tris) by "stretching" the line along
     * X or Y.
@@ -95,10 +98,10 @@ static void wideline_line( struct draw_stage *stage,
 
    if (dx > dy) {
       /* x-major line */
-      pos0[1] = pos0[1] - half_width - 0.25f;
-      pos1[1] = pos1[1] + half_width - 0.25f;
-      pos2[1] = pos2[1] - half_width - 0.25f;
-      pos3[1] = pos3[1] + half_width - 0.25f;
+      pos0[1] = pos0[1] - half_width - bias;
+      pos1[1] = pos1[1] + half_width - bias;
+      pos2[1] = pos2[1] - half_width - bias;
+      pos3[1] = pos3[1] + half_width - bias;
       if (pos0[0] < pos2[0]) {
          /* left to right line */
          pos0[0] -= 0.5f;
@@ -116,10 +119,10 @@ static void wideline_line( struct draw_stage *stage,
    }
    else {
       /* y-major line */
-      pos0[0] = pos0[0] - half_width + 0.25f;
-      pos1[0] = pos1[0] + half_width + 0.25f;
-      pos2[0] = pos2[0] - half_width + 0.25f;
-      pos3[0] = pos3[0] + half_width + 0.25f;
+      pos0[0] = pos0[0] - half_width + bias;
+      pos1[0] = pos1[0] + half_width + bias;
+      pos2[0] = pos2[0] - half_width + bias;
+      pos3[0] = pos3[0] + half_width + bias;
       if (pos0[1] < pos2[1]) {
          /* top to bottom line */
          pos0[1] -= 0.5f;
index 8f877a102a5f87852e35f3abf3c718b84f682ca5..65bd50f2b8e40593d25d8e965c1b2c9b6f42b53a 100644 (file)
@@ -109,7 +109,7 @@ static void widepoint_point( struct draw_stage *stage,
    const struct widepoint_stage *wide = widepoint_stage(stage);
    const boolean sprite = (boolean) stage->draw->rasterizer->point_sprite;
    float half_size;
-   float left_adj, right_adj;
+   float left_adj, right_adj, bot_adj, top_adj;
 
    struct prim_header tri;
 
@@ -124,6 +124,8 @@ static void widepoint_point( struct draw_stage *stage,
    float *pos2 = v2->data[0];
    float *pos3 = v3->data[0];
 
+   const float xbias = 0.0, ybias = -0.125;
+
    /* point size is either per-vertex or fixed size */
    if (wide->psize_slot >= 0) {
       half_size = 0.5f * header->v[0]->data[wide->psize_slot][0];
@@ -132,20 +134,22 @@ static void widepoint_point( struct draw_stage *stage,
       half_size = wide->half_point_size;
    }
 
-   left_adj = -half_size; /* + 0.25f;*/
-   right_adj = half_size; /* + 0.25f;*/
+   left_adj = -half_size + xbias;
+   right_adj = half_size + xbias;
+   bot_adj = half_size + ybias;
+   top_adj = -half_size + ybias;
 
    pos0[0] += left_adj;
-   pos0[1] -= half_size;
+   pos0[1] += top_adj;
 
    pos1[0] += left_adj;
-   pos1[1] += half_size;
+   pos1[1] += bot_adj;
 
    pos2[0] += right_adj;
-   pos2[1] -= half_size;
+   pos2[1] += top_adj;
 
    pos3[0] += right_adj;
-   pos3[1] += half_size;
+   pos3[1] += bot_adj;
 
    if (sprite) {
       static const float tex00[4] = { 0, 0, 0, 1 };
index 3f795a38989dc54027fec0963b344c3e26851fc7..287d7839812fc6b4bce175d9a199d5442540a5a4 100644 (file)
@@ -697,3 +697,127 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
 
    FREE(packed);
 }
+
+
+/**
+ * Get a block of Z values, converted to 32-bit range.
+ */
+void
+pipe_get_tile_z(struct pipe_context *pipe,
+                struct pipe_surface *ps,
+                uint x, uint y, uint w, uint h,
+                uint *z)
+{
+   const uint dstStride = w;
+   uint *pDest = z;
+   uint i, j;
+
+   if (pipe_clip_tile(x, y, &w, &h, ps))
+      return;
+
+   switch (ps->format) {
+   case PIPE_FORMAT_Z32_UNORM:
+      {
+         const uint *pSrc
+            = (const uint *) pipe_surface_map(ps) + (y * ps->pitch + x);
+         for (i = 0; i < h; i++) {
+            memcpy(pDest, pSrc, 4 * w);
+            pDest += dstStride;
+            pSrc += ps->pitch;
+         }
+      }
+      break;
+   case PIPE_FORMAT_S8Z24_UNORM:
+      {
+         const uint *pSrc
+            = (const uint *) pipe_surface_map(ps) + (y * ps->pitch + x);
+         for (i = 0; i < h; i++) {
+            for (j = 0; j < w; j++) {
+               /* convert 24-bit Z to 32-bit Z */
+               pDest[j] = (pSrc[j] << 8) | (pSrc[j] & 0xff);
+            }
+            pDest += dstStride;
+            pSrc += ps->pitch;
+         }
+      }
+      break;
+   case PIPE_FORMAT_Z16_UNORM:
+      {
+         const ushort *pSrc
+            = (const ushort *) pipe_surface_map(ps) + (y * ps->pitch + x);
+         for (i = 0; i < h; i++) {
+            for (j = 0; j < w; j++) {
+               /* convert 16-bit Z to 32-bit Z */
+               pDest[j] = (pSrc[j] << 16) | pSrc[j];
+            }
+            pDest += dstStride;
+            pSrc += ps->pitch;
+         }
+      }
+      break;
+   default:
+      assert(0);
+   }
+
+   pipe_surface_unmap(ps);
+}
+
+
+void
+pipe_put_tile_z(struct pipe_context *pipe,
+                struct pipe_surface *ps,
+                uint x, uint y, uint w, uint h,
+                const uint *zSrc)
+{
+   const uint srcStride = w;
+   const uint *pSrc = zSrc;
+   uint i, j;
+
+   if (pipe_clip_tile(x, y, &w, &h, ps))
+      return;
+
+   switch (ps->format) {
+   case PIPE_FORMAT_Z32_UNORM:
+      {
+         uint *pDest = (uint *) pipe_surface_map(ps) + (y * ps->pitch + x);
+         for (i = 0; i < h; i++) {
+            memcpy(pDest, pSrc, 4 * w);
+            pDest += ps->pitch;
+            pSrc += srcStride;
+         }
+      }
+      break;
+   case PIPE_FORMAT_S8Z24_UNORM:
+      {
+         uint *pDest = (uint *) pipe_surface_map(ps) + (y * ps->pitch + x);
+         for (i = 0; i < h; i++) {
+            for (j = 0; j < w; j++) {
+               /* convert 32-bit Z to 24-bit Z (0 stencil) */
+               pDest[j] = pSrc[j] >> 8;
+            }
+            pDest += ps->pitch;
+            pSrc += srcStride;
+         }
+      }
+      break;
+   case PIPE_FORMAT_Z16_UNORM:
+      {
+         ushort *pDest = (ushort *) pipe_surface_map(ps) + (y * ps->pitch + x);
+         for (i = 0; i < h; i++) {
+            for (j = 0; j < w; j++) {
+               /* convert 32-bit Z to 16-bit Z */
+               pDest[j] = pSrc[j] >> 16;
+            }
+            pDest += ps->pitch;
+            pSrc += srcStride;
+         }
+      }
+      break;
+   default:
+      assert(0);
+   }
+
+   pipe_surface_unmap(ps);
+}
+
+
index cd8124bf11f2993e23ec78887468543c08674e76..318b6d11a68d4abd46b0ecf7fae6543df4c6ca20 100644 (file)
@@ -78,4 +78,18 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
                    uint x, uint y, uint w, uint h,
                    const float *p);
 
+
+extern void
+pipe_get_tile_z(struct pipe_context *pipe,
+                struct pipe_surface *ps,
+                uint x, uint y, uint w, uint h,
+                uint *z);
+
+extern void
+pipe_put_tile_z(struct pipe_context *pipe,
+                struct pipe_surface *ps,
+                uint x, uint y, uint w, uint h,
+                const uint *z);
+
+
 #endif
index 4c1a6d5df0b88bd19496192e6699dfe9cf5d2e5a..88c21ee3b0f193e5d719dafb2e278cafa721246e 100644 (file)
@@ -28,6 +28,7 @@ softpipe = env.ConvenienceLibrary(
                'sp_quad_stencil.c',
                'sp_quad_stipple.c',
                'sp_query.c',
+               'sp_screen.c',
                'sp_state_blend.c',
                'sp_state_clip.c',
                'sp_state_derived.c',
index d0f25d7d4670896333c6bb42aac1161b7ef086ee..1501b52f3e511575081b62f31017bc266948a3ed 100644 (file)
@@ -56,6 +56,7 @@ struct pipe_context {
    struct pipe_screen *screen;
 
    void *priv;  /** context private data (for DRI for example) */
+   void *draw;  /** private, for draw module (temporary? */
 
    void (*destroy)( struct pipe_context * );
 
index a4ac72681608f85eb0974205d60d4f961c99ea76..697d2cdfb442069eb569dbfe93cf8b28e55a2bf3 100644 (file)
@@ -55,6 +55,7 @@ update_textures(struct st_context *st)
       const GLuint su = fprog->Base.SamplerUnits[unit];
       struct gl_texture_object *texObj = st->ctx->Texture.Unit[su]._Current;
       struct st_texture_object *stObj = st_texture_object(texObj);
+      struct pipe_texture *pt;
 
       if (texObj) {
          GLboolean flush, retval;
@@ -67,16 +68,15 @@ update_textures(struct st_context *st)
        * this table before being deleted, otherwise the pointer
        * comparison below could fail.
        */
-      if (st->state.sampler_texture[unit] != stObj) {
-         struct pipe_texture *pt = st_get_stobj_texture(stObj);
-         st->state.sampler_texture[unit] = stObj;
+
+      pt = st_get_stobj_texture(stObj);
+
+      if (st->state.sampler_texture[unit] != pt) {
+         st->state.sampler_texture[unit] = pt;
          st->pipe->set_sampler_texture(st->pipe, unit, pt);
       }
 
-      stObj = st->state.sampler_texture[unit];
-
       if (stObj && stObj->dirtyData) {
-         struct pipe_texture *pt = st_get_stobj_texture(stObj);
          st->pipe->texture_update(st->pipe, pt);
          stObj->dirtyData = GL_FALSE;
       }
index 6c0d75cc550214c13c206f30abd58ffef61869b4..65c9fda9cb683fafb33fccf8c21c4a97c0b17e89 100644 (file)
@@ -727,8 +727,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
    pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data);
    pipe->bind_fs_state(pipe, ctx->st->state.fs->data);
    pipe->bind_vs_state(pipe, ctx->st->state.vs->cso->data);
-   pipe->set_sampler_texture(pipe, unit,
-                st_get_stobj_texture(ctx->st->state.sampler_texture[unit]));
+   pipe->set_sampler_texture(pipe, unit, ctx->st->state.sampler_texture[unit]);
    pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]->data);
    pipe->set_viewport_state(pipe, &ctx->st->state.viewport);
 }
@@ -1299,7 +1298,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
                         psRead,
                         srcx, srcy, width, height);
    }
-   else {
+   else if (type == GL_COLOR) {
       /* alternate path using get/put_tile() */
       GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
 
@@ -1308,6 +1307,13 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
 
       free(buf);
    }
+   else {
+      /* GL_DEPTH */
+      GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint));
+      pipe_get_tile_z(pipe, psRead, srcx, srcy, width, height, buf);
+      pipe_put_tile_z(pipe, psTex, 0, 0, width, height, buf);
+      free(buf);
+   }
 
    /* draw textured quad */
    draw_textured_quad(ctx, dstx, dsty, ctx->Current.RasterPos[2],
index 5be4769be43ab5cf8efb4e76a016ee783de840b5..1fbf9721e79b33dea0c69a7ddac98c0ce3979e54 100644 (file)
@@ -86,7 +86,7 @@ struct st_context
       struct pipe_clip_state clip;
       struct pipe_constant_buffer constants[2];
       struct pipe_framebuffer_state framebuffer;
-      struct st_texture_object *sampler_texture[PIPE_MAX_SAMPLERS];
+      struct pipe_texture *sampler_texture[PIPE_MAX_SAMPLERS];
       struct pipe_poly_stipple poly_stipple;
       struct pipe_scissor_state scissor;
       struct pipe_viewport_state viewport;
index 243dc0b1d083ecb7827030f1e356bce0b4e71bcc..841d77abbc7a5f0d745b3d10315fd65e3df8f184 100644 (file)
@@ -312,8 +312,7 @@ st_render_mipmap(struct st_context *st,
       pipe->bind_vs_state(pipe, st->state.vs->cso->data);
    if (st->state.sampler[0])
       pipe->bind_sampler_state(pipe, 0, st->state.sampler[0]->data);
-   pipe->set_sampler_texture(pipe, 0,
-                        st_get_stobj_texture(st->state.sampler_texture[0]));
+   pipe->set_sampler_texture(pipe, 0, st->state.sampler_texture[0]);
    pipe->set_viewport_state(pipe, &st->state.viewport);
 
    return TRUE;