pipe_reference_init(&prsc->reference, 1);
prsc->screen = pscreen;
- rsc->bo = panfrost_drm_import_bo(screen, whandle);
+ rsc->bo = panfrost_drm_import_bo(screen, whandle->handle);
rsc->slices[0].stride = whandle->stride;
rsc->slices[0].initialized = true;
handle->handle = args.fd;
return TRUE;
- } else
- return panfrost_drm_export_bo(screen, rsrc->bo->gem_handle,
- rsrc->slices[0].stride,
- handle);
+ } else {
+ int fd = panfrost_drm_export_bo(screen, rsrc->bo);
+
+ if (fd < 0)
+ return FALSE;
+
+ handle->handle = fd;
+ handle->stride = rsrc->slices[0].stride;
+ return TRUE;
+ }
}
return FALSE;
unsigned width,
unsigned height)
{
- unsigned aligned_width = ALIGN(width, CHECKSUM_TILE_WIDTH);
- unsigned aligned_height = ALIGN(height, CHECKSUM_TILE_HEIGHT);
+ unsigned aligned_width = ALIGN_POT(width, CHECKSUM_TILE_WIDTH);
+ unsigned aligned_height = ALIGN_POT(height, CHECKSUM_TILE_HEIGHT);
unsigned tile_count_x = aligned_width / CHECKSUM_TILE_WIDTH;
unsigned tile_count_y = aligned_height / CHECKSUM_TILE_HEIGHT;
unsigned effective_depth = depth;
if (should_align) {
- effective_width = ALIGN(effective_width, 16);
- effective_height = ALIGN(effective_height, 16);
+ effective_width = ALIGN_POT(effective_width, 16);
+ effective_height = ALIGN_POT(effective_height, 16);
/* We don't need to align depth */
}
/* ..but cache-line align it for performance */
if (can_align_stride && pres->layout == PAN_LINEAR)
- stride = ALIGN(stride, 64);
+ stride = ALIGN_POT(stride, 64);
slice->stride = stride;
if (res->target != PIPE_TEXTURE_3D) {
/* Arrays and cubemaps have the entire miptree duplicated */
- pres->cubemap_stride = ALIGN(offset, 64);
- *bo_size = ALIGN(pres->cubemap_stride * res->array_size, 4096);
+ pres->cubemap_stride = ALIGN_POT(offset, 64);
+ *bo_size = ALIGN_POT(pres->cubemap_stride * res->array_size, 4096);
} else {
/* 3D strides across the 2D layers */
assert(res->array_size == 1);
pres->cubemap_stride = size_2d;
- *bo_size = ALIGN(offset, 4096);
+ *bo_size = ALIGN_POT(offset, 4096);
}
}
size_t bo_size;
panfrost_setup_slices(pres, &bo_size);
-
- struct panfrost_memory mem;
- struct panfrost_bo *bo = rzalloc(screen, struct panfrost_bo);
-
- pipe_reference_init(&bo->reference, 1);
- panfrost_drm_allocate_slab(screen, &mem, bo_size / 4096, true, 0, 0, 0);
-
- bo->cpu = mem.cpu;
- bo->gpu = mem.gpu;
- bo->gem_handle = mem.gem_handle;
- bo->size = bo_size;
- pres->bo = bo;
+ pres->bo = panfrost_drm_create_bo(screen, bo_size, 0);
}
static struct pipe_resource *
return (struct pipe_resource *)so;
}
-static void
-panfrost_destroy_bo(struct panfrost_screen *screen, struct panfrost_bo *bo)
-{
- struct panfrost_memory mem = {
- .cpu = bo->cpu,
- .gpu = bo->gpu,
- .size = bo->size,
- .gem_handle = bo->gem_handle,
- };
-
- panfrost_drm_free_slab(screen, &mem);
- ralloc_free(bo);
-}
-
void
panfrost_bo_reference(struct panfrost_bo *bo)
{
{
/* When the reference count goes to zero, we need to cleanup */
- if (pipe_reference(&bo->reference, NULL)) {
- panfrost_destroy_bo(pan_screen(screen), bo);
- }
+ if (pipe_reference(&bo->reference, NULL))
+ panfrost_drm_release_bo(pan_screen(screen), bo);
}
static void