[vulkan] Make the tracy macros more robust

Now some of the hacks needed for GPU zones work without tracy being
enabled (ie, no compiler warnings about unused variables).
This commit is contained in:
Bill Currie 2023-12-07 14:50:58 +09:00
parent 800e984880
commit 03af3c5cc9
2 changed files with 17 additions and 8 deletions

View file

@ -419,9 +419,7 @@ typedef struct qfv_renderframe_s {
VkSemaphore imageAvailableSemaphore; VkSemaphore imageAvailableSemaphore;
VkSemaphore renderDoneSemaphore; VkSemaphore renderDoneSemaphore;
qfv_cmdpoolmgr_t cmdpool; qfv_cmdpoolmgr_t cmdpool;
#ifdef TRACY_ENABLE
qftVkCtx_t *qftVkCtx; qftVkCtx_t *qftVkCtx;
#endif
} qfv_renderframe_t; } qfv_renderframe_t;
typedef struct qfv_renderframeset_s typedef struct qfv_renderframeset_s

View file

@ -23,12 +23,19 @@ static inline void __qftVkZoneEnd (___tracy_vkctx_scope ***zone)
TracyCVkZoneEnd (**zone); TracyCVkZoneEnd (**zone);
} }
#define __qftVkScoped(varname) \
__attribute__((cleanup(__qftVkZoneEnd))) \
___tracy_vkctx_scope **qfConcat(__qfScoped##varname, __COUNTER__) \
= &varname;
#define qftVkZone(ctx, cmdbuf, name) TracyCVkZone (ctx, cmdbuf, name) #define qftVkZone(ctx, cmdbuf, name) TracyCVkZone (ctx, cmdbuf, name)
#define qftVkScopedZone(ctx, cmdbuf, name) \ #define qftVkScopedZone(ctx, cmdbuf, name) \
qftVkZone (ctx, cmdbuf, name) \ qftVkZone (ctx, cmdbuf, name) \
__attribute__((cleanup(__qftVkZoneEnd))) \ __qftVkScoped (___tracy_gpu_zone)
___tracy_vkctx_scope **qfConcat(__qfScoped##varname, __COUNTER__) = &___tracy_gpu_zone #define qftVkZoneC(ctx, cmdbuf, name, color) \
#define qftVkZoneC(ctx, cmdbuf, name, color) TracyCVkZone (ctx, cmdbuf, name, color) TracyCVkZoneC (ctx, cmdbuf, name, color)
#define qftVkScopedZoneC(ctx, cmdbuf, name, color) \
qftVkZoneC (ctx, cmdbuf, name, color) \
__qftVkScoped (___tracy_gpu_zone)
#define qftVkZoneEnd(varname) TracyCVkZoneEnd (varname) #define qftVkZoneEnd(varname) TracyCVkZoneEnd (varname)
#else #else
@ -40,9 +47,13 @@ static inline void __qftVkZoneEnd (___tracy_vkctx_scope ***zone)
#define qftCVkContextName(ctx, name, size) #define qftCVkContextName(ctx, name, size)
#define qftCVkContextCollect(ctx, cmdbuf) #define qftCVkContextCollect(ctx, cmdbuf)
#define qftVkZone(ctx, cmdbuf, name) #define qftVkZone(ctx, cmdbuf, name) \
#define qftVkScopedZone(ctx, cmdbuf, name) do { (void)(ctx); (void) (cmdbuf); } while (0)
#define qftVkZoneC(ctx, cmdbuf, name, color) #define qftVkScopedZone(ctx, cmdbuf, name) qftVkZone (ctx, cmdbuf, name)
#define qftVkZoneC(ctx, cmdbuf, name, color) \
do { (void)(ctx); (void)(cmdbuf); (void)(name); (void)(color);} while (0)
#define qftVkScopedZoneC(ctx, cmdbuf, name, color) \
qftVkZoneC (ctx, cmdbuf, name, color)
#define qftVkZoneEnd(varname) #define qftVkZoneEnd(varname)
#endif #endif