summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hellström <thomas@tungstengraphics.com>2006-09-26 09:00:03 +0000
committerThomas Hellström <thomas@tungstengraphics.com>2006-09-26 09:00:03 +0000
commitd17637d47f7536eb46c1e0cf246120d36895642f (patch)
treefa8404ed3c0b544fbea3dfcda0724604ed01b9bd
parent980a25cd92d70015c6aee4d6d2c60fb05b74d534 (diff)
Fix up buffer object and region refcounting
Sinlence some compilation warnings.
-rw-r--r--src/mesa/drivers/dri/common/dri_bufmgr.c6
-rw-r--r--src/mesa/drivers/dri/common/dri_bufmgr.h6
-rw-r--r--src/mesa/drivers/dri/i915/i915_texstate.c5
-rw-r--r--src/mesa/drivers/dri/i915/intel_batchpool.c1
-rw-r--r--src/mesa/drivers/dri/i915/intel_blit.c1
-rw-r--r--src/mesa/drivers/dri/i915/intel_buffer_objects.c3
-rw-r--r--src/mesa/drivers/dri/i915/intel_regions.c13
7 files changed, 19 insertions, 16 deletions
diff --git a/src/mesa/drivers/dri/common/dri_bufmgr.c b/src/mesa/drivers/dri/common/dri_bufmgr.c
index 0387c7a927..370b56c3a3 100644
--- a/src/mesa/drivers/dri/common/dri_bufmgr.c
+++ b/src/mesa/drivers/dri/common/dri_bufmgr.c
@@ -122,12 +122,13 @@ driFenceType(DriFenceObject * fence)
}
-void
+DriFenceObject *
driFenceReference(DriFenceObject * fence)
{
_glthread_LOCK_MUTEX(bmMutex);
++fence->refCount;
_glthread_UNLOCK_MUTEX(bmMutex);
+ return fence;
}
void
@@ -243,7 +244,7 @@ driBOFlags(struct _DriBufferObject *buf)
return ret;
}
-void
+struct _DriBufferObject *
driBOReference(struct _DriBufferObject *buf)
{
_glthread_LOCK_MUTEX(bmMutex);
@@ -251,6 +252,7 @@ driBOReference(struct _DriBufferObject *buf)
BM_CKFATAL(-EINVAL);
}
_glthread_UNLOCK_MUTEX(bmMutex);
+ return buf;
}
void
diff --git a/src/mesa/drivers/dri/common/dri_bufmgr.h b/src/mesa/drivers/dri/common/dri_bufmgr.h
index 0ee5867d2d..01f149ae4e 100644
--- a/src/mesa/drivers/dri/common/dri_bufmgr.h
+++ b/src/mesa/drivers/dri/common/dri_bufmgr.h
@@ -42,7 +42,7 @@ struct _DriBufferPool;
extern struct _DriFenceObject *driFenceBuffers(int fd, char *name,
unsigned flags);
-extern void driFenceReference(struct _DriFenceObject *fence);
+extern struct _DriFenceObject *driFenceReference(struct _DriFenceObject *fence);
extern void driFenceUnReference(struct _DriFenceObject *fence);
@@ -63,7 +63,7 @@ extern void *driBOMap(struct _DriBufferObject *buf, unsigned flags,
extern void driBOUnmap(struct _DriBufferObject *buf);
extern unsigned long driBOOffset(struct _DriBufferObject *buf);
extern unsigned driBOFlags(struct _DriBufferObject *buf);
-extern void driBOReference(struct _DriBufferObject *buf);
+extern struct _DriBufferObject *driBOReference(struct _DriBufferObject *buf);
extern void driBOUnReference(struct _DriBufferObject *buf);
extern void driBOData(struct _DriBufferObject *r_buf,
unsigned size, const void *data, unsigned flags);
@@ -94,6 +94,6 @@ extern void driBOSetStatic(struct _DriBufferObject *buf,
unsigned long offset,
unsigned long size, void *virtual, unsigned flags);
extern void driBOWaitIdle(struct _DriBufferObject *buf, int lazy);
-
+extern void driPoolTakeDown(struct _DriBufferPool *pool);
#endif
diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c
index 1430e6e99d..e0ecdfde24 100644
--- a/src/mesa/drivers/dri/i915/i915_texstate.c
+++ b/src/mesa/drivers/dri/i915/i915_texstate.c
@@ -28,6 +28,7 @@
#include "mtypes.h"
#include "enums.h"
#include "texformat.h"
+#include "dri_bufmgr.h"
#include "intel_mipmap_tree.h"
#include "intel_tex.h"
@@ -140,9 +141,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
*/
firstImage = tObj->Image[0][intelObj->firstLevel];
-
- driBOReference(intelObj->mt->region->buffer);
- i915->state.tex_buffer[unit] = intelObj->mt->region->buffer;
+ i915->state.tex_buffer[unit] = driBOReference(intelObj->mt->region->buffer);
i915->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt, 0,
intelObj->
firstLevel);
diff --git a/src/mesa/drivers/dri/i915/intel_batchpool.c b/src/mesa/drivers/dri/i915/intel_batchpool.c
index ee6085a6c0..fb5b236a09 100644
--- a/src/mesa/drivers/dri/i915/intel_batchpool.c
+++ b/src/mesa/drivers/dri/i915/intel_batchpool.c
@@ -36,6 +36,7 @@
#include "glthread.h"
#include "dri_bufpool.h"
#include "dri_bufmgr.h"
+#include "intel_screen.h"
typedef struct
{
diff --git a/src/mesa/drivers/dri/i915/intel_blit.c b/src/mesa/drivers/dri/i915/intel_blit.c
index 1f3749bb3c..e55f05bd1f 100644
--- a/src/mesa/drivers/dri/i915/intel_blit.c
+++ b/src/mesa/drivers/dri/i915/intel_blit.c
@@ -40,6 +40,7 @@
#include "intel_fbo.h"
#include "intel_reg.h"
#include "intel_regions.h"
+#include "vblank.h"
#define FILE_DEBUG_FLAG DEBUG_BLIT
diff --git a/src/mesa/drivers/dri/i915/intel_buffer_objects.c b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
index 7562e9497c..31c41d8685 100644
--- a/src/mesa/drivers/dri/i915/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
@@ -65,7 +65,8 @@ intel_bufferobj_release_region(struct intel_context *intel,
assert(intel_obj->region->buffer == intel_obj->buffer);
intel_obj->region->pbo = NULL;
intel_obj->region = NULL;
- intel_obj->buffer = NULL; /* refcount? */
+ driBOUnReference(intel_obj->buffer);
+ intel_obj->buffer = NULL;
/* This leads to a large number of buffer deletion/creation events.
* Currently the drm doesn't like that:
diff --git a/src/mesa/drivers/dri/i915/intel_regions.c b/src/mesa/drivers/dri/i915/intel_regions.c
index 8a5ce5df91..9c33152d98 100644
--- a/src/mesa/drivers/dri/i915/intel_regions.c
+++ b/src/mesa/drivers/dri/i915/intel_regions.c
@@ -98,7 +98,6 @@ intel_region_alloc(intelScreenPrivate *intelScreen,
driGenBuffers(intelScreen->regionPool,
"region", 1, &region->buffer, 64, 0, 0);
driBOData(region->buffer, pitch * cpp * height, NULL, 0);
-
return region;
}
@@ -129,8 +128,8 @@ intel_region_release(intelScreenPrivate *intelScreen,
if ((*region)->pbo)
intel_region_release_pbo(intelScreen, *region);
- else
- driDeleteBuffers(1, &(*region)->buffer);
+
+ driDeleteBuffers(1, &(*region)->buffer);
free(*region);
}
@@ -364,17 +363,16 @@ intel_region_attach_pbo(intelScreenPrivate *intelScreen,
if (region->pbo) {
region->pbo->region = NULL;
region->pbo = NULL;
- region->buffer = NULL; /* refcount? */
}
if (region->buffer) {
driDeleteBuffers(1, &region->buffer);
+ region->buffer = NULL;
}
region->pbo = pbo;
region->pbo->region = region;
- region->buffer = pbo->buffer; /* refcount? */
-
+ region->buffer = driBOReference(pbo->buffer);
}
@@ -387,7 +385,8 @@ intel_region_release_pbo(intelScreenPrivate *intelScreen,
assert(region->buffer == region->pbo->buffer);
region->pbo->region = NULL;
region->pbo = NULL;
- region->buffer = NULL; /* refcount? */
+ driBOUnReference(region->buffer);
+ region->buffer = NULL;
driGenBuffers(intelScreen->regionPool,
"region", 1, &region->buffer, 64, 0, 0);