diff options
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r-- | src/gallium/winsys/drm/intel/gem/intel_be_api.c | 7 | ||||
-rw-r--r-- | src/gallium/winsys/drm/intel/gem/intel_be_device.c | 102 | ||||
-rw-r--r-- | src/gallium/winsys/drm/intel/gem/intel_be_device.h | 46 |
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 * |