if (bo->current_stream == stream) {
idx = bo->idx;
} else {
- /* slow-path: */
- for (idx = 0; idx < priv->nr_bos; idx++)
- if (priv->bos[idx] == bo)
- break;
- if (idx == priv->nr_bos) {
- /* not found */
+ void *val;
+
+ if (!priv->bo_table)
+ priv->bo_table = drmHashCreate();
+
+ if (!drmHashLookup(priv->bo_table, bo->handle, &val)) {
+ /* found */
+ idx = (uint32_t)(uintptr_t)val;
+ } else {
idx = append_bo(stream, bo);
+ val = (void *)(uintptr_t)idx;
+ drmHashInsert(priv->bo_table, bo->handle, val);
}
+
bo->current_stream = stream;
bo->idx = idx;
}
etna_bo_del(bo);
}
+ if (priv->bo_table) {
+ drmHashDestroy(priv->bo_table);
+ priv->bo_table = NULL;
+ }
+
if (out_fence_fd)
*out_fence_fd = req.fence_fd;
}