Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

457 lines
20 KiB

  1. //========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef CSHADER_H
  8. #define CSHADER_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. // uncomment this if you want to build for nv3x
  13. //#define NV3X 1
  14. // This is what all shaders include.
  15. // CBaseShader will become CShader in this file.
  16. #include "materialsystem/ishaderapi.h"
  17. #include "utlvector.h"
  18. #include "materialsystem/imaterialvar.h"
  19. #include "materialsystem/imaterial.h"
  20. #include "BaseShader.h"
  21. #include "shaderlib/shadercombosemantics.h"
  22. #include "materialsystem/itexture.h"
  23. // Included for convenience because they are used in a bunch of shaders
  24. #include "materialsystem/imesh.h"
  25. #include "materialsystem/imaterialsystemhardwareconfig.h"
  26. #include "materialsystem/materialsystem_config.h"
  27. #include "shaderlib/ShaderDLL.h"
  28. // make "local variable is initialized but not referenced" warnings errors for combo checking macros
  29. #pragma warning ( error : 4189 )
  30. //-----------------------------------------------------------------------------
  31. // Global interfaces
  32. //-----------------------------------------------------------------------------
  33. #if defined( _PS3 ) || defined( _OSX )
  34. #include "shaderapidx9/hardwareconfig.h"
  35. #else
  36. extern IMaterialSystemHardwareConfig *g_pHardwareConfig;
  37. #endif
  38. extern const MaterialSystem_Config_t *g_pConfig;
  39. extern bool g_shaderConfigDumpEnable;
  40. // Helper method
  41. bool IsUsingGraphics();
  42. #define SOFTWARE_VERTEX_SHADER(name) \
  43. static void SoftwareVertexShader_ ## name( CMeshBuilder &meshBuilder, IMaterialVar **params, IShaderDynamicAPI* pShaderAPI )
  44. #define FORWARD_DECLARE_SOFTWARE_VERTEX_SHADER(name)\
  45. static void SoftwareVertexShader_ ## name( CMeshBuilder &meshBuilder, IMaterialVar **params, IShaderDynamicAPI* pShaderAPI );
  46. #define USE_SOFTWARE_VERTEX_SHADER(name) \
  47. m_SoftwareVertexShader = SoftwareVertexShader_ ## name
  48. #define SHADER_INIT_PARAMS() \
  49. virtual void OnInitShaderParams( IMaterialVar **params, const char *pMaterialName )
  50. #define SHADER_FALLBACK \
  51. virtual char const* GetFallbackShader( IMaterialVar** params ) const
  52. // Typesafe flag setting
  53. inline void CShader_SetFlags( IMaterialVar **params, MaterialVarFlags_t _flag )
  54. {
  55. params[FLAGS]->SetIntValue( params[FLAGS]->GetIntValue() | (_flag) );
  56. }
  57. inline bool CShader_IsFlagSet( IMaterialVar **params, MaterialVarFlags_t _flag )
  58. {
  59. return ((params[FLAGS]->GetIntValue() & (_flag) ) != 0);
  60. }
  61. #define SET_FLAGS( _flag ) CShader_SetFlags( params, _flag )
  62. #define CLEAR_FLAGS( _flag ) params[FLAGS]->SetIntValue( params[FLAGS]->GetIntValue() & ~(_flag) )
  63. #define IS_FLAG_SET( _flag ) CShader_IsFlagSet( params, _flag )
  64. #define IS_FLAG_DEFINED( _flag ) ((params[FLAGS_DEFINED]->GetIntValue() & (_flag) ) != 0)
  65. #define IS_PARAM_DEFINED( _param ) ( ( ( _param >= 0 ) && ( params[_param]->IsDefined() ) ) )
  66. #define SET_PARAM_STRING_IF_NOT_DEFINED( nParamIndex, kDefaultValue ) \
  67. if ( ( (nParamIndex) != -1 ) && ( !params[nParamIndex]->IsDefined() ) ) \
  68. { \
  69. params[nParamIndex]->SetStringValue( kDefaultValue ); \
  70. }
  71. #define SET_PARAM_FLOAT_IF_NOT_DEFINED( nParamIndex, kDefaultValue ) \
  72. if ( ( (nParamIndex) != -1 ) && ( !params[nParamIndex]->IsDefined() ) ) \
  73. { \
  74. params[nParamIndex]->SetFloatValue( kDefaultValue ); \
  75. }
  76. #define SET_PARAM_VEC_IF_NOT_DEFINED( nParamIndex, kDefaultValue, nSize ) \
  77. if ( ( (nParamIndex) != -1 ) && ( !params[nParamIndex]->IsDefined() ) ) \
  78. { \
  79. params[nParamIndex]->SetVecValue( kDefaultValue, nSize ); \
  80. }
  81. #define SET_PARAM_INT_IF_NOT_DEFINED( nParamIndex, kDefaultValue ) \
  82. if ( ( (nParamIndex) != -1 ) && ( !params[nParamIndex]->IsDefined() ) ) \
  83. { \
  84. params[nParamIndex]->SetIntValue( kDefaultValue ); \
  85. }
  86. // Typesafe flag setting
  87. inline void CShader_SetFlags2( IMaterialVar **params, MaterialVarFlags2_t _flag )
  88. {
  89. params[FLAGS2]->SetIntValue( params[FLAGS2]->GetIntValue() | (_flag) );
  90. }
  91. inline bool CShader_IsFlag2Set( IMaterialVar **params, MaterialVarFlags2_t _flag )
  92. {
  93. return ((params[FLAGS2]->GetIntValue() & (_flag) ) != 0);
  94. }
  95. #define SET_FLAGS2( _flag ) CShader_SetFlags2( params, _flag )
  96. #define CLEAR_FLAGS2( _flag ) params[FLAGS2]->SetIntValue( params[FLAGS2]->GetIntValue() & ~(_flag) )
  97. #define IS_FLAG2_SET( _flag ) CShader_IsFlag2Set( params, _flag )
  98. #define IS_FLAG2_DEFINED( _flag ) ((params[FLAGS_DEFINED2]->GetIntValue() & (_flag) ) != 0)
  99. #define __BEGIN_SHADER_INTERNAL(_baseclass, name, help, flags) \
  100. namespace name \
  101. {\
  102. typedef _baseclass CBaseClass;\
  103. static const char *s_HelpString = help; \
  104. static const char *s_Name = #name; \
  105. static int s_nFlags = flags; \
  106. class CShaderParam;\
  107. static CUtlVector<CShaderParam *> s_ShaderParams;\
  108. static CShaderParam *s_pShaderParamOverrides[NUM_SHADER_MATERIAL_VARS];\
  109. class CShaderParam\
  110. {\
  111. public:\
  112. CShaderParam( ShaderMaterialVars_t var, ShaderParamType_t type, const char *pDefaultParam, const char *pHelp, int nFlags )\
  113. {\
  114. m_Info.m_pName = "override";\
  115. m_Info.m_Type = type;\
  116. m_Info.m_pDefaultValue = pDefaultParam;\
  117. m_Info.m_pHelp = pHelp;\
  118. m_Info.m_nFlags = nFlags;\
  119. AssertMsg( !s_pShaderParamOverrides[var], ( "Shader parameter override duplicately defined!" ) );\
  120. s_pShaderParamOverrides[var] = this;\
  121. m_Index = var;\
  122. }\
  123. CShaderParam( const char *pName, ShaderParamType_t type, const char *pDefaultParam, const char *pHelp, int nFlags )\
  124. {\
  125. m_Info.m_pName = pName;\
  126. m_Info.m_Type = type;\
  127. m_Info.m_pDefaultValue = pDefaultParam;\
  128. m_Info.m_pHelp = pHelp;\
  129. m_Info.m_nFlags = nFlags;\
  130. m_Index = NUM_SHADER_MATERIAL_VARS + s_ShaderParams.Count();\
  131. s_ShaderParams.AddToTail( this );\
  132. }\
  133. operator int() \
  134. {\
  135. return m_Index;\
  136. }\
  137. const ShaderParamInfo_t &GetInfo() const\
  138. {\
  139. return m_Info;\
  140. }\
  141. private:\
  142. ShaderParamInfo_t m_Info; \
  143. int m_Index;\
  144. };\
  145. #define BEGIN_SHADER(name,help) __BEGIN_SHADER_INTERNAL( CBaseShader, name, help, 0 )
  146. #define BEGIN_SHADER_FLAGS(name,help,flags) __BEGIN_SHADER_INTERNAL( CBaseShader, name, help, flags )
  147. #define BEGIN_SHADER_PARAMS
  148. #define SHADER_PARAM( param, paramtype, paramdefault, paramhelp ) \
  149. static CShaderParam param( "$" #param, paramtype, paramdefault, paramhelp, 0 );
  150. #define SHADER_PARAM_FLAGS( param, paramtype, paramdefault, paramhelp, flags ) \
  151. static CShaderParam param( "$" #param, paramtype, paramdefault, paramhelp, flags );
  152. #define SHADER_PARAM_OVERRIDE( param, paramtype, paramdefault, paramhelp, flags ) \
  153. static CShaderParam param( (ShaderMaterialVars_t) ::param, paramtype, paramdefault, paramhelp, flags );
  154. // regarding the macro above: the "::" was added to the first argument in order to disambiguate it for GCC.
  155. // for example, in cloak.cpp, this usage appears:
  156. // SHADER_PARAM_OVERRIDE( COLOR, SHADER_PARAM_TYPE_COLOR, "{255 255 255}", "unused", SHADER_PARAM_NOT_EDITABLE )
  157. // which in turn tries to ask the compiler to instantiate an object like so:
  158. // static CShaderParam COLOR( (ShaderMaterialVars_t)COLOR, SHADER_PARAM_TYPE_COLOR, "{255 255 255}", "unused", SHADER_PARAM_NOT_EDITABLE )
  159. // and GCC thinks that the reference to COLOR in the arg list is actually a reference to the object we're in the middle of making.
  160. // and you get --> error: invalid cast from type ‘Cloak_DX90::CShaderParam’ to type ‘ShaderMaterialVars_t’
  161. // Resolved: add the "::" so compiler knows that reference is to the enum, not to the name of the object being made.
  162. #define END_SHADER_PARAMS \
  163. class CShader : public CBaseClass\
  164. {\
  165. public:
  166. #define END_SHADER }; \
  167. static CShader s_ShaderInstance;\
  168. } // namespace
  169. #define SHADER_INIT \
  170. char const* GetName() const \
  171. { \
  172. return s_Name; \
  173. } \
  174. int GetFlags() const \
  175. { \
  176. return s_nFlags; \
  177. } \
  178. int GetParamCount() const \
  179. {\
  180. return CBaseClass::GetParamCount() + s_ShaderParams.Count();\
  181. }\
  182. const ShaderParamInfo_t& GetParamInfo( int param ) const \
  183. {\
  184. int nBaseClassParamCount = CBaseClass::GetParamCount( ); \
  185. if (param < nBaseClassParamCount) \
  186. return CBaseClass::GetParamInfo( param ); \
  187. else \
  188. return s_ShaderParams[param - nBaseClassParamCount]->GetInfo(); \
  189. }\
  190. void OnInitShaderInstance( IMaterialVar **params, IShaderInit *pShaderInit, const char *pMaterialName )
  191. #define SHADER_DRAW \
  192. void OnDrawElements( IMaterialVar **params, IShaderShadow* pShaderShadow, IShaderDynamicAPI* pShaderAPI, VertexCompressionType_t vertexCompression, CBasePerMaterialContextData **pContextDataPtr )
  193. #define SHADOW_STATE if (pShaderShadow)
  194. #define DYNAMIC_STATE if (pShaderAPI)
  195. #define ShaderWarning if (pShaderShadow) Warning
  196. //-----------------------------------------------------------------------------
  197. // Used to easily define a shader which *always* falls back
  198. //-----------------------------------------------------------------------------
  199. #define DEFINE_FALLBACK_SHADER( _shadername, _fallbackshadername ) \
  200. BEGIN_SHADER( _shadername, "" ) \
  201. BEGIN_SHADER_PARAMS \
  202. END_SHADER_PARAMS \
  203. SHADER_FALLBACK { return #_fallbackshadername; } \
  204. SHADER_INIT {} \
  205. SHADER_DRAW {} \
  206. END_SHADER
  207. //-----------------------------------------------------------------------------
  208. // Used to easily define a shader which inherits from another shader
  209. //-----------------------------------------------------------------------------
  210. // FIXME: There's a compiler bug preventing this from working.
  211. // Maybe it'll work under VC7!
  212. //#define BEGIN_INHERITED_SHADER( name, _baseclass, help ) \
  213. // namespace _baseclass \
  214. // {\
  215. // __BEGIN_SHADER_INTERNAL( _baseclass::CShader, name, help )
  216. //#define END_INHERITED_SHADER END_SHADER }
  217. //#define CHAIN_SHADER_INIT_PARAMS() CBaseClass::OnInitShaderParams( params, pMaterialName )
  218. //#define CHAIN_SHADER_FALLBACK() CBaseClass::GetFallbackShader( params )
  219. //#define CHAIN_SHADER_INIT() CBaseClass::OnInitShaderInstance( params, pShaderInit, pMaterialName )
  220. //#define CHAIN_SHADER_DRAW() CBaseClass::OnDrawElements( params, pShaderShadow, pShaderAPI )
  221. // A dumbed-down version which does what I need now which works
  222. // This version doesn't allow you to do chain *anything* down to the base class
  223. #define BEGIN_INHERITED_SHADER_FLAGS( _name, _base, _help, _flags ) \
  224. namespace _base\
  225. {\
  226. namespace _name\
  227. {\
  228. static const char *s_Name = #_name; \
  229. static const char *s_HelpString = _help;\
  230. static int s_nFlags = _flags;\
  231. class CShader : public _base::CShader\
  232. {\
  233. public:\
  234. char const* GetName() const \
  235. { \
  236. return s_Name; \
  237. } \
  238. int GetFlags() const \
  239. { \
  240. return s_nFlags; \
  241. }
  242. #define BEGIN_INHERITED_SHADER( _name, _base, _help ) BEGIN_INHERITED_SHADER_FLAGS( _name, _base, _help, 0 )
  243. #define END_INHERITED_SHADER END_SHADER }
  244. // psh ## shader is used here to generate a warning if you don't ever call SET_DYNAMIC_PIXEL_SHADER
  245. #define DECLARE_DYNAMIC_PIXEL_SHADER( shader ) \
  246. int declaredynpixshader_ ## shader ## _missingcurlybraces = 0; \
  247. declaredynpixshader_ ## shader ## _missingcurlybraces = declaredynpixshader_ ## shader ## _missingcurlybraces; \
  248. shader ## _Dynamic_Index _pshIndex( pShaderAPI ); \
  249. int psh ## shader = 0
  250. // vsh ## shader is used here to generate a warning if you don't ever call SET_DYNAMIC_VERTEX_SHADER
  251. #define DECLARE_DYNAMIC_VERTEX_SHADER( shader ) \
  252. int declaredynvertshader_ ## shader ## _missingcurlybraces = 0; \
  253. declaredynvertshader_ ## shader ## _missingcurlybraces = declaredynvertshader_ ## shader ## _missingcurlybraces; \
  254. shader ## _Dynamic_Index _vshIndex( pShaderAPI ); \
  255. int vsh ## shader = 0
  256. // psh ## shader is used here to generate a warning if you don't ever call SET_STATIC_PIXEL_SHADER
  257. #define DECLARE_STATIC_PIXEL_SHADER( shader ) \
  258. int declarestaticpixshader_ ## shader ## _missingcurlybraces = 0; \
  259. declarestaticpixshader_ ## shader ## _missingcurlybraces = declarestaticpixshader_ ## shader ## _missingcurlybraces; \
  260. shader ## _Static_Index _pshIndex( pShaderShadow, params ); \
  261. int psh ## shader = 0
  262. // vsh ## shader is used here to generate a warning if you don't ever call SET_STATIC_VERTEX_SHADER
  263. #define DECLARE_STATIC_VERTEX_SHADER( shader ) \
  264. int declarestaticvertshader_ ## shader ## _missingcurlybraces = 0; \
  265. declarestaticvertshader_ ## shader ## _missingcurlybraces = declarestaticvertshader_ ## shader ## _missingcurlybraces; \
  266. shader ## _Static_Index _vshIndex( pShaderShadow, params ); \
  267. int vsh ## shader = 0
  268. // psh_forgot_to_set_dynamic_ ## var is used to make sure that you set all
  269. // all combos. If you don't, you will get an undefined variable used error
  270. // in the SET_DYNAMIC_PIXEL_SHADER block.
  271. #define SET_DYNAMIC_PIXEL_SHADER_COMBO( var, val ) \
  272. int dynpixshadercombo_ ## var ## _missingcurlybraces = 0; \
  273. dynpixshadercombo_ ## var ## _missingcurlybraces = dynpixshadercombo_ ## var ## _missingcurlybraces; \
  274. _pshIndex.Set ## var( ( val ) ); if(g_shaderConfigDumpEnable){printf("\n PS dyn var %s = %d (%s)", #var, (int) val, #val );}; \
  275. int psh_forgot_to_set_dynamic_ ## var = 0
  276. // Same as SET_DYNAMIC_PIXEL_SHADER_COMBO, except doesn't set "psh_forgot_to_set_dynamic_*" since
  277. // it isn't required to set a default variable, and we don't want an error when we do set it.
  278. #define SET_DYNAMIC_PIXEL_SHADER_COMBO_OVERRIDE_DEFAULT( var, val ) \
  279. int dynpixshadercombo_ ## var ## _missingcurlybraces = 0; \
  280. dynpixshadercombo_ ## var ## _missingcurlybraces = dynpixshadercombo_ ## var ## _missingcurlybraces; \
  281. _pshIndex.Set ## var( ( val ) );
  282. // vsh_forgot_to_set_dynamic_ ## var is used to make sure that you set all
  283. // all combos. If you don't, you will get an undefined variable used error
  284. // in the SET_DYNAMIC_VERTEX_SHADER block.
  285. #define SET_DYNAMIC_VERTEX_SHADER_COMBO( var, val ) \
  286. int dynvertshadercombo_ ## var ## _missingcurlybraces = 0; \
  287. dynvertshadercombo_ ## var ## _missingcurlybraces = dynvertshadercombo_ ## var ## _missingcurlybraces; \
  288. _vshIndex.Set ## var( ( val ) ); if(g_shaderConfigDumpEnable){printf("\n VS dyn var %s = %d (%s)", #var, (int) val, #val );}; \
  289. int vsh_forgot_to_set_dynamic_ ## var = 0
  290. // psh_forgot_to_set_static_ ## var is used to make sure that you set all
  291. // all combos. If you don't, you will get an undefined variable used error
  292. // in the SET_STATIC_PIXEL_SHADER block.
  293. #define SET_STATIC_PIXEL_SHADER_COMBO( var, val ) \
  294. int staticpixshadercombo_ ## var ## _missingcurlybraces = 0; \
  295. staticpixshadercombo_ ## var ## _missingcurlybraces = staticpixshadercombo_ ## var ## _missingcurlybraces; \
  296. _pshIndex.Set ## var( ( val ) ); if(g_shaderConfigDumpEnable){printf("\n PS stat var %s = %d (%s)", #var, (int) val, #val );}; \
  297. int psh_forgot_to_set_static_ ## var = 0
  298. // vsh_forgot_to_set_static_ ## var is used to make sure that you set all
  299. // all combos. If you don't, you will get an undefined variable used error
  300. // in the SET_STATIC_VERTEX_SHADER block.
  301. #define SET_STATIC_VERTEX_SHADER_COMBO( var, val ) \
  302. int staticvertshadercombo_ ## var ## _missingcurlybraces = 0; \
  303. staticvertshadercombo_ ## var ## _missingcurlybraces = staticvertshadercombo_ ## var ## _missingcurlybraces; \
  304. _vshIndex.Set ## var( ( val ) ); if(g_shaderConfigDumpEnable){printf("\n VS stat var %s = %d (%s)", #var, (int) val, #val );}; \
  305. int vsh_forgot_to_set_static_ ## var = 0
  306. #define SET_STATIC_VERTEX_SHADER_COMBO_HAS_DEFAULT( var, val ) \
  307. int staticvertshadercombo_ ## var ## _missingcurlybraces = 0; \
  308. staticvertshadercombo_ ## var ## _missingcurlybraces = staticvertshadercombo_ ## var ## _missingcurlybraces; \
  309. _vshIndex.Set ## var( ( val ) );
  310. // psh_testAllCombos adds up all of the psh_forgot_to_set_dynamic_ ## var's from
  311. // SET_DYNAMIC_PIXEL_SHADER_COMBO so that an error is generated if they aren't set.
  312. // psh_testAllCombos is set to itself to avoid an unused variable warning.
  313. // psh ## shader being set to itself ensures that DECLARE_DYNAMIC_PIXEL_SHADER
  314. // was called for this particular shader.
  315. #define SET_DYNAMIC_PIXEL_SHADER( shader ) \
  316. int dynamicpixshader_ ## shader ## _missingcurlybraces = 0; \
  317. dynamicpixshader_ ## shader ## _missingcurlybraces = dynamicpixshader_ ## shader ## _missingcurlybraces; \
  318. int psh_testAllCombos = shaderDynamicTest_ ## shader; \
  319. psh_testAllCombos = psh_testAllCombos; \
  320. psh ## shader = psh ## shader; \
  321. pShaderAPI->SetPixelShaderIndex( _pshIndex.GetIndex() )
  322. #ifdef _PS3
  323. #define SET_DYNAMIC_PIXEL_SHADER_CMD( cmdstream, shader ) SET_DYNAMIC_PIXEL_SHADER( shader )
  324. #else
  325. #define SET_DYNAMIC_PIXEL_SHADER_CMD( cmdstream, shader ) \
  326. int dynamicpixshader_ ## shader ## _missingcurlybraces = 0; \
  327. dynamicpixshader_ ## shader ## _missingcurlybraces = dynamicpixshader_ ## shader ## _missingcurlybraces; \
  328. int psh_testAllCombos = shaderDynamicTest_ ## shader; \
  329. psh_testAllCombos = psh_testAllCombos; \
  330. psh ## shader = psh ## shader; \
  331. cmdstream.SetPixelShaderIndex( _pshIndex.GetIndex() )
  332. #endif
  333. // vsh_testAllCombos adds up all of the vsh_forgot_to_set_dynamic_ ## var's from
  334. // SET_DYNAMIC_VERTEX_SHADER_COMBO so that an error is generated if they aren't set.
  335. // vsh_testAllCombos is set to itself to avoid an unused variable warning.
  336. // vsh ## shader being set to itself ensures that DECLARE_DYNAMIC_VERTEX_SHADER
  337. // was called for this particular shader.
  338. #define SET_DYNAMIC_VERTEX_SHADER( shader ) \
  339. int dynamicvertshader_ ## shader ## _missingcurlybraces = 0; \
  340. dynamicvertshader_ ## shader ## _missingcurlybraces = dynamicvertshader_ ## shader ## _missingcurlybraces; \
  341. int vsh_testAllCombos = shaderDynamicTest_ ## shader; \
  342. vsh_testAllCombos = vsh_testAllCombos; \
  343. vsh ## shader = vsh ## shader; \
  344. pShaderAPI->SetVertexShaderIndex( _vshIndex.GetIndex() )
  345. #ifdef _PS3
  346. #define SET_DYNAMIC_VERTEX_SHADER_CMD( cmdstream, shader ) SET_DYNAMIC_VERTEX_SHADER( shader )
  347. #else
  348. #define SET_DYNAMIC_VERTEX_SHADER_CMD( cmdstream, shader ) \
  349. int dynamicvertshader_ ## shader ## _missingcurlybraces = 0; \
  350. dynamicvertshader_ ## shader ## _missingcurlybraces = dynamicvertshader_ ## shader ## _missingcurlybraces; \
  351. int vsh_testAllCombos = shaderDynamicTest_ ## shader; \
  352. vsh_testAllCombos = vsh_testAllCombos; \
  353. vsh ## shader = vsh ## shader; \
  354. cmdstream.SetVertexShaderIndex( _vshIndex.GetIndex() )
  355. #endif
  356. // psh_testAllCombos adds up all of the psh_forgot_to_set_static_ ## var's from
  357. // SET_STATIC_PIXEL_SHADER_COMBO so that an error is generated if they aren't set.
  358. // psh_testAllCombos is set to itself to avoid an unused variable warning.
  359. // psh ## shader being set to itself ensures that DECLARE_STATIC_PIXEL_SHADER
  360. // was called for this particular shader.
  361. #define SET_STATIC_PIXEL_SHADER( shader ) \
  362. int staticpixshader_ ## shader ## _missingcurlybraces = 0; \
  363. staticpixshader_ ## shader ## _missingcurlybraces = staticpixshader_ ## shader ## _missingcurlybraces; \
  364. int psh_testAllCombos = shaderStaticTest_ ## shader; \
  365. psh_testAllCombos = psh_testAllCombos; \
  366. psh ## shader = psh ## shader; \
  367. pShaderShadow->SetPixelShader( #shader, _pshIndex.GetIndex() )
  368. // vsh_testAllCombos adds up all of the vsh_forgot_to_set_static_ ## var's from
  369. // SET_STATIC_VERTEX_SHADER_COMBO so that an error is generated if they aren't set.
  370. // vsh_testAllCombos is set to itself to avoid an unused variable warning.
  371. // vsh ## shader being set to itself ensures that DECLARE_STATIC_VERTEX_SHADER
  372. // was called for this particular shader.
  373. #define SET_STATIC_VERTEX_SHADER( shader ) \
  374. int staticvertshader_ ## shader ## _missingcurlybraces = 0; \
  375. staticvertshader_ ## shader ## _missingcurlybraces = staticvertshader_ ## shader ## _missingcurlybraces; \
  376. int vsh_testAllCombos = shaderStaticTest_ ## shader; \
  377. vsh_testAllCombos = vsh_testAllCombos; \
  378. vsh ## shader = vsh ## shader; \
  379. pShaderShadow->SetVertexShader( #shader, _vshIndex.GetIndex() )
  380. #endif // CSHADER_H