/*---------------------------------------------------------------------------* Copyright (C) Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ // // shaderUtils optimization defines // #ifndef OPTFLAGS_HEADER_ #define OPTFLAGS_HEADER_ #if defined(__cplusplus) extern "C" { #endif /// \brief Optimization flag settings for optimizeFlags (only if options.optFlagsPresent is 1). /// Note that optimization flags are bit numbers, and have to be converted to bit masks vish GSH2_OPTMASK(). /// For example, to set optimizeFlags to do -Ofastmath and -Oloopvar, we would set: /// optimizeFlags = GSH2_OPTMASK(GSH2_OPTFLAG_FASTMATH) | GSH2_OPTMASK(GSH2_OPTFLAG_LOOPVAR) enum GSH2OptimizeFlags { GSH2_OPTFLAG_SC = 0, ///< enable AMD specific Shader Compiler optimizations GSH2_OPTFLAG_FASTMATH = 1, ///< enable optimizations that may violate IEEE floating point guarantees GSH2_OPTFLAG_LOOPVAR = 2, ///< enable optimizations to find loop initialization GSH2_OPTFLAG_CONST = 3, ///< enable constant propagation GSH2_OPTFLAG_LOOPEXPR = 4, ///< enable unrolling loops containing complex expressions GSH2_OPTFLAG_UNUSEDVAR = 5, ///< enable removing unused variables GSH2_OPTFLAG_LIMITARRAYSYMS = 6, ///< do not emit more than 2 symbols for array elements (size optimization) GSH2_OPTFLAG_GLSL = 7, ///< run first glsl to glsl optimization pass }; /// \brief Convert a flag into a bit mask. #define GSH2_OPTMASK(bit) (((uint64)1)<glsl optimization pass to remove unused code and variables", GSH2_OPTMASK(GSH2_OPTFLAG_GLSL) }, \ { "all", "enable all optimizations", GSH2_OPTFLAGS_ALL }, \ { "none", NULL, 0 }, \ { NULL, NULL, 0 } // Some defines that are for optimizing the compiler itself, rather than the generated code, // but it's convenient to put them in this header because the optimize passes include this. /// \brief Shader compiler passes that we instrument for time taken #define GSH2_BT_UNKNOWN 0 ///< Time in an unknown part of code #define GSH2_BT_INIT 1 ///< General initialization time #define GSH2_BT_GLSLOPT 2 ///< GLSL Optimizer #define GSH2_BT_PARSER 3 ///< Construct parse tree #define GSH2_BT_CONVERTIL 4 ///< Convert to IL #define GSH2_BT_OPTIMIZEIL 5 ///< IL Optimization (-Oxxx flags) #define GSH2_BT_LINKSYM 6 ///< Link symbols #define GSH2_BT_PATCHIL 7 ///< IL patcher #define GSH2_BT_AMDSC 8 ///< AMD Shader Compiler (IL to ISA) #define GSH2_BT_FINALOUT 9 ///< Final GFD file output #define GSH2_BT_MISC 10 ///< Everything else #define GSH2_BT_SYMTABINIT 11 ///< Symbol table initialization #define GSH2_BT_FUNCINIT 12 ///< Function initialization #define GSH2_BT_USEDITEMS 13 ///< Number of build time options currently used // reserve some space here for new items #define GSH2_BT_NUMITEMS 24 ///< total size of build time statistics array /// \brief Initialize build time tracking system void InitBuildTimes(void); /// \brief Set which build time item the current code should be charged against void SetCurrentBuildTime(int gsh2_bt_index); /// \brief Get values for build time items /// Retrieve the time taken for the various compiler phases (as given by the GSH2_BT_XXX flags) /// into the results array. The values returned are milliseconds. resultcount is the number /// of elements in the results array. void GetBuildTimes(double *results, int resultcount); #if defined(__cplusplus) } #endif #endif