minigbm: dri: Set the plane sizes on bo creation.
I cut a corner here on a previous patch and apparently it is used. Since DRI does not give us useful horizontal & vertical strides (especially considering things like auxiliary surfaces), do this calculation based on offsets & buffer strides. BUG=1061315 TEST=test_that graphics_Gbm on Zork. Change-Id: Idbca7ce42f4f8a692129a2f8ab5d9c3ccd796496 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2100795 Tested-by: Bas Nieuwenhuizen <basni@chromium.org> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Commit-Queue: Ilja H. Friedel <ihf@chromium.org>
This commit is contained in:
parent
cfcea2f165
commit
912c4c33a9
1 changed files with 26 additions and 5 deletions
31
dri.c
31
dri.c
|
|
@ -87,6 +87,7 @@ static int import_into_minigbm(struct dri_driver *dri, struct bo *bo)
|
|||
{
|
||||
uint32_t handle;
|
||||
int ret, modifier_upper, modifier_lower, num_planes, i, j;
|
||||
off_t dmabuf_sizes[DRV_MAX_PLANES];
|
||||
__DRIimage *plane_image = NULL;
|
||||
|
||||
if (dri->image_extension->queryImage(bo->priv, __DRI_IMAGE_ATTRIB_MODIFIER_UPPER,
|
||||
|
|
@ -125,6 +126,15 @@ static int import_into_minigbm(struct dri_driver *dri, struct bo *bo)
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
dmabuf_sizes[i] = lseek(prime_fd, 0, SEEK_END);
|
||||
if (dmabuf_sizes[i] == (off_t)-1) {
|
||||
ret = -errno;
|
||||
close(prime_fd);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
lseek(prime_fd, 0, SEEK_SET);
|
||||
|
||||
ret = drmPrimeFDToHandle(bo->drv->fd, prime_fd, &handle);
|
||||
|
||||
close(prime_fd);
|
||||
|
|
@ -139,15 +149,26 @@ static int import_into_minigbm(struct dri_driver *dri, struct bo *bo)
|
|||
bo->meta.strides[i] = stride;
|
||||
bo->meta.offsets[i] = offset;
|
||||
|
||||
/* Not setting sizes[i] and total_size as these are not
|
||||
* provided by DRI. The best way to "approximate" would be
|
||||
* what drv_bo_import does, but I see nothing in the minigbm
|
||||
* core that needs it. */
|
||||
|
||||
if (plane_image)
|
||||
dri->image_extension->destroyImage(plane_image);
|
||||
}
|
||||
|
||||
for (i = 0; i < num_planes; ++i) {
|
||||
off_t next_plane = dmabuf_sizes[i];
|
||||
for (j = 0; j < num_planes; ++j) {
|
||||
if (bo->meta.offsets[j] < next_plane &&
|
||||
bo->meta.offsets[j] > bo->meta.offsets[i] &&
|
||||
bo->handles[j].u32 == bo->handles[i].u32)
|
||||
next_plane = bo->meta.offsets[j];
|
||||
}
|
||||
|
||||
bo->meta.sizes[i] = next_plane - bo->meta.offsets[i];
|
||||
|
||||
/* This is kind of misleading if different planes use
|
||||
different dmabufs. */
|
||||
bo->meta.total_size += bo->meta.sizes[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue