Revert "minigbm: introduce test allocation"
This reverts commit f0e607c7d4.
Reason for revert: caused flaky regressions across the board.
BUG=b:150997559
Exempt-From-Owner-Approval: revert.
Original change's description:
> minigbm: introduce test allocation
>
> This change introduces a GBM_TEST_ALLOC flag to minigbm, which allows
> for the creation of fake buffers that can be used to determine buffer
> metadata without actually allocating a full buffer. The new flag is
> supported by the i915 backends. This flag also alleviates the need to
> cache buffers when virtio_gpu queries metadata properties.
>
> BUG=b:145994510
> TEST=play youtube with arcvm demo image plus this and virgl change
>
> Change-Id: I9c6819aa3b5b674e4bb33b0656f2a9f155b0884e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1980688
> Tested-by: David Stevens <stevensd@chromium.org>
> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
> Commit-Queue: David Stevens <stevensd@chromium.org>
Bug: b:145994510
Change-Id: I50079b7f0aabf38e1f373cac0f28c0e057eed760
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2093923
Commit-Queue: Ilja H. Friedel <ihf@chromium.org>
Tested-by: Ilja H. Friedel <ihf@chromium.org>
Reviewed-by: Ilja H. Friedel <ihf@chromium.org>
This commit is contained in:
parent
c5352e6b36
commit
08d8dbf094
5 changed files with 58 additions and 119 deletions
89
drv.c
89
drv.c
|
|
@ -114,21 +114,11 @@ static const struct backend *drv_get_backend(int fd)
|
|||
&backend_vgem, &backend_virtio_gpu,
|
||||
};
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(backend_list); i++) {
|
||||
const struct backend *b = backend_list[i];
|
||||
// Exactly one of the main create functions must be defined.
|
||||
assert((b->bo_create != NULL) ^ (b->bo_create_from_metadata != NULL));
|
||||
// Either both or neither must be implemented.
|
||||
assert((b->bo_compute_metadata != NULL) == (b->bo_create_from_metadata != NULL));
|
||||
// Both can't be defined, but it's okay for neither to be (i.e. only bo_create).
|
||||
assert((b->bo_create_with_modifiers == NULL) ||
|
||||
(b->bo_create_from_metadata == NULL));
|
||||
|
||||
if (!strcmp(drm_version->name, b->name)) {
|
||||
for (i = 0; i < ARRAY_SIZE(backend_list); i++)
|
||||
if (!strcmp(drm_version->name, backend_list[i]->name)) {
|
||||
drmFreeVersion(drm_version);
|
||||
return b;
|
||||
return backend_list[i];
|
||||
}
|
||||
}
|
||||
|
||||
drmFreeVersion(drm_version);
|
||||
return NULL;
|
||||
|
|
@ -233,7 +223,7 @@ struct combination *drv_get_combination(struct driver *drv, uint32_t format, uin
|
|||
}
|
||||
|
||||
struct bo *drv_bo_new(struct driver *drv, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t use_flags, bool is_test_buffer)
|
||||
uint64_t use_flags)
|
||||
{
|
||||
|
||||
struct bo *bo;
|
||||
|
|
@ -248,7 +238,6 @@ struct bo *drv_bo_new(struct driver *drv, uint32_t width, uint32_t height, uint3
|
|||
bo->meta.format = format;
|
||||
bo->meta.use_flags = use_flags;
|
||||
bo->meta.num_planes = drv_num_planes_from_format(format);
|
||||
bo->is_test_buffer = is_test_buffer;
|
||||
|
||||
if (!bo->meta.num_planes) {
|
||||
free(bo);
|
||||
|
|
@ -264,28 +253,13 @@ struct bo *drv_bo_create(struct driver *drv, uint32_t width, uint32_t height, ui
|
|||
int ret;
|
||||
size_t plane;
|
||||
struct bo *bo;
|
||||
bool is_test_alloc;
|
||||
|
||||
is_test_alloc = use_flags & BO_USE_TEST_ALLOC;
|
||||
use_flags &= ~BO_USE_TEST_ALLOC;
|
||||
|
||||
bo = drv_bo_new(drv, width, height, format, use_flags, is_test_alloc);
|
||||
bo = drv_bo_new(drv, width, height, format, use_flags);
|
||||
|
||||
if (!bo)
|
||||
return NULL;
|
||||
|
||||
ret = -EINVAL;
|
||||
if (drv->backend->bo_compute_metadata) {
|
||||
ret = drv->backend->bo_compute_metadata(bo, width, height, format, use_flags, NULL,
|
||||
0);
|
||||
if (!is_test_alloc && ret == 0) {
|
||||
ret = drv->backend->bo_create_from_metadata(bo);
|
||||
if (ret == 0)
|
||||
return bo;
|
||||
}
|
||||
} else if (!is_test_alloc) {
|
||||
ret = drv->backend->bo_create(bo, width, height, format, use_flags);
|
||||
}
|
||||
ret = drv->backend->bo_create(bo, width, height, format, use_flags);
|
||||
|
||||
if (ret) {
|
||||
free(bo);
|
||||
|
|
@ -313,26 +287,17 @@ struct bo *drv_bo_create_with_modifiers(struct driver *drv, uint32_t width, uint
|
|||
size_t plane;
|
||||
struct bo *bo;
|
||||
|
||||
if (!drv->backend->bo_create_with_modifiers && !drv->backend->bo_compute_metadata) {
|
||||
if (!drv->backend->bo_create_with_modifiers) {
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bo = drv_bo_new(drv, width, height, format, BO_USE_NONE, false);
|
||||
bo = drv_bo_new(drv, width, height, format, BO_USE_NONE);
|
||||
|
||||
if (!bo)
|
||||
return NULL;
|
||||
|
||||
ret = -EINVAL;
|
||||
if (drv->backend->bo_compute_metadata) {
|
||||
ret = drv->backend->bo_compute_metadata(bo, width, height, format, BO_USE_NONE,
|
||||
modifiers, count);
|
||||
if (ret == 0)
|
||||
ret = drv->backend->bo_create_from_metadata(bo);
|
||||
} else {
|
||||
ret = drv->backend->bo_create_with_modifiers(bo, width, height, format, modifiers,
|
||||
count);
|
||||
}
|
||||
ret = drv->backend->bo_create_with_modifiers(bo, width, height, format, modifiers, count);
|
||||
|
||||
if (ret) {
|
||||
free(bo);
|
||||
|
|
@ -360,22 +325,20 @@ void drv_bo_destroy(struct bo *bo)
|
|||
uintptr_t total = 0;
|
||||
struct driver *drv = bo->drv;
|
||||
|
||||
if (!bo->is_test_buffer) {
|
||||
pthread_mutex_lock(&drv->driver_lock);
|
||||
pthread_mutex_lock(&drv->driver_lock);
|
||||
|
||||
for (plane = 0; plane < bo->meta.num_planes; plane++)
|
||||
drv_decrement_reference_count(drv, bo, plane);
|
||||
for (plane = 0; plane < bo->meta.num_planes; plane++)
|
||||
drv_decrement_reference_count(drv, bo, plane);
|
||||
|
||||
for (plane = 0; plane < bo->meta.num_planes; plane++)
|
||||
total += drv_get_reference_count(drv, bo, plane);
|
||||
for (plane = 0; plane < bo->meta.num_planes; plane++)
|
||||
total += drv_get_reference_count(drv, bo, plane);
|
||||
|
||||
pthread_mutex_unlock(&drv->driver_lock);
|
||||
pthread_mutex_unlock(&drv->driver_lock);
|
||||
|
||||
if (total == 0) {
|
||||
ret = drv_mapping_destroy(bo);
|
||||
assert(ret == 0);
|
||||
bo->drv->backend->bo_destroy(bo);
|
||||
}
|
||||
if (total == 0) {
|
||||
ret = drv_mapping_destroy(bo);
|
||||
assert(ret == 0);
|
||||
bo->drv->backend->bo_destroy(bo);
|
||||
}
|
||||
|
||||
free(bo);
|
||||
|
|
@ -388,7 +351,7 @@ struct bo *drv_bo_import(struct driver *drv, struct drv_import_fd_data *data)
|
|||
struct bo *bo;
|
||||
off_t seek_end;
|
||||
|
||||
bo = drv_bo_new(drv, data->width, data->height, data->format, data->use_flags, false);
|
||||
bo = drv_bo_new(drv, data->width, data->height, data->format, data->use_flags);
|
||||
|
||||
if (!bo)
|
||||
return NULL;
|
||||
|
|
@ -452,10 +415,6 @@ void *drv_bo_map(struct bo *bo, const struct rectangle *rect, uint32_t map_flags
|
|||
/* No CPU access for protected buffers. */
|
||||
assert(!(bo->meta.use_flags & BO_USE_PROTECTED));
|
||||
|
||||
if (bo->is_test_buffer) {
|
||||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
memset(&mapping, 0, sizeof(mapping));
|
||||
mapping.rect = *rect;
|
||||
mapping.refcount = 1;
|
||||
|
|
@ -603,10 +562,6 @@ int drv_bo_get_plane_fd(struct bo *bo, size_t plane)
|
|||
int ret, fd;
|
||||
assert(plane < bo->meta.num_planes);
|
||||
|
||||
if (bo->is_test_buffer) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = drmPrimeHandleToFD(bo->drv->fd, bo->handles[plane].u32, DRM_CLOEXEC | DRM_RDWR, &fd);
|
||||
|
||||
// Older DRM implementations blocked DRM_RDWR, but gave a read/write mapping anyways
|
||||
|
|
@ -658,10 +613,6 @@ uint32_t drv_num_buffers_per_bo(struct bo *bo)
|
|||
uint32_t count = 0;
|
||||
size_t plane, p;
|
||||
|
||||
if (bo->is_test_buffer) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (plane = 0; plane < bo->meta.num_planes; plane++) {
|
||||
for (p = 0; p < plane; p++)
|
||||
if (bo->handles[p].u32 == bo->handles[plane].u32)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue