isl: make isl_surf_get_uncompressed_surf robust to argument accesses

Since the input & output arguments can point to the same location in
memory, if you ever access the input after writing the output you're
in trouble.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23620>
This commit is contained in:
Lionel Landwerlin
2023-08-29 11:54:47 +03:00
committed by Marge Bot
parent 988fa2006a
commit 866af3d8fa

View File

@@ -3462,14 +3462,17 @@ isl_surf_get_image_surf(const struct isl_device *dev,
bool
isl_surf_get_uncompressed_surf(const struct isl_device *dev,
const struct isl_surf *surf,
const struct isl_view *view,
const struct isl_surf *_surf,
const struct isl_view *_view,
struct isl_surf *ucompr_surf,
struct isl_view *ucompr_view,
uint64_t *offset_B,
uint32_t *x_offset_el,
uint32_t *y_offset_el)
{
/* Input and output pointers may be the same, save the input contents now. */
const struct isl_surf __surf = *_surf, *surf = &__surf;
const struct isl_view __view = *_view, *view = &__view;
const struct isl_format_layout *fmtl =
isl_format_get_layout(surf->format);
const enum isl_format view_format = view->format;