unsigned hint;
unsigned alignment;
void *private;
+ /* user-space buffer: */
+ unsigned userBuffer;
+ void *userData;
+ unsigned userSize;
} DriBufferObject;
void *
driBOMap(struct _DriBufferObject *buf, unsigned flags, unsigned hint)
{
- void *virtual;
+ if (buf->userBuffer) {
+ return buf->userData;
+ }
+ else {
+ void *virtual;
- assert(buf->private != NULL);
+ assert(buf->private != NULL);
- _glthread_LOCK_MUTEX(buf->mutex);
- BM_CKFATAL(buf->pool->map(buf->pool, buf->private, flags, hint, &virtual));
- _glthread_UNLOCK_MUTEX(buf->mutex);
- return virtual;
+ _glthread_LOCK_MUTEX(buf->mutex);
+ BM_CKFATAL(buf->pool->map(buf->pool, buf->private, flags, hint, &virtual));
+ _glthread_UNLOCK_MUTEX(buf->mutex);
+ return virtual;
+ }
}
void
driBOUnmap(struct _DriBufferObject *buf)
{
- assert(buf->private != NULL);
+ if (!buf->userBuffer) {
+ assert(buf->private != NULL);
- buf->pool->unmap(buf->pool, buf->private);
+ buf->pool->unmap(buf->pool, buf->private);
+ }
}
unsigned long
tmp = --buf->refCount;
_glthread_UNLOCK_MUTEX(bmMutex);
if (!tmp) {
- buf->pool->destroy(buf->pool, buf->private);
+ if (buf->private)
+ buf->pool->destroy(buf->pool, buf->private);
free(buf);
}
}
int newBuffer;
struct _DriBufferPool *pool;
+ assert(!buf->userBuffer); /* XXX just do a memcpy? */
+
_glthread_LOCK_MUTEX(buf->mutex);
pool = buf->pool;
if (!pool->create) {
{
void *virtual;
+ assert(!buf->userBuffer); /* XXX just do a memcpy? */
+
_glthread_LOCK_MUTEX(buf->mutex);
if (size && data) {
BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
{
void *virtual;
+ assert(!buf->userBuffer); /* XXX just do a memcpy? */
+
_glthread_LOCK_MUTEX(buf->mutex);
if (size && data) {
BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
unsigned long offset,
unsigned long size, void *virtual, unsigned flags)
{
+ assert(!buf->userBuffer); /* XXX what to do? */
+
_glthread_LOCK_MUTEX(buf->mutex);
if (buf->private != NULL) {
_mesa_error(NULL, GL_INVALID_OPERATION,
}
}
+void
+driGenUserBuffer(struct _DriBufferPool *pool,
+ const char *name,
+ struct _DriBufferObject **buffers,
+ void *ptr, unsigned bytes)
+{
+ const unsigned alignment = 1, flags = 0, hint = 0;
+
+ driGenBuffers(pool, name, 1, buffers, alignment, flags, hint);
+
+ (*buffers)->userBuffer = 1;
+ (*buffers)->userData = ptr;
+ (*buffers)->userSize = bytes;
+}
+
+
void
driDeleteBuffers(unsigned n, struct _DriBufferObject *buffers[])
{
unsigned n,
struct _DriBufferObject *buffers[],
unsigned alignment, unsigned flags, unsigned hint);
+extern void driGenUserBuffer(struct _DriBufferPool *pool,
+ const char *name,
+ struct _DriBufferObject *buffers[],
+ void *ptr, unsigned bytes);
extern void driDeleteBuffers(unsigned n, struct _DriBufferObject *buffers[]);
extern void driInitBufMgr(int fd);
extern void driBOCreateList(int target, drmBOList * list);