Lift region-related functions up to the pipe interface.
authorBrian <brian@i915.localnet.net>
Tue, 31 Jul 2007 21:44:50 +0000 (15:44 -0600)
committerBrian <brian@i915.localnet.net>
Tue, 31 Jul 2007 21:44:50 +0000 (15:44 -0600)
Some of these functions probably should be driver-private.
Note: intel_buffer_object is in p_state.h and should be fixed/removed.
There are just a few i915 dependencies in intel_region.c

27 files changed:
src/mesa/drivers/dri/i915pipe/intel_blit.c
src/mesa/drivers/dri/i915pipe/intel_buffer_objects.c
src/mesa/drivers/dri/i915pipe/intel_buffer_objects.h
src/mesa/drivers/dri/i915pipe/intel_buffers.c
src/mesa/drivers/dri/i915pipe/intel_buffers.h
src/mesa/drivers/dri/i915pipe/intel_context.c
src/mesa/drivers/dri/i915pipe/intel_context.h
src/mesa/drivers/dri/i915pipe/intel_depthstencil.c
src/mesa/drivers/dri/i915pipe/intel_fbo.c
src/mesa/drivers/dri/i915pipe/intel_fbo.h
src/mesa/drivers/dri/i915pipe/intel_ioctl.c
src/mesa/drivers/dri/i915pipe/intel_mipmap_tree.c
src/mesa/drivers/dri/i915pipe/intel_mipmap_tree.h
src/mesa/drivers/dri/i915pipe/intel_pixel.c
src/mesa/drivers/dri/i915pipe/intel_pixel.h
src/mesa/drivers/dri/i915pipe/intel_regions.c
src/mesa/drivers/dri/i915pipe/intel_regions.h
src/mesa/drivers/dri/i915pipe/intel_screen.c
src/mesa/drivers/dri/i915pipe/intel_screen.h
src/mesa/drivers/dri/i915pipe/intel_span.c
src/mesa/drivers/dri/i915pipe/intel_state.c
src/mesa/drivers/dri/i915pipe/intel_surface.c
src/mesa/drivers/dri/i915pipe/intel_tex_copy.c
src/mesa/drivers/dri/i915pipe/intel_tex_image.c
src/mesa/drivers/dri/i915pipe/intel_tex_subimage.c
src/mesa/pipe/p_context.h
src/mesa/pipe/p_state.h

index 28441f4b835ae03fab93eabacebd3efef5009ca4..8e7f294b575d6f35a2a9b2baf9f2a18a046f7d27 100644 (file)
@@ -26,9 +26,6 @@
  **************************************************************************/
 
 
-#include <stdio.h>
-#include <errno.h>
-
 #include "mtypes.h"
 #include "context.h"
 #include "enums.h"
 #include "intel_context.h"
 #include "intel_fbo.h"
 #include "intel_reg.h"
-#include "intel_regions.h"
 #include "vblank.h"
 
+#include "pipe/p_context.h"
+
+
 #define FILE_DEBUG_FLAG DEBUG_BLIT
 
 /**
@@ -87,9 +86,9 @@ intelCopyBuffer(__DRIdrawablePrivate * dPriv,
 
    if (dPriv && dPriv->numClipRects) {
       struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
-      const struct intel_region *frontRegion
+      const struct pipe_region *frontRegion
         = intelScreen->front_region;
-      const struct intel_region *backRegion
+      const struct pipe_region *backRegion
         = intel_fb->Base._ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT ?
           intel_get_rb_region(&intel_fb->Base, BUFFER_FRONT_LEFT) :
           intel_get_rb_region(&intel_fb->Base, BUFFER_BACK_LEFT);
@@ -447,10 +446,10 @@ intelClearWithBlit(GLcontext * ctx, GLbitfield mask)
             const GLbitfield bufBit = 1 << buf;
             if ((clearMask & bufBit) && !(bufBit & skipBuffers)) {
                /* OK, clear this renderbuffer */
-               struct intel_region *irb_region =
+               struct pipe_region *irb_region =
                  intel_get_rb_region(fb, buf);
                struct _DriBufferObject *write_buffer =
-                  intel_region_buffer(intel->intelScreen, irb_region,
+                  intel->pipe->region_buffer(intel->pipe, irb_region,
                                       all ? INTEL_WRITE_FULL :
                                       INTEL_WRITE_PART);
 
index 91c45ad95be56ca85e3e9ad3ba4b824cefeecf9f..eee5fa9bf47329c4a3a4715ccb44ca8a28966007 100644 (file)
 
 #include "intel_context.h"
 #include "intel_buffer_objects.h"
-#include "intel_regions.h"
 #include "dri_bufmgr.h"
 
+#include "pipe/p_state.h"
+#include "pipe/p_context.h"
+
+
 /**
  * There is some duplication between mesa's bufferobjects and our
  * bufmgr buffers.  Both have an integer handle and a hashtable to
@@ -89,7 +92,7 @@ intel_bufferobj_cow(struct intel_context *intel,
                     struct intel_buffer_object *intel_obj)
 {
    assert(intel_obj->region);
-   intel_region_cow(intel->intelScreen, intel_obj->region);
+   intel->pipe->region_cow(intel->pipe, intel_obj->region);
 }
 
 
index afe9b2f7cf21b5fdb83a596cf32b972254248cbf..a1f63c147b80df3723229a5551fb9f7296d77dcd 100644 (file)
@@ -31,7 +31,7 @@
 #include "mtypes.h"
 
 struct intel_context;
-struct intel_region;
+struct pipe_region;
 struct gl_buffer_object;
 
 
@@ -43,7 +43,7 @@ struct intel_buffer_object
    struct gl_buffer_object Base;
    struct _DriBufferObject *buffer;     /* the low-level buffer manager's buffer handle */
 
-   struct intel_region *region; /* Is there a zero-copy texture
+   struct pipe_region *region; /* Is there a zero-copy texture
                                    associated with this (pixel)
                                    buffer object? */
 };
@@ -75,7 +75,7 @@ intel_buffer_object(struct gl_buffer_object *obj)
       return NULL;
 }
 
-/* Helpers for zerocopy image uploads.  See also intel_regions.h:
+/* Helpers for zerocopy image uploads.  See also pipe_regions.h:
  */
 void intel_bufferobj_cow(struct intel_context *intel,
                          struct intel_buffer_object *intel_obj);
index cc9a4262df6e22904387cb36413e06a45441ff58..c03c009a3aa56acd0008f6748e7c1f571f5dbb67 100644 (file)
@@ -31,7 +31,6 @@
 #include "intel_buffers.h"
 #include "intel_depthstencil.h"
 #include "intel_fbo.h"
-#include "intel_regions.h"
 #include "intel_batchbuffer.h"
 #include "intel_reg.h"
 #include "context.h"
