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.

112 lines
3.4 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #ifndef SHADERAPI_GLOBAL_H
  9. #define SHADERAPI_GLOBAL_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "tier0/threadtools.h"
  14. //-----------------------------------------------------------------------------
  15. // Use this to fill in structures with the current board state
  16. //-----------------------------------------------------------------------------
  17. #ifdef _DEBUG
  18. #define DEBUG_BOARD_STATE 0
  19. #endif
  20. //-----------------------------------------------------------------------------
  21. // Forward declarations
  22. //-----------------------------------------------------------------------------
  23. class IShaderUtil;
  24. class CShaderDeviceBase;
  25. class CShaderDeviceMgrBase;
  26. class CShaderAPIBase;
  27. class IShaderShadow;
  28. //-----------------------------------------------------------------------------
  29. // Global interfaces
  30. //-----------------------------------------------------------------------------
  31. #ifdef _PS3
  32. #include "shaderutil_ps3nonvirt.h"
  33. #define g_pShaderUtil ShaderUtil()
  34. inline CPs3NonVirt_IShaderUtil * ShaderUtil()
  35. {
  36. return ( CPs3NonVirt_IShaderUtil * ) 1;
  37. }
  38. #else
  39. extern IShaderUtil* g_pShaderUtil;
  40. inline IShaderUtil* ShaderUtil()
  41. {
  42. return g_pShaderUtil;
  43. }
  44. #endif
  45. extern CShaderDeviceBase *g_pShaderDevice;
  46. extern CShaderDeviceMgrBase *g_pShaderDeviceMgr;
  47. extern CShaderAPIBase *g_pShaderAPI;
  48. extern IShaderShadow *g_pShaderShadow;
  49. //-----------------------------------------------------------------------------
  50. // Memory debugging
  51. //-----------------------------------------------------------------------------
  52. #define MEM_ALLOC_D3D_CREDIT() MEM_ALLOC_CREDIT_("D3D:" __FILE__)
  53. #define BEGIN_D3D_ALLOCATION() MemAlloc_PushAllocDbgInfo("D3D:" __FILE__, __LINE__)
  54. #define END_D3D_ALLOCATION() MemAlloc_PopAllocDbgInfo()
  55. //-----------------------------------------------------------------------------
  56. // Threading
  57. //-----------------------------------------------------------------------------
  58. extern bool g_bUseShaderMutex;
  59. //#define USE_SHADER_DISALLOW 1
  60. //#define STRICT_MT_SHADERAPI 1
  61. #if defined(_DEBUG)
  62. #if !defined(STRICT_MT_SHADERAPI)
  63. #define UNCONDITIONAL_MT_SHADERAPI 1
  64. #endif
  65. #else
  66. #if !defined(STRICT_MT_SHADERAPI) && !defined(UNCONDITIONAL_MT_SHADERAPI)
  67. #define ST_SHADERAPI 1
  68. #endif
  69. #endif
  70. #if defined(ST_SHADERAPI)
  71. typedef CThreadNullMutex CShaderMutex;
  72. #elif defined(STRICT_MT_SHADERAPI)
  73. typedef CThreadConditionalMutex<CThreadTerminalMutex<CThreadFastMutex>, &g_bUseShaderMutex> CShaderMutex;
  74. #elif defined(UNCONDITIONAL_MT_SHADERAPI)
  75. typedef CThreadFastMutex CShaderMutex;
  76. #else
  77. typedef CThreadConditionalMutex<CThreadFastMutex, &g_bUseShaderMutex> CShaderMutex;
  78. #endif
  79. extern CShaderMutex g_ShaderMutex;
  80. extern bool g_bShaderAccessDisallowed;
  81. #ifdef USE_SHADER_DISALLOW
  82. #define TestShaderPermission() do { if ( (!g_bUseShaderMutex || g_ShaderMutex.GetDepth() == 0) && g_bShaderAccessDisallowed ) { ExecuteOnce( DebuggerBreakIfDebugging() ); } } while (0)
  83. #define LOCK_SHADERAPI() TestShaderPermission(); AUTO_LOCK_( CShaderMutex, g_ShaderMutex )
  84. #define LockShaderMutex() TestShaderPermission(); g_ShaderMutex.Lock();
  85. #define UnlockShaderMutex() TestShaderPermission(); g_ShaderMutex.Unlock();
  86. #else
  87. #define TestShaderPermission() ((void)0)
  88. #define LOCK_SHADERAPI() ((void)0)
  89. #define LockShaderMutex() ((void)0)
  90. #define UnlockShaderMutex() ((void)0)
  91. #endif
  92. #endif // SHADERAPI_GLOBAL_H