summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965/intel_regions.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/i965/intel_regions.c')
-rw-r--r--src/mesa/drivers/dri/i965/intel_regions.c182
1 files changed, 95 insertions, 87 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_regions.c b/src/mesa/drivers/dri/i965/intel_regions.c
index 9c92ab4777..feaecbc754 100644
--- a/src/mesa/drivers/dri/i965/intel_regions.c
+++ b/src/mesa/drivers/dri/i965/intel_regions.c
@@ -42,7 +42,8 @@
#include "intel_context.h"
#include "intel_regions.h"
#include "intel_blit.h"
-#include "bufmgr.h"
+#include "dri_bufmgr.h"
+#include "intel_bufmgr_ttm.h"
#include "imports.h"
#define FILE_DEBUG_FLAG DEBUG_REGION
@@ -53,9 +54,8 @@ GLubyte *intel_region_map(struct intel_context *intel, struct intel_region *regi
{
DBG("%s\n", __FUNCTION__);
if (!region->map_refcount++) {
- region->map = bmMapBuffer(intel, region->buffer, 0);
- if (!region->map)
- region->map_refcount--;
+ dri_bo_map(region->buffer, GL_TRUE);
+ region->map = region->buffer->virtual;
}
return region->map;
@@ -66,7 +66,7 @@ void intel_region_unmap(struct intel_context *intel,
{
DBG("%s\n", __FUNCTION__);
if (!--region->map_refcount) {
- bmUnmapBuffer(intel, region->buffer);
+ dri_bo_unmap(region->buffer);
region->map = NULL;
}
}
@@ -86,8 +86,8 @@ struct intel_region *intel_region_alloc( struct intel_context *intel,
region->height = height; /* needed? */
region->refcount = 1;
- bmGenBuffers(intel, "tex", 1, &region->buffer, 6);
- bmBufferData(intel, region->buffer, pitch * cpp * height, NULL, 0);
+ region->buffer = dri_bo_alloc(intel->bufmgr, "region",
+ pitch * cpp * height, 64, DRM_BO_FLAG_MEM_TT);
return region;
}
@@ -110,56 +110,12 @@ void intel_region_release( struct intel_context *intel,
if (--(*region)->refcount == 0) {
assert((*region)->map_refcount == 0);
- bmDeleteBuffers(intel, 1, &(*region)->buffer);
+ dri_bo_unreference((*region)->buffer);
free(*region);
}
*region = NULL;
}
-
-struct intel_region *intel_region_create_static( struct intel_context *intel,
- GLuint mem_type,
- GLuint offset,
- void *virtual,
- GLuint cpp,
- GLuint pitch,
- GLuint height,
- GLuint size,
- GLboolean tiled )
-{
- struct intel_region *region = calloc(sizeof(*region), 1);
- GLint pool;
-
- DBG("%s\n", __FUNCTION__);
-
- region->cpp = cpp;
- region->pitch = pitch;
- region->height = height; /* needed? */
- region->refcount = 1;
- region->tiled = tiled;
-
- /* Recipe for creating a static buffer - create a static pool with
- * the right offset and size, generate a buffer and use a special
- * call to bind it to all of the memory in that pool.
- */
- pool = bmInitPool(intel, offset, virtual, size,
- (BM_MEM_AGP |
- BM_NO_UPLOAD |
- BM_NO_EVICT |
- BM_NO_MOVE));
- if (pool < 0) {
- _mesa_printf("bmInitPool failed for static region\n");
- exit(1);
- }
-
- region->buffer = bmGenBufferStatic(intel, pool);
-
- return region;
-}
-
-
-
-
void _mesa_copy_rect( GLubyte *dst,
GLuint cpp,
GLuint dst_pitch,
@@ -212,41 +168,17 @@ GLboolean intel_region_data(struct intel_context *intel,
{
DBG("%s\n", __FUNCTION__);
- if (width == dst->pitch &&
- width == src_pitch &&
- dst_offset == 0 &&
- height == dst->height &&
- srcx == 0 &&
- srcy == 0)
- {
- return (bmBufferData(intel,
- dst->buffer,
- dst->cpp * width * dst->height,
- src, 0) == 0);
- }
- else {
- GLubyte *map = intel_region_map(intel, dst);
-
- if (map) {
- assert (dst_offset + dstx + width +
- (dsty + height - 1) * dst->pitch * dst->cpp <=
- dst->pitch * dst->cpp * dst->height);
-
- _mesa_copy_rect(map + dst_offset,
- dst->cpp,
- dst->pitch,
- dstx, dsty,
- width, height,
- src,
- src_pitch,
- srcx, srcy);
-
- intel_region_unmap(intel, dst);
- return GL_TRUE;
- }
- else
- return GL_FALSE;
- }
+ 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
@@ -295,3 +227,79 @@ void intel_region_fill( struct intel_context *intel,
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);
+}