OSDN Git Service

Use tile functions in new p_tile.[ch]
authorBrian <brian.paul@tungstengraphics.com>
Sat, 15 Dec 2007 23:44:29 +0000 (16:44 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Sat, 15 Dec 2007 23:44:29 +0000 (16:44 -0700)
This removes quite a bit of code duplicated in the drivers.

src/mesa/pipe/i915simple/i915_surface.c
src/mesa/pipe/i965simple/brw_surface.c
src/mesa/pipe/softpipe/Makefile
src/mesa/pipe/softpipe/sp_surface.c
src/mesa/sources

index d4c02c5..3406461 100644 (file)
 #include "pipe/p_util.h"
 #include "pipe/p_inlines.h"
 #include "pipe/p_winsys.h"
-
-#include "pipe/softpipe/sp_rgba_tile.h" /* XXX TEMPORARY */
-
-
-#define CLIP_TILE \
-   do { \
-      if (x >= ps->width) \
-         return; \
-      if (y >= ps->height) \
-         return; \
-      if (x + w > ps->width) \
-         w = ps->width - x; \
-      if (y + h > ps->height) \
-         h = ps->height -y; \
-   } while(0)
-
-
-/*
- * XXX note: same as code in sp_surface.c
- */
-static void
-i915_get_tile(struct pipe_context *pipe,
-              struct pipe_surface *ps,
-              uint x, uint y, uint w, uint h,
-              void *p, int dst_stride)
-{
-   const uint cpp = ps->cpp;
-   const uint w0 = w;
-   const ubyte *pSrc;
-   ubyte *pDest;
-   uint i;
-
-   assert(ps->map);
-
-   CLIP_TILE;
-
-   if (dst_stride == 0) {
-      dst_stride = w0 * cpp;
-   }
-
-   pSrc = ps->map + (y * ps->pitch + x) * cpp;
-   pDest = (ubyte *) p;
-
-   for (i = 0; i < h; i++) {
-      memcpy(pDest, pSrc, w0 * cpp);
-      pDest += dst_stride;
-      pSrc += ps->pitch * cpp;
-   }
-}
-
-
-/*
- * XXX note: same as code in sp_surface.c
- */
-static void
-i915_put_tile(struct pipe_context *pipe,
-              struct pipe_surface *ps,
-              uint x, uint y, uint w, uint h,
-              const void *p, int src_stride)
-{
-   const uint cpp = ps->cpp;
-   const uint w0 = w;
-   const ubyte *pSrc;
-   ubyte *pDest;
-   uint i;
-
-   assert(ps->map);
-
-   CLIP_TILE;
-
-   if (src_stride == 0) {
-      src_stride = w0 * cpp;
-   }
-
-   pSrc = (const ubyte *) p;
-   pDest = ps->map + (y * ps->pitch + x) * cpp;
-
-   for (i = 0; i < h; i++) {
-      memcpy(pDest, pSrc, w0 * cpp);
-      pDest += ps->pitch * cpp;
-      pSrc += src_stride;
-   }
-}
+#include "pipe/util/p_tile.h"
 
 
 /*
@@ -323,10 +241,10 @@ void
 i915_init_surface_functions(struct i915_context *i915)
 {
    i915->pipe.get_tex_surface = i915_get_tex_surface;
-   i915->pipe.get_tile = i915_get_tile;
-   i915->pipe.put_tile = i915_put_tile;
-   i915->pipe.get_tile_rgba = softpipe_get_tile_rgba;
-   i915->pipe.put_tile_rgba = softpipe_put_tile_rgba;
+   i915->pipe.get_tile = pipe_get_tile_raw;
+   i915->pipe.put_tile = pipe_put_tile_raw;
+   i915->pipe.get_tile_rgba = pipe_get_tile_rgba;
+   i915->pipe.put_tile_rgba = pipe_put_tile_rgba;
 
    i915->pipe.surface_data = i915_surface_data;
    i915->pipe.surface_copy = i915_surface_copy;
index b0d2fec..96f17e4 100644 (file)
 #include "pipe/p_util.h"
 #include "pipe/p_inlines.h"
 #include "pipe/p_winsys.h"
-
-#include "pipe/softpipe/sp_rgba_tile.h" /* XXX TEMPORARY */
-
-
-#define CLIP_TILE \
-   do { \
-      if (x >= ps->width) \
-         return; \
-      if (y >= ps->height) \
-         return; \
-      if (x + w > ps->width) \
-         w = ps->width - x; \
-      if (y + h > ps->height) \
-         h = ps->height -y; \
-   } while(0)
-
-
-/*
- * XXX note: same as code in sp_surface.c
- */
-static void
-brw_get_tile(struct pipe_context *pipe,
-              struct pipe_surface *ps,
-              uint x, uint y, uint w, uint h,
-              void *p, int dst_stride)
-{
-   const uint cpp = ps->cpp;
-   const uint w0 = w;
-   const ubyte *pSrc;
-   ubyte *pDest;
-   uint i;
-
-   assert(ps->map);
-
-   CLIP_TILE;
-
-   if (dst_stride == 0) {
-      dst_stride = w0 * cpp;
-   }
-
-   pSrc = ps->map + ps->offset + (y * ps->pitch + x) * cpp;
-   pDest = (ubyte *) p;
-
-   for (i = 0; i < h; i++) {
-      memcpy(pDest, pSrc, w0 * cpp);
-      pDest += dst_stride;
-      pSrc += ps->pitch * cpp;
-   }
-}
-
-
-/*
- * XXX note: same as code in sp_surface.c
- */
-static void
-brw_put_tile(struct pipe_context *pipe,
-              struct pipe_surface *ps,
-              uint x, uint y, uint w, uint h,
-              const void *p, int src_stride)
-{
-   const uint cpp = ps->cpp;
-   const uint w0 = w;
-   const ubyte *pSrc;
-   ubyte *pDest;
-   uint i;
-
-   assert(ps->map);
-
-   CLIP_TILE;
-
-   if (src_stride == 0) {
-      src_stride = w0 * cpp;
-   }
-
-   pSrc = (const ubyte *) p;
-   pDest = ps->map + ps->offset + (y * ps->pitch + x) * cpp;
-
-   for (i = 0; i < h; i++) {
-      memcpy(pDest, pSrc, w0 * cpp);
-      pDest += ps->pitch * cpp;
-      pSrc += src_stride;
-   }
-}
+#include "pipe/util/p_tile.h"
 
 
 /*
@@ -321,10 +239,10 @@ void
 brw_init_surface_functions(struct brw_context *brw)
 {
    brw->pipe.get_tex_surface = brw_get_tex_surface;
-   brw->pipe.get_tile = brw_get_tile;
-   brw->pipe.put_tile = brw_put_tile;
-   brw->pipe.get_tile_rgba = softpipe_get_tile_rgba;
-   brw->pipe.put_tile_rgba = softpipe_put_tile_rgba;
+   brw->pipe.get_tile = pipe_get_tile_raw;
+   brw->pipe.put_tile = pipe_put_tile_raw;
+   brw->pipe.get_tile_rgba = pipe_get_tile_rgba;
+   brw->pipe.put_tile_rgba = pipe_put_tile_rgba;
 
    brw->pipe.surface_data  = brw_surface_data;
    brw->pipe.surface_copy  = brw_surface_copy;
index 7608ff1..31438a8 100644 (file)
@@ -25,7 +25,6 @@ DRIVER_SOURCES = \
        sp_quad_output.c \
        sp_quad_stencil.c \
        sp_quad_stipple.c \
-       sp_rgba_tile.c \
        sp_state_blend.c \
        sp_state_clip.c \
        sp_state_derived.c \
index 2a69090..5259fbf 100644 (file)
 #include "pipe/p_util.h"
 #include "pipe/p_inlines.h"
 #include "pipe/p_winsys.h"
+#include "pipe/util/p_tile.h"
 #include "sp_context.h"
 #include "sp_surface.h"
 #include "sp_texture.h"
-#include "sp_rgba_tile.h"
-
-
-
-#define CLIP_TILE \
-   do { \
-      if (x >= ps->width) \
-         return; \
-      if (y >= ps->height) \
-         return; \
-      if (x + w > ps->width) \
-         w = ps->width - x; \
-      if (y + h > ps->height) \
-         h = ps->height - y; \
-   } while(0)
 
 
 /**
@@ -91,72 +77,6 @@ softpipe_get_tex_surface(struct pipe_context *pipe,
 
 
 /**
- * Move raw block of pixels from surface to user memory.
- */
-void
-softpipe_get_tile(struct pipe_context *pipe, struct pipe_surface *ps,
-                  uint x, uint y, uint w, uint h,
-                  void *p, int dst_stride)
-{
-   const uint cpp = ps->cpp;
-   const ubyte *pSrc;
-   const uint src_stride = ps->pitch * cpp;
-   ubyte *pDest;
-   uint i;
-
-   assert(ps->map);
-
-   if (dst_stride == 0) {
-      dst_stride = w * cpp;
-   }
-
-   CLIP_TILE;
-
-   pSrc = ps->map + (y * ps->pitch + x) * cpp;
-   pDest = (ubyte *) p;
-
-   for (i = 0; i < h; i++) {
-      memcpy(pDest, pSrc, w * cpp);
-      pDest += dst_stride;
-      pSrc += src_stride;
-   }
-}
-
-
-/**
- * Move raw block of pixels from user memory to surface.
- */
-void
-softpipe_put_tile(struct pipe_context *pipe, struct pipe_surface *ps,
-                  uint x, uint y, uint w, uint h,
-                  const void *p, int src_stride)
-{
-   const uint cpp = ps->cpp;
-   const ubyte *pSrc;
-   const uint dst_stride = ps->pitch * cpp;
-   ubyte *pDest;
-   uint i;
-
-   assert(ps->map);
-
-   if (src_stride == 0) {
-      src_stride = w * cpp;
-   }
-
-   CLIP_TILE;
-
-   pSrc = (const ubyte *) p;
-   pDest = ps->map + (y * ps->pitch + x) * cpp;
-
-   for (i = 0; i < h; i++) {
-      memcpy(pDest, pSrc, w * cpp);
-      pDest += dst_stride;
-      pSrc += src_stride;
-   }
-}
-
-
-/**
  * Copy 2D rect from one place to another.
  * Position and sizes are in pixels.
  */
@@ -308,6 +228,10 @@ sp_surface_fill(struct pipe_context *pipe,
          ushort val1 = UBYTE_TO_USHORT((value >>  8) & 0xff);
          ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff);
          ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff);
