summaryrefslogtreecommitdiff
path: root/materialsystem/shaderapidx9/shaderapi_global.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /materialsystem/shaderapidx9/shaderapi_global.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'materialsystem/shaderapidx9/shaderapi_global.h')
-rw-r--r--materialsystem/shaderapidx9/shaderapi_global.h105
1 files changed, 105 insertions, 0 deletions
diff --git a/materialsystem/shaderapidx9/shaderapi_global.h b/materialsystem/shaderapidx9/shaderapi_global.h
new file mode 100644
index 0000000..ae8f6ab
--- /dev/null
+++ b/materialsystem/shaderapidx9/shaderapi_global.h
@@ -0,0 +1,105 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//===========================================================================//
+
+#ifndef SHADERAPI_GLOBAL_H
+#define SHADERAPI_GLOBAL_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "tier0/threadtools.h"
+
+//-----------------------------------------------------------------------------
+// Use this to fill in structures with the current board state
+//-----------------------------------------------------------------------------
+#ifdef _DEBUG
+#define DEBUG_BOARD_STATE 0
+#endif
+
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+class IShaderUtil;
+class CShaderDeviceBase;
+class CShaderDeviceMgrBase;
+class CShaderAPIBase;
+class IShaderShadow;
+
+
+//-----------------------------------------------------------------------------
+// Global interfaces
+//-----------------------------------------------------------------------------
+extern IShaderUtil* g_pShaderUtil;
+inline IShaderUtil* ShaderUtil()
+{
+ return g_pShaderUtil;
+}
+
+extern CShaderDeviceBase *g_pShaderDevice;
+extern CShaderDeviceMgrBase *g_pShaderDeviceMgr;
+extern CShaderAPIBase *g_pShaderAPI;
+extern IShaderShadow *g_pShaderShadow;
+
+
+//-----------------------------------------------------------------------------
+// Memory debugging
+//-----------------------------------------------------------------------------
+#define MEM_ALLOC_D3D_CREDIT() MEM_ALLOC_CREDIT_("D3D:" __FILE__)
+#define BEGIN_D3D_ALLOCATION() MemAlloc_PushAllocDbgInfo("D3D:" __FILE__, __LINE__)
+#define END_D3D_ALLOCATION() MemAlloc_PopAllocDbgInfo()
+
+
+//-----------------------------------------------------------------------------
+// Threading
+//-----------------------------------------------------------------------------
+extern bool g_bUseShaderMutex;
+
+//#define USE_SHADER_DISALLOW 1
+//#define STRICT_MT_SHADERAPI 1
+
+#if defined(_DEBUG)
+#if !defined(STRICT_MT_SHADERAPI)
+#define UNCONDITIONAL_MT_SHADERAPI 1
+#endif
+#else
+#if !defined(STRICT_MT_SHADERAPI) && !defined(UNCONDITIONAL_MT_SHADERAPI)
+#define ST_SHADERAPI 1
+#endif
+#endif
+
+
+#if defined(ST_SHADERAPI)
+typedef CThreadNullMutex CShaderMutex;
+#elif defined(STRICT_MT_SHADERAPI)
+typedef CThreadConditionalMutex<CThreadTerminalMutex<CThreadFastMutex>, &g_bUseShaderMutex> CShaderMutex;
+#elif defined(UNCONDITIONAL_MT_SHADERAPI)
+typedef CThreadFastMutex CShaderMutex;
+#else
+typedef CThreadConditionalMutex<CThreadFastMutex, &g_bUseShaderMutex> CShaderMutex;
+#endif
+
+extern CShaderMutex g_ShaderMutex;
+
+extern bool g_bShaderAccessDisallowed;
+
+#ifdef USE_SHADER_DISALLOW
+#define TestShaderPermission() do { if ( (!g_bUseShaderMutex || g_ShaderMutex.GetDepth() == 0) && g_bShaderAccessDisallowed ) { ExecuteOnce( DebuggerBreakIfDebugging() ); } } while (0)
+#define LOCK_SHADERAPI() TestShaderPermission(); AUTO_LOCK_( CShaderMutex, g_ShaderMutex )
+#define LockShaderMutex() TestShaderPermission(); g_ShaderMutex.Lock();
+#define UnlockShaderMutex() TestShaderPermission(); g_ShaderMutex.Unlock();
+#else
+#define TestShaderPermission() ((void)0)
+#define LOCK_SHADERAPI() ((void)0)
+#define LockShaderMutex() ((void)0)
+#define UnlockShaderMutex() ((void)0)
+#endif
+
+
+#endif // SHADERAPI_GLOBAL_H