panfrost: Simplify panfrost_resource_get_handle

Unify the exit paths to clean up the logic. There are logically three modes we
support (KMS without renderonly, KMS with renderonly, and FD); these each
correspond to a leg of a small if statement. Outside of the small if's,
everything else should be identical.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: James Jones <jajones@nvidia.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15120>
This commit is contained in:
Alyssa Rosenzweig 2022-02-22 11:30:05 -05:00 committed by Marge Bot
parent b5734cc1c4
commit 51689a2b80
1 changed files with 9 additions and 14 deletions

View File

@ -153,17 +153,10 @@ panfrost_resource_get_handle(struct pipe_screen *pscreen,
handle->modifier = rsrc->image.layout.modifier;
rsrc->modifier_constant = true;
if (handle->type == WINSYS_HANDLE_TYPE_SHARED) {
return false;
if (handle->type == WINSYS_HANDLE_TYPE_KMS && dev->ro) {
return renderonly_get_handle(scanout, handle);
} else if (handle->type == WINSYS_HANDLE_TYPE_KMS) {
if (dev->ro) {
return renderonly_get_handle(scanout, handle);
} else {
handle->handle = rsrc->image.data.bo->gem_handle;
handle->stride = rsrc->image.layout.slices[0].line_stride;
handle->offset = rsrc->image.layout.slices[0].offset;
return true;
}
handle->handle = rsrc->image.data.bo->gem_handle;
} else if (handle->type == WINSYS_HANDLE_TYPE_FD) {
int fd = panfrost_bo_export(rsrc->image.data.bo);
@ -171,12 +164,14 @@ panfrost_resource_get_handle(struct pipe_screen *pscreen,
return false;
handle->handle = fd;
handle->stride = rsrc->image.layout.slices[0].line_stride;
handle->offset = rsrc->image.layout.slices[0].offset;
return true;
} else {
/* Other handle types not supported */
return false;
}
return false;
handle->stride = rsrc->image.layout.slices[0].line_stride;
handle->offset = rsrc->image.layout.slices[0].offset;
return true;
}
static bool