+         val0 = (val0 << 8) | val0;
+         val1 = (val1 << 8) | val1;
+         val2 = (val2 << 8) | val2;
+         val3 = (val3 << 8) | val3;
          for (i = 0; i < height; i++) {
             for (j = 0; j < width; j++) {
                row[j*4+0] = val0;
@@ -331,11 +255,10 @@ sp_surface_fill(struct pipe_context *pipe,
 void
 sp_init_surface_functions(struct softpipe_context *sp)
 {
-   sp->pipe.get_tile = softpipe_get_tile;
-   sp->pipe.put_tile = softpipe_put_tile;
-
-   sp->pipe.get_tile_rgba = softpipe_get_tile_rgba;
-   sp->pipe.put_tile_rgba = softpipe_put_tile_rgba;
+   sp->pipe.get_tile = pipe_get_tile_raw;
+   sp->pipe.put_tile = pipe_put_tile_raw;
+   sp->pipe.get_tile_rgba = pipe_get_tile_rgba;
+   sp->pipe.put_tile_rgba = pipe_put_tile_rgba;
 
    sp->pipe.surface_data = sp_surface_data;
    sp->pipe.surface_copy = sp_surface_copy;
index f889fb3..5d29d20 100644 (file)
@@ -196,6 +196,9 @@ STATECACHE_SOURCES = \
        pipe/cso_cache/cso_hash.c \
        pipe/cso_cache/cso_cache.c
 
+PIPEUTIL_SOURCES = \
+       pipe/util/p_tile.c
+
 STATETRACKER_SOURCES = \
        state_tracker/st_atom.c \
        state_tracker/st_atom_alphatest.c \
@@ -383,6 +386,7 @@ SOLO_SOURCES = \
        $(DRAW_SOURCES)         \
        $(TGSIEXEC_SOURCES)     \
        $(TGSIUTIL_SOURCES)     \
+       $(PIPEUTIL_SOURCES)     \
        $(STATECACHE_SOURCES)   \
        $(STATETRACKER_SOURCES) \
        $(TNL_SOURCES)          \