1 /*---------------------------------------------------------------------------* 2 3 Copyright 2013 Nintendo. All rights reserved. 4 5 These coded instructions, statements, and computer programs contain 6 proprietary information of Nintendo of America Inc. and/or Nintendo 7 Company Ltd., and are protected by Federal copyright law. They may 8 not be disclosed to third parties or copied or duplicated in any form, 9 in whole or in part, without the prior written consent of Nintendo. 10 11 *---------------------------------------------------------------------------*/ 12 13 // 14 // shaderUtils optimization defines 15 // 16 17 #ifndef OPTFLAGS_HEADER_ 18 #define OPTFLAGS_HEADER_ 19 20 #if defined(__cplusplus) 21 extern "C" { 22 #endif 23 24 25 /// \brief Optimization flag settings for optimizeFlags (only if options.optFlagsPresent is 1). 26 27 /// Note that optimization flags are bit numbers, and have to be converted to bit masks vish GSH2_OPTMASK(). 28 /// For example, to set optimizeFlags to do -Ofastmath and -Oloopvar, we would set: 29 /// optimizeFlags = GSH2_OPTMASK(GSH2_OPTFLAG_FASTMATH) | GSH2_OPTMASK(GSH2_OPTFLAG_LOOPVAR) 30 31 enum GSH2OptimizeFlags 32 { 33 GSH2_OPTFLAG_SC = 0, ///< enable AMD specific Shader Compiler optimizations 34 GSH2_OPTFLAG_FASTMATH = 1, ///< enable optimizations that may violate IEEE floating point guarantees 35 GSH2_OPTFLAG_LOOPVAR = 2, ///< enable optimizations to find loop initialization 36 GSH2_OPTFLAG_CONST = 3, ///< enable constant propagation 37 GSH2_OPTFLAG_LOOPEXPR = 4, ///< enable unrolling loops containing complex expressions 38 GSH2_OPTFLAG_UNUSEDVAR = 5, ///< enable removing unused variables 39 GSH2_OPTFLAG_LIMITARRAYSYMS = 6, ///< do not emit more than 2 symbols for array elements (size optimization) 40 GSH2_OPTFLAG_GLSL = 7, ///< run first glsl to glsl optimization pass 41 }; 42 43 /// \brief Convert a flag into a bit mask. 44 #define GSH2_OPTMASK(bit) (((uint64)1)<<bit) 45 46 /// \brief defines for manipulating optimization flag sets (which are 64 bits) 47 48 /// Check to see if a flag is set. 49 #define GSH2_OPTFLAG_ISSET(flags, bit) (0 != ((flags) & GSH2_OPTMASK(bit))) 50 /// Set a specific flag in a mask. 51 #define GSH2_OPTFLAG_SETBIT(flags, bit) (flags |= GSH2_OPTMASK(bit)) 52 /// Clear a specific flag in a mask. 53 #define GSH2_OPTFLAG_CLRBIT(flags, bit) (flags &= ~GSH2_OPTMASK(bit)) 54 55 /// Mask representing all (non-experimental) flags; what we get from -Oall 56 #define GSH2_OPTFLAGS_ALL ( ((uint64)-1) & ~(GSH2_OPTMASK(GSH2_OPTFLAG_LIMITARRAYSYMS)|GSH2_OPTMASK(GSH2_OPTFLAG_GLSL)) ) 57 /// Mask representing no flags. 58 #define GSH2_OPTFLAGS_NONE ((uint64)0) 59 60 /// structure giving standard names for the flags 61 #define OFLAGDEF_CONTENTS \ 62 { "1", NULL, GSH2_OPTFLAGS_ALL }, \ 63 { "0", NULL, 0 }, \ 64 { "const", "additional constant propagation optimizations", GSH2_OPTMASK(GSH2_OPTFLAG_CONST) }, \ 65 { "fastmath", "enable optimizations that may violate strict IEEE semantics", GSH2_OPTMASK(GSH2_OPTFLAG_FASTMATH) }, \ 66 { "loopexpr", "allow unrolling of loops with complex expressions", GSH2_OPTMASK(GSH2_OPTFLAG_LOOPEXPR) }, \ 67 { "loopvar", "analyze variables to find loop variable initialization", GSH2_OPTMASK(GSH2_OPTFLAG_LOOPVAR) }, \ 68 { "sc", "enable AMD shader compiler optimizations", GSH2_OPTMASK(GSH2_OPTFLAG_SC) }, \ 69 { "unusedvar", "remove assignments to variables that are never used", GSH2_OPTMASK(GSH2_OPTFLAG_UNUSEDVAR) }, \ 70 { "glsl", "run an initial glsl->glsl optimization pass to remove unused code and variables", GSH2_OPTMASK(GSH2_OPTFLAG_GLSL) }, \ 71 { "all", "enable all optimizations", GSH2_OPTFLAGS_ALL }, \ 72 { "none", NULL, 0 }, \ 73 { NULL, NULL, 0 } 74 75 #if defined(__cplusplus) 76 } 77 #endif 78 79 #endif 80