pvr: break out macros to separate header

Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37432>
This commit is contained in:
Erik Faye-Lund 2025-09-03 14:36:31 +02:00 committed by Marge Bot
parent a68d22b6ad
commit 93d00bdbc1
2 changed files with 64 additions and 46 deletions

View file

@ -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 <valgrind/valgrind.h>
# include <valgrind/memcheck.h>
# 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 */

View file

@ -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 <valgrind/valgrind.h>
# include <valgrind/memcheck.h>
# 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 */