summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2007-12-14 16:00:48 -0800
committerEric Anholt <eric@anholt.net>2007-12-15 12:45:52 -0800
commitf5b3cd46202517c21fcfcec0102732411df1af18 (patch)
tree96309dda2df142311a9086853dd7f7c37c94e33b
parent5e3ef623ee8a6f7ea25242908b76bd47e48f4781 (diff)
[965] Use shared intel_regions.c.
This adds (so far) unused PBO functions, and holding the lock while writing to regions (which may be shared static screen regions).
-rw-r--r--src/mesa/drivers/dri/i965/brw_vtbl.c4
-rw-r--r--src/mesa/drivers/dri/i965/intel_buffer_objects.h4
-rw-r--r--src/mesa/drivers/dri/i965/intel_buffers.c4
-rw-r--r--src/mesa/drivers/dri/i965/intel_context.c8
-rw-r--r--src/mesa/drivers/dri/i965/intel_context.h4
-rw-r--r--src/mesa/drivers/dri/i965/intel_mipmap_tree.c23
l---------[-rw-r--r--]src/mesa/drivers/dri/i965/intel_regions.c306
-rw-r--r--src/mesa/drivers/dri/i965/intel_regions.h152
-rw-r--r--src/mesa/drivers/dri/intel/intel_regions.c2
9 files changed, 29 insertions, 478 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c
index 45e1b7235d..2bc8849867 100644
--- a/src/mesa/drivers/dri/i965/brw_vtbl.c
+++ b/src/mesa/drivers/dri/i965/brw_vtbl.c
@@ -75,8 +75,8 @@ static void brw_set_draw_region( struct intel_context *intel,
{
struct brw_context *brw = brw_context(&intel->ctx);
- intel_region_release(intel, &brw->state.draw_region);
- intel_region_release(intel, &brw->state.depth_region);
+ intel_region_release(&brw->state.draw_region);
+ intel_region_release(&brw->state.depth_region);
intel_region_reference(&brw->state.draw_region, draw_region);
intel_region_reference(&brw->state.depth_region, depth_region);
}
diff --git a/src/mesa/drivers/dri/i965/intel_buffer_objects.h b/src/mesa/drivers/dri/i965/intel_buffer_objects.h
index a80f448716..f2077567bc 100644
--- a/src/mesa/drivers/dri/i965/intel_buffer_objects.h
+++ b/src/mesa/drivers/dri/i965/intel_buffer_objects.h
@@ -40,6 +40,10 @@ struct gl_buffer_object;
struct intel_buffer_object {
struct gl_buffer_object Base;
dri_bo *buffer; /* the low-level buffer manager's buffer handle */
+
+ struct intel_region *region; /* Is there a zero-copy texture
+ associated with this (pixel)
+ buffer object? */
};
diff --git a/src/mesa/drivers/dri/i965/intel_buffers.c b/src/mesa/drivers/dri/i965/intel_buffers.c
index 2567b36120..6af53374b5 100644
--- a/src/mesa/drivers/dri/i965/intel_buffers.c
+++ b/src/mesa/drivers/dri/i965/intel_buffers.c
@@ -556,12 +556,12 @@ static void intelDrawBuffer(GLcontext *ctx, GLenum mode )
if (front) {
if (intel->draw_region != intel->front_region) {
- intel_region_release(intel, &intel->draw_region);
+ intel_region_release(&intel->draw_region);
intel_region_reference(&intel->draw_region, intel->front_region);
}
} else {
if (intel->draw_region != intel->back_region) {
- intel_region_release(intel, &intel->draw_region);
+ intel_region_release(&intel->draw_region);
intel_region_reference(&intel->draw_region, intel->back_region);
}
}
diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c
index 1277dd15aa..6b397ed03d 100644
--- a/src/mesa/drivers/dri/i965/intel_context.c
+++ b/src/mesa/drivers/dri/i965/intel_context.c
@@ -616,10 +616,10 @@ void intelDestroyContext(__DRIcontextPrivate *driContextPriv)
* buffers:
*/
#if 0
- intel_region_release(intel, &intel->front_region);
- intel_region_release(intel, &intel->back_region);
- intel_region_release(intel, &intel->depth_region);
- intel_region_release(intel, &intel->draw_region);
+ intel_region_release(&intel->front_region);
+ intel_region_release(&intel->back_region);
+ intel_region_release(&intel->depth_region);
+ intel_region_release(&intel->draw_region);
#endif
/* free the Mesa context */
diff --git a/src/mesa/drivers/dri/i965/intel_context.h b/src/mesa/drivers/dri/i965/intel_context.h
index 17612acdaf..c1ad504af4 100644
--- a/src/mesa/drivers/dri/i965/intel_context.h
+++ b/src/mesa/drivers/dri/i965/intel_context.h
@@ -63,7 +63,9 @@ typedef void (*intel_point_func)(struct intel_context *, intelVertex *);
extern void intelFallback( struct intel_context *intel, GLuint bit, GLboolean mode );
#define FALLBACK( intel, bit, mode ) intelFallback( intel, bit, mode )
-
+#define INTEL_WRITE_PART 0x1
+#define INTEL_WRITE_FULL 0x2
+#define INTEL_READ 0x4
struct intel_texture_object
{
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index edca84c64e..8cc54703e3 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -119,7 +119,7 @@ void intel_miptree_destroy( struct intel_context *intel,
if (mt) {
GLuint i;
- intel_region_release(intel, &(mt->region));
+ intel_region_release(&mt->region);
for (i = 0; i < MAX_TEXTURE_LEVELS; i++)
if (mt->level[i].image_offset)
@@ -242,17 +242,16 @@ GLboolean intel_miptree_image_data(struct intel_context *intel,
DBG("%s\n", __FUNCTION__);
for (i = 0; i < depth; i++) {
- if (!intel_region_data(intel,
- dst->region,
- dst_offset + dst_depth_offset[i],
- 0,
- 0,
- src,
- src_row_pitch,
- 0, 0, /* source x,y */
- width,
- height))
- return GL_FALSE;
+ intel_region_data(intel,
+ dst->region,
+ dst_offset + dst_depth_offset[i],
+ 0,
+ 0,
+ src,
+ src_row_pitch,
+ 0, 0, /* source x,y */
+ width,
+ height);
src += src_image_pitch;
}
return GL_TRUE;
diff --git a/src/mesa/drivers/dri/i965/intel_regions.c b/src/mesa/drivers/dri/i965/intel_regions.c
index feaecbc754..89b2f15c10 100644..120000
--- a/src/mesa/drivers/dri/i965/intel_regions.c
+++ b/src/mesa/drivers/dri/i965/intel_regions.c
@@ -1,305 +1 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Provide additional functionality on top of bufmgr buffers:
- * - 2d semantics and blit operations
- * - refcounting of buffers for multiple images in a buffer.
- * - refcounting of buffer mappings.
- * - some logic for moving the buffers to the best memory pools for
- * given operations.
- *
- * Most of this is to make it easier to implement the fixed-layout
- * mipmap tree required by intel hardware in the face of GL's
- * programming interface where each image can be specifed in random
- * order and it isn't clear what layout the tree should have until the
- * last moment.
- */
-
-#include "intel_context.h"
-#include "intel_regions.h"
-#include "intel_blit.h"
-#include "dri_bufmgr.h"
-#include "intel_bufmgr_ttm.h"
-#include "imports.h"
-
-#define FILE_DEBUG_FLAG DEBUG_REGION
-
-/* XXX: Thread safety?
- */
-GLubyte *intel_region_map(struct intel_context *intel, struct intel_region *region)
-{
- DBG("%s\n", __FUNCTION__);
- if (!region->map_refcount++) {
- dri_bo_map(region->buffer, GL_TRUE);
- region->map = region->buffer->virtual;
- }
-
- return region->map;
-}
-
-void intel_region_unmap(struct intel_context *intel,
- struct intel_region *region)
-{
- DBG("%s\n", __FUNCTION__);
- if (!--region->map_refcount) {
- dri_bo_unmap(region->buffer);
- region->map = NULL;
- }
-}
-
-struct intel_region *intel_region_alloc( struct intel_context *intel,
- GLuint cpp,
- GLuint pitch,
- GLuint height )
-{
- struct intel_region *region = calloc(sizeof(*region), 1);
-
- DBG("%s %dx%dx%d == 0x%x bytes\n", __FUNCTION__,
- cpp, pitch, height, cpp*pitch*height);
-
- region->cpp = cpp;
- region->pitch = pitch;
- region->height = height; /* needed? */
- region->refcount = 1;
-
- region->buffer = dri_bo_alloc(intel->bufmgr, "region",
- pitch * cpp * height, 64, DRM_BO_FLAG_MEM_TT);
-
- return region;
-}
-
-void intel_region_reference( struct intel_region **dst,
- struct intel_region *src)
-{
- src->refcount++;
- assert(*dst == NULL);
- *dst = src;
-}
-
-void intel_region_release( struct intel_context *intel,
- struct intel_region **region )
-{
- if (!*region)
- return;
-
- DBG("%s %d\n", __FUNCTION__, (*region)->refcount-1);
-
- if (--(*region)->refcount == 0) {
- assert((*region)->map_refcount == 0);
- dri_bo_unreference((*region)->buffer);
- free(*region);
- }
- *region = NULL;
-}
-
-void _mesa_copy_rect( GLubyte *dst,
- GLuint cpp,
- GLuint dst_pitch,
- GLuint dst_x,
- GLuint dst_y,
- GLuint width,
- GLuint height,
- const GLubyte *src,
- GLuint src_pitch,
- GLuint src_x,
- GLuint src_y )
-{
- GLuint i;
-
- dst_pitch *= cpp;
- src_pitch *= cpp;
- dst += dst_x * cpp;
- src += src_x * cpp;
- dst += dst_y * dst_pitch;
- src += src_y * dst_pitch;
- width *= cpp;
-
- if (width == dst_pitch &&
- width == src_pitch)
- do_memcpy(dst, src, height * width);
- else {
- for (i = 0; i < height; i++) {
- do_memcpy(dst, src, width);
- dst += dst_pitch;
- src += src_pitch;
- }
- }
-}
-
-
-/* Upload data to a rectangular sub-region. Lots of choices how to do this:
- *
- * - memcpy by span to current destination
- * - upload data as new buffer and blit
- *
- * Currently always memcpy.
- */
-GLboolean intel_region_data(struct intel_context *intel,
- struct intel_region *dst,
- GLuint dst_offset,
- GLuint dstx, GLuint dsty,
- const void *src, GLuint src_pitch,
- GLuint srcx, GLuint srcy,
- GLuint width, GLuint height)
-{
- DBG("%s\n", __FUNCTION__);
-
- assert (dst_offset + dstx + width +
- (dsty + height - 1) * dst->pitch * dst->cpp <=
- dst->pitch * dst->cpp * dst->height);
-
- _mesa_copy_rect(intel_region_map(intel, dst) + dst_offset,
- dst->cpp,
- dst->pitch,
- dstx, dsty, width, height, src, src_pitch, srcx, srcy);
- intel_region_unmap(intel, dst);
-
- return GL_TRUE;
-}
-
-/* Copy rectangular sub-regions. Need better logic about when to
- * push buffers into AGP - will currently do so whenever possible.
- */
-void intel_region_copy( struct intel_context *intel,
- struct intel_region *dst,
- GLuint dst_offset,
- GLuint dstx, GLuint dsty,
- struct intel_region *src,
- GLuint src_offset,
- GLuint srcx, GLuint srcy,
- GLuint width, GLuint height )
-{
- DBG("%s\n", __FUNCTION__);
-
- assert(src->cpp == dst->cpp);
-
- intelEmitCopyBlit(intel,
- dst->cpp,
- src->pitch, src->buffer, src_offset, src->tiled,
- dst->pitch, dst->buffer, dst_offset, dst->tiled,
- srcx, srcy,
- dstx, dsty,
- width, height,
- GL_COPY );
-}
-
-/* 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( struct intel_context *intel,
- struct intel_region *dst,
- GLuint dst_offset,
- GLuint dstx, GLuint dsty,
- GLuint width, GLuint height,
- GLuint color )
-{
- DBG("%s\n", __FUNCTION__);
-
- intelEmitFillBlit(intel,
- dst->cpp,
- dst->pitch, dst->buffer, dst_offset, dst->tiled,
- dstx, dsty,
- width, height,
- color );
-}
-
-static struct intel_region *
-intel_recreate_static(struct intel_context *intel,
- const char *name,
- struct intel_region *region,
- intelRegion *region_desc,
- GLuint mem_type)
-{
- intelScreenPrivate *intelScreen = intel->intelScreen;
-
- if (region == NULL) {
- region = calloc(sizeof(*region), 1);
- region->refcount = 1;
- }
-
- region->cpp = intelScreen->cpp;
- region->pitch = region_desc->pitch / intelScreen->cpp;
- region->height = intelScreen->height; /* needed? */
- region->tiled = region_desc->tiled;
-
- if (intel->ttm) {
- assert(region_desc->bo_handle != -1);
- region->buffer = intel_ttm_bo_create_from_handle(intel->bufmgr,
- name,
- region_desc->bo_handle);
- } else {
- region->buffer = dri_bo_alloc_static(intel->bufmgr,
- name,
- region_desc->offset,
- region_desc->pitch *
- intelScreen->height,
- region_desc->map,
- DRM_BO_FLAG_MEM_TT);
- }
-
- assert(region->buffer != NULL);
-
- return region;
-}
-
-/**
- * Create intel_region structs to describe the static front, back, and depth
- * buffers created by the xserver.
- *
- * Although FBO's mean we now no longer use these as render targets in
- * all circumstances, they won't go away until the back and depth
- * buffers become private, and the front buffer will remain even then.
- *
- * Note that these don't allocate video memory, just describe
- * allocations alread made by the X server.
- */
-void
-intel_recreate_static_regions(struct intel_context *intel)
-{
- intelScreenPrivate *intelScreen = intel->intelScreen;
-
- intel->front_region =
- intel_recreate_static(intel, "front",
- intel->front_region,
- &intelScreen->front,
- DRM_BO_FLAG_MEM_TT);
-
- intel->back_region =
- intel_recreate_static(intel, "back",
- intel->back_region,
- &intelScreen->back,
- DRM_BO_FLAG_MEM_TT);
-
- /* Still assumes front.cpp == depth.cpp. We can kill this when we move to
- * private buffers.
- */
- intel->depth_region =
- intel_recreate_static(intel, "depth",
- intel->depth_region,
- &intelScreen->depth,
- DRM_BO_FLAG_MEM_TT);
-}
+../intel/intel_regions.c \ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_regions.h b/src/mesa/drivers/dri/i965/intel_regions.h
deleted file mode 100644
index 3e130203c3..0000000000
--- a/src/mesa/drivers/dri/i965/intel_regions.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef INTEL_REGIONS_H
-#define INTEL_REGIONS_H
-
-#include "mtypes.h"
-#include "dri_bufmgr.h" /* for DBG! */
-#include "intel_screen.h"
-struct intel_context;
-
-/* 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.
- */
-struct intel_region {
- dri_bo *buffer;
- GLuint refcount;
- GLuint cpp;
- GLuint pitch;
- GLuint height;
- GLboolean tiled;
- GLubyte *map;
- GLuint map_refcount;
-};
-
-/* Allocate a refcounted region. Pointers to regions should only be
- * copied by calling intel_reference_region().
- *
- * No support for dynamically allocating tiled regions at this point.
- */
-struct intel_region *intel_region_alloc( struct intel_context *intel,
- GLuint cpp,
- GLuint pitch,
- GLuint height );
-
-void intel_region_reference( struct intel_region **dst,
- struct intel_region *src );
-
-void intel_region_release(struct intel_context *intel,
- struct intel_region **ib );
-
-void intel_recreate_static_regions(struct intel_context *intel);
-
-/* Static regions may be tiled. The assumption is that the X server
- * has set up fence registers to define tiled zones in agp and these
- * buffers are within those zones. Tiling regions without fence
- * registers is more work.
- */
-struct intel_region *
-intel_region_create_static(intelScreenPrivate *intelScreen,
- char *name,
- GLuint mem_type,
- unsigned int bo_handle,
- GLuint offset,
- void *virtual,
- GLuint cpp,
- GLuint pitch, GLuint height, GLboolean tiled);
-void
-intel_region_update_static(intelScreenPrivate *intelScreen,
- struct intel_region *region,
- GLuint mem_type,
- unsigned int bo_handle,
- GLuint offset,
- void *virtual,
- GLuint cpp, GLuint pitch, GLuint height,
- GLboolean tiled);
-
-/* Map/unmap regions. This is refcounted also:
- */
-GLubyte *intel_region_map(struct intel_context *intel,
- struct intel_region *ib);
-
-void intel_region_unmap(struct intel_context *intel,
- struct intel_region *ib);
-
-
-/* Upload data to a rectangular sub-region
- */
-GLboolean intel_region_data(struct intel_context *intel,
- 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( struct intel_context *intel,
- 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( struct intel_context *intel,
- struct intel_region *dest,
- GLuint dest_offset,
- GLuint destx, GLuint desty,
- GLuint width, GLuint height,
- GLuint color );
-
-
-/***********************************************************************
- * Misc utilities: move to somewhere generic
- */
-void _mesa_copy_rect( GLubyte *dst,
- GLuint cpp,
- GLuint dst_pitch,
- GLuint dst_x,
- GLuint dst_y,
- GLuint width,
- GLuint height,
- const GLubyte *src,
- GLuint src_pitch,
- GLuint src_x,
- GLuint src_y );
-
-
-#endif
diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c
index 56ca6d2fd2..d66cc641f5 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.c
+++ b/src/mesa/drivers/dri/intel/intel_regions.c
@@ -442,6 +442,7 @@ intel_recreate_static_regions(struct intel_context *intel)
&intelScreen->back,
DRM_BO_FLAG_MEM_TT);
+#ifdef I915
if (intelScreen->third.handle) {
intel->third_region =
intel_recreate_static(intel, "third",
@@ -449,6 +450,7 @@ intel_recreate_static_regions(struct intel_context *intel)
&intelScreen->third,
DRM_BO_FLAG_MEM_TT);
}
+#endif /* I915 */
/* Still assumes front.cpp == depth.cpp. We can kill this when we move to
* private buffers.