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
**************************************************************************/
-#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
/**
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);
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);
#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
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);
}
#include "mtypes.h"
struct intel_context;
-struct intel_region;
+struct pipe_region;
struct gl_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? */
};
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);
#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"
/**
* 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 =
/**
* 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
/* 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 */
if (blit_mask)
intelClearWithBlit(ctx, blit_mask);
+#if 1
if (swrast_mask | tri_mask)
_swrast_Clear(ctx, swrast_mask | tri_mask);
+#endif
}
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) {
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);
#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"
#include "extension_helper.h"
-#define DRIVER_DATE "20061102"
+#define DRIVER_DATE "20070731"
_glthread_Mutex lockMutex;
static GLboolean lockMutexInit = GL_FALSE;
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,
_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;
}
- st_create_context( &intel->ctx,
- softpipe_create() );
-
-
return GL_TRUE;
}
#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;
{
GLcontext ctx; /* the parent class */
+ struct pipe_context *pipe;
+
GLint refcount;
GLuint Fallback;
GLuint NewGLState;
extern struct intel_renderbuffer *intel_renderbuffer(struct gl_renderbuffer
*rb);
+extern void intel_init_region_functions(struct pipe_context *pipe);
+
#endif
#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
{
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;
}
{
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;
}
#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
}
-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);
}
if (intel && irb->region) {
- intel_region_release(&irb->region);
+ intel->pipe->region_release(intel->pipe, &irb->region);
}
_mesa_free(irb);
/* free old region */
if (irb->region) {
- intel_region_release(&irb->region);
+ intel->pipe->region_release(intel->pipe, &irb->region);
}
/* allocate new memory region/renderbuffer */
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? */
irb->Base.surface = intel_new_surface(intFormat);
irb->Base.surface->rb = irb;
- return &irb->Base;
+ return irb;
}
/**
irb->Base.Delete = intel_delete_renderbuffer;
irb->Base.AllocStorage = intel_nop_alloc_storage;
+
intel_set_span_functions(&irb->Base);
irb->RenderToTexture = GL_TRUE;
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);
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 */
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 */
struct intel_context;
-struct intel_region;
+struct pipe_region;
/**
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? */
/* 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);
#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
#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
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) {
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)
GLuint level,
GLuint * row_stride, GLuint * image_offsets)
{
+ GLubyte *ptr;
DBG("%s \n", __FUNCTION__);
if (row_stride)
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
struct intel_mipmap_tree *mt)
{
DBG("%s\n", __FUNCTION__);
- intel_region_unmap(intel->intelScreen, mt->region);
+ intel->pipe->region_unmap(intel->pipe, mt->region);
}
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,
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,
#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
* 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
/* The data is held here:
*/
- struct intel_region *region;
+ struct pipe_region *region;
/* These are also refcounted:
*/
*
**************************************************************************/
-#include "enums.h"
#include "state.h"
#include "swrast/swrast.h"
#include "intel_context.h"
#include "intel_pixel.h"
-#include "intel_regions.h"
void
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);
* 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)
/* 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);
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) {
#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__);
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;
}
-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;
-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;
*
* 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__);
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);
/* 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__);
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);
/* 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__);
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,
/* 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.
*/
/* 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);
/* 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);
}
}
-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;
+}
+
#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
#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
}
-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.
*
{
/* 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,
*
**************************************************************************/
-#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;
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;
#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
*/
/* 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;
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;
}
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;
}
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;
}
/* 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++) {
/* 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++) {
#include "intel_screen.h"
#include "intel_context.h"
#include "intel_fbo.h"
-#include "intel_regions.h"
#include "swrast/swrast.h"
int
#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"
#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;
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;
#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;
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) {
#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
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,
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;
}
/* 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 &&
if (intelImage->mt)
- intel_region_idle(intel->intelScreen, intelImage->mt->region);
+ intel->pipe->region_idle(intel->pipe, intelImage->mt->region);
LOCK_HARDWARE(intel);
#include "intel_tex.h"
#include "intel_mipmap_tree.h"
+#include "pipe/p_context.h"
+
+
#define FILE_DEBUG_FLAG DEBUG_TEXTURE
static void
return;
if (intelImage->mt)
- intel_region_idle(intel->intelScreen, intelImage->mt->region);
+ intel->pipe->region_idle(intel->pipe, intelImage->mt->region);
LOCK_HARDWARE(intel);
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 */
};
+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.