Merge commit 'origin/master' into gallium-sampler-view
authorKeith Whitwell <keithw@vmware.com>
Sat, 13 Mar 2010 15:06:35 +0000 (15:06 +0000)
committerKeith Whitwell <keithw@vmware.com>
Sat, 13 Mar 2010 15:06:35 +0000 (15:06 +0000)
Conflicts:
src/gallium/auxiliary/util/u_tile.c
src/gallium/auxiliary/util/u_tile.h
src/gallium/drivers/identity/id_context.c
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_setup.h
src/gallium/drivers/softpipe/sp_tex_tile_cache.c
src/gallium/include/pipe/p_context.h
src/mesa/state_tracker/st_cb_bitmap.c
src/mesa/state_tracker/st_cb_drawpixels.c

36 files changed:
1  2 
src/gallium/auxiliary/draw/draw_pipe_aaline.c
src/gallium/auxiliary/draw/draw_pipe_pstipple.c
src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_inlines.h
src/gallium/auxiliary/util/u_tile.c
src/gallium/auxiliary/util/u_tile.h
src/gallium/drivers/i915/i915_context.h
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/identity/id_context.c
src/gallium/drivers/identity/id_objects.h
src/gallium/drivers/llvmpipe/lp_context.c
src/gallium/drivers/llvmpipe/lp_context.h
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_setup.h
src/gallium/drivers/llvmpipe/lp_state.h
src/gallium/drivers/llvmpipe/lp_state_fs.c
src/gallium/drivers/nv30/nv30_context.h
src/gallium/drivers/nv40/nv40_context.h
src/gallium/drivers/nv50/nv50_context.h
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/softpipe/sp_context.c
src/gallium/drivers/softpipe/sp_flush.c
src/gallium/drivers/softpipe/sp_tex_tile_cache.c
src/gallium/drivers/softpipe/sp_tex_tile_cache.h
src/gallium/drivers/trace/tr_context.c
src/gallium/drivers/trace/tr_rbug.c
src/gallium/drivers/trace/tr_texture.h
src/gallium/include/pipe/p_context.h
src/mesa/state_tracker/st_atom_pixeltransfer.c
src/mesa/state_tracker/st_cb_bitmap.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_context.h

index 8a36d4d9d187b95d1fea0e9d371aa5a4e4b5d292,e445895efc593fec711dcd4ecc4a5a4475ff1f3b..82e44192aaf21acf0c33483b28e7cbb4a3b93b91
@@@ -1273,70 -1274,9 +1274,72 @@@ pipe_get_tile_rgba(struct pipe_context 
  }
  
  
- pipe_get_tile_swizzle(struct pipe_transfer *pt,
 +void
-    pipe_get_tile_raw(pt, x, y, w, h, packed, 0);
++pipe_get_tile_swizzle(struct pipe_context *pipe,
++                    struct pipe_transfer *pt,
 +                      uint x,
 +                      uint y,
 +                      uint w,
 +                      uint h,
 +                      uint swizzle_r,
 +                      uint swizzle_g,
 +                      uint swizzle_b,
 +                      uint swizzle_a,
 +                      enum pipe_format format,
 +                      float *p)
 +{
 +   unsigned dst_stride = w * 4;
 +   void *packed;
 +   uint i;
 +   float rgba01[6];
 +
 +   if (pipe_clip_tile(x, y, &w, &h, pt)) {
 +      return;
 +   }
 +
 +   packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
 +   if (!packed) {
 +      return;
 +   }
 +
 +   if (format == PIPE_FORMAT_UYVY || format == PIPE_FORMAT_YUYV) {
 +      assert((x & 1) == 0);
 +   }
 +
++   pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0);
 +
 +   pipe_tile_raw_to_rgba(format, packed, w, h, p, dst_stride);
 +
 +   FREE(packed);
 +
 +   if (swizzle_r == PIPE_SWIZZLE_RED &&
 +       swizzle_g == PIPE_SWIZZLE_GREEN &&
 +       swizzle_b == PIPE_SWIZZLE_BLUE &&
 +       swizzle_a == PIPE_SWIZZLE_ALPHA) {
 +      /* no-op, skip */
 +      return;
 +   }
 +
 +   rgba01[PIPE_SWIZZLE_ZERO] = 0.0f;
 +   rgba01[PIPE_SWIZZLE_ONE] = 1.0f;
 +
 +   for (i = 0; i < w * h; i++) {
 +      rgba01[PIPE_SWIZZLE_RED] = p[0];
 +      rgba01[PIPE_SWIZZLE_GREEN] = p[1];
 +      rgba01[PIPE_SWIZZLE_BLUE] = p[2];
 +      rgba01[PIPE_SWIZZLE_ALPHA] = p[3];
 +
 +      *p++ = rgba01[swizzle_r];
 +      *p++ = rgba01[swizzle_g];
 +      *p++ = rgba01[swizzle_b];
 +      *p++ = rgba01[swizzle_a];
 +   }
 +}
 +
 +
  void
