// This file is part of the FidelityFX SDK.1//2// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.3//4// Permission is hereby granted, free of charge, to any person obtaining a copy5// of this software and associated documentation files (the "Software"), to deal6// in the Software without restriction, including without limitation the rights7// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell8// copies of the Software, and to permit persons to whom the Software is9// furnished to do so, subject to the following conditions:10// The above copyright notice and this permission notice shall be included in11// all copies or substantial portions of the Software.12//13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN19// THE SOFTWARE.2021#pragma once2223#include "ffx_types.h"24#include "ffx_util.h"2526#ifdef __cplusplus27extern "C" {28#endif // #ifdef __cplusplus2930#ifdef _DEBUG31#ifdef _WIN323233#ifdef DISABLE_FFX_DEBUG_BREAK34#define FFX_DEBUG_BREAK \35{ \36}37#else38/// Macro to force the debugger to break at this point in the code.39#define FFX_DEBUG_BREAK __debugbreak();40#endif41#else42#define FFX_DEBUG_BREAK \43{ \44}45#endif46#else47// don't allow debug break in release builds.48#define FFX_DEBUG_BREAK49#endif5051/// A typedef for the callback function for assert printing.52///53/// This can be used to re-route printing of assert messages from the FFX backend54/// to another destination. For example instead of the default behaviour of printing55/// the assert messages to the debugger's TTY the message can be re-routed to a56/// MessageBox in a GUI application.57///58/// @param [in] message The message generated by the assert.59///60typedef void (*FfxAssertCallback)(const char* message);6162/// Function to report an assert.63///64/// @param [in] file The name of the file as a string.65/// @param [in] line The index of the line in the file.66/// @param [in] condition The boolean condition that was tested.67/// @param [in] msg The optional message to print.68///69/// @returns70/// Always returns true.71///72FFX_API bool ffxAssertReport(const char* file, int32_t line, const char* condition, const char* msg);7374/// Provides the ability to set a callback for assert messages.75///76/// @param [in] callback The callback function that will receive assert messages.77///78FFX_API void ffxAssertSetPrintingCallback(FfxAssertCallback callback);7980#ifdef _DEBUG81/// Standard assert macro.82#define FFX_ASSERT(condition) \83do \84{ \85if (!(condition) && ffxAssertReport(__FILE__, __LINE__, #condition, NULL)) \86FFX_DEBUG_BREAK \87} while (0)8889/// Assert macro with message.90#define FFX_ASSERT_MESSAGE(condition, msg) \91do \92{ \93if (!(condition) && ffxAssertReport(__FILE__, __LINE__, #condition, msg)) \94FFX_DEBUG_BREAK \95} while (0)9697/// Assert macro that always fails.98#define FFX_ASSERT_FAIL(message) \99do \100{ \101ffxAssertReport(__FILE__, __LINE__, NULL, message); \102FFX_DEBUG_BREAK \103} while (0)104#else105// asserts disabled106#define FFX_ASSERT(condition) \107do \108{ \109FFX_UNUSED(condition); \110} while (0)111112#define FFX_ASSERT_MESSAGE(condition, message) \113do \114{ \115FFX_UNUSED(condition); \116FFX_UNUSED(message); \117} while (0)118119#define FFX_ASSERT_FAIL(message) \120do \121{ \122FFX_UNUSED(message); \123} while (0)124#endif // #if _DEBUG125126/// Simple static assert.127#define FFX_STATIC_ASSERT(condition) static_assert(condition, #condition)128129#ifdef __cplusplus130}131#endif // #ifdef __cplusplus132133134