yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1#ifndef GFX_FLAG_COMBINER_H 2#define GFX_FLAG_COMBINER_H 3 4#include "../../source/core/slang-list.h" 5 6namespace gfx 7{ 8 9/* A default set of flags that can be used for checking devices */ 10typedef uint32_t DeviceCheckFlags ; 11struct DeviceCheckFlag 12{ 13enum Enum :DeviceCheckFlags 14 { 15UseFullFeatureLevel = 0x1 ,//< If set will use full feature level (on dx this is 16// D3D_FEATURE_LEVEL_11_1 else will try D3D_FEATURE_LEVEL_11_0) 17UseHardwareDevice = 0x2 ,//< If set will try a hardware device 18UseDebug = 0x4 ,//< If set will enable use of debug 19 }; 20}; 21 22/* Controls how and the order flags are changed, on the FlagCombiner */ 23enum class ChangeType 24{ 25On ,///< Always on 26Off ,///< Always off 27OnOff ,///< Initially on then off 28OffOn ,///< Initially off then on 29}; 30 31/* Calculates all the combinations of flags as controlled by the change types. 32 33The order of adding flags can be considered to be like a nested loop 34for (first added) { 35for (second added) 36{ 37///.. 38} 39} 40 41So the last added flags will have the highest frequency. 42*/ 43class FlagCombiner 44{ 45public : 46/// Add a flag and how it changes over the combinations 47/// NOTE! That the order flags are added controls the order they change when combinations are 48/// calculated - earlier added flags will change with the highest frequency 49void add (uint32_t flags ,ChangeType changeType ); 50/// Calculate all of the combinations and place in an array 51void calcCombinations (Slang ::List < uint32_t >& outCombinations )const ; 52 53/// Reset back to initial state 54void reset (); 55 56/// Get the total amount of combinations 57int getNumCombinations ()const {return 1 <<m_numChangingBits ; } 58 59/// Get the combination at i 60uint32_t getCombination (int i )const ; 61 62protected : 63uint32_t m_changingBits [32 ]; 64int m_numChangingBits = 0 ; 65 66uint32_t m_usedFlags = 0 ; 67uint32_t m_invertBits = 0 ; 68}; 69 70}// namespace gfx 71 72#endif // GFX_FLAG_COMBINER_H