return FALSE;
}
- return rws->buffer_get_handle(tex->buf, tex->tex.stride_in_bytes[0],
+ return rws->buffer_get_handle(rws, tex->buf, tex->tex.stride_in_bytes[0],
0, 0, whandle);
}
res->external_usage = usage;
}
- return rscreen->ws->buffer_get_handle(res->buf, stride, offset,
- slice_size, whandle);
+ return rscreen->ws->buffer_get_handle(rscreen->ws, res->buf, stride,
+ offset, slice_size, whandle);
}
static void r600_texture_destroy(struct pipe_screen *screen,
* Get a winsys handle from a winsys buffer. The internal structure
* of the handle is platform-specific and only a winsys should access it.
*
+ * \param ws The winsys instance for which the handle is to be valid
* \param buf A winsys buffer object to get the handle from.
* \param whandle A winsys handle pointer.
* \param stride A stride of the buffer in bytes, for texturing.
* \return true on success.
*/
- bool (*buffer_get_handle)(struct pb_buffer *buf,
+ bool (*buffer_get_handle)(struct radeon_winsys *ws,
+ struct pb_buffer *buf,
unsigned stride, unsigned offset,
unsigned slice_size,
struct winsys_handle *whandle);
res->external_usage = usage;
}
- return sscreen->ws->buffer_get_handle(res->buf, stride, offset,
- slice_size, whandle);
+ return sscreen->ws->buffer_get_handle(sscreen->ws, res->buf, stride,
+ offset, slice_size, whandle);
}
static void si_texture_destroy(struct pipe_screen *screen,
return NULL;
}
-static bool amdgpu_bo_get_handle(struct pb_buffer *buffer,
+static bool amdgpu_bo_get_handle(struct radeon_winsys *rws,
+ struct pb_buffer *buffer,
unsigned stride, unsigned offset,
unsigned slice_size,
struct winsys_handle *whandle)
{
+ struct amdgpu_screen_winsys *sws = amdgpu_screen_winsys(rws);
struct amdgpu_winsys_bo *bo = amdgpu_winsys_bo(buffer);
struct amdgpu_winsys *ws = bo->ws;
enum amdgpu_bo_handle_type type;
case WINSYS_HANDLE_TYPE_SHARED:
type = amdgpu_bo_handle_type_gem_flink_name;
break;
+ case WINSYS_HANDLE_TYPE_KMS:
case WINSYS_HANDLE_TYPE_FD:
type = amdgpu_bo_handle_type_dma_buf_fd;
break;
- case WINSYS_HANDLE_TYPE_KMS:
- type = amdgpu_bo_handle_type_kms;
- break;
default:
return false;
}
if (r)
return false;
+ if (whandle->type == WINSYS_HANDLE_TYPE_KMS) {
+ int dma_fd = whandle->handle;
+
+ r = drmPrimeFDToHandle(sws->fd, dma_fd, &whandle->handle);
+ close(dma_fd);
+
+ if (r)
+ return false;
+ }
+
simple_mtx_lock(&ws->bo_export_table_lock);
util_hash_table_set(ws->bo_export_table, bo->bo, bo);
simple_mtx_unlock(&ws->bo_export_table_lock);
return NULL;
}
-static bool radeon_winsys_bo_get_handle(struct pb_buffer *buffer,
+static bool radeon_winsys_bo_get_handle(struct radeon_winsys *rws,
+ struct pb_buffer *buffer,
unsigned stride, unsigned offset,
unsigned slice_size,
struct winsys_handle *whandle)