- pipe_put_tile_rgba(struct pipe_transfer *pt,
+ pipe_put_tile_rgba(struct pipe_context *pipe,
+                    struct pipe_transfer *pt,
                     uint x, uint y, uint w, uint h,
                     const float *p)
  {
index d665fdb1bb14aece2f78e644efcb2543ae951a17,8329087cfa6f0da649be66e4f2d60fc9a97dcbd8..1d8ce7d8cbc3f7402812e9eeed33776a16be883a
@@@ -71,21 -74,9 +74,23 @@@ pipe_get_tile_rgba(struct pipe_context 
                     uint x, uint y, uint w, uint h,
                     float *p);
  
- pipe_get_tile_swizzle(struct pipe_transfer *pt,
 +void
++pipe_get_tile_swizzle(struct pipe_context *pipe,
++                    struct pipe_transfer *pt,
 +                      uint x,
 +                      uint y,
 +                      uint w,
 +                      uint h,
 +                      uint swizzle_r,
 +                      uint swizzle_g,
 +                      uint swizzle_b,
 +                      uint swizzle_a,
 +                      enum pipe_format format,
 +                      float *p);
 +
  void
- pipe_put_tile_rgba(struct pipe_transfer *pt,
+ pipe_put_tile_rgba(struct pipe_context *pipe,
+                    struct pipe_transfer *pt,
                     uint x, uint y, uint w, uint h,
                     const float *p);
  
Simple merge
index ef5b428161c651523151d9c297d08572ea24936a,26770d6b1e9ff1bf598e520cc2564ca1573402e1..00a542215ad2add658ce97fc44c107ced63ed843
@@@ -707,46 -711,76 +707,115 @@@ identity_is_buffer_referenced(struct pi
                                       buffer);
  }
  
 +static struct pipe_sampler_view *
 +identity_create_sampler_view(struct pipe_context *pipe,
 +                             struct pipe_texture *texture,
 +                             const struct pipe_sampler_view *templ)
 +{
 +   struct identity_context *id_pipe = identity_context(pipe);
 +   struct identity_texture *id_texture = identity_texture(texture);
 +   struct pipe_context *pipe_unwrapped = id_pipe->pipe;
 +   struct pipe_texture *texture_unwrapped = id_texture->texture;
 +   struct identity_sampler_view *view = malloc(sizeof(struct identity_sampler_view));
 +
 +   view->sampler_view = pipe_unwrapped->create_sampler_view(pipe_unwrapped,
 +                                                            texture_unwrapped,
 +                                                            templ);
 +
 +   view->base = *templ;
 +   view->base.reference.count = 1;
 +   view->base.texture = NULL;
 +   pipe_texture_reference(&view->base.texture, texture);
 +   view->base.context = pipe;
 +
 +   return &view->base;
 +}
 +
 +static void
 +identity_sampler_view_destroy(struct pipe_context *pipe,
 +                              struct pipe_sampler_view *view)
 +{
 +   struct identity_context *id_pipe = identity_context(pipe);
 +   struct identity_sampler_view *id_view = identity_sampler_view(view);
 +   struct pipe_context *pipe_unwrapped = id_pipe->pipe;
 +   struct pipe_sampler_view *view_unwrapped = id_view->sampler_view;
 +
 +   pipe_unwrapped->sampler_view_destroy(pipe_unwrapped,
 +                                        view_unwrapped);
 +
 +   pipe_texture_reference(&view->texture, NULL);
 +   free(view);
 +}
  
+ static struct pipe_transfer *
+ identity_context_get_tex_transfer(struct pipe_context *_context,
+                                 struct pipe_texture *_texture,
+                                  unsigned face,
+                                  unsigned level,
+                                  unsigned zslice,
+                                  enum pipe_transfer_usage usage,
+                                  unsigned x,
+                                  unsigned y,
+                                  unsigned w,
+                                  unsigned h)
+ {
+    struct identity_context *id_context = identity_context(_context);
+    struct identity_texture *id_texture = identity_texture(_texture);
+    struct pipe_context *context = id_context->pipe;
+    struct pipe_texture *texture = id_texture->texture;
+    struct pipe_transfer *result;
+    result = context->get_tex_transfer(context,
+                                      texture,
+                                      face,
+                                      level,
+                                      zslice,
+                                      usage,
+                                      x,
+                                      y,
+                                      w,
+                                      h);
+    if (result)
+       return identity_transfer_create(id_context, id_texture, result);
+    return NULL;
+ }
+ static void
+ identity_context_tex_transfer_destroy(struct pipe_context *_pipe,
+                                       struct pipe_transfer *_transfer)
+ {
+    identity_transfer_destroy(identity_context(_pipe),
+                              identity_transfer(_transfer));
+ }
+ static void *
+ identity_context_transfer_map(struct pipe_context *_context,
+                              struct pipe_transfer *_transfer)
+ {
+    struct identity_context *id_context = identity_context(_context);
+    struct identity_transfer *id_transfer = identity_transfer(_transfer);
+    struct pipe_context *context = id_context->pipe;
+    struct pipe_transfer *transfer = id_transfer->transfer;
+    return context->transfer_map(context,
+                               transfer);
+ }
+ static void
+ identity_context_transfer_unmap(struct pipe_context *_context,
+                                struct pipe_transfer *_transfer)
+ {
+    struct identity_context *id_context = identity_context(_context);
+    struct identity_transfer *id_transfer = identity_transfer(_transfer);
+    struct pipe_context *context = id_context->pipe;
+    struct pipe_transfer *transfer = id_transfer->transfer;
+    context->transfer_unmap(context,
+                           transfer);
+ }
  struct pipe_context *
  identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
  {
     id_pipe->base.flush = identity_flush;
     id_pipe->base.is_texture_referenced = identity_is_texture_referenced;
     id_pipe->base.is_buffer_referenced = identity_is_buffer_referenced;
 +   id_pipe->base.create_sampler_view = identity_create_sampler_view;
 +   id_pipe->base.sampler_view_destroy = identity_sampler_view_destroy;
+    id_pipe->base.get_tex_transfer = identity_context_get_tex_transfer;
+    id_pipe->base.tex_transfer_destroy = identity_context_tex_transfer_destroy;
+    id_pipe->base.transfer_map = identity_context_transfer_map;
+    id_pipe->base.transfer_unmap = identity_context_transfer_unmap;
  
     id_pipe->pipe = pipe;
  
index 059584f2a7742de0cbb963d835539752fd626ab8,16128c34c80878cf4384522d9b17df3abebe8847..cd16b6b2d38783010e3494964a87642cbb208486
@@@ -448,12 -450,11 +450,12 @@@ lp_setup_set_vertex_info( struct lp_set
  
  
  /**
 - * Called during state validation when LP_NEW_TEXTURE is set.
 + * Called during state validation when LP_NEW_SAMPLER_VIEW is set.
   */
  void
- lp_setup_set_fragment_sampler_views(struct setup_context *setup,
 -lp_setup_set_sampler_textures( struct lp_setup_context *setup,
 -                               unsigned num, struct pipe_texture **texture)
++lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
 +                                    unsigned num,
 +                                    struct pipe_sampler_view **views)
  {
     unsigned i;
  
index 72116b8c6c40dde77b1af27377b2d8552e39b32f,be1bf96f12d5719945a2f81cc8cec12ec322264c..414eaec98d15e56c1a165b19b00ccbadeb1bc216
@@@ -120,12 -121,11 +121,12 @@@ lp_setup_set_scissor( struct lp_setup_c
                        const struct pipe_scissor_state *scissor );
  
  void
- lp_setup_set_fragment_sampler_views(struct setup_context *setup,
 -lp_setup_set_sampler_textures( struct lp_setup_context *setup,
 -                               unsigned num, struct pipe_texture **texture);
++lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
 +                                    unsigned num,
 +                                    struct pipe_sampler_view **views);
  
  unsigned
- lp_setup_is_texture_referenced( const struct setup_context *setup,
+ lp_setup_is_texture_referenced( const struct lp_setup_context *setup,
                                  const struct pipe_texture *texture );
  
  void
Simple merge
index dfa002a79b408dd6bf3372604ec5d847666de121,e3a5e37ce442c3973c9d0cf78e49c1d7a6758f09..6594514c38f0ae0de1397e0c6dc5e413b2b1166b
@@@ -266,17 -251,12 +260,18 @@@ sp_find_cached_tile_tex(struct softpipe
        }
  
        /* get tile from the transfer (view into texture) */
-       pipe_get_tile_swizzle(tc->tex_trans,
 -      pipe_get_tile_rgba(tc->pipe,
 -                         tc->tex_trans,
 -                         addr.bits.x * TILE_SIZE, 
 -                         addr.bits.y * TILE_SIZE,
 -                         TILE_SIZE, TILE_SIZE,
 -                         (float *) tile->data.color);
++      pipe_get_tile_swizzle(tc->pipe,
++                          tc->tex_trans,
 +                            addr.bits.x * TILE_SIZE, 
 +                            addr.bits.y * TILE_SIZE,
 +                            TILE_SIZE,
 +                            TILE_SIZE,
 +                            tc->swizzle_r,
 +                            tc->swizzle_g,
 +                            tc->swizzle_b,
 +                            tc->swizzle_a,
 +                            tc->format,
 +                            (float *) tile->data.color);
        tile->addr = addr;
     }
  
index f9555fb922c1bcc75caedb7a84d8d7a9ddf9f35d,b7e6bbac68ec2411ad2c04f266ca0ec10c8dd11f..5c24bd1f7dfcc3316ecdbd61c49ef4b10d0cdb35
   *
   **************************************************************************/
  
 +#include "util/u_inlines.h"
  #include "util/u_memory.h"
  #include "util/u_simple_list.h"
+ #include "util/u_format.h"
  
+ #include "pipe/p_format.h"
  #include "pipe/p_screen.h"
  
  #include "tr_dump.h"
Simple merge
index 17fad1fa2435e4eda0c22d2b320dcce2b746363b,a7f12fb81e16513c092264857efcdb5874bb9af5..d1b734a9f9a3247f72d84c03320e2fe90d80d814
@@@ -307,15 -307,32 +307,41 @@@ struct pipe_context 
     unsigned int (*is_buffer_referenced)(struct pipe_context *pipe,
                                        struct pipe_buffer *buf);
  
 +   /**
 +    * Create a view on a texture to be used by a shader stage.
 +    */
 +   struct pipe_sampler_view * (*create_sampler_view)(struct pipe_context *ctx,
 +                                                     struct pipe_texture *texture,
 +                                                     const struct pipe_sampler_view *templat);
 +
 +   void (*sampler_view_destroy)(struct pipe_context *ctx,
 +                                struct pipe_sampler_view *view);
+    /**
+     * Get a transfer object for transferring data to/from a texture.
+     *
+     * Transfers are (by default) context-private and allow uploads to be
+     * interleaved with
+     */
+    struct pipe_transfer *(*get_tex_transfer)(struct pipe_context *,
+                                              struct pipe_texture *texture,
+                                              unsigned face, unsigned level,
+                                              unsigned zslice,
+                                              enum pipe_transfer_usage usage,
+                                              unsigned x, unsigned y,
+                                              unsigned w, unsigned h);
+    void (*tex_transfer_destroy)(struct pipe_context *,
+                                 struct pipe_transfer *);
+    
+    void *(*transfer_map)( struct pipe_context *,
+                           struct pipe_transfer *transfer );
+    void (*transfer_unmap)( struct pipe_context *,
+                            struct pipe_transfer *transfer );
  };
  
  
index 25d33b933e3f1b76c77a65edae93ee04069b0277,dfd8925edf4d66d2c6487d23d7aadeed4487b280..9a0446bb7103679a2ac3a06b7aa6e1359a730bb9
@@@ -601,8 -598,6 +598,7 @@@ st_flush_bitmap_cache(struct st_contex
  
        if (st->ctx->DrawBuffer) {
           struct pipe_context *pipe = st->pipe;
-          struct pipe_screen *screen = pipe->screen;
 +         struct pipe_sampler_view *sv;
  
           assert(cache->xmin <= cache->xmax);
   
index 236010c5b5d5ed2003bffb6ce6fde2185d3baa03,c44d0fc3e86e87a291713b04d613a2227c776ca0..75be79fd4b01ecade82b77f36baa42c8f31d2275
@@@ -586,16 -608,16 +608,16 @@@ draw_textured_quad(GLcontext *ctx, GLin
  
     /* texture state: */
     if (st->pixel_xfer.pixelmap_enabled) {
 -      struct pipe_texture *textures[2];
 -      textures[0] = pt;
 -      textures[1] = st->pixel_xfer.pixelmap_texture;
 -      pipe->set_fragment_sampler_textures(pipe, 2, textures);
 +      struct pipe_sampler_view *sampler_views[2];
 +      sampler_views[0] = sv;
 +      sampler_views[1] = st->pixel_xfer.pixelmap_sampler_view;
 +      cso_set_fragment_sampler_views(cso, 2, sampler_views);
     }
     else {
 -      pipe->set_fragment_sampler_textures(pipe, 1, &pt);
 +      cso_set_fragment_sampler_views(cso, 1, &sv);
     }
  
-    /* Compute window coords (y=0=bottom) with pixel zoom.
+    /* Compute Gallium window coords (y=0=top) with pixel zoom.
      * Recall that these coords are transformed by the current
      * vertex shader and viewport transformation.
      */
@@@ -938,10 -959,9 +964,10 @@@ st_CopyPixels(GLcontext *ctx, GLint src
     struct st_renderbuffer *rbRead;
     void *driver_vp, *driver_fp;
     struct pipe_texture *pt;
 +   struct pipe_sampler_view *sv;
     GLfloat *color;
     enum pipe_format srcFormat, texFormat;
-    int ptw, pth;
+    GLboolean invertTex = GL_FALSE;
  
     pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
  
     if (!pt)
        return;
  
 +   sv = st_sampler_view_from_texture(st->pipe, pt);
 +   if (!sv) {
 +      pipe_texture_reference(&pt, NULL);
 +      return;
 +   }
 +
+    /* Make temporary texture which is a copy of the src region.
+     * We'll draw a quad with this texture to draw the dest image.
+     */
     if (srcFormat == texFormat) {
        /* copy source framebuffer surface into mipmap/texture */
        struct pipe_surface *psRead = screen->get_tex_surface(screen,
     /* draw textured quad */
     draw_textured_quad(ctx, dstx, dsty, ctx->Current.RasterPos[2],
                        width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
 -                      pt
 +                      sv
                        driver_vp, 
                        driver_fp,
-                       color, GL_TRUE);
+                       color, invertTex);
  
     pipe_texture_reference(&pt, NULL);
 +   pipe_sampler_view_reference(&sv, NULL);
  }
  
  
Simple merge
Simple merge