diff options
author | Jakob Bornecrantz <[email protected]> | 2009-02-27 03:27:31 +0100 |
---|---|---|
committer | Jakob Bornecrantz <[email protected]> | 2009-02-27 03:36:48 +0100 |
commit | e1d276f9351a6524f4a48d9606ae531cc04ccad4 (patch) | |
tree | a60ed46a4c2cc44b463c26c9cbbd2c370c07aba6 /src/gallium | |
parent | 6a72a2d3f4ea50996593bfa55ae671eee9836d76 (diff) |
intel: Use flink for global buffer ids
Also fix minor drm api change
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/winsys/drm/intel/gem/intel_be_api.c | 1 | ||||
-rw-r--r-- | src/gallium/winsys/drm/intel/gem/intel_be_device.c | 35 | ||||
-rw-r--r-- | src/gallium/winsys/drm/intel/gem/intel_be_device.h | 17 |
3 files changed, 47 insertions, 6 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 e79ff0c6a3d..3f71c254414 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_api.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_api.c @@ -11,4 +11,5 @@ struct drm_api drm_api_hocks = .buffer_from_texture = i915_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, }; 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 c0ba8340069..595de447267 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_device.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.c @@ -70,6 +70,8 @@ intel_be_buffer_create(struct pipe_winsys *winsys, buffer->base.alignment = alignment; buffer->base.usage = usage; buffer->base.size = size; + buffer->flinked = FALSE; + buffer->flink = 0; if (usage & (PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_CONSTANT)) { /* Local buffer */ @@ -162,14 +164,39 @@ err: return NULL; } -unsigned +boolean intel_be_handle_from_buffer(struct pipe_screen *screen, - struct pipe_buffer *buf) + struct pipe_buffer *buffer, + unsigned *handle) { - drm_intel_bo *bo = intel_bo(buf); - return bo->handle; + drm_intel_bo *bo; + + if (!buffer) + return FALSE; + + *handle = intel_bo(buffer)->handle; + return TRUE; } +boolean +intel_be_global_handle_from_buffer(struct pipe_screen *screen, + struct pipe_buffer *buffer, + unsigned *handle) +{ + struct intel_be_buffer *buf = intel_be_buffer(buffer); + + if (!buffer) + return FALSE; + + if (!buf->flinked) { + if (drm_intel_bo_flink(intel_bo(buffer), &buf->flink)) + return FALSE; + buf->flinked = TRUE; + } + + *handle = buf->flink; + return TRUE; +} /* * Fence */ 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 5bf7d3fc4f1..47d2176cb42 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_device.h +++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.h @@ -44,6 +44,8 @@ intel_be_init_device(struct intel_be_device *device, int fd, unsigned id); struct intel_be_buffer { struct pipe_buffer base; drm_intel_bo *bo; + boolean flinked; + unsigned flink; }; /** @@ -60,9 +62,20 @@ intel_be_buffer_from_handle(struct pipe_screen *screen, * * If buffer is destroyed handle may become invalid. */ -unsigned +boolean intel_be_handle_from_buffer(struct pipe_screen *screen, - struct pipe_buffer *buffer); + struct pipe_buffer *buffer, + unsigned *handle); + +/** + * Gets the global handle from a buffer. + * + * If buffer is destroyed handle may become invalid. + */ +boolean +intel_be_global_handle_from_buffer(struct pipe_screen *screen, + struct pipe_buffer *buffer, + unsigned *handle); static INLINE struct intel_be_buffer * intel_be_buffer(struct pipe_buffer *buf) |