summaryrefslogtreecommitdiff
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorJakob Bornecrantz <jakob@vmware.com>2009-08-27 18:57:29 +0100
committerJakob Bornecrantz <jakob@vmware.com>2009-08-28 13:38:23 +0100
commit1e5014f7dfabcaf1f4b5608eb08e97179446eb09 (patch)
tree75ab693e5e07467c36fd3593c440143d62ce907e /src/gallium/winsys
parent7d9af52bc59bfeb19d9bdb55258f4a830a1b0d04 (diff)
drm_api: Operate on textures instead of buffers
Most use cases just got the buffer from the texture and then called into one of the get_handle functions. Also with this patch it would be easier to move to a generic function for getting handles from textures and textures from handles, that is exposed via the screen.
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_api.c7
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_device.c102
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_device.h46
3 files changed, 92 insertions, 63 deletions
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_api.c b/src/gallium/winsys/drm/intel/gem/intel_be_api.c
index dd5f814da3..3e90088d5e 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_be_api.c
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_api.c
@@ -15,10 +15,9 @@ struct drm_api intel_be_drm_api =
.create_context = intel_be_create_context,
/* intel_be_device.c */
.create_screen = intel_be_create_screen,
- .buffer_from_texture = intel_be_get_texture_buffer,
- .buffer_from_handle = intel_be_buffer_from_handle,
- .handle_from_buffer = intel_be_handle_from_buffer,
- .global_handle_from_buffer = intel_be_global_handle_from_buffer,
+ .texture_from_shared_handle = intel_be_texture_from_shared_handle,
+ .shared_handle_from_texture = intel_be_shared_handle_from_texture,
+ .local_handle_from_texture = intel_be_local_handle_from_texture,
.destroy = destroy,
};
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_device.c b/src/gallium/winsys/drm/intel/gem/intel_be_device.c
index 5312865a03..f58334ffff 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_be_device.c
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.c
@@ -209,25 +209,7 @@ intel_be_surface_buffer_create(struct pipe_winsys *winsys,
buf_size);
}
-boolean
-intel_be_get_texture_buffer(struct drm_api *api,
- struct pipe_texture *texture,
- struct pipe_buffer **buffer,
- unsigned *stride)
-{
- struct intel_be_device *dev;
-
- if (!texture)
- return FALSE;
-
- dev = intel_be_device(texture->screen->winsys);
- if (dev->softpipe)
- return softpipe_get_texture_buffer(texture, buffer, stride);
- else
- return i915_get_texture_buffer(texture, buffer, stride);
-}
-
-struct pipe_buffer *
+static struct pipe_buffer *
intel_be_buffer_from_handle(struct drm_api *api,
struct pipe_screen *screen,
const char* name, unsigned handle)
@@ -259,30 +241,60 @@ err:
return NULL;
}
-boolean
-intel_be_handle_from_buffer(struct drm_api *api,
- struct pipe_screen *screen,
- struct pipe_buffer *buffer,
- unsigned *handle)
+struct pipe_texture *
+intel_be_texture_from_shared_handle(struct drm_api *api,
+ struct pipe_screen *screen,
+ struct pipe_texture *templ,
+ const char* name,
+ unsigned pitch,
+ unsigned handle)
{
+ struct pipe_buffer *buffer;
+
+ buffer = intel_be_buffer_from_handle(api,
+ screen,
+ name,
+ handle);
if (!buffer)
+ return NULL;
+
+ return screen->texture_blanket(screen, templ, &pitch, buffer);
+}
+
+static boolean
+intel_be_get_texture_buffer(struct drm_api *api,
+ struct pipe_texture *texture,
+ struct pipe_buffer **buffer,
+ unsigned *stride)
+{
+ struct intel_be_device *dev;
+
+ if (!texture)
return FALSE;
- *handle = intel_bo(buffer)->handle;
- return TRUE;
+ dev = intel_be_device(texture->screen->winsys);
+ if (dev->softpipe)
+ return softpipe_get_texture_buffer(texture, buffer, stride);
+ else
+ return i915_get_texture_buffer(texture, buffer, stride);
}
boolean
-intel_be_global_handle_from_buffer(struct drm_api *api,
- struct pipe_screen *screen,
- struct pipe_buffer *buffer,
- unsigned *handle)
+intel_be_shared_handle_from_texture(struct drm_api *api,
+ struct pipe_screen *screen,
+ struct pipe_texture *texture,
+ unsigned *pitch,
+ unsigned *handle)
{
- struct intel_be_buffer *buf = intel_be_buffer(buffer);
-
- if (!buffer)
+ struct pipe_buffer *buffer;
+ struct intel_be_buffer *buf;
+ if (!intel_be_get_texture_buffer(api,
+ texture,
+ &buffer,
+ pitch))
return FALSE;
+ buf = intel_be_buffer(buffer);
if (!buf->flinked) {
if (drm_intel_bo_flink(intel_bo(buffer), &buf->flink))
return FALSE;
@@ -290,6 +302,30 @@ intel_be_global_handle_from_buffer(struct drm_api *api,
}
*handle = buf->flink;
+
+ pipe_buffer_reference(&buffer, NULL);
+
+ return TRUE;
+}
+
+boolean
+intel_be_local_handle_from_texture(struct drm_api *api,
+ struct pipe_screen *screen,
+ struct pipe_texture *texture,
+ unsigned *pitch,
+ unsigned *handle)
+{
+ struct pipe_buffer *buffer;
+ if (!intel_be_get_texture_buffer(api,
+ texture,
+ &buffer,
+ pitch))
+ return FALSE;
+
+ *handle = intel_bo(buffer)->handle;
+
+ pipe_buffer_reference(&buffer, NULL);
+
return TRUE;
}
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_device.h b/src/gallium/winsys/drm/intel/gem/intel_be_device.h
index c397048f8c..15916b0b10 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_be_device.h
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.h
@@ -57,45 +57,39 @@ struct intel_be_buffer {
unsigned flink;
};
-/*
- * Wrapper for driver get_texture_buffer functions.
- */
-boolean
-intel_be_get_texture_buffer(struct drm_api *api,
- struct pipe_texture *texture,
- struct pipe_buffer **buffer,
- unsigned *stride);
-
/**
- * Create a be buffer from a drm bo handle.
- *
- * Takes a reference.
+ * Create a texture from a shared drm handle.
*/
-struct pipe_buffer *
-intel_be_buffer_from_handle(struct drm_api *api,
- struct pipe_screen *screen,
- const char* name, unsigned handle);
+struct pipe_texture *
+intel_be_texture_from_shared_handle(struct drm_api *api,
+ struct pipe_screen *screen,
+ struct pipe_texture *templ,
+ const char* name,
+ unsigned pitch,
+ unsigned handle);
/**
- * Gets a handle from a buffer.
+ * Gets a shared handle from a texture.
*
- * If buffer is destroyed handle may become invalid.
+ * If texture is destroyed handle may become invalid.
*/
boolean
-intel_be_handle_from_buffer(struct drm_api *api,
- struct pipe_screen *screen,
- struct pipe_buffer *buffer,
- unsigned *handle);
+intel_be_shared_handle_from_texture(struct drm_api *api,
+ struct pipe_screen *screen,
+ struct pipe_texture *texture,
+ unsigned *pitch,
+ unsigned *handle);
/**
- * Gets the global handle from a buffer.
+ * Gets the local handle from a texture. As used by KMS.
*
- * If buffer is destroyed handle may become invalid.
+ * If texture is destroyed handle may become invalid.
*/
boolean
-intel_be_global_handle_from_buffer(struct drm_api *api,
+intel_be_local_handle_from_texture(struct drm_api *api,
struct pipe_screen *screen,
- struct pipe_buffer *buffer,
+ struct pipe_texture *texture,
+ unsigned *pitch,
unsigned *handle);
static INLINE struct intel_be_buffer *