@@ -96,7 +95,7 @@ intel_intersect_cliprects(drm_clip_rect_t * dst,
 /**
  * Return pointer to current color drawing region, or NULL.
  */
-struct intel_region *
+struct pipe_region *
 intel_drawbuf_region(struct intel_context *intel)
 {
    struct intel_renderbuffer *irbColor =
@@ -110,7 +109,7 @@ intel_drawbuf_region(struct intel_context *intel)
 /**
  * Return pointer to current color reading region, or NULL.
  */
-struct intel_region *
+struct pipe_region *
 intel_readbuf_region(struct intel_context *intel)
 {
    struct intel_renderbuffer *irb
@@ -325,7 +324,7 @@ intelClear(GLcontext *ctx, GLbitfield mask)
 
    /* HW stencil */
    if (mask & BUFFER_BIT_STENCIL) {
-      const struct intel_region *stencilRegion
+      const struct pipe_region *stencilRegion
          = intel_get_rb_region(fb, BUFFER_STENCIL);
       if (stencilRegion) {
          /* have hw stencil */
@@ -369,8 +368,10 @@ intelClear(GLcontext *ctx, GLbitfield mask)
    if (blit_mask)
       intelClearWithBlit(ctx, blit_mask);
 
+#if 1
    if (swrast_mask | tri_mask)
       _swrast_Clear(ctx, swrast_mask | tri_mask);
+#endif
 }
 
 
@@ -625,7 +626,7 @@ void
 intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
 {
    struct intel_context *intel = intel_context(ctx);
-   struct intel_region *colorRegion, *depthRegion = NULL;
+   struct pipe_region *colorRegion, *depthRegion = NULL;
    struct intel_renderbuffer *irbDepth = NULL, *irbStencil = NULL;
 
    if (!fb) {
index 13d1a15ffbfb3faaf968d6aeb9cbe2dafa478aaa..5834e3950100d1bc4b9547e95314b4a884886276 100644 (file)
@@ -38,9 +38,9 @@ intel_intersect_cliprects(drm_clip_rect_t * dest,
                           const drm_clip_rect_t * a,
                           const drm_clip_rect_t * b);
 
-extern struct intel_region *intel_readbuf_region(struct intel_context *intel);
+extern struct pipe_region *intel_readbuf_region(struct intel_context *intel);
 
-extern struct intel_region *intel_drawbuf_region(struct intel_context *intel);
+extern struct pipe_region *intel_drawbuf_region(struct intel_context *intel);
 
 extern void intel_wait_flips(struct intel_context *intel, GLuint batch_flags);
 
index 395b0f63be4ec9c7b37bf963b3b6c06960424cb6..c8129c9e5fc892f6e2b09b9741b41cfe664c9b81 100644 (file)
 #include "intel_batchbuffer.h"
 #include "intel_blit.h"
 #include "intel_pixel.h"
-#include "intel_regions.h"
 #include "intel_buffer_objects.h"
 #include "intel_fbo.h"
 
 #include "pipe/softpipe/sp_context.h"
 #include "state_tracker/st_public.h"
+#include "state_tracker/st_context.h"
 
 
 #include "drirenderbuffer.h"
@@ -90,7 +90,7 @@ int INTEL_DEBUG = (0);
 #include "extension_helper.h"
 
 
-#define DRIVER_DATE                     "20061102"
+#define DRIVER_DATE                     "20070731"
 
 _glthread_Mutex lockMutex;
 static GLboolean lockMutexInit = GL_FALSE;
@@ -355,13 +355,6 @@ intelCreateContext(const __GLcontextModes * mesaVis,
    int fthrottle_mode;
    GLboolean havePools;
 
-   DRM_LIGHT_LOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
-   havePools = intelCreatePools(intelScreen);
-   DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
-
-   if (!havePools)
-      return GL_FALSE;
-
    intelInitDriverFunctions(&functions);
 
    if (!_mesa_initialize_context(&intel->ctx,
@@ -416,11 +409,31 @@ intelCreateContext(const __GLcontextModes * mesaVis,
    _tnl_CreateContext(ctx);
    _swsetup_CreateContext(ctx);
 
-
    /* Configure swrast to match hardware characteristics: */
    _swrast_allow_pixel_fog(ctx, GL_FALSE);
    _swrast_allow_vertex_fog(ctx, GL_TRUE);
 
+   /*
+    * Pipe-related setup
+    */
+   st_create_context( &intel->ctx,
+                     softpipe_create() );
+   
+   intel->pipe = intel->ctx.st->pipe;
+   intel->pipe->screen = intelScreen;
+   intelScreen->pipe = intel->pipe;
+   intel_init_region_functions(intel->pipe);
+
+   /*
+    * memory pools
+    */
+   DRM_LIGHT_LOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
+   havePools = intelCreatePools(intelScreen);
+   DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
+   if (!havePools)
+      return GL_FALSE;
+
+
    /* Dri stuff */
    intel->hHWContext = driContextPriv->hHWContext;
    intel->driFd = sPriv->fd;
@@ -497,10 +510,6 @@ intelCreateContext(const __GLcontextModes * mesaVis,
    }
 
 
-   st_create_context( &intel->ctx,
-                     softpipe_create() );
-   
-
    return GL_TRUE;
 }
 
index 154be972b91c42e52962c0f1b625a1b71cc69587..9d331e41b5441ee4a38890fca57b788bbea2858f 100644 (file)
@@ -48,7 +48,8 @@
 #define DV_PF_565  (2<<8)
 #define DV_PF_8888 (3<<8)
 
-struct intel_region;
+struct pipe_context;
+struct pipe_region;
 struct intel_context;
 struct _DriBufferObject;
 
@@ -121,6 +122,8 @@ struct intel_context
 {
    GLcontext ctx;               /* the parent class */
    
+   struct pipe_context *pipe;
+
    GLint refcount;
    GLuint Fallback;
    GLuint NewGLState;
@@ -422,5 +425,7 @@ intel_texture_image(struct gl_texture_image *img)
 extern struct intel_renderbuffer *intel_renderbuffer(struct gl_renderbuffer
                                                      *rb);
 
+extern void intel_init_region_functions(struct pipe_context *pipe);
+
 
 #endif
index d269a85a3c91b6d2ca59c8a22caaa8263909c57d..81e09698cc56524812ac65d3293f9ac6accabb90 100644 (file)
@@ -38,8 +38,8 @@
 #include "intel_context.h"
 #include "intel_fbo.h"
 #include "intel_depthstencil.h"
-#include "intel_regions.h"
 
+#include "pipe/p_context.h"
 
 /**
  * The GL_EXT_framebuffer_object allows the user to create their own
@@ -95,12 +95,12 @@ map_regions(GLcontext * ctx,
 {
    struct intel_context *intel = intel_context(ctx);
    if (depthRb && depthRb->region) {
-      intel_region_map(intel->intelScreen, depthRb->region);
+      intel->pipe->region_map(intel->pipe, depthRb->region);
       depthRb->pfMap = depthRb->region->map;
       depthRb->pfPitch = depthRb->region->pitch;
    }
    if (stencilRb && stencilRb->region) {
-      intel_region_map(intel->intelScreen, stencilRb->region);
+      intel->pipe->region_map(intel->pipe, stencilRb->region);
       stencilRb->pfMap = stencilRb->region->map;
       stencilRb->pfPitch = stencilRb->region->pitch;
    }
@@ -113,12 +113,12 @@ unmap_regions(GLcontext * ctx,
 {
    struct intel_context *intel = intel_context(ctx);
    if (depthRb && depthRb->region) {
-      intel_region_unmap(intel->intelScreen, depthRb->region);
+      intel->pipe->region_unmap(intel->pipe, depthRb->region);
       depthRb->pfMap = NULL;
       depthRb->pfPitch = 0;
    }
    if (stencilRb && stencilRb->region) {
-      intel_region_unmap(intel->intelScreen, stencilRb->region);
+      intel->pipe->region_unmap(intel->pipe, stencilRb->region);
       stencilRb->pfMap = NULL;
       stencilRb->pfPitch = 0;
    }
index a2a5c811b1392c3bb94a83c5211d22981f75c3ee..bac2ef8467bfee9e5dcbb0bed84480ae6bcee8f3 100644 (file)
@@ -40,9 +40,9 @@
 #include "intel_depthstencil.h"
 #include "intel_fbo.h"
 #include "intel_mipmap_tree.h"
-#include "intel_regions.h"
 #include "intel_span.h"
 
+#include "pipe/p_context.h"
 
 #define FILE_DEBUG_FLAG DEBUG_FBO
 
@@ -111,7 +111,7 @@ intel_flip_renderbuffers(struct intel_framebuffer *intel_fb)
 }
 
 
-struct intel_region *
+struct pipe_region *
 intel_get_rb_region(struct gl_framebuffer *fb, GLuint attIndex)
 {
    struct intel_renderbuffer *irb = intel_get_renderbuffer(fb, attIndex);
@@ -153,7 +153,7 @@ intel_delete_renderbuffer(struct gl_renderbuffer *rb)
    }
 
    if (intel && irb->region) {
-      intel_region_release(&irb->region);
+      intel->pipe->region_release(intel->pipe, &irb->region);
    }
 
    _mesa_free(irb);
@@ -265,7 +265,7 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
 
    /* free old region */
    if (irb->region) {
-      intel_region_release(&irb->region);
+      intel->pipe->region_release(intel->pipe, &irb->region);
    }
 
    /* allocate new memory region/renderbuffer */
@@ -282,7 +282,7 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
       DBG("Allocating %d x %d Intel RBO (pitch %d)\n", width,
          height, pitch);
 
-      irb->region = intel_region_alloc(intel->intelScreen, cpp, pitch, height);
+      irb->region = intel->pipe->region_alloc(intel->pipe, cpp, pitch, height);
       if (!irb->region)
          return GL_FALSE;       /* out of memory? */
 
@@ -382,7 +382,7 @@ intel_new_renderbuffer_fb(GLuint intFormat)
    irb->Base.surface = intel_new_surface(intFormat);
    irb->Base.surface->rb = irb;
 
-   return &irb->Base;
+   return irb;
 }
 
 /**
@@ -509,6 +509,7 @@ intel_wrap_texture(GLcontext * ctx, struct gl_texture_image *texImage)
 
    irb->Base.Delete = intel_delete_renderbuffer;
    irb->Base.AllocStorage = intel_nop_alloc_storage;
+
    intel_set_span_functions(&irb->Base);
 
    irb->RenderToTexture = GL_TRUE;
@@ -528,6 +529,7 @@ intel_render_texture(GLcontext * ctx,
                      struct gl_framebuffer *fb,
                      struct gl_renderbuffer_attachment *att)
 {
+   struct intel_context *intel = intel_context(ctx);
    struct gl_texture_image *newImage
       = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
    struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer);
@@ -560,8 +562,8 @@ intel_render_texture(GLcontext * ctx,
    intel_image = intel_texture_image(newImage);
    if (irb->region != intel_image->mt->region) {
       if (irb->region)
-        intel_region_release(&irb->region);
-      intel_region_reference(&irb->region, intel_image->mt->region);
+        intel->pipe->region_release(intel->pipe, &irb->region);
+      pipe_region_reference(&irb->region, intel_image->mt->region);
    }
 
    /* compute offset of the particular 2D image within the texture region */
@@ -590,13 +592,14 @@ static void
 intel_finish_render_texture(GLcontext * ctx,
                             struct gl_renderbuffer_attachment *att)
 {
+   struct intel_context *intel = intel_context(ctx);
    struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer);
 
    DBG("End render texture (tid %x) tex %u\n", _glthread_GetID(), att->Texture->Name);
 
    if (irb) {
       /* just release the region */
-      intel_region_release(&irb->region);
+      intel->pipe->region_release(intel->pipe, &irb->region);
    }
    else if (att->Renderbuffer) {
       /* software fallback */
index 7dc39675337701701ca490227bf8bbaf9f99fe21..0f99a3e98db39f3c5a923770346934dccc4047ce 100644 (file)
@@ -34,7 +34,7 @@
 
 
 struct intel_context;
-struct intel_region;
+struct pipe_region;
 
 
 /**
@@ -76,7 +76,7 @@ struct intel_framebuffer
 struct intel_renderbuffer
 {
    struct gl_renderbuffer Base;
-   struct intel_region *region;
+   struct pipe_region *region;
    void *pfMap;                 /* possibly paged flipped map pointer */
    GLuint pfPitch;              /* possibly paged flipped pitch */
    GLboolean RenderToTexture;   /* RTT? */
@@ -115,7 +115,7 @@ extern void intel_flip_renderbuffers(struct intel_framebuffer *intel_fb);
 
 
 /* XXX make inline or macro */
-extern struct intel_region *intel_get_rb_region(struct gl_framebuffer *fb,
+extern struct pipe_region *intel_get_rb_region(struct gl_framebuffer *fb,
                                                 GLuint attIndex);
 
 
index e349a3ecd9c2d9faaeb46c2acaa8b7f17afe887e..fb5b518903d6120a34c63b2c84590c593a3d7992 100644 (file)
@@ -39,7 +39,6 @@
 #include "intel_ioctl.h"
 #include "intel_batchbuffer.h"
 #include "intel_blit.h"
-#include "intel_regions.h"
 #include "drm.h"
 
 #define FILE_DEBUG_FLAG DEBUG_IOCTL
index 88a92774276da6f42cb805ac866b3cec87bdd2c6..6717984f7d6ca776e04b4f3dcf539e061d3fb998 100644 (file)
 
 #include "intel_context.h"
 #include "intel_mipmap_tree.h"
-#include "intel_regions.h"
 #include "enums.h"
 
+#include "pipe/p_state.h"
+#include "pipe/p_context.h"
+
+
 #define FILE_DEBUG_FLAG DEBUG_MIPTREE
 
 static GLenum
@@ -100,7 +103,7 @@ intel_miptree_create(struct intel_context *intel,
    ok = 0;                     /* TODO */
 
    if (ok)
-      mt->region = intel_region_alloc(intel->intelScreen,
+      mt->region = intel->pipe->region_alloc(intel->pipe,
                                       mt->cpp, mt->pitch, mt->total_height);
 
    if (!mt->region) {
@@ -134,7 +137,7 @@ intel_miptree_release(struct intel_context *intel,
 
       DBG("%s deleting %p\n", __FUNCTION__, *mt);
 
-      intel_region_release(&((*mt)->region));
+      intel->pipe->region_release(intel->pipe, &((*mt)->region));
 
       for (i = 0; i < MAX_TEXTURE_LEVELS; i++)
          if ((*mt)->level[i].image_offset)
@@ -271,6 +274,7 @@ intel_miptree_image_map(struct intel_context * intel,
                         GLuint level,
                         GLuint * row_stride, GLuint * image_offsets)
 {
+   GLubyte *ptr;
    DBG("%s \n", __FUNCTION__);
 
    if (row_stride)
@@ -280,8 +284,9 @@ intel_miptree_image_map(struct intel_context * intel,
       memcpy(image_offsets, mt->level[level].image_offset,
              mt->level[level].depth * sizeof(GLuint));
 
-   return (intel_region_map(intel->intelScreen, mt->region) +
-           intel_miptree_image_offset(mt, face, level));
+   ptr = intel->pipe->region_map(intel->pipe, mt->region);
+
+   return ptr + intel_miptree_image_offset(mt, face, level);
 }
 
 void
@@ -289,7 +294,7 @@ intel_miptree_image_unmap(struct intel_context *intel,
                           struct intel_mipmap_tree *mt)
 {
    DBG("%s\n", __FUNCTION__);
-   intel_region_unmap(intel->intelScreen, mt->region);
+   intel->pipe->region_unmap(intel->pipe, mt->region);
 }
 
 
@@ -315,7 +320,7 @@ intel_miptree_image_data(struct intel_context *intel,
       height = dst->level[level].height;
       if(dst->compressed)
         height /= 4;
-      intel_region_data(intel->intelScreen, dst->region,
+      intel->pipe->region_data(intel->pipe, dst->region,
                         dst_offset + dst_depth_offset[i], /* dst_offset */
                         0, 0,                             /* dstx, dsty */
                         src,
@@ -347,7 +352,7 @@ intel_miptree_image_copy(struct intel_context *intel,
    if (dst->compressed)
       height /= 4;
    for (i = 0; i < depth; i++) {
-      intel_region_copy(intel->intelScreen,
+      intel->pipe->region_copy(intel->pipe,
                         dst->region, dst_offset + dst_depth_offset[i],
                         0,
                         0,
index ecdb7be244f3b779987527819b9dc4218c385596..09b2e362fcf099b9886db061b08279a0cc182aa0 100644 (file)
 #ifndef INTEL_MIPMAP_TREE_H
 #define INTEL_MIPMAP_TREE_H
 
-#include "intel_regions.h"
+#include "intel_context.h"
+#include "main/glheader.h"
 
-/* A layer on top of the intel_regions code which adds:
+struct pipe_region;
+
+
+/* A layer on top of the pipe_regions code which adds:
  *
  * - Code to size and layout a region to hold a set of mipmaps.
  * - Query to determine if a new image fits in an existing tree.
  * - More refcounting 
- *     - maybe able to remove refcounting from intel_region?
+ *     - maybe able to remove refcounting from pipe_region?
  * - ?
  *
  * The fixed mipmap layout of intel hardware where one offset
@@ -45,7 +49,7 @@
  * independent offset.
  *
  * In an ideal world, each texture object would be associated with a
- * single bufmgr buffer or 2d intel_region, and all the images within
+ * single bufmgr buffer or 2d pipe_region, and all the images within
  * the texture object would slot into the tree as they arrive.  The
  * reality can be a little messier, as images can arrive from the user
  * with sizes that don't fit in the existing tree, or in an order
@@ -103,7 +107,7 @@ struct intel_mipmap_tree
 
    /* The data is held here:
     */
-   struct intel_region *region;
+   struct pipe_region *region;
 
    /* These are also refcounted:
     */
index 104d288de0438293b86fcc56eddedee6d59de2db..74d4ce7f2ae9aafd4d41bb18565b9b9980218cb6 100644 (file)
  * 
  **************************************************************************/
 
-#include "enums.h"
 #include "state.h"
 #include "swrast/swrast.h"
 
 #include "intel_context.h"
 #include "intel_pixel.h"
-#include "intel_regions.h"
 
 
 void
index a6fcf90ce03bf17550fdfb57774cddab70437bdc..73a06c11ec0c049650ef74624cbb24dc7f4c4a39 100644 (file)
@@ -36,7 +36,7 @@ GLboolean intel_check_blit_fragment_ops(GLcontext * ctx);
 
 GLboolean intel_check_meta_tex_fragment_ops(GLcontext * ctx);
 
-GLboolean intel_check_blit_format(struct intel_region *region,
+GLboolean intel_check_blit_format(struct pipe_region *region,
                                   GLenum format, GLenum type);
 
 
index 7d19bd07d367a6fc21cdf40ca5881cc6f8c54178..e95e745adc23109fb0c14faa244261729779756e 100644 (file)
  * last moment.
  */
 
+#include "pipe/p_state.h"
+#include "pipe/p_context.h"
+
 #include "intel_context.h"
-#include "intel_regions.h"
 #include "intel_blit.h"
 #include "intel_buffer_objects.h"
 #include "dri_bufmgr.h"
 #include "intel_batchbuffer.h"
 
+
 #define FILE_DEBUG_FLAG DEBUG_REGION
 
-void
-intel_region_idle(intelScreenPrivate *intelScreen, struct intel_region *region)
+
+/** XXX temporary helper */
+static intelScreenPrivate *
+pipe_screen(struct pipe_context *pipe)
+{
+   return (intelScreenPrivate *) pipe->screen;
+}
+
+
+static void
+intel_region_idle(struct pipe_context *pipe, struct pipe_region *region)
 {
    DBG("%s\n", __FUNCTION__);
    if (region && region->buffer)
@@ -58,13 +70,14 @@ intel_region_idle(intelScreenPrivate *intelScreen, struct intel_region *region)
 
 /* XXX: Thread safety?
  */
-GLubyte *
-intel_region_map(intelScreenPrivate *intelScreen, struct intel_region *region)
+static GLubyte *
+intel_region_map(struct pipe_context *pipe, struct pipe_region *region)
 {
    DBG("%s\n", __FUNCTION__);
    if (!region->map_refcount++) {
-      if (region->pbo)
-         intel_region_cow(intelScreen, region);
+      if (region->pbo) {
+         pipe->region_cow(pipe, region);
+      }
 
       region->map = driBOMap(region->buffer,
                              DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0);
@@ -73,8 +86,8 @@ intel_region_map(intelScreenPrivate *intelScreen, struct intel_region *region)
    return region->map;
 }
 
-void
-intel_region_unmap(intelScreenPrivate *intelScreen, struct intel_region *region)
+static void
+intel_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
 {
    DBG("%s\n", __FUNCTION__);
    if (!--region->map_refcount) {
@@ -85,11 +98,12 @@ intel_region_unmap(intelScreenPrivate *intelScreen, struct intel_region *region)
 
 #undef TEST_CACHED_TEXTURES
 
-struct intel_region *
-intel_region_alloc(intelScreenPrivate *intelScreen,
+static struct pipe_region *
+intel_region_alloc(struct pipe_context *pipe,
                    GLuint cpp, GLuint pitch, GLuint height)
 {
-   struct intel_region *region = calloc(sizeof(*region), 1);
+   intelScreenPrivate *intelScreen = pipe_screen(pipe);
+   struct pipe_region *region = calloc(sizeof(*region), 1);
    struct intel_context *intel = intelScreenContext(intelScreen);
 
    DBG("%s\n", __FUNCTION__);
@@ -114,18 +128,8 @@ intel_region_alloc(intelScreenPrivate *intelScreen,
    return region;
 }
 
-void
-intel_region_reference(struct intel_region **dst, struct intel_region *src)
-{
-   assert(*dst == NULL);
-   if (src) {
-      src->refcount++;
-      *dst = src;
-   }
-}
-
-void
-intel_region_release(struct intel_region **region)
+static void
+intel_region_release(struct pipe_context *pipe, struct pipe_region **region)
 {
    if (!*region)
       return;
@@ -148,14 +152,15 @@ intel_region_release(struct intel_region **region)
 }
 
 
-struct intel_region *
-intel_region_create_static(intelScreenPrivate *intelScreen,
+static struct pipe_region *
+intel_region_create_static(struct pipe_context *pipe,
                            GLuint mem_type,
                            GLuint offset,
                            void *virtual,
                            GLuint cpp, GLuint pitch, GLuint height)
 {
-   struct intel_region *region = calloc(sizeof(*region), 1);
+   intelScreenPrivate *intelScreen = pipe_screen(pipe);
+   struct pipe_region *region = calloc(sizeof(*region), 1);
    DBG("%s\n", __FUNCTION__);
 
    region->cpp = cpp;
@@ -179,14 +184,16 @@ intel_region_create_static(intelScreenPrivate *intelScreen,
 
 
 
-void
-intel_region_update_static(intelScreenPrivate *intelScreen,
-                          struct intel_region *region,
+static void
+intel_region_update_static(struct pipe_context *pipe,
+                          struct pipe_region *region,
                            GLuint mem_type,
                            GLuint offset,
                            void *virtual,
                            GLuint cpp, GLuint pitch, GLuint height)
 {
+   intelScreenPrivate *intelScreen = pipe_screen(pipe);
+
    DBG("%s\n", __FUNCTION__);
 
    region->cpp = cpp;
@@ -252,14 +259,15 @@ _mesa_copy_rect(GLubyte * dst,
  *
  * Currently always memcpy.
  */
-void
-intel_region_data(intelScreenPrivate *intelScreen,
-                  struct intel_region *dst,
+static void
+intel_region_data(struct pipe_context *pipe,
+                  struct pipe_region *dst,
                   GLuint dst_offset,
                   GLuint dstx, GLuint dsty,
                   const void *src, GLuint src_pitch,
                   GLuint srcx, GLuint srcy, GLuint width, GLuint height)
 {
+   intelScreenPrivate *intelScreen = pipe_screen(pipe);
    struct intel_context *intel = intelScreenContext(intelScreen);
 
    DBG("%s\n", __FUNCTION__);
@@ -270,20 +278,20 @@ intel_region_data(intelScreenPrivate *intelScreen,
    if (dst->pbo) {
       if (dstx == 0 &&
           dsty == 0 && width == dst->pitch && height == dst->height)
-         intel_region_release_pbo(intelScreen, dst);
+         pipe->region_release_pbo(pipe, dst);
       else
-         intel_region_cow(intelScreen, dst);
+         pipe->region_cow(pipe, dst);
    }
 
 
    LOCK_HARDWARE(intel);
 
-   _mesa_copy_rect(intel_region_map(intelScreen, dst) + dst_offset,
+   _mesa_copy_rect(pipe->region_map(pipe, dst) + dst_offset,
                    dst->cpp,
                    dst->pitch,
                    dstx, dsty, width, height, src, src_pitch, srcx, srcy);
 
-   intel_region_unmap(intelScreen, dst);
+   pipe->region_unmap(pipe, dst);
 
    UNLOCK_HARDWARE(intel);
 
@@ -292,15 +300,16 @@ intel_region_data(intelScreenPrivate *intelScreen,
 /* Copy rectangular sub-regions. Need better logic about when to
  * push buffers into AGP - will currently do so whenever possible.
  */
-void
-intel_region_copy(intelScreenPrivate *intelScreen,
-                  struct intel_region *dst,
+static void
+intel_region_copy(struct pipe_context *pipe,
+                  struct pipe_region *dst,
                   GLuint dst_offset,
                   GLuint dstx, GLuint dsty,
-                  struct intel_region *src,
+                  const struct pipe_region *src,
                   GLuint src_offset,
                   GLuint srcx, GLuint srcy, GLuint width, GLuint height)
 {
+   intelScreenPrivate *intelScreen = pipe_screen(pipe);
    struct intel_context *intel = intelScreenContext(intelScreen);
 
    DBG("%s\n", __FUNCTION__);
@@ -311,9 +320,9 @@ intel_region_copy(intelScreenPrivate *intelScreen,
    if (dst->pbo) {
       if (dstx == 0 &&
           dsty == 0 && width == dst->pitch && height == dst->height)
-         intel_region_release_pbo(intelScreen, dst);
+         pipe->region_release_pbo(pipe, dst);
       else
-         intel_region_cow(intelScreen, dst);
+         pipe->region_cow(pipe, dst);
    }
 
    assert(src->cpp == dst->cpp);
@@ -329,13 +338,14 @@ intel_region_copy(intelScreenPrivate *intelScreen,
 /* Fill a rectangular sub-region.  Need better logic about when to
  * push buffers into AGP - will currently do so whenever possible.
  */
-void
-intel_region_fill(intelScreenPrivate *intelScreen,
-                  struct intel_region *dst,
+static void
+intel_region_fill(struct pipe_context *pipe,
+                  struct pipe_region *dst,
                   GLuint dst_offset,
                   GLuint dstx, GLuint dsty,
                   GLuint width, GLuint height, GLuint color)
 {
+   intelScreenPrivate *intelScreen = pipe_screen(pipe);
    struct intel_context *intel = intelScreenContext(intelScreen);
 
    DBG("%s\n", __FUNCTION__);
@@ -346,9 +356,9 @@ intel_region_fill(intelScreenPrivate *intelScreen,
    if (dst->pbo) {
       if (dstx == 0 &&
           dsty == 0 && width == dst->pitch && height == dst->height)
-         intel_region_release_pbo(intelScreen, dst);
+         pipe->region_release_pbo(pipe, dst);
       else
-         intel_region_cow(intelScreen, dst);
+         pipe->region_cow(pipe, dst);
    }
 
    intelEmitFillBlit(intel,
@@ -360,16 +370,16 @@ intel_region_fill(intelScreenPrivate *intelScreen,
 /* Attach to a pbo, discarding our data.  Effectively zero-copy upload
  * the pbo's data.
  */
-void
-intel_region_attach_pbo(intelScreenPrivate *intelScreen,
-                        struct intel_region *region,
+static void
+intel_region_attach_pbo(struct pipe_context *pipe,
+                        struct pipe_region *region,
                         struct intel_buffer_object *pbo)
 {
    if (region->pbo == pbo)
       return;
 
    /* If there is already a pbo attached, break the cow tie now.
-    * Don't call intel_region_release_pbo() as that would
+    * Don't call pipe_region_release_pbo() as that would
     * unnecessarily allocate a new buffer we would have to immediately
     * discard.
     */
@@ -391,10 +401,11 @@ intel_region_attach_pbo(intelScreenPrivate *intelScreen,
 
 /* Break the COW tie to the pbo.  The pbo gets to keep the data.
  */
-void
-intel_region_release_pbo(intelScreenPrivate *intelScreen,
-                         struct intel_region *region)
+static void
+intel_region_release_pbo(struct pipe_context *pipe,
+                         struct pipe_region *region)
 {
+   intelScreenPrivate *intelScreen = pipe_screen(pipe);
    struct intel_context *intel = intelScreenContext(intelScreen);
 
    assert(region->buffer == region->pbo->buffer);
@@ -415,16 +426,17 @@ intel_region_release_pbo(intelScreenPrivate *intelScreen,
 /* Break the COW tie to the pbo.  Both the pbo and the region end up
  * with a copy of the data.
  */
-void
-intel_region_cow(intelScreenPrivate *intelScreen, struct intel_region *region)
+static void
+intel_region_cow(struct pipe_context *pipe, struct pipe_region *region)
 {
+   intelScreenPrivate *intelScreen = pipe_screen(pipe);
    struct intel_context *intel = intelScreenContext(intelScreen);
    struct intel_buffer_object *pbo = region->pbo;
 
    if (intel == NULL)
       return;
 
-   intel_region_release_pbo(intelScreen, region);
+   pipe->region_release_pbo(pipe, region);
 
    assert(region->cpp * region->pitch * region->height == pbo->Base.Size);
 
@@ -465,16 +477,38 @@ intel_region_cow(intelScreenPrivate *intelScreen, struct intel_region *region)
    }
 }
 
-struct _DriBufferObject *
-intel_region_buffer(intelScreenPrivate *intelScreen,
-                    struct intel_region *region, GLuint flag)
+static struct _DriBufferObject *
+intel_region_buffer(struct pipe_context *pipe,
+                    struct pipe_region *region, GLuint flag)
 {
    if (region->pbo) {
       if (flag == INTEL_WRITE_PART)
-         intel_region_cow(intelScreen, region);
+         pipe->region_cow(pipe, region);
       else if (flag == INTEL_WRITE_FULL)
-         intel_region_release_pbo(intelScreen, region);
+         pipe->region_release_pbo(pipe, region);
    }
 
    return region->buffer;
 }
+
+
+
+void
+intel_init_region_functions(struct pipe_context *pipe)
+{
+   pipe->region_idle = intel_region_idle;
+   pipe->region_map = intel_region_map;
+   pipe->region_unmap = intel_region_unmap;
+   pipe->region_alloc = intel_region_alloc;
+   pipe->region_release = intel_region_release;
+   pipe->region_create_static = intel_region_create_static;
+   pipe->region_update_static = intel_region_update_static;
+   pipe->region_data = intel_region_data;
+   pipe->region_copy = intel_region_copy;
+   pipe->region_fill = intel_region_fill;
+   pipe->region_cow = intel_region_cow;
+   pipe->region_attach_pbo = intel_region_attach_pbo;
+   pipe->region_release_pbo = intel_region_release_pbo;
+   pipe->region_buffer = intel_region_buffer;
+}
+
index d938c107a46dc11c18c293007db1fffc8faaa967..2a3b5b4025c3a2d5ec19dcb7580955892246ecb5 100644 (file)
 #include "mtypes.h"
 #include "intel_screen.h"
 
-struct intel_context;
-struct intel_buffer_object;
 
-/**
- * A layer on top of the bufmgr buffers that adds a few useful things:
- *
- * - Refcounting for local buffer references.
- * - Refcounting for buffer maps
- * - Buffer dimensions - pitch and height.
- * - Blitter commands for copying 2D regions between buffers. (really???)
- */
-struct intel_region
-{
-   struct _DriBufferObject *buffer;   /**< buffer manager's buffer ID */
-   GLuint refcount; /**< Reference count for region */
-   GLuint cpp;      /**< bytes per pixel */
-   GLuint pitch;    /**< in pixels */
-   GLuint height;   /**< in pixels */
-   GLubyte *map;    /**< only non-NULL when region is actually mapped */
-   GLuint map_refcount;  /**< Reference count for mapping */
-
-   GLuint draw_offset; /**< Offset of drawing address within the region */
-
-   struct intel_buffer_object *pbo;     /* zero-copy uploads */
-};
-
-
-/* Allocate a refcounted region.  Pointers to regions should only be
- * copied by calling intel_reference_region().
- */
-struct intel_region *intel_region_alloc(intelScreenPrivate *intelScreen,
-                                        GLuint cpp,
-                                        GLuint pitch, GLuint height);
-
-void intel_region_reference(struct intel_region **dst,
-                            struct intel_region *src);
-
-void intel_region_release(struct intel_region **ib);
-
-extern struct intel_region 
-*intel_region_create_static(intelScreenPrivate *intelScreen,
-                           GLuint mem_type,
-                           GLuint offset,
-                           void *virtual,
-                           GLuint cpp,
-                           GLuint pitch, GLuint height);
-extern void 
-intel_region_update_static(intelScreenPrivate *intelScreen,
-                          struct intel_region *region,
-                          GLuint mem_type,
-                          GLuint offset,
-                          void *virtual,
-                          GLuint cpp, GLuint pitch, GLuint height);
-
-
-void intel_region_idle(intelScreenPrivate *intelScreen,
-                      struct intel_region *ib);
-
-/* Map/unmap regions.  This is refcounted also: 
- */
-GLubyte *intel_region_map(intelScreenPrivate *intelScreen,
-                          struct intel_region *ib);
-
-void intel_region_unmap(intelScreenPrivate *intelScreen, struct intel_region *ib);
-
-
-/* Upload data to a rectangular sub-region
- */
-void intel_region_data(intelScreenPrivate *intelScreen,
-                       struct intel_region *dest,
-                       GLuint dest_offset,
-                       GLuint destx, GLuint desty,
-                       const void *src, GLuint src_stride,
-                       GLuint srcx, GLuint srcy, GLuint width, GLuint height);
-
-/* Copy rectangular sub-regions
- */
-void intel_region_copy(intelScreenPrivate *intelScreen,
-                       struct intel_region *dest,
-                       GLuint dest_offset,
-                       GLuint destx, GLuint desty,
-                       struct intel_region *src,
-                       GLuint src_offset,
-                       GLuint srcx, GLuint srcy, GLuint width, GLuint height);
-
-/* Fill a rectangular sub-region
- */
-void intel_region_fill(intelScreenPrivate *intelScreen,
-                       struct intel_region *dest,
-                       GLuint dest_offset,
-                       GLuint destx, GLuint desty,
-                       GLuint width, GLuint height, GLuint color);
-
-/* Helpers for zerocopy uploads, particularly texture image uploads:
- */
-void intel_region_attach_pbo(intelScreenPrivate *intelScreen,
-                             struct intel_region *region,
-                             struct intel_buffer_object *pbo);
-void intel_region_release_pbo(intelScreenPrivate *intelScreen,
-                              struct intel_region *region);
-void intel_region_cow(intelScreenPrivate *intelScreen,
-                      struct intel_region *region);
-
-struct _DriBufferObject *intel_region_buffer(intelScreenPrivate *intelScreen,
-                                             struct intel_region *region,
-                                             GLuint flag);
 
 #endif
index c7c5ed8bbd8aa82142b5842f9d0bbd1ae2f7144f..4f3a20a819fe27328ae39bc5120fc13c6305b5d8 100644 (file)
@@ -35,9 +35,8 @@
 #include "vblank.h"
 #include "xmlpool.h"
 
-
 #include "intel_screen.h"
-
+#include "intel_batchbuffer.h"
 #include "intel_buffers.h"
 #include "intel_tex.h"
 #include "intel_span.h"
 
 #include "i830_dri.h"
 #include "dri_bufpool.h"
-#include "intel_regions.h"
-#include "intel_batchbuffer.h"
+
+#include "pipe/p_context.h"
+
+
 
 PUBLIC const char __driConfigOptions[] =
    DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE
@@ -93,26 +94,27 @@ intelMapScreenRegions(__DRIscreenPrivate * sPriv)
 }
 
 
-static struct intel_region *
-intel_recreate_static(intelScreenPrivate *intelScreen,
-                     struct intel_region *region,
+static struct pipe_region *
+intel_recreate_static(struct pipe_context *pipe,
+                     struct pipe_region *region,
                      GLuint mem_type,
                      GLuint offset,
                      void *virtual,
                      GLuint cpp, GLuint pitch, GLuint height)
 {
+   struct intel_context *intel = 0;
   if (region) {
-    intel_region_update_static(intelScreen, region, mem_type, offset,
-                              virtual, cpp, pitch, height);
+     pipe->region_update_static(pipe, region, mem_type, offset,
+                                virtual, cpp, pitch, height);
   } else {
-    region = intel_region_create_static(intelScreen, mem_type, offset,
-                                       virtual, cpp, pitch, height);
+     region = pipe->region_create_static(pipe, mem_type, offset,
+                                         virtual, cpp, pitch, height);
   }
   return region;
 }
 
 
-/* Create intel_region structs to describe the static front,back,depth
+/* Create pipe_region structs to describe the static front,back,depth
  * buffers created by the xserver.
  * Only used for real front buffer now.
  *
@@ -124,7 +126,7 @@ intel_recreate_static_regions(intelScreenPrivate *intelScreen)
 {
 /* this is the real front buffer which is only used for blitting to */
    intelScreen->front_region =
-      intel_recreate_static(intelScreen,
+      intel_recreate_static(intelScreen->pipe,
                            intelScreen->front_region,
                            DRM_BO_FLAG_MEM_TT,
                            intelScreen->front.offset,
index eb4685d6e9e38e4bb8f06204480d3d9ed945f620..d5866ac0ec8dfea8198933d1ed0b5760766cbcc0 100644 (file)
  * 
  **************************************************************************/
 
-#ifndef _INTEL_INIT_H_
-#define _INTEL_INIT_H_
+#ifndef _INTEL_SCREEN_H_
+#define _INTEL_SCREEN_H_
 
-#include <sys/time.h>
 #include "dri_util.h"
 #include "intel_rotate.h"
 #include "i830_common.h"
 #include "xmlconfig.h"
 #include "dri_bufpool.h"
 
-/* XXX: change name or eliminate to avoid conflict with "struct
- * intel_region"!!!
- */
 typedef struct
 {
    drm_handle_t handle;
@@ -49,9 +45,10 @@ typedef struct
 
 typedef struct
 {
+   struct pipe_context *pipe;   /** for accessing region functions */
    intelRegion front;
 
-   struct intel_region *front_region;
+   struct pipe_region *front_region;
 
    int deviceID;
    int width;
index 5a978d9ce265bced2b7737e2ebaa1652996cd7c2..c635ebe0af46328acd33f14a7d78b7ab26d1be1d 100644 (file)
 #include "intel_fbo.h"
 #include "intel_screen.h"
 #include "intel_span.h"
-#include "intel_regions.h"
 #include "intel_ioctl.h"
 #include "intel_tex.h"
 
 #include "swrast/swrast.h"
 
+#include "pipe/p_context.h"
+
 /*
   break intelWriteRGBASpan_ARGB8888
 */
@@ -187,9 +188,9 @@ intel_map_unmap_buffers(struct intel_context *intel, GLboolean map)
             /* this is a user-created intel_renderbuffer */
             if (irb->region) {
                if (map)
-                  intel_region_map(intel->intelScreen, irb->region);
+                  intel->pipe->region_map(intel->pipe, irb->region);
                else
-                  intel_region_unmap(intel->intelScreen, irb->region);
+                  intel->pipe->region_unmap(intel->pipe, irb->region);
             }
             irb->pfMap = irb->region->map;
             irb->pfPitch = irb->region->pitch;
@@ -220,9 +221,9 @@ intel_map_unmap_buffers(struct intel_context *intel, GLboolean map)
    irb = intel_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
    if (irb && irb->region) {
       if (map)
-         intel_region_map(intel->intelScreen, irb->region);
+         intel->pipe->region_map(intel->pipe, irb->region);
       else
-         intel_region_unmap(intel->intelScreen, irb->region);
+         intel->pipe->region_unmap(intel->pipe, irb->region);
       irb->pfMap = irb->region->map;
       irb->pfPitch = irb->region->pitch;
    }
@@ -261,12 +262,12 @@ intel_map_unmap_buffers(struct intel_context *intel, GLboolean map)
       irb = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped);
       if (irb && irb->region) {
          if (map) {
-            intel_region_map(intel->intelScreen, irb->region);
+            intel->pipe->region_map(intel->pipe, irb->region);
             irb->pfMap = irb->region->map;
             irb->pfPitch = irb->region->pitch;
          }
          else {
-            intel_region_unmap(intel->intelScreen, irb->region);
+            intel->pipe->region_unmap(intel->pipe, irb->region);
             irb->pfMap = NULL;
             irb->pfPitch = 0;
          }
@@ -278,12 +279,12 @@ intel_map_unmap_buffers(struct intel_context *intel, GLboolean map)
       irb = intel_renderbuffer(ctx->DrawBuffer->_StencilBuffer->Wrapped);
       if (irb && irb->region) {
          if (map) {
-            intel_region_map(intel->intelScreen, irb->region);
+            intel->pipe->region_map(intel->pipe, irb->region);
             irb->pfMap = irb->region->map;
             irb->pfPitch = irb->region->pitch;
          }
          else {
-            intel_region_unmap(intel->intelScreen, irb->region);
+            intel->pipe->region_unmap(intel->pipe, irb->region);
             irb->pfMap = NULL;
             irb->pfPitch = 0;
          }
@@ -312,9 +313,9 @@ intelSpanRenderStart(GLcontext * ctx)
    /* Just map the framebuffer and all textures.  Bufmgr code will
     * take care of waiting on the necessary fences:
     */
-   intel_region_map(intel->intelScreen, intel->front_region);
-   intel_region_map(intel->intelScreen, intel->back_region);
-   intel_region_map(intel->intelScreen, intel->intelScreen->depth_region);
+   intel->pipe->region_map(intel->intelScreen, intel->front_region);
+   intel->pipe->region_map(intel->intelScreen, intel->back_region);
+   intel->pipe->region_map(intel->intelScreen, intel->intelScreen->depth_region);
 #endif
 
    for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
@@ -342,9 +343,9 @@ intelSpanRenderFinish(GLcontext * ctx)
    /* Now unmap the framebuffer:
     */
 #if 0
-   intel_region_unmap(intel, intel->front_region);
-   intel_region_unmap(intel, intel->back_region);
-   intel_region_unmap(intel, intel->intelScreen->depth_region);
+   intel->pipe->region_unmap(intel, intel->front_region);
+   intel->pipe->region_unmap(intel, intel->back_region);
+   intel->pipe->region_unmap(intel, intel->intelScreen->depth_region);
 #endif
 
    for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
index 5c5f2c6de5c7e843e524c24cc658415c54c6af5f..fc98b6a12bafa5255c0045ac3caf68a7c10023dc 100644 (file)
@@ -36,7 +36,6 @@
 #include "intel_screen.h"
 #include "intel_context.h"
 #include "intel_fbo.h"
-#include "intel_regions.h"
 #include "swrast/swrast.h"
 
 int
index e64e5f8a32643682e3d8bb61e0be2dcb5ad146ac..58f5cb5f96e598831e86400c1a696df6afd88fe5 100644 (file)
 
 #include "intel_context.h"
 #include "intel_buffers.h"
-#include "intel_regions.h"
 #include "intel_span.h"
 #include "intel_fbo.h"
 
 #include "pipe/p_state.h"
+#include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/softpipe/sp_surface.h"
 
@@ -173,7 +173,7 @@ map_surface_buffer(struct pipe_buffer *pb, GLuint access_mode)
 #if 0
       intelFinish(&intel->ctx);  /* XXX need this? */
 #endif
-      intel_region_map(intel->intelScreen, irb->region);
+      intel->pipe->region_map(intel->pipe, irb->region);
    }
    pb->ptr = irb->region->map;
 
@@ -194,7 +194,7 @@ unmap_surface_buffer(struct pipe_buffer *pb)
    if (irb->region) {
       GET_CURRENT_CONTEXT(ctx);
       struct intel_context *intel = intel_context(ctx);
-      intel_region_unmap(intel->intelScreen, irb->region);
+      intel->pipe->region_unmap(intel->pipe, irb->region);
    }
    pb->ptr = NULL;
 
index 8d7f8f9d91b1b01ca3eca72cc4faadc09b617787..6deb6abd4d9529e1c6feee377b541079480da6b4 100644 (file)
@@ -36,7 +36,6 @@
 #include "intel_batchbuffer.h"
 #include "intel_buffers.h"
 #include "intel_mipmap_tree.h"
-#include "intel_regions.h"
 #include "intel_fbo.h"
 #include "intel_tex.h"
 #include "intel_blit.h"
 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
 
 /**
- * Get the intel_region which is the source for any glCopyTex[Sub]Image call.
+ * Get the pipe_region which is the source for any glCopyTex[Sub]Image call.
  *
  * Do the best we can using the blitter.  A future project is to use
  * the texture engine and fragment programs for these copies.
  */
-static const struct intel_region *
+static const struct pipe_region *
 get_teximage_source(struct intel_context *intel, GLenum internalFormat)
 {
    struct intel_renderbuffer *irb;
@@ -92,7 +91,7 @@ do_copy_texsubimage(struct intel_context *intel,
                     GLint x, GLint y, GLsizei width, GLsizei height)
 {
    GLcontext *ctx = &intel->ctx;
-   const struct intel_region *src =
+   const struct pipe_region *src =
       get_teximage_source(intel, internalFormat);
 
    if (!intelImage->mt || !src) {
index f790b1e6f731c2fe53ba22997c973967fc6a9685..37307b49c5ea1f542a5b2dabc65c70ec1e89558d 100644 (file)
@@ -23,6 +23,8 @@
 #include "intel_ioctl.h"
 #include "intel_blit.h"
 
+#include "pipe/p_context.h"
+
 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
 
 /* Functions to store texture images.  Where possible, mipmap_tree's
@@ -224,8 +226,8 @@ try_pbo_upload(struct intel_context *intel,
       struct _DriBufferObject *src_buffer =
          intel_bufferobj_buffer(intel, pbo, INTEL_READ);
       struct _DriBufferObject *dst_buffer =
-         intel_region_buffer(intel->intelScreen, intelImage->mt->region,
-                             INTEL_WRITE_FULL);
+         intel->pipe->region_buffer(intel->pipe, intelImage->mt->region,
+                                    INTEL_WRITE_FULL);
 
 
       intelEmitCopyBlit(intel,
@@ -281,7 +283,7 @@ try_pbo_zcopy(struct intel_context *intel,
       return GL_FALSE;
    }
 
-   intel_region_attach_pbo(intel->intelScreen, intelImage->mt->region, pbo);
+   intel->pipe->region_attach_pbo(intel->pipe, intelImage->mt->region, pbo);
 
    return GL_TRUE;
 }
@@ -411,7 +413,7 @@ intelTexImage(GLcontext * ctx,
       /* Attempt to texture directly from PBO data (zero copy upload).
        *
        * Currently disable as it can lead to worse as well as better
-       * performance (in particular when intel_region_cow() is
+       * performance (in particular when pipe_region_cow() is
        * required).
        */
       if (intelObj->mt == intelImage->mt &&
@@ -460,7 +462,7 @@ intelTexImage(GLcontext * ctx,
 
 
    if (intelImage->mt)
-      intel_region_idle(intel->intelScreen, intelImage->mt->region);
+      intel->pipe->region_idle(intel->pipe, intelImage->mt->region);
 
    LOCK_HARDWARE(intel);
 
index 3935787806b75c88f7c151a118045dbd36692913..d660c2dceec8153489516e0fa5a78283be678b50 100644 (file)
@@ -35,6 +35,9 @@
 #include "intel_tex.h"
 #include "intel_mipmap_tree.h"
 
+#include "pipe/p_context.h"
+
+
 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
 
 static void
@@ -65,7 +68,7 @@ intelTexSubimage(GLcontext * ctx,
       return;
 
    if (intelImage->mt)
-      intel_region_idle(intel->intelScreen, intelImage->mt->region);
+      intel->pipe->region_idle(intel->pipe, intelImage->mt->region);
 
    LOCK_HARDWARE(intel);
 
index 05a175c8dc02c98f4385207ba27cf5e8ddc05b68..bfae55a4bab9565d61ca30cce71c79042592c823 100644 (file)
@@ -114,7 +114,86 @@ struct pipe_context {
 
    void (*set_viewport_state)( struct pipe_context *,
                                const struct pipe_viewport_state * );
+
+
+   /*
+    * Memory region functions
+    * Some of these may go away...
+    */
+   struct pipe_region *(*region_alloc)(struct pipe_context *pipe,
+                                       GLuint cpp, GLuint pitch, GLuint height);
+
+   void (*region_release)(struct pipe_context *pipe, struct pipe_region **r);
+
+   struct pipe_region *(*region_create_static)(struct pipe_context *pipe,
+                                               GLuint mem_type,
+                                               GLuint offset,
+                                               void *virtual,
+                                               GLuint cpp, GLuint pitch,
+                                               GLuint height);
+
+   void (*region_update_static)(struct pipe_context *pipe,
+                                struct pipe_region *region,
+                                GLuint mem_type,
+                                GLuint offset,
+                                void *virtual,
+                                GLuint cpp, GLuint pitch, GLuint height);
+
+   void (*region_idle)(struct pipe_context *pipe, struct pipe_region *region);
+
+   GLubyte *(*region_map)(struct pipe_context *pipe, struct pipe_region *r);
+
+   void (*region_unmap)(struct pipe_context *pipe, struct pipe_region *r);
+
+   void (*region_data)(struct pipe_context *pipe,
+                       struct pipe_region *dest,
+                       GLuint dest_offset,
+                       GLuint destx, GLuint desty,
+                       const void *src, GLuint src_stride,
+                       GLuint srcx, GLuint srcy, GLuint width, GLuint height);
+
+   void (*region_copy)(struct pipe_context *pipe,
+                       struct pipe_region *dest,
+                       GLuint dest_offset,
+                       GLuint destx, GLuint desty,
+                       const struct pipe_region *src,
+                       GLuint src_offset,
+                       GLuint srcx, GLuint srcy, GLuint width, GLuint height);
+
+   void (*region_fill)(struct pipe_context *pipe,
+                       struct pipe_region *dst,
+                       GLuint dst_offset,
+                       GLuint dstx, GLuint dsty,
+                       GLuint width, GLuint height, GLuint color);
+
+   void (*region_cow)(struct pipe_context *pipe, struct pipe_region *region);
+
+   void (*region_attach_pbo)(struct pipe_context *pipe,
+                             struct pipe_region *region,
+                             struct intel_buffer_object *pbo);
+
+   void (*region_release_pbo)(struct pipe_context *pipe,
+                              struct pipe_region *region);
+
+   struct _DriBufferObject *(*region_buffer)(struct pipe_context *pipe,
+                                             struct pipe_region *region,
+                                             GLuint flag);
+
+   void *screen;  /**< temporary */
 };
 
 
-#endif
+
+static INLINE void
+pipe_region_reference(struct pipe_region **dst, struct pipe_region *src)
+{
+   assert(*dst == NULL);
+   if (src) {
+      src->refcount++;
+      *dst = src;
+   }
+}
+
+
+
+#endif /* PIPE_CONTEXT_H */
index 9973a7b8dd7d03b2d86a73850da2a4ca98505dc6..d81c3f17782f945db2911cb196c2f6ba8266b7d5 100644 (file)
@@ -272,6 +272,24 @@ struct pipe_surface
 };
 
 
+struct _DriBufferObject;
+struct intel_buffer_object;
+
+struct pipe_region
+{
+   struct _DriBufferObject *buffer;   /**< buffer manager's buffer ID */
+   GLuint refcount; /**< Reference count for region */
+   GLuint cpp;      /**< bytes per pixel */
+   GLuint pitch;    /**< in pixels */
+   GLuint height;   /**< in pixels */
+   GLubyte *map;    /**< only non-NULL when region is actually mapped */
+   GLuint map_refcount;  /**< Reference count for mapping */
+
+   GLuint draw_offset; /**< Offset of drawing address within the region */
+
+   struct intel_buffer_object *pbo;     /* zero-copy uploads */
+};
+
 /**
  * Texture object.
  * Mipmap levels, cube faces, 3D slices can be accessed as surfaces.