From 51689a2b80b4daf5e78532304df311be8e627715 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 22 Feb 2022 11:30:05 -0500 Subject: [PATCH] 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 Reviewed-by: Simon Ser Reviewed-by: James Jones Acked-by: Daniel Stone Part-of: --- src/gallium/drivers/panfrost/pan_resource.c | 23 ++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 094332862ff..477bf1d7ce1 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -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