summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian <brian@i915.localnet.net>2007-07-31 15:44:50 -0600
committerBrian <brian@i915.localnet.net>2007-07-31 15:44:50 -0600
commit2f245bce420c7a6c6928c4927d0f9a5701cde17f (patch)
tree452d9fc0bf376477f1eb69ee085171f5b6792282 /src
parent33891b64a9a00ddfd7b9c57a2020e83449af62e5 (diff)
Lift region-related functions up to the pipe interface.
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
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_blit.c15
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_buffer_objects.c7
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_buffer_objects.h6
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_buffers.c11
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_buffers.h4
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_context.c37
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_context.h7
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_depthstencil.c10
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_fbo.c21
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_fbo.h6
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_ioctl.c1
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_mipmap_tree.c21
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_mipmap_tree.h14
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_pixel.c2
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_pixel.h2
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_regions.c160
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_regions.h105
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_screen.c28
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_screen.h11
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_span.c31
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_state.c1
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_surface.c6
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_tex_copy.c7
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_tex_image.c12
-rw-r--r--src/mesa/drivers/dri/i915pipe/intel_tex_subimage.c5
-rw-r--r--src/mesa/pipe/p_context.h81
-rw-r--r--src/mesa/pipe/p_state.h18
27 files changed, 342 insertions, 287 deletions
diff --git a/src/mesa/drivers/dri/i915pipe/intel_blit.c b/src/mesa/drivers/dri/i915pipe/intel_blit.c
index 28441f4b83..8e7f294b57 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_blit.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_blit.c
@@ -26,9 +26,6 @@
**************************************************************************/
-#include <stdio.h>
-#include <errno.h>
-
#include "mtypes.h"
#include "context.h"
#include "enums.h"
@@ -39,9 +36,11 @@
#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);
diff --git a/src/mesa/drivers/dri/i915pipe/intel_buffer_objects.c b/src/mesa/drivers/dri/i915pipe/intel_buffer_objects.c
index 91c45ad95b..eee5fa9bf4 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_buffer_objects.c
@@ -32,9 +32,12 @@
#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);
}
diff --git a/src/mesa/drivers/dri/i915pipe/intel_buffer_objects.h b/src/mesa/drivers/dri/i915pipe/intel_buffer_objects.h
index afe9b2f7cf..a1f63c147b 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_buffer_objects.h
+++ b/src/mesa/drivers/dri/i915pipe/intel_buffer_objects.h
@@ -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);
diff --git a/src/mesa/drivers/dri/i915pipe/intel_buffers.c b/src/mesa/drivers/dri/i915pipe/intel_buffers.c
index cc9a4262df..c03c009a3a 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_buffers.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_buffers.c
@@ -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) {
diff --git a/src/mesa/drivers/dri/i915pipe/intel_buffers.h b/src/mesa/drivers/dri/i915pipe/intel_buffers.h
index 13d1a15ffb..5834e39501 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_buffers.h
+++ b/src/mesa/drivers/dri/i915pipe/intel_buffers.h
@@ -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);
diff --git a/src/mesa/drivers/dri/i915pipe/intel_context.c b/src/mesa/drivers/dri/i915pipe/intel_context.c
index 395b0f63be..c8129c9e5f 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_context.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_context.c
@@ -55,12 +55,12 @@
#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;
}
diff --git a/src/mesa/drivers/dri/i915pipe/intel_context.h b/src/mesa/drivers/dri/i915pipe/intel_context.h
index 154be972b9..9d331e41b5 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_context.h
+++ b/src/mesa/drivers/dri/i915pipe/intel_context.h
@@ -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
diff --git a/src/mesa/drivers/dri/i915pipe/intel_depthstencil.c b/src/mesa/drivers/dri/i915pipe/intel_depthstencil.c
index d269a85a3c..81e09698cc 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_depthstencil.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_depthstencil.c
@@ -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;
}
diff --git a/src/mesa/drivers/dri/i915pipe/intel_fbo.c b/src/mesa/drivers/dri/i915pipe/intel_fbo.c
index a2a5c811b1..bac2ef8467 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_fbo.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_fbo.c
@@ -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 */
diff --git a/src/mesa/drivers/dri/i915pipe/intel_fbo.h b/src/mesa/drivers/dri/i915pipe/intel_fbo.h
index 7dc3967533..0f99a3e98d 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_fbo.h
+++ b/src/mesa/drivers/dri/i915pipe/intel_fbo.h
@@ -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);
diff --git a/src/mesa/drivers/dri/i915pipe/intel_ioctl.c b/src/mesa/drivers/dri/i915pipe/intel_ioctl.c
index e349a3ecd9..fb5b518903 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_ioctl.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_ioctl.c
@@ -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
diff --git a/src/mesa/drivers/dri/i915pipe/intel_mipmap_tree.c b/src/mesa/drivers/dri/i915pipe/intel_mipmap_tree.c
index 88a9277427..6717984f7d 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_mipmap_tree.c
@@ -27,9 +27,12 @@
#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,
diff --git a/src/mesa/drivers/dri/i915pipe/intel_mipmap_tree.h b/src/mesa/drivers/dri/i915pipe/intel_mipmap_tree.h
index ecdb7be244..09b2e362fc 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/i915pipe/intel_mipmap_tree.h
@@ -28,14 +28,18 @@
#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:
*/
diff --git a/src/mesa/drivers/dri/i915pipe/intel_pixel.c b/src/mesa/drivers/dri/i915pipe/intel_pixel.c
index 104d288de0..74d4ce7f2a 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_pixel.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_pixel.c
@@ -25,13 +25,11 @@
*
**************************************************************************/
-#include "enums.h"
#include "state.h"
#include "swrast/swrast.h"
#include "intel_context.h"
#include "intel_pixel.h"
-#include "intel_regions.h"
void
diff --git a/src/mesa/drivers/dri/i915pipe/intel_pixel.h b/src/mesa/drivers/dri/i915pipe/intel_pixel.h
index a6fcf90ce0..73a06c11ec 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_pixel.h
+++ b/src/mesa/drivers/dri/i915pipe/intel_pixel.h
@@ -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);
diff --git a/src/mesa/drivers/dri/i915pipe/intel_regions.c b/src/mesa/drivers/dri/i915pipe/intel_regions.c
index 7d19bd07d3..e95e745adc 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_regions.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_regions.c
@@ -39,17 +39,29 @@
* 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;
+}
+
diff --git a/src/mesa/drivers/dri/i915pipe/intel_regions.h b/src/mesa/drivers/dri/i915pipe/intel_regions.h
index d938c107a4..2a3b5b4025 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_regions.h
+++ b/src/mesa/drivers/dri/i915pipe/intel_regions.h
@@ -31,111 +31,6 @@
#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
diff --git a/src/mesa/drivers/dri/i915pipe/intel_screen.c b/src/mesa/drivers/dri/i915pipe/intel_screen.c
index c7c5ed8bbd..4f3a20a819 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_screen.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_screen.c
@@ -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"
@@ -46,8 +45,10 @@
#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,
diff --git a/src/mesa/drivers/dri/i915pipe/intel_screen.h b/src/mesa/drivers/dri/i915pipe/intel_screen.h
index eb4685d6e9..d5866ac0ec 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_screen.h
+++ b/src/mesa/drivers/dri/i915pipe/intel_screen.h
@@ -25,19 +25,15 @@
*
**************************************************************************/
-#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;
diff --git a/src/mesa/drivers/dri/i915pipe/intel_span.c b/src/mesa/drivers/dri/i915pipe/intel_span.c
index 5a978d9ce2..c635ebe0af 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_span.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_span.c
@@ -33,12 +33,13 @@
#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++) {
diff --git a/src/mesa/drivers/dri/i915pipe/intel_state.c b/src/mesa/drivers/dri/i915pipe/intel_state.c
index 5c5f2c6de5..fc98b6a12b 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_state.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_state.c
@@ -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
diff --git a/src/mesa/drivers/dri/i915pipe/intel_surface.c b/src/mesa/drivers/dri/i915pipe/intel_surface.c
index e64e5f8a32..58f5cb5f96 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_surface.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_surface.c
@@ -10,11 +10,11 @@
#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;
diff --git a/src/mesa/drivers/dri/i915pipe/intel_tex_copy.c b/src/mesa/drivers/dri/i915pipe/intel_tex_copy.c
index 8d7f8f9d91..6deb6abd4d 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_tex_copy.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_tex_copy.c
@@ -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"
@@ -45,12 +44,12 @@
#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) {
diff --git a/src/mesa/drivers/dri/i915pipe/intel_tex_image.c b/src/mesa/drivers/dri/i915pipe/intel_tex_image.c
index f790b1e6f7..37307b49c5 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_tex_image.c
@@ -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);
diff --git a/src/mesa/drivers/dri/i915pipe/intel_tex_subimage.c b/src/mesa/drivers/dri/i915pipe/intel_tex_subimage.c
index 3935787806..d660c2dcee 100644
--- a/src/mesa/drivers/dri/i915pipe/intel_tex_subimage.c
+++ b/src/mesa/drivers/dri/i915pipe/intel_tex_subimage.c
@@ -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);
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index 05a175c8dc..bfae55a4ba 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -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 */
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
index 9973a7b8dd..d81c3f1778 100644
--- a/src/mesa/pipe/p_state.h
+++ b/src/mesa/pipe/p_state.h
@@ -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.