From 93d00bdbc1d5e0186654110a110458702841c40e Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 3 Sep 2025 14:36:31 +0200 Subject: [PATCH] pvr: break out macros to separate header Reviewed-by: Frank Binns Part-of: --- src/imagination/vulkan/pvr_macros.h | 63 ++++++++++++++++++++++++++++ src/imagination/vulkan/pvr_private.h | 47 +-------------------- 2 files changed, 64 insertions(+), 46 deletions(-) create mode 100644 src/imagination/vulkan/pvr_macros.h diff --git a/src/imagination/vulkan/pvr_macros.h b/src/imagination/vulkan/pvr_macros.h new file mode 100644 index 00000000000..7376d344c0e --- /dev/null +++ b/src/imagination/vulkan/pvr_macros.h @@ -0,0 +1,63 @@ +/* + * Copyright © 2022 Imagination Technologies Ltd. + * + * based in part on anv driver which is: + * Copyright © 2015 Intel Corporation + * + * based in part on radv driver which is: + * Copyright © 2016 Red Hat. + * Copyright © 2016 Bas Nieuwenhuizen + * + * SPDX-License-Identifier: MIT + */ + +#ifndef PVR_MACROS_H +#define PVR_MACROS_H + +#ifdef HAVE_VALGRIND +# include +# include +# define VG(x) x +#else +# define VG(x) ((void)0) +#endif + +/** + * Print a FINISHME message, including its source location. + */ +#define pvr_finishme(format, ...) \ + do { \ + static bool reported = false; \ + if (!reported) { \ + mesa_logw("%s:%d: FINISHME: " format, \ + __FILE__, \ + __LINE__, \ + ##__VA_ARGS__); \ + reported = true; \ + } \ + } while (false) + +#define PVR_WRITE(_buffer, _value, _offset, _max) \ + do { \ + __typeof__(_value) __value = _value; \ + uint64_t __offset = _offset; \ + uint32_t __nr_dwords = sizeof(__value) / sizeof(uint32_t); \ + static_assert(__same_type(*_buffer, __value), \ + "Buffer and value type mismatch"); \ + assert((__offset + __nr_dwords) <= (_max)); \ + assert((__offset % __nr_dwords) == 0U); \ + _buffer[__offset / __nr_dwords] = __value; \ + } while (0) + +/* A non-fatal assert. Useful for debugging. */ +#if MESA_DEBUG +# define pvr_assert(x) \ + ({ \ + if (unlikely(!(x))) \ + mesa_loge("%s:%d ASSERT: %s", __FILE__, __LINE__, #x); \ + }) +#else +# define pvr_assert(x) +#endif + +#endif /* PVR_MACROS_H */ diff --git a/src/imagination/vulkan/pvr_private.h b/src/imagination/vulkan/pvr_private.h index dbb13458388..26dd0fb388c 100644 --- a/src/imagination/vulkan/pvr_private.h +++ b/src/imagination/vulkan/pvr_private.h @@ -50,6 +50,7 @@ #include "pvr_hw_pass.h" #include "pvr_job_render.h" #include "pvr_limits.h" +#include "pvr_macros.h" #include "pvr_pds.h" #include "pvr_usc.h" #include "pvr_spm.h" @@ -68,50 +69,4 @@ #include "vk_sync.h" #include "wsi_common.h" -#ifdef HAVE_VALGRIND -# include -# include -# define VG(x) x -#else -# define VG(x) ((void)0) -#endif - -/** - * Print a FINISHME message, including its source location. - */ -#define pvr_finishme(format, ...) \ - do { \ - static bool reported = false; \ - if (!reported) { \ - mesa_logw("%s:%d: FINISHME: " format, \ - __FILE__, \ - __LINE__, \ - ##__VA_ARGS__); \ - reported = true; \ - } \ - } while (false) - -#define PVR_WRITE(_buffer, _value, _offset, _max) \ - do { \ - __typeof__(_value) __value = _value; \ - uint64_t __offset = _offset; \ - uint32_t __nr_dwords = sizeof(__value) / sizeof(uint32_t); \ - static_assert(__same_type(*_buffer, __value), \ - "Buffer and value type mismatch"); \ - assert((__offset + __nr_dwords) <= (_max)); \ - assert((__offset % __nr_dwords) == 0U); \ - _buffer[__offset / __nr_dwords] = __value; \ - } while (0) - -/* A non-fatal assert. Useful for debugging. */ -#if MESA_DEBUG -# define pvr_assert(x) \ - ({ \ - if (unlikely(!(x))) \ - mesa_loge("%s:%d ASSERT: %s", __FILE__, __LINE__, #x); \ - }) -#else -# define pvr_assert(x) -#endif - #endif /* PVR_PRIVATE_H */