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.

2741 lines
75 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #include "utlvector.h"
  9. #include "materialsystem/imaterialsystem.h"
  10. #include "IHardwareConfigInternal.h"
  11. #include "shadersystem.h"
  12. #include "shaderapi/ishaderutil.h"
  13. #include "shaderapi/ishaderapi.h"
  14. #include "materialsystem/imesh.h"
  15. #include "tier0/dbg.h"
  16. #include "materialsystem/idebugtextureinfo.h"
  17. #include "materialsystem/deformations.h"
  18. // NOTE: This has to be the last file included!
  19. #include "tier0/memdbgon.h"
  20. //-----------------------------------------------------------------------------
  21. // The empty mesh
  22. //-----------------------------------------------------------------------------
  23. class CEmptyMesh : public IMesh
  24. {
  25. public:
  26. CEmptyMesh( bool bIsDynamic );
  27. virtual ~CEmptyMesh();
  28. // FIXME: Make this work! Unsupported methods of IIndexBuffer + IVertexBuffer
  29. virtual bool Lock( int nMaxIndexCount, bool bAppend, IndexDesc_t& desc );
  30. virtual void Unlock( int nWrittenIndexCount, IndexDesc_t& desc );
  31. virtual void ModifyBegin( bool bReadOnly, int nFirstIndex, int nIndexCount, IndexDesc_t& desc );
  32. virtual void ModifyEnd( IndexDesc_t& desc );
  33. virtual void Spew( int nIndexCount, const IndexDesc_t & desc );
  34. virtual void ValidateData( int nIndexCount, const IndexDesc_t &desc );
  35. virtual bool Lock( int nVertexCount, bool bAppend, VertexDesc_t &desc );
  36. virtual void Unlock( int nVertexCount, VertexDesc_t &desc );
  37. virtual void Spew( int nVertexCount, const VertexDesc_t &desc );
  38. virtual void ValidateData( int nVertexCount, const VertexDesc_t & desc );
  39. virtual bool IsDynamic() const { return m_bIsDynamic; }
  40. virtual void BeginCastBuffer( VertexFormat_t format ) {}
  41. virtual void BeginCastBuffer( MaterialIndexFormat_t format ) {}
  42. virtual void EndCastBuffer( ) {}
  43. virtual int GetRoomRemaining() const { return 0; }
  44. virtual MaterialIndexFormat_t IndexFormat() const { return MATERIAL_INDEX_FORMAT_UNKNOWN; }
  45. void LockMesh( int numVerts, int numIndices, MeshDesc_t& desc, MeshBuffersAllocationSettings_t *pSettings = 0 );
  46. void UnlockMesh( int numVerts, int numIndices, MeshDesc_t& desc );
  47. void ModifyBeginEx( bool bReadOnly, int firstVertex, int numVerts, int firstIndex, int numIndices, MeshDesc_t& desc );
  48. void ModifyBegin( int firstVertex, int numVerts, int firstIndex, int numIndices, MeshDesc_t& desc );
  49. void ModifyEnd( MeshDesc_t& desc );
  50. // returns the # of vertices (static meshes only)
  51. int VertexCount() const;
  52. // Sets the primitive type
  53. void SetPrimitiveType( MaterialPrimitiveType_t type );
  54. // Draws the entire mesh
  55. void Draw(int firstIndex, int numIndices);
  56. void DrawModulated( const Vector4D &vecDiffuseModulation, int firstIndex, int numIndices) {}
  57. void Draw(CPrimList *pPrims, int nPrims);
  58. // Copy verts and/or indices to a mesh builder. This only works for temp meshes!
  59. virtual void CopyToMeshBuilder(
  60. int iStartVert, // Which vertices to copy.
  61. int nVerts,
  62. int iStartIndex, // Which indices to copy.
  63. int nIndices,
  64. int indexOffset, // This is added to each index.
  65. CMeshBuilder &builder );
  66. // Spews the mesh data
  67. void Spew( int numVerts, int numIndices, const MeshDesc_t & desc );
  68. void ValidateData( int numVerts, int numIndices, const MeshDesc_t & desc );
  69. // gets the associated material
  70. IMaterial* GetMaterial();
  71. void SetColorMesh( IMesh *pColorMesh, int nVertexOffset )
  72. {
  73. }
  74. virtual int IndexCount() const
  75. {
  76. return 0;
  77. }
  78. virtual void SetFlexMesh( IMesh *pMesh, int nVertexOffset ) {}
  79. virtual void DisableFlexMesh() {}
  80. virtual void MarkAsDrawn() {}
  81. virtual VertexFormat_t GetVertexFormat() const { return VERTEX_POSITION; }
  82. virtual IMesh *GetMesh()
  83. {
  84. return this;
  85. }
  86. virtual unsigned int ComputeMemoryUsed() { return 0; }
  87. virtual void * AccessRawHardwareDataStream( uint8 nRawStreamIndex, uint32 numBytes, uint32 uiFlags, void *pvContext ) { return NULL; }
  88. virtual ICachedPerFrameMeshData *GetCachedPerFrameMeshData() { return NULL; }
  89. virtual void ReconstructFromCachedPerFrameMeshData( ICachedPerFrameMeshData *pData ) {}
  90. private:
  91. enum
  92. {
  93. VERTEX_BUFFER_SIZE = 1024 // * 1024
  94. };
  95. unsigned char* m_pVertexMemory;
  96. bool m_bIsDynamic;
  97. };
  98. //-----------------------------------------------------------------------------
  99. // The empty shader shadow
  100. //-----------------------------------------------------------------------------
  101. class CShaderShadowEmpty : public IShaderShadow
  102. {
  103. public:
  104. CShaderShadowEmpty();
  105. virtual ~CShaderShadowEmpty();
  106. // Sets the default *shadow* state
  107. void SetDefaultState();
  108. // Methods related to depth buffering
  109. void DepthFunc( ShaderDepthFunc_t depthFunc );
  110. void EnableDepthWrites( bool bEnable );
  111. void EnableDepthTest( bool bEnable );
  112. void EnablePolyOffset( PolygonOffsetMode_t nOffsetMode );
  113. // Suppresses/activates color writing
  114. void EnableColorWrites( bool bEnable );
  115. void EnableAlphaWrites( bool bEnable );
  116. // Methods related to alpha blending
  117. void EnableBlending( bool bEnable );
  118. void EnableBlendingForceOpaque( bool bEnable );
  119. void BlendFunc( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor );
  120. // Alpha testing
  121. void EnableAlphaTest( bool bEnable );
  122. void AlphaFunc( ShaderAlphaFunc_t alphaFunc, float alphaRef /* [0-1] */ );
  123. // Wireframe/filled polygons
  124. void PolyMode( ShaderPolyModeFace_t face, ShaderPolyMode_t polyMode );
  125. // Back face culling
  126. void EnableCulling( bool bEnable );
  127. // Indicates the vertex format for use with a vertex shader
  128. // The flags to pass in here come from the VertexFormatFlags_t enum
  129. // If pTexCoordDimensions is *not* specified, we assume all coordinates
  130. // are 2-dimensional
  131. void VertexShaderVertexFormat( unsigned int nFlags,
  132. int nTexCoordCount, int* pTexCoordDimensions, int nUserDataSize );
  133. // Per texture unit stuff
  134. void EnableTexture( Sampler_t stage, bool bEnable ) {};
  135. void EnableVertexTexture( VertexTextureSampler_t stage, bool bEnable ) {};
  136. // Separate alpha blending
  137. void EnableBlendingSeparateAlpha( bool bEnable );
  138. void BlendFuncSeparateAlpha( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor );
  139. // Sets the vertex and pixel shaders
  140. void SetVertexShader( const char *pFileName, int vshIndex );
  141. void SetPixelShader( const char *pFileName, int pshIndex );
  142. // Convert from linear to gamma color space on writes to frame buffer.
  143. void EnableSRGBWrite( bool bEnable )
  144. {
  145. }
  146. void EnableSRGBRead( Sampler_t stage, bool bEnable )
  147. {
  148. }
  149. virtual void FogMode( ShaderFogMode_t fogMode, bool bVertexFog )
  150. {
  151. }
  152. virtual void DisableFogGammaCorrection( bool bDisable )
  153. {
  154. }
  155. virtual void ExecuteCommandBuffer( uint8 *pBuf )
  156. {
  157. }
  158. // Alpha to coverage
  159. void EnableAlphaToCoverage( bool bEnable );
  160. virtual void SetShadowDepthFiltering( Sampler_t stage )
  161. {
  162. }
  163. virtual void BlendOp( ShaderBlendOp_t blendOp )
  164. {
  165. }
  166. virtual void BlendOpSeparateAlpha( ShaderBlendOp_t blendOp )
  167. {
  168. }
  169. virtual float GetLightMapScaleFactor( void ) const
  170. {
  171. return 1.0;
  172. }
  173. bool m_IsTranslucent;
  174. bool m_ForceOpaque;
  175. bool m_IsAlphaTested;
  176. bool m_bIsDepthWriteEnabled;
  177. bool m_bUsesVertexAndPixelShaders;
  178. };
  179. //-----------------------------------------------------------------------------
  180. // The DX8 implementation of the shader device
  181. //-----------------------------------------------------------------------------
  182. class CShaderDeviceEmpty : public IShaderDevice
  183. {
  184. public:
  185. CShaderDeviceEmpty() : m_DynamicMesh( true ), m_Mesh( false ) {}
  186. // Methods of IShaderDevice
  187. virtual int GetCurrentAdapter() const { return 0; }
  188. virtual bool IsUsingGraphics() const { return false; }
  189. virtual void SpewDriverInfo() const;
  190. virtual ImageFormat GetBackBufferFormat() const { return IMAGE_FORMAT_RGB888; }
  191. virtual void GetBackBufferDimensions( int& width, int& height ) const;
  192. virtual const AspectRatioInfo_t &GetAspectRatioInfo( void ) const
  193. {
  194. static AspectRatioInfo_t dummy;
  195. return dummy;
  196. }
  197. virtual int StencilBufferBits() const { return 0; }
  198. virtual bool IsAAEnabled() const { return false; }
  199. virtual void Present( ) {}
  200. virtual void GetWindowSize( int &width, int &height ) const;
  201. virtual bool AddView( void* hwnd );
  202. virtual void RemoveView( void* hwnd );
  203. virtual void SetView( void* hwnd );
  204. virtual void ReleaseResources( bool bReleaseManagedResources = true );
  205. virtual void ReacquireResources();
  206. virtual IMesh* CreateStaticMesh( VertexFormat_t fmt, const char *pTextureBudgetGroup, IMaterial * pMaterial = NULL, VertexStreamSpec_t *pStreamSpec = NULL );
  207. virtual void DestroyStaticMesh( IMesh* mesh );
  208. virtual IShaderBuffer* CompileShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion ) { return NULL; }
  209. virtual VertexShaderHandle_t CreateVertexShader( IShaderBuffer* pShaderBuffer ) { return VERTEX_SHADER_HANDLE_INVALID; }
  210. virtual void DestroyVertexShader( VertexShaderHandle_t hShader ) {}
  211. virtual GeometryShaderHandle_t CreateGeometryShader( IShaderBuffer* pShaderBuffer ) { return GEOMETRY_SHADER_HANDLE_INVALID; }
  212. virtual void DestroyGeometryShader( GeometryShaderHandle_t hShader ) {}
  213. virtual PixelShaderHandle_t CreatePixelShader( IShaderBuffer* pShaderBuffer ) { return PIXEL_SHADER_HANDLE_INVALID; }
  214. virtual void DestroyPixelShader( PixelShaderHandle_t hShader ) {}
  215. virtual IVertexBuffer *CreateVertexBuffer( ShaderBufferType_t type, VertexFormat_t fmt, int nVertexCount, const char *pBudgetGroup );
  216. virtual void DestroyVertexBuffer( IVertexBuffer *pVertexBuffer );
  217. virtual IIndexBuffer *CreateIndexBuffer( ShaderBufferType_t bufferType, MaterialIndexFormat_t fmt, int nIndexCount, const char *pBudgetGroup );
  218. virtual void DestroyIndexBuffer( IIndexBuffer *pIndexBuffer );
  219. virtual IVertexBuffer *GetDynamicVertexBuffer( int streamID, VertexFormat_t vertexFormat, bool bBuffered );
  220. virtual IIndexBuffer *GetDynamicIndexBuffer();
  221. virtual void SetHardwareGammaRamp( float fGamma, float fGammaTVRangeMin, float fGammaTVRangeMax, float fGammaTVExponent, bool bTVEnabled ) {}
  222. virtual void EnableNonInteractiveMode( MaterialNonInteractiveMode_t mode, ShaderNonInteractiveInfo_t *pInfo ) {}
  223. virtual void RefreshFrontBufferNonInteractive( ) {}
  224. virtual void HandleThreadEvent( uint32 threadEvent ) {}
  225. #if defined( DX_TO_GL_ABSTRACTION )
  226. virtual void DoStartupShaderPreloading( void ) {}
  227. #endif
  228. private:
  229. CEmptyMesh m_Mesh;
  230. CEmptyMesh m_DynamicMesh;
  231. };
  232. static CShaderDeviceEmpty s_ShaderDeviceEmpty;
  233. // FIXME: Remove; it's for backward compat with the materialsystem only for now
  234. EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CShaderDeviceEmpty, IShaderDevice,
  235. SHADER_DEVICE_INTERFACE_VERSION, s_ShaderDeviceEmpty )
  236. //-----------------------------------------------------------------------------
  237. // The DX8 implementation of the shader device
  238. //-----------------------------------------------------------------------------
  239. class CShaderDeviceMgrEmpty : public CBaseAppSystem< IShaderDeviceMgr >
  240. {
  241. public:
  242. // Methods of IAppSystem
  243. virtual bool Connect( CreateInterfaceFn factory );
  244. virtual void Disconnect();
  245. virtual void *QueryInterface( const char *pInterfaceName );
  246. virtual InitReturnVal_t Init();
  247. virtual void Shutdown();
  248. public:
  249. // Methods of IShaderDeviceMgr
  250. virtual int GetAdapterCount() const;
  251. virtual void GetAdapterInfo( int adapter, MaterialAdapterInfo_t& info ) const;
  252. virtual bool GetRecommendedVideoConfig( int nAdapter, KeyValues *pKeyValues );
  253. virtual bool GetRecommendedConfigurationInfo( int nAdapter, int nDXLevel, KeyValues *pKeyValues );
  254. virtual int GetModeCount( int adapter ) const;
  255. virtual void GetModeInfo( ShaderDisplayMode_t *pInfo, int nAdapter, int mode ) const;
  256. virtual void GetCurrentModeInfo( ShaderDisplayMode_t* pInfo, int nAdapter ) const;
  257. virtual bool SetAdapter( int nAdapter, int nFlags );
  258. virtual CreateInterfaceFn SetMode( void *hWnd, int nAdapter, const ShaderDeviceInfo_t& mode );
  259. virtual void AddModeChangeCallback( ShaderModeChangeCallbackFunc_t func ) {}
  260. virtual void RemoveModeChangeCallback( ShaderModeChangeCallbackFunc_t func ) {}
  261. virtual void AddDeviceDependentObject( IShaderDeviceDependentObject *pObject ) {}
  262. virtual void RemoveDeviceDependentObject( IShaderDeviceDependentObject *pObject ) {}
  263. };
  264. static CShaderDeviceMgrEmpty s_ShaderDeviceMgrEmpty;
  265. EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CShaderDeviceMgrEmpty, IShaderDeviceMgr,
  266. SHADER_DEVICE_MGR_INTERFACE_VERSION, s_ShaderDeviceMgrEmpty )
  267. //-----------------------------------------------------------------------------
  268. // The DX8 implementation of the shader API
  269. //-----------------------------------------------------------------------------
  270. class CShaderAPIEmpty : public IShaderAPI, public IHardwareConfigInternal, public IDebugTextureInfo
  271. {
  272. public:
  273. // constructor, destructor
  274. CShaderAPIEmpty( );
  275. virtual ~CShaderAPIEmpty();
  276. // IDebugTextureInfo implementation.
  277. public:
  278. virtual bool IsDebugTextureListFresh( int numFramesAllowed = 1 ) { return false; }
  279. virtual bool SetDebugTextureRendering( bool bEnable ) { return false; }
  280. virtual void EnableDebugTextureList( bool bEnable ) {}
  281. virtual void EnableGetAllTextures( bool bEnable ) {}
  282. virtual KeyValues* LockDebugTextureList( void ) { return NULL; }
  283. virtual void UnlockDebugTextureList( void ) {}
  284. virtual KeyValues* GetDebugTextureList() { return NULL; }
  285. virtual int GetTextureMemoryUsed( TextureMemoryType eTextureMemory ) { return 0; }
  286. virtual void SetVertexShaderViewProj() {}
  287. virtual void UpdateVertexShaderMatrix( int m ) {}
  288. virtual void SetVertexShaderModelViewProjAndModelView() {}
  289. virtual void SetVertexShaderCameraPos() {}
  290. virtual bool SetSkinningMatrices( const MeshInstanceData_t &instance ) { return false; }
  291. virtual void BeginGeneratingCSMs() {}
  292. virtual void EndGeneratingCSMs() {}
  293. virtual void PerpareForCascadeDraw( int cascade, float fShadowSlopeScaleDepthBias, float fShadowDepthBias ) {}
  294. // Methods of IShaderDynamicAPI
  295. #ifdef _PS3
  296. virtual void ExecuteSingleCommandBuffer( uint8 *pCmdBuffer, int size ) {}
  297. virtual void ExecuteCommandBuffer( uint8 *pCmdBuffer1, int size1,
  298. uint8 *pCmdBuffer2, int size2) {}
  299. virtual void ExecuteCommandBuffer( uint8 *pCmdBuffer1, int size1,
  300. uint8 *pCmdBuffer2, int size2,
  301. uint8 *pCmdBuffer3, int size3) {}
  302. #endif
  303. virtual void GetBackBufferDimensions( int& width, int& height ) const
  304. {
  305. s_ShaderDeviceEmpty.GetBackBufferDimensions( width, height );
  306. }
  307. virtual const AspectRatioInfo_t &GetAspectRatioInfo( void ) const
  308. {
  309. static AspectRatioInfo_t dummy;
  310. return dummy;
  311. }
  312. // Get the dimensions of the current render target
  313. virtual void GetCurrentRenderTargetDimensions( int& nWidth, int& nHeight ) const
  314. {
  315. s_ShaderDeviceEmpty.GetBackBufferDimensions( nWidth, nHeight );
  316. }
  317. // Get the current viewport
  318. virtual void GetCurrentViewport( int& nX, int& nY, int& nWidth, int& nHeight ) const
  319. {
  320. nX = 0;
  321. nY = 0;
  322. s_ShaderDeviceEmpty.GetBackBufferDimensions( nWidth, nHeight );
  323. }
  324. virtual void GetCurrentColorCorrection( ShaderColorCorrectionInfo_t* pInfo )
  325. {
  326. pInfo->m_bIsEnabled = false;
  327. pInfo->m_nLookupCount = 0;
  328. pInfo->m_flDefaultWeight = 0.0f;
  329. }
  330. // Methods of IShaderAPI
  331. public:
  332. virtual void SetViewports( int nCount, const ShaderViewport_t* pViewports, bool setImmediately = false );
  333. virtual int GetViewports( ShaderViewport_t* pViewports, int nMax ) const;
  334. virtual void ClearBuffers( bool bClearColor, bool bClearDepth, bool bClearStencil, int renderTargetWidth, int renderTargetHeight );
  335. virtual void ClearBuffersEx( bool bClearRed, bool bClearGreen, bool bClearBlue, bool bClearAlpha,
  336. unsigned char r, unsigned char g, unsigned char b, unsigned char a );
  337. virtual void ClearColor3ub( unsigned char r, unsigned char g, unsigned char b );
  338. virtual void ClearColor4ub( unsigned char r, unsigned char g, unsigned char b, unsigned char a );
  339. virtual void BindVertexShader( VertexShaderHandle_t hVertexShader ) {}
  340. virtual void BindGeometryShader( GeometryShaderHandle_t hGeometryShader ) {}
  341. virtual void BindPixelShader( PixelShaderHandle_t hPixelShader ) {}
  342. virtual void SetRasterState( const ShaderRasterState_t& state ) {}
  343. virtual void MarkUnusedVertexFields( unsigned int nFlags, int nTexCoordCount, bool *pUnusedTexCoords ) {}
  344. #if defined( _GAMECONSOLE )
  345. virtual bool PostQueuedTexture( const void *pData, int nSize, ShaderAPITextureHandle_t *pHandles, int nHandles, int nWidth, int nHeight, int nDepth, int nMips, int *pRefCount )
  346. {
  347. return false;
  348. }
  349. #endif
  350. virtual bool OwnGPUResources( bool bEnable ) { return false; }
  351. virtual void OnPresent( void ) {}
  352. virtual bool DoRenderTargetsNeedSeparateDepthBuffer() const;
  353. // Used to clear the transition table when we know it's become invalid.
  354. void ClearSnapshots();
  355. // Sets the mode...
  356. bool SetMode( void* hwnd, int nAdapter, const ShaderDeviceInfo_t &info )
  357. {
  358. return true;
  359. }
  360. void ChangeVideoMode( const ShaderDeviceInfo_t &info )
  361. {
  362. }
  363. // Called when the dx support level has changed
  364. virtual void DXSupportLevelChanged( int nDXLevel ) {}
  365. virtual void EnableUserClipTransformOverride( bool bEnable ) {}
  366. virtual void UserClipTransform( const VMatrix &worldToView ) {}
  367. // Sets the default *dynamic* state
  368. void SetDefaultState( );
  369. // Returns the snapshot id for the shader state
  370. StateSnapshot_t TakeSnapshot( );
  371. // Returns true if the state snapshot is transparent
  372. bool IsTranslucent( StateSnapshot_t id ) const;
  373. bool IsAlphaTested( StateSnapshot_t id ) const;
  374. bool UsesVertexAndPixelShaders( StateSnapshot_t id ) const;
  375. virtual bool IsDepthWriteEnabled( StateSnapshot_t id ) const;
  376. // Gets the vertex format for a set of snapshot ids
  377. VertexFormat_t ComputeVertexFormat( int numSnapshots, StateSnapshot_t* pIds ) const;
  378. // Gets the vertex format for a set of snapshot ids
  379. VertexFormat_t ComputeVertexUsage( int numSnapshots, StateSnapshot_t* pIds ) const;
  380. // Begins a rendering pass that uses a state snapshot
  381. void BeginPass( StateSnapshot_t snapshot );
  382. // Uses a state snapshot
  383. void UseSnapshot( StateSnapshot_t snapshot );
  384. // Use this to get the mesh builder that allows us to modify vertex data
  385. CMeshBuilder* GetVertexModifyBuilder();
  386. // Sets the lights
  387. void SetLightingState( const MaterialLightingState_t &state ) {}
  388. void SetLights( int nCount, const LightDesc_t *pDesc );
  389. void SetLightingOrigin( Vector vLightingOrigin );
  390. void SetAmbientLightCube( Vector4D cube[6] );
  391. void CopyRenderTargetToTexture( ShaderAPITextureHandle_t texID ){}
  392. void CopyRenderTargetToTextureEx( ShaderAPITextureHandle_t texID, int nRenderTargetID, Rect_t *pSrcRect, Rect_t *pDstRect ){}
  393. void CopyRenderTargetToTextureEx( ShaderAPITextureHandle_t textureHandle, int nRenderTargetID, Rect_t *pSrcRect = NULL, Rect_t *pDstRect = NULL, bool bUseBackBuffer = false ) {}
  394. void CopyTextureToRenderTargetEx( int nRenderTargetID, ShaderAPITextureHandle_t textureHandle, Rect_t *pSrcRect, Rect_t *pDstRect )
  395. {
  396. }
  397. // Set the number of bone weights
  398. void SetNumBoneWeights( int numBones );
  399. void EnableHWMorphing( bool bEnable );
  400. // Gets the dynamic mesh; note that you've got to render the mesh
  401. // before calling this function a second time. Clients should *not*
  402. // call DestroyStaticMesh on the mesh returned by this call.
  403. IMesh* GetDynamicMesh( IMaterial* pMaterial, int nHWSkinBoneCount, bool buffered, IMesh* pVertexOverride, IMesh* pIndexOverride );
  404. IMesh* GetDynamicMeshEx( IMaterial* pMaterial, VertexFormat_t fmt, int nHWSkinBoneCount, bool buffered, IMesh* pVertexOverride, IMesh* pIndexOverride );
  405. IMesh* GetFlexMesh();
  406. // Renders a single pass of a material
  407. void RenderPass( const unsigned char *pInstanceCommandBuffer, int nPass, int nPassCount );
  408. // stuff related to matrix stacks
  409. void MatrixMode( MaterialMatrixMode_t matrixMode );
  410. void PushMatrix();
  411. void PopMatrix();
  412. void LoadMatrix( float *m );
  413. void LoadBoneMatrix( int boneIndex, const float *m ) {}
  414. void MultMatrix( float *m );
  415. void MultMatrixLocal( float *m );
  416. void GetActualProjectionMatrix( float *pMatrix );
  417. void GetMatrix( MaterialMatrixMode_t matrixMode, float *dst );
  418. void LoadIdentity( void );
  419. void LoadCameraToWorld( void );
  420. void Ortho( double left, double top, double right, double bottom, double zNear, double zFar );
  421. void PerspectiveX( double fovx, double aspect, double zNear, double zFar );
  422. void PerspectiveOffCenterX( double fovx, double aspect, double zNear, double zFar, double bottom, double top, double left, double right );
  423. void PickMatrix( int x, int y, int width, int height );
  424. void Rotate( float angle, float x, float y, float z );
  425. void Translate( float x, float y, float z );
  426. void Scale( float x, float y, float z );
  427. void ScaleXY( float x, float y );
  428. // Fog methods...
  429. void FogMode( MaterialFogMode_t fogMode );
  430. void FogStart( float fStart );
  431. void FogEnd( float fEnd );
  432. void SetFogZ( float fogZ );
  433. void FogMaxDensity( float flMaxDensity );
  434. void GetFogDistances( float *fStart, float *fEnd, float *fFogZ );
  435. void FogColor3f( float r, float g, float b );
  436. void FogColor3fv( float const* rgb );
  437. void FogColor3ub( unsigned char r, unsigned char g, unsigned char b );
  438. void FogColor3ubv( unsigned char const* rgb );
  439. virtual void SceneFogColor3ub( unsigned char r, unsigned char g, unsigned char b );
  440. virtual void SceneFogMode( MaterialFogMode_t fogMode );
  441. virtual void GetSceneFogColor( unsigned char *rgb );
  442. virtual MaterialFogMode_t GetSceneFogMode( );
  443. virtual int GetPixelFogCombo( );
  444. void SetHeightClipZ( float z );
  445. void SetHeightClipMode( enum MaterialHeightClipMode_t heightClipMode );
  446. void SetClipPlane( int index, const float *pPlane );
  447. void EnableClipPlane( int index, bool bEnable );
  448. void SetFastClipPlane( const float *pPlane );
  449. void EnableFastClip( bool bEnable );
  450. // We use smaller dynamic VBs during level transitions, to free up memory
  451. virtual int GetCurrentDynamicVBSize( void );
  452. virtual int GetCurrentDynamicVBSize( int nIndex = 0 );
  453. virtual void DestroyVertexBuffers( bool bExitingLevel = false );
  454. // Get stats on GPU memory usage
  455. virtual void GetGPUMemoryStats( GPUMemoryStats &stats );
  456. // Sets the vertex and pixel shaders
  457. void SetVertexShaderIndex( int vshIndex );
  458. void SetPixelShaderIndex( int pshIndex );
  459. // Sets the constant register for vertex and pixel shaders
  460. void SetVertexShaderConstant( int var, float const* pVec, int numConst = 1, bool bForce = false );
  461. void SetBooleanVertexShaderConstant( int var, BOOL const* pVec, int numConst = 1, bool bForce = false );
  462. void SetIntegerVertexShaderConstant( int var, int const* pVec, int numConst = 1, bool bForce = false );
  463. void SetPixelShaderConstant( int var, float const* pVec, int numConst = 1, bool bForce = false );
  464. void SetBooleanPixelShaderConstant( int var, BOOL const* pVec, int numBools = 1, bool bForce = false );
  465. void SetIntegerPixelShaderConstant( int var, int const* pVec, int numIntVecs = 1, bool bForce = false );
  466. void InvalidateDelayedShaderConstants( void );
  467. // Gamma<->Linear conversions according to the video hardware we're running on
  468. float GammaToLinear_HardwareSpecific( float fGamma ) const;
  469. float LinearToGamma_HardwareSpecific( float fLinear ) const;
  470. //Set's the linear->gamma conversion textures to use for this hardware for both srgb writes enabled and disabled(identity)
  471. void SetLinearToGammaConversionTextures( ShaderAPITextureHandle_t hSRGBWriteEnabledTexture, ShaderAPITextureHandle_t hIdentityTexture );
  472. // Cull mode
  473. void CullMode( MaterialCullMode_t cullMode );
  474. void FlipCullMode( void );
  475. // Force writes only when z matches. . . useful for stenciling things out
  476. // by rendering the desired Z values ahead of time.
  477. void ForceDepthFuncEquals( bool bEnable );
  478. // Forces Z buffering on or off
  479. void OverrideDepthEnable( bool bEnable, bool bDepthWriteEnable, bool bDepthTestEnable = true );
  480. void OverrideAlphaWriteEnable( bool bOverrideEnable, bool bAlphaWriteEnable );
  481. void OverrideColorWriteEnable( bool bOverrideEnable, bool bColorWriteEnable );
  482. // Sets the shade mode
  483. void ShadeMode( ShaderShadeMode_t mode );
  484. // Binds a particular material to render with
  485. void Bind( IMaterial* pMaterial );
  486. // Returns the nearest supported format
  487. ImageFormat GetNearestSupportedFormat( ImageFormat fmt, bool bFilteringRequired = true ) const;
  488. ImageFormat GetNearestRenderTargetFormat( ImageFormat fmt ) const;
  489. // Sets the texture state
  490. void BindTexture( Sampler_t stage, TextureBindFlags_t nBindFlags, ShaderAPITextureHandle_t textureHandle );
  491. void BindVertexTexture( VertexTextureSampler_t vtSampler, ShaderAPITextureHandle_t textureHandle );
  492. void SetRenderTarget( ShaderAPITextureHandle_t colorTextureHandle, ShaderAPITextureHandle_t depthTextureHandle )
  493. {
  494. }
  495. void SetRenderTargetEx( int nRenderTargetID, ShaderAPITextureHandle_t colorTextureHandle, ShaderAPITextureHandle_t depthTextureHandle )
  496. {
  497. }
  498. // Indicates we're going to be modifying this texture
  499. // TexImage2D, TexSubImage2D, TexWrap, TexMinFilter, and TexMagFilter
  500. // all use the texture specified by this function.
  501. void ModifyTexture( ShaderAPITextureHandle_t textureHandle );
  502. // Texture management methods
  503. void TexImage2D( int level, int cubeFace, ImageFormat dstFormat, int zOffset, int width, int height,
  504. ImageFormat srcFormat, bool bSrcIsTiled, void *imageData );
  505. void TexSubImage2D( int level, int cubeFace, int xOffset, int yOffset, int zOffset, int width, int height,
  506. ImageFormat srcFormat, int srcStride, bool bSrcIsTiled, void *imageData );
  507. bool TexLock( int level, int cubeFaceID, int xOffset, int yOffset,
  508. int width, int height, CPixelWriter& writer );
  509. void TexUnlock( );
  510. void UpdateTexture( int xOffset, int yOffset, int w, int h, ShaderAPITextureHandle_t hDstTexture, ShaderAPITextureHandle_t hSrcTexture );
  511. void *LockTex( ShaderAPITextureHandle_t hTexture );
  512. void UnlockTex( ShaderAPITextureHandle_t hTexture );
  513. void* GetD3DTexturePtr( ShaderAPITextureHandle_t hTexture ) { return NULL; }
  514. bool IsStandardTextureHandleValid( StandardTextureId_t textureId ) { return false; }
  515. // These are bound to the texture, not the texture environment
  516. void TexMinFilter( ShaderTexFilterMode_t texFilterMode );
  517. void TexMagFilter( ShaderTexFilterMode_t texFilterMode );
  518. void TexWrap( ShaderTexCoordComponent_t coord, ShaderTexWrapMode_t wrapMode );
  519. void TexSetPriority( int priority );
  520. ShaderAPITextureHandle_t CreateTexture(
  521. int width,
  522. int height,
  523. int depth,
  524. ImageFormat dstImageFormat,
  525. int numMipLevels,
  526. int numCopies,
  527. int flags,
  528. const char *pDebugName,
  529. const char *pTextureGroupName );
  530. // Create a multi-frame texture (equivalent to calling "CreateTexture" multiple times, but more efficient)
  531. void CreateTextures(
  532. ShaderAPITextureHandle_t *pHandles,
  533. int count,
  534. int width,
  535. int height,
  536. int depth,
  537. ImageFormat dstImageFormat,
  538. int numMipLevels,
  539. int numCopies,
  540. int flags,
  541. const char *pDebugName,
  542. const char *pTextureGroupName );
  543. ShaderAPITextureHandle_t CreateDepthTexture( ImageFormat renderFormat, int width, int height, const char *pDebugName, bool bTexture, bool bAliasDepthTextureOverSceneDepthX360 );
  544. void DeleteTexture( ShaderAPITextureHandle_t textureHandle );
  545. bool IsTexture( ShaderAPITextureHandle_t textureHandle );
  546. bool IsTextureResident( ShaderAPITextureHandle_t textureHandle );
  547. // stuff that isn't to be used from within a shader
  548. void ClearBuffersObeyStencil( bool bClearColor, bool bClearDepth );
  549. void ClearBuffersObeyStencilEx( bool bClearColor, bool bClearAlpha, bool bClearDepth );
  550. void PerformFullScreenStencilOperation( void );
  551. void ReadPixels( int x, int y, int width, int height, unsigned char *data, ImageFormat dstFormat, ITexture *pRenderTargetTexture = NULL );
  552. void ReadPixelsAsync( int x, int y, int width, int height, unsigned char *data, ImageFormat dstFormat, ITexture *pRenderTargetTexture = NULL, CThreadEvent *pPixelsReadEvent = NULL );
  553. void ReadPixelsAsyncGetResult( int x, int y, int width, int height, unsigned char *data, ImageFormat dstFormat, CThreadEvent *pGetResultEvent = NULL );
  554. virtual void ReadPixels( Rect_t *pSrcRect, Rect_t *pDstRect, unsigned char *data, ImageFormat dstFormat, int nDstStride );
  555. // Selection mode methods
  556. int SelectionMode( bool selectionMode );
  557. void SelectionBuffer( unsigned int* pBuffer, int size );
  558. void ClearSelectionNames( );
  559. void LoadSelectionName( int name );
  560. void PushSelectionName( int name );
  561. void PopSelectionName();
  562. void FlushHardware();
  563. void ResetRenderState( bool bFullReset = true );
  564. void SetScissorRect( const int nLeft, const int nTop, const int nRight, const int nBottom, const bool bEnableScissor );
  565. // Can we download textures?
  566. virtual bool CanDownloadTextures() const;
  567. // Board-independent calls, here to unify how shaders set state
  568. // Implementations should chain back to IShaderUtil->BindTexture(), etc.
  569. // Use this to begin and end the frame
  570. void BeginFrame();
  571. void EndFrame();
  572. // returns current time
  573. double CurrentTime() const;
  574. // Get the current camera position in world space.
  575. void GetWorldSpaceCameraPosition( float* pPos ) const;
  576. void GetWorldSpaceCameraDirection( float* pDir ) const;
  577. // Members of IMaterialSystemHardwareConfig
  578. bool HasDestAlphaBuffer() const;
  579. bool HasStencilBuffer() const;
  580. virtual int MaxViewports() const;
  581. virtual void OverrideStreamOffsetSupport( bool bOverrideEnabled, bool bEnableSupport ) {}
  582. virtual ShadowFilterMode_t GetShadowFilterMode( bool bForceLowQualityShadows, bool bPS30 ) const;
  583. int StencilBufferBits() const;
  584. int GetFrameBufferColorDepth() const;
  585. int GetSamplerCount() const;
  586. int GetVertexSamplerCount() const;
  587. bool HasSetDeviceGammaRamp() const;
  588. bool SupportsCompressedTextures() const;
  589. VertexCompressionType_t SupportsCompressedVertices() const;
  590. bool SupportsStaticControlFlow() const;
  591. int MaximumAnisotropicLevel() const;
  592. int MaxTextureWidth() const;
  593. int MaxTextureHeight() const;
  594. int MaxTextureAspectRatio() const;
  595. int GetDXSupportLevel() const;
  596. int GetMinDXSupportLevel() const { return 90; }
  597. bool SupportsShadowDepthTextures( void ) const
  598. {
  599. return false;
  600. }
  601. ImageFormat GetShadowDepthTextureFormat( void ) const
  602. {
  603. return IMAGE_FORMAT_RGBA8888;
  604. }
  605. ImageFormat GetHighPrecisionShadowDepthTextureFormat( void ) const
  606. {
  607. return IMAGE_FORMAT_RGBA8888;
  608. }
  609. ImageFormat GetNullTextureFormat( void ) const
  610. {
  611. return IMAGE_FORMAT_RGBA8888;
  612. }
  613. const char *GetShaderDLLName() const
  614. {
  615. return "UNKNOWN";
  616. }
  617. int TextureMemorySize() const;
  618. bool SupportsMipmappedCubemaps() const;
  619. int GetTextureStageCount() const;
  620. int NumVertexShaderConstants() const;
  621. int NumBooleanVertexShaderConstants() const;
  622. int NumIntegerVertexShaderConstants() const;
  623. int NumPixelShaderConstants() const;
  624. int MaxNumLights() const;
  625. bool SupportsHardwareLighting() const;
  626. int MaxBlendMatrices() const;
  627. int MaxBlendMatrixIndices() const;
  628. int MaxVertexShaderBlendMatrices() const;
  629. int MaxUserClipPlanes() const;
  630. bool UseFastClipping() const
  631. {
  632. return false;
  633. }
  634. bool SpecifiesFogColorInLinearSpace() const;
  635. virtual bool SupportsSRGB() const;
  636. virtual bool FakeSRGBWrite() const;
  637. virtual bool CanDoSRGBReadFromRTs() const;
  638. virtual bool SupportsGLMixedSizeTargets() const;
  639. const char *GetHWSpecificShaderDLLName() const;
  640. bool NeedsAAClamp() const
  641. {
  642. return false;
  643. }
  644. virtual int MaxHWMorphBatchCount() const { return 0; }
  645. // This is the max dx support level supported by the card
  646. virtual int GetMaxDXSupportLevel() const;
  647. bool ReadPixelsFromFrontBuffer() const;
  648. bool PreferDynamicTextures() const;
  649. void ForceHardwareSync( void );
  650. int GetCurrentNumBones( void ) const;
  651. bool IsHWMorphingEnabled( void ) const;
  652. void GetDX9LightState( LightState_t *state ) const;
  653. MaterialFogMode_t GetCurrentFogType( void ) const;
  654. void RecordString( const char *pStr );
  655. void EvictManagedResources();
  656. // Gets the lightmap dimensions
  657. virtual void GetLightmapDimensions( int *w, int *h );
  658. virtual void SyncToken( const char *pToken );
  659. // Setup standard vertex shader constants (that don't change)
  660. // This needs to be called anytime that overbright changes.
  661. virtual void SetStandardVertexShaderConstants( float fOverbright )
  662. {
  663. }
  664. // Level of anisotropic filtering
  665. virtual void SetAnisotropicLevel( int nAnisotropyLevel );
  666. #ifdef _GAMECONSOLE
  667. // Vitaliy: need HDR to run with -noshaderapi on console
  668. bool SupportsHDR() const
  669. {
  670. return true;
  671. }
  672. HDRType_t GetHDRType() const
  673. {
  674. return HDR_TYPE_INTEGER;
  675. }
  676. HDRType_t GetHardwareHDRType() const
  677. {
  678. return HDR_TYPE_INTEGER;
  679. }
  680. #else
  681. bool SupportsHDR() const
  682. {
  683. return false;
  684. }
  685. HDRType_t GetHDRType() const
  686. {
  687. return HDR_TYPE_NONE;
  688. }
  689. HDRType_t GetHardwareHDRType() const
  690. {
  691. return HDR_TYPE_NONE;
  692. }
  693. #endif
  694. virtual bool NeedsATICentroidHack() const
  695. {
  696. return false;
  697. }
  698. virtual bool SupportsColorOnSecondStream() const
  699. {
  700. return false;
  701. }
  702. virtual bool SupportsStaticPlusDynamicLighting() const
  703. {
  704. return false;
  705. }
  706. virtual bool SupportsStreamOffset() const
  707. {
  708. return false;
  709. }
  710. void SetDefaultDynamicState()
  711. {
  712. }
  713. virtual void CommitPixelShaderLighting( int pshReg )
  714. {
  715. }
  716. ShaderAPIOcclusionQuery_t CreateOcclusionQueryObject( void )
  717. {
  718. return INVALID_SHADERAPI_OCCLUSION_QUERY_HANDLE;
  719. }
  720. void DestroyOcclusionQueryObject( ShaderAPIOcclusionQuery_t handle )
  721. {
  722. }
  723. void BeginOcclusionQueryDrawing( ShaderAPIOcclusionQuery_t handle )
  724. {
  725. }
  726. void EndOcclusionQueryDrawing( ShaderAPIOcclusionQuery_t handle )
  727. {
  728. }
  729. int OcclusionQuery_GetNumPixelsRendered( ShaderAPIOcclusionQuery_t handle, bool bFlush )
  730. {
  731. return 0;
  732. }
  733. virtual void AcquireThreadOwnership() {}
  734. virtual void ReleaseThreadOwnership() {}
  735. virtual bool SupportsBorderColor() const { return false; }
  736. virtual bool SupportsFetch4() const { return false; }
  737. virtual void EnableBuffer2FramesAhead( bool bEnable ) {}
  738. virtual float GetShadowDepthBias() const { return 0.0f; }
  739. virtual float GetShadowSlopeScaleDepthBias() const { return 0.0f; }
  740. virtual bool PreferZPrepass() const { return false; }
  741. virtual bool SuppressPixelShaderCentroidHackFixup() const { return true; }
  742. virtual bool PreferTexturesInHWMemory() const { return false; }
  743. virtual bool PreferHardwareSync() const { return false; }
  744. virtual bool IsUnsupported() const { return false; }
  745. virtual void SetDepthFeatheringShaderConstants( int iConstant, float fDepthBlendScale ) {}
  746. virtual TessellationMode_t GetTessellationMode() const { return TESSELLATION_MODE_DISABLED; }
  747. void SetPixelShaderFogParams( int reg ) {}
  748. virtual bool InFlashlightMode() const
  749. {
  750. return false;
  751. }
  752. virtual bool IsRenderingPaint() const
  753. {
  754. return false;
  755. }
  756. virtual bool InEditorMode() const
  757. {
  758. return false;
  759. }
  760. // Binds a standard texture
  761. virtual void BindStandardTexture( Sampler_t stage, TextureBindFlags_t nBindFlags, StandardTextureId_t id )
  762. {
  763. }
  764. virtual void BindStandardVertexTexture( VertexTextureSampler_t stage, StandardTextureId_t id )
  765. {
  766. }
  767. virtual void GetStandardTextureDimensions( int *pWidth, int *pHeight, StandardTextureId_t id )
  768. {
  769. *pWidth = *pHeight = 0;
  770. }
  771. virtual float GetSubDHeight()
  772. {
  773. return 0.0f;
  774. }
  775. virtual bool IsStereoActiveThisFrame() const
  776. {
  777. return false;
  778. }
  779. virtual void SetFlashlightState( const FlashlightState_t &state, const VMatrix &worldToTexture )
  780. {
  781. }
  782. virtual void SetFlashlightStateEx( const FlashlightState_t &state, const VMatrix &worldToTexture, ITexture *pFlashlightDepthTexture )
  783. {
  784. }
  785. virtual bool IsCascadedShadowMapping() const
  786. {
  787. return false;
  788. }
  789. virtual void SetCascadedShadowMapping( bool bEnable )
  790. {
  791. bEnable;
  792. }
  793. virtual void SetCascadedShadowMappingState( const CascadedShadowMappingState_t &state, ITexture *pDepthTextureAtlas )
  794. {
  795. state, pDepthTextureAtlas;
  796. }
  797. virtual const CascadedShadowMappingState_t &GetCascadedShadowMappingState( ITexture **pDepthTextureAtlas, bool bLightMapScale = false ) const
  798. {
  799. static CascadedShadowMappingState_t dummyState;
  800. return dummyState;
  801. }
  802. virtual const FlashlightState_t &GetFlashlightState( VMatrix &worldToTexture ) const
  803. {
  804. static FlashlightState_t blah;
  805. return blah;
  806. }
  807. virtual const FlashlightState_t &GetFlashlightStateEx( VMatrix &worldToTexture, ITexture **pFlashlightDepthTexture ) const
  808. {
  809. static FlashlightState_t blah;
  810. return blah;
  811. }
  812. virtual void GetFlashlightShaderInfo( bool *pShadowsEnabled, bool *pUberLight ) const
  813. {
  814. *pShadowsEnabled = false;
  815. *pUberLight = false;
  816. }
  817. virtual float GetFlashlightAmbientOcclusion( ) const { return 1.0f; }
  818. virtual void ClearVertexAndPixelShaderRefCounts()
  819. {
  820. }
  821. virtual void PurgeUnusedVertexAndPixelShaders()
  822. {
  823. }
  824. virtual void DrawInstances( int nCount, const MeshInstanceData_t *pInstanceData ) {}
  825. virtual bool IsAAEnabled() const
  826. {
  827. return false;
  828. }
  829. virtual int GetVertexTextureCount() const
  830. {
  831. return 0;
  832. }
  833. virtual int GetMaxVertexTextureDimension() const
  834. {
  835. return 0;
  836. }
  837. virtual int MaxTextureDepth() const
  838. {
  839. return 0;
  840. }
  841. // Sets morph target factors
  842. virtual void SetFlexWeights( int nFirstWeight, int nCount, const MorphWeight_t* pWeights )
  843. {
  844. }
  845. // NOTE: Stuff after this is added after shipping HL2.
  846. ITexture *GetRenderTargetEx( int nRenderTargetID ) const
  847. {
  848. return NULL;
  849. }
  850. void SetToneMappingScaleLinear( const Vector &scale )
  851. {
  852. }
  853. const Vector &GetToneMappingScaleLinear( void ) const
  854. {
  855. static Vector dummy;
  856. return dummy;
  857. }
  858. // For dealing with device lost in cases where SwapBuffers isn't called all the time (Hammer)
  859. virtual void HandleDeviceLost()
  860. {
  861. }
  862. virtual void EnableLinearColorSpaceFrameBuffer( bool bEnable )
  863. {
  864. }
  865. // Lets the shader know about the full-screen texture so it can
  866. virtual void SetFullScreenTextureHandle( ShaderAPITextureHandle_t h )
  867. {
  868. }
  869. void SetFloatRenderingParameter(int parm_number, float value)
  870. {
  871. }
  872. void SetIntRenderingParameter(int parm_number, int value)
  873. {
  874. }
  875. void SetTextureRenderingParameter(int parm_number, ITexture *pTexture)
  876. {
  877. }
  878. void SetVectorRenderingParameter(int parm_number, Vector const &value)
  879. {
  880. }
  881. float GetFloatRenderingParameter(int parm_number) const
  882. {
  883. return 0;
  884. }
  885. int GetIntRenderingParameter(int parm_number) const
  886. {
  887. return 0;
  888. }
  889. ITexture *GetTextureRenderingParameter(int parm_number) const
  890. {
  891. return NULL;
  892. }
  893. Vector GetVectorRenderingParameter(int parm_number) const
  894. {
  895. return Vector(0,0,0);
  896. }
  897. // Methods related to stencil
  898. void SetStencilState( const ShaderStencilState_t &state )
  899. {
  900. }
  901. void ClearStencilBufferRectangle( int xmin, int ymin, int xmax, int ymax,int value)
  902. {
  903. }
  904. virtual void GetMaxToRender( IMesh *pMesh, bool bMaxUntilFlush, int *pMaxVerts, int *pMaxIndices )
  905. {
  906. *pMaxVerts = 32768;
  907. *pMaxIndices = 32768;
  908. }
  909. // Returns the max possible vertices + indices to render in a single draw call
  910. virtual int GetMaxVerticesToRender( IMaterial *pMaterial )
  911. {
  912. return 32768;
  913. }
  914. virtual int GetMaxIndicesToRender( )
  915. {
  916. return 32768;
  917. }
  918. virtual int CompareSnapshots( StateSnapshot_t snapshot0, StateSnapshot_t snapshot1 ) { return 0; }
  919. virtual void DisableAllLocalLights() {}
  920. virtual bool SupportsMSAAMode( int nMSAAMode ) { return false; }
  921. virtual bool SupportsCSAAMode( int nNumSamples, int nQualityLevel ) { return false; }
  922. // Hooks for firing PIX events from outside the Material System...
  923. virtual void BeginPIXEvent( unsigned long color, const char *szName ) {}
  924. virtual void EndPIXEvent() {}
  925. virtual void SetPIXMarker( unsigned long color, const char *szName ) {}
  926. virtual void ComputeVertexDescription( unsigned char* pBuffer, VertexFormat_t vertexFormat, MeshDesc_t& desc ) const {}
  927. virtual int VertexFormatSize( VertexFormat_t vertexFormat ) const { return 0; }
  928. virtual bool SupportsShadowDepthTextures() { return false; }
  929. virtual bool SupportsFetch4() { return false; }
  930. virtual int NeedsShaderSRGBConversion(void) const { return 0; }
  931. virtual bool UsesSRGBCorrectBlending() const { return false; }
  932. virtual bool HasFastVertexTextures() const { return false; }
  933. virtual bool ActualHasFastVertexTextures() const { return false; }
  934. virtual void SetShadowDepthBiasFactors( float fShadowSlopeScaleDepthBias, float fShadowDepthBias ) {}
  935. virtual void SetDisallowAccess( bool ) {}
  936. virtual void EnableShaderShaderMutex( bool ) {}
  937. virtual void ShaderLock() {}
  938. virtual void ShaderUnlock() {}
  939. // ------------ New Vertex/Index Buffer interface ----------------------------
  940. void BindVertexBuffer( int streamID, IVertexBuffer *pVertexBuffer, int nOffsetInBytes, int nFirstVertex, int nVertexCount, VertexFormat_t fmt, int nRepetitions1 )
  941. {
  942. }
  943. void BindIndexBuffer( IIndexBuffer *pIndexBuffer, int nOffsetInBytes )
  944. {
  945. }
  946. void Draw( MaterialPrimitiveType_t primitiveType, int firstIndex, int numIndices )
  947. {
  948. }
  949. // ------------ End ----------------------------
  950. virtual int GetVertexBufferCompression( void ) const { return 0; };
  951. virtual bool ShouldWriteDepthToDestAlpha( void ) const { return false; };
  952. #ifdef _GAMECONSOLE
  953. // Vitaliy: need HDR to run with -noshaderapi on console
  954. virtual bool SupportsHDRMode( HDRType_t nMode ) const { return nMode == HDR_TYPE_NONE || nMode == HDR_TYPE_INTEGER; }
  955. #else
  956. virtual bool SupportsHDRMode( HDRType_t nMode ) const { return false; }
  957. #endif
  958. virtual bool IsDX10Card() const { return false; };
  959. void PushDeformation( const DeformationBase_t *pDeformation )
  960. {
  961. }
  962. virtual void PopDeformation( )
  963. {
  964. }
  965. int GetNumActiveDeformations( ) const
  966. {
  967. return 0;
  968. }
  969. // for shaders to set vertex shader constants. returns a packed state which can be used to set the dynamic combo
  970. int GetPackedDeformationInformation( int nMaskOfUnderstoodDeformations,
  971. float *pConstantValuesOut,
  972. int nBufferSize,
  973. int nMaximumDeformations,
  974. int *pNumDefsOut ) const
  975. {
  976. *pNumDefsOut = 0;
  977. return 0;
  978. }
  979. void SetStandardTextureHandle(StandardTextureId_t,ShaderAPITextureHandle_t)
  980. {
  981. }
  982. virtual void ExecuteCommandBuffer( uint8 *pData )
  983. {
  984. }
  985. virtual bool GetHDREnabled( void ) const { return true; }
  986. virtual void SetHDREnabled( bool bEnable ) {}
  987. virtual void SetTextureFilterMode( Sampler_t sampler, TextureFilterMode_t nMode )
  988. {
  989. }
  990. virtual void SetScreenSizeForVPOS( int pshReg ) {}
  991. virtual void SetVSNearAndFarZ( int vshReg ) {}
  992. virtual float GetFarZ() { return 1000.0f; }
  993. virtual void EnableSinglePassFlashlightMode( bool bEnable ) {}
  994. virtual bool SinglePassFlashlightModeEnabled( void ) { return false; }
  995. virtual void FlipCulling( bool bFlipCulling ) {}
  996. virtual void UpdateGameTime( float flTime ) {}
  997. virtual bool IsStereoSupported() const { return false; }
  998. virtual void UpdateStereoTexture( ShaderAPITextureHandle_t texHandle, bool *pStereoActiveThisFrame ) {}
  999. virtual void SetSRGBWrite( bool bState ) {}
  1000. void PrintfVA( char *fmt, va_list vargs ) {}
  1001. void Printf( char *fmt, ... ) {}
  1002. float Knob( char *knobname, float *setvalue = NULL ) { return 0.0f; };
  1003. void AddShaderComboInformation( const ShaderComboSemantics_t *pSemantics ) {}
  1004. virtual void SpinPresent( uint nFrames ){}
  1005. virtual void AntiAliasingHint( int nHint ) {}
  1006. virtual bool SupportsCascadedShadowMapping() const { return true; }
  1007. virtual CSMQualityMode_t GetCSMQuality() const { return CSMQUALITY_VERY_LOW; }
  1008. virtual bool SupportsBilinearPCFSampling() const { return true; }
  1009. virtual CSMShaderMode_t GetCSMShaderMode( CSMQualityMode_t nQualityLevel ) const { nQualityLevel; return CSMSHADERMODE_LOW_OR_VERY_LOW; }
  1010. virtual void SetCSMAccurateBlending( bool bEnable ) {}
  1011. virtual bool GetCSMAccurateBlending() const { return true; }
  1012. virtual bool SupportsResolveDepth() const { return false; }
  1013. virtual bool HasFullResolutionDepthTexture() const { return false; }
  1014. private:
  1015. enum
  1016. {
  1017. TRANSLUCENT = 0x1,
  1018. ALPHATESTED = 0x2,
  1019. VERTEX_AND_PIXEL_SHADERS = 0x4,
  1020. DEPTHWRITE = 0x8,
  1021. };
  1022. CEmptyMesh m_Mesh;
  1023. void EnableAlphaToCoverage() {} ;
  1024. void DisableAlphaToCoverage() {} ;
  1025. ImageFormat GetShadowDepthTextureFormat() { return IMAGE_FORMAT_UNKNOWN; };
  1026. ImageFormat GetHighPrecisionShadowDepthTextureFormat() { return IMAGE_FORMAT_UNKNOWN; };
  1027. ImageFormat GetNullTextureFormat() { return IMAGE_FORMAT_UNKNOWN; };
  1028. float GetLightMapScaleFactor() const { return 1.0f; }
  1029. ShaderAPITextureHandle_t FindTexture( const char *pDebugName ) { return INVALID_SHADERAPI_TEXTURE_HANDLE;};
  1030. void GetTextureDimensions( ShaderAPITextureHandle_t hTexture, int &nWidth, int &nHeight, int &nDepth ) {};
  1031. ShaderAPITextureHandle_t GetStandardTextureHandle(StandardTextureId_t id) { return INVALID_SHADERAPI_TEXTURE_HANDLE; }
  1032. };
  1033. //-----------------------------------------------------------------------------
  1034. // Class Factory
  1035. //-----------------------------------------------------------------------------
  1036. static CShaderAPIEmpty g_ShaderAPIEmpty;
  1037. static CShaderShadowEmpty g_ShaderShadow;
  1038. // FIXME: Remove; it's for backward compat with the materialsystem only for now
  1039. EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CShaderAPIEmpty, IShaderAPI,
  1040. SHADERAPI_INTERFACE_VERSION, g_ShaderAPIEmpty )
  1041. EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CShaderShadowEmpty, IShaderShadow,
  1042. SHADERSHADOW_INTERFACE_VERSION, g_ShaderShadow )
  1043. EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CShaderAPIEmpty, IMaterialSystemHardwareConfig,
  1044. MATERIALSYSTEM_HARDWARECONFIG_INTERFACE_VERSION, g_ShaderAPIEmpty )
  1045. EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CShaderAPIEmpty, IDebugTextureInfo,
  1046. DEBUG_TEXTURE_INFO_VERSION, g_ShaderAPIEmpty )
  1047. //-----------------------------------------------------------------------------
  1048. // The main GL Shader util interface
  1049. //-----------------------------------------------------------------------------
  1050. IShaderUtil* g_pShaderUtil;
  1051. //-----------------------------------------------------------------------------
  1052. // Factory to return from SetMode
  1053. //-----------------------------------------------------------------------------
  1054. static void* ShaderInterfaceFactory( const char *pInterfaceName, int *pReturnCode )
  1055. {
  1056. if ( pReturnCode )
  1057. {
  1058. *pReturnCode = IFACE_OK;
  1059. }
  1060. if ( !Q_stricmp( pInterfaceName, SHADER_DEVICE_INTERFACE_VERSION ) )
  1061. return static_cast< IShaderDevice* >( &s_ShaderDeviceEmpty );
  1062. if ( !Q_stricmp( pInterfaceName, SHADERAPI_INTERFACE_VERSION ) )
  1063. return static_cast< IShaderAPI* >( &g_ShaderAPIEmpty );
  1064. if ( !Q_stricmp( pInterfaceName, SHADERSHADOW_INTERFACE_VERSION ) )
  1065. return static_cast< IShaderShadow* >( &g_ShaderShadow );
  1066. if ( pReturnCode )
  1067. {
  1068. *pReturnCode = IFACE_FAILED;
  1069. }
  1070. return NULL;
  1071. }
  1072. //-----------------------------------------------------------------------------
  1073. //
  1074. // CShaderDeviceMgrEmpty
  1075. //
  1076. //-----------------------------------------------------------------------------
  1077. bool CShaderDeviceMgrEmpty::Connect( CreateInterfaceFn factory )
  1078. {
  1079. // So others can access it
  1080. g_pShaderUtil = (IShaderUtil*)factory( SHADER_UTIL_INTERFACE_VERSION, NULL );
  1081. return true;
  1082. }
  1083. void CShaderDeviceMgrEmpty::Disconnect()
  1084. {
  1085. g_pShaderUtil = NULL;
  1086. }
  1087. void *CShaderDeviceMgrEmpty::QueryInterface( const char *pInterfaceName )
  1088. {
  1089. if ( !Q_stricmp( pInterfaceName, SHADER_DEVICE_MGR_INTERFACE_VERSION ) )
  1090. return static_cast< IShaderDeviceMgr* >( this );
  1091. if ( !Q_stricmp( pInterfaceName, MATERIALSYSTEM_HARDWARECONFIG_INTERFACE_VERSION ) )
  1092. return static_cast< IMaterialSystemHardwareConfig* >( &g_ShaderAPIEmpty );
  1093. return NULL;
  1094. }
  1095. InitReturnVal_t CShaderDeviceMgrEmpty::Init()
  1096. {
  1097. return INIT_OK;
  1098. }
  1099. void CShaderDeviceMgrEmpty::Shutdown()
  1100. {
  1101. }
  1102. // Sets the adapter
  1103. bool CShaderDeviceMgrEmpty::SetAdapter( int nAdapter, int nFlags )
  1104. {
  1105. return true;
  1106. }
  1107. // FIXME: Is this a public interface? Might only need to be private to shaderapi
  1108. CreateInterfaceFn CShaderDeviceMgrEmpty::SetMode( void *hWnd, int nAdapter, const ShaderDeviceInfo_t& mode )
  1109. {
  1110. return ShaderInterfaceFactory;
  1111. }
  1112. // Gets the number of adapters...
  1113. int CShaderDeviceMgrEmpty::GetAdapterCount() const
  1114. {
  1115. return 0;
  1116. }
  1117. bool CShaderDeviceMgrEmpty::GetRecommendedVideoConfig( int nAdapter, KeyValues *pKeyValues )
  1118. {
  1119. return true;
  1120. }
  1121. bool CShaderDeviceMgrEmpty::GetRecommendedConfigurationInfo( int nAdapter, int nDXLevel, KeyValues *pKeyValues )
  1122. {
  1123. return true;
  1124. }
  1125. // Returns info about each adapter
  1126. void CShaderDeviceMgrEmpty::GetAdapterInfo( int adapter, MaterialAdapterInfo_t& info ) const
  1127. {
  1128. memset( &info, 0, sizeof( info ) );
  1129. info.m_nDXSupportLevel = 90;
  1130. }
  1131. // Returns the number of modes
  1132. int CShaderDeviceMgrEmpty::GetModeCount( int nAdapter ) const
  1133. {
  1134. return 0;
  1135. }
  1136. // Returns mode information..
  1137. void CShaderDeviceMgrEmpty::GetModeInfo( ShaderDisplayMode_t *pInfo, int nAdapter, int nMode ) const
  1138. {
  1139. }
  1140. void CShaderDeviceMgrEmpty::GetCurrentModeInfo( ShaderDisplayMode_t* pInfo, int nAdapter ) const
  1141. {
  1142. }
  1143. //-----------------------------------------------------------------------------
  1144. //
  1145. // Shader device empty
  1146. //
  1147. //-----------------------------------------------------------------------------
  1148. void CShaderDeviceEmpty::GetWindowSize( int &width, int &height ) const
  1149. {
  1150. if ( IsPC() )
  1151. {
  1152. width = 0;
  1153. height = 0;
  1154. }
  1155. else
  1156. {
  1157. width = 640;
  1158. height = 480;
  1159. }
  1160. }
  1161. void CShaderDeviceEmpty::GetBackBufferDimensions( int& width, int& height ) const
  1162. {
  1163. if ( IsPC() )
  1164. {
  1165. width = 1024;
  1166. height = 768;
  1167. }
  1168. else
  1169. {
  1170. width = 640;
  1171. height = 480;
  1172. }
  1173. }
  1174. // Use this to spew information about the 3D layer
  1175. void CShaderDeviceEmpty::SpewDriverInfo() const
  1176. {
  1177. Warning("Empty shader\n");
  1178. }
  1179. // Creates/ destroys a child window
  1180. bool CShaderDeviceEmpty::AddView( void* hwnd )
  1181. {
  1182. return true;
  1183. }
  1184. void CShaderDeviceEmpty::RemoveView( void* hwnd )
  1185. {
  1186. }
  1187. // Activates a view
  1188. void CShaderDeviceEmpty::SetView( void* hwnd )
  1189. {
  1190. }
  1191. void CShaderDeviceEmpty::ReleaseResources( bool bReleaseManagedResources /*= true*/ )
  1192. {
  1193. }
  1194. void CShaderDeviceEmpty::ReacquireResources()
  1195. {
  1196. }
  1197. // Creates/destroys Mesh
  1198. IMesh* CShaderDeviceEmpty::CreateStaticMesh( VertexFormat_t fmt, const char *pTextureBudgetGroup, IMaterial * pMaterial, VertexStreamSpec_t *pStreamSpec )
  1199. {
  1200. return &m_Mesh;
  1201. }
  1202. void CShaderDeviceEmpty::DestroyStaticMesh( IMesh* mesh )
  1203. {
  1204. }
  1205. // Creates/destroys static vertex + index buffers
  1206. IVertexBuffer *CShaderDeviceEmpty::CreateVertexBuffer( ShaderBufferType_t type, VertexFormat_t fmt, int nVertexCount, const char *pTextureBudgetGroup )
  1207. {
  1208. return ( type == SHADER_BUFFER_TYPE_STATIC || type == SHADER_BUFFER_TYPE_STATIC_TEMP ) ? &m_Mesh : &m_DynamicMesh;
  1209. }
  1210. void CShaderDeviceEmpty::DestroyVertexBuffer( IVertexBuffer *pVertexBuffer )
  1211. {
  1212. }
  1213. IIndexBuffer *CShaderDeviceEmpty::CreateIndexBuffer( ShaderBufferType_t bufferType, MaterialIndexFormat_t fmt, int nIndexCount, const char *pTextureBudgetGroup )
  1214. {
  1215. switch( bufferType )
  1216. {
  1217. case SHADER_BUFFER_TYPE_STATIC:
  1218. case SHADER_BUFFER_TYPE_STATIC_TEMP:
  1219. return &m_Mesh;
  1220. default:
  1221. Assert( 0 );
  1222. case SHADER_BUFFER_TYPE_DYNAMIC:
  1223. case SHADER_BUFFER_TYPE_DYNAMIC_TEMP:
  1224. return &m_DynamicMesh;
  1225. }
  1226. }
  1227. void CShaderDeviceEmpty::DestroyIndexBuffer( IIndexBuffer *pIndexBuffer )
  1228. {
  1229. }
  1230. IVertexBuffer *CShaderDeviceEmpty::GetDynamicVertexBuffer( int streamID, VertexFormat_t vertexFormat, bool bBuffered )
  1231. {
  1232. return &m_DynamicMesh;
  1233. }
  1234. IIndexBuffer *CShaderDeviceEmpty::GetDynamicIndexBuffer()
  1235. {
  1236. return &m_Mesh;
  1237. }
  1238. //-----------------------------------------------------------------------------
  1239. //
  1240. // The empty mesh...
  1241. //
  1242. //-----------------------------------------------------------------------------
  1243. CEmptyMesh::CEmptyMesh( bool bIsDynamic ) : m_bIsDynamic( bIsDynamic )
  1244. {
  1245. m_pVertexMemory = new unsigned char[VERTEX_BUFFER_SIZE];
  1246. }
  1247. CEmptyMesh::~CEmptyMesh()
  1248. {
  1249. delete[] m_pVertexMemory;
  1250. }
  1251. bool CEmptyMesh::Lock( int nMaxIndexCount, bool bAppend, IndexDesc_t& desc )
  1252. {
  1253. static int s_BogusIndex;
  1254. desc.m_pIndices = (unsigned short*)&s_BogusIndex;
  1255. desc.m_nIndexSize = 0;
  1256. desc.m_nFirstIndex = 0;
  1257. desc.m_nOffset = 0;
  1258. return true;
  1259. }
  1260. void CEmptyMesh::Unlock( int nWrittenIndexCount, IndexDesc_t& desc )
  1261. {
  1262. }
  1263. void CEmptyMesh::ModifyBegin( bool bReadOnly, int nFirstIndex, int nIndexCount, IndexDesc_t& desc )
  1264. {
  1265. Lock( nIndexCount, false, desc );
  1266. }
  1267. void CEmptyMesh::ModifyEnd( IndexDesc_t& desc )
  1268. {
  1269. }
  1270. void CEmptyMesh::Spew( int nIndexCount, const IndexDesc_t & desc )
  1271. {
  1272. }
  1273. void CEmptyMesh::ValidateData( int nIndexCount, const IndexDesc_t &desc )
  1274. {
  1275. }
  1276. bool CEmptyMesh::Lock( int nVertexCount, bool bAppend, VertexDesc_t &desc )
  1277. {
  1278. // Who cares about the data?
  1279. desc.m_pPosition = (float*)m_pVertexMemory;
  1280. desc.m_pNormal = (float*)m_pVertexMemory;
  1281. desc.m_pColor = m_pVertexMemory;
  1282. int i;
  1283. for ( i = 0; i < VERTEX_MAX_TEXTURE_COORDINATES; ++i)
  1284. {
  1285. desc.m_pTexCoord[i] = (float*)m_pVertexMemory;
  1286. }
  1287. desc.m_pBoneWeight = (float*)m_pVertexMemory;
  1288. desc.m_pBoneMatrixIndex = (unsigned char*)m_pVertexMemory;
  1289. desc.m_pTangentS = (float*)m_pVertexMemory;
  1290. desc.m_pTangentT = (float*)m_pVertexMemory;
  1291. desc.m_pUserData = (float*)m_pVertexMemory;
  1292. desc.m_pSpecular = m_pVertexMemory;
  1293. desc.m_pWrinkle = (float*)m_pVertexMemory;
  1294. desc.m_NumBoneWeights = 2;
  1295. desc.m_VertexSize_Position = 0;
  1296. desc.m_VertexSize_BoneWeight = 0;
  1297. desc.m_VertexSize_BoneMatrixIndex = 0;
  1298. desc.m_VertexSize_Normal = 0;
  1299. desc.m_VertexSize_Color = 0;
  1300. for( i=0; i < VERTEX_MAX_TEXTURE_COORDINATES; i++ )
  1301. {
  1302. desc.m_VertexSize_TexCoord[i] = 0;
  1303. }
  1304. desc.m_VertexSize_TangentS = 0;
  1305. desc.m_VertexSize_TangentT = 0;
  1306. desc.m_VertexSize_UserData = 0;
  1307. desc.m_VertexSize_Specular = 0;
  1308. desc.m_VertexSize_Wrinkle = 0;
  1309. desc.m_ActualVertexSize = 0; // Size of the vertices.. Some of the m_VertexSize_ elements above
  1310. desc.m_nFirstVertex = 0;
  1311. desc.m_nOffset = 0;
  1312. return true;
  1313. }
  1314. void CEmptyMesh::Unlock( int nVertexCount, VertexDesc_t &desc )
  1315. {
  1316. }
  1317. void CEmptyMesh::Spew( int nVertexCount, const VertexDesc_t &desc )
  1318. {
  1319. }
  1320. void CEmptyMesh::ValidateData( int nVertexCount, const VertexDesc_t & desc )
  1321. {
  1322. }
  1323. void CEmptyMesh::LockMesh( int numVerts, int numIndices, MeshDesc_t& desc, MeshBuffersAllocationSettings_t *pSettings )
  1324. {
  1325. Lock( numVerts, false, *static_cast<VertexDesc_t*>( &desc ) );
  1326. Lock( numIndices, false, *static_cast<IndexDesc_t*>( &desc ) );
  1327. }
  1328. void CEmptyMesh::UnlockMesh( int numVerts, int numIndices, MeshDesc_t& desc )
  1329. {
  1330. }
  1331. void CEmptyMesh::ModifyBeginEx( bool bReadOnly, int firstVertex, int numVerts, int firstIndex, int numIndices, MeshDesc_t& desc )
  1332. {
  1333. Lock( numVerts, false, *static_cast<VertexDesc_t*>( &desc ) );
  1334. Lock( numIndices, false, *static_cast<IndexDesc_t*>( &desc ) );
  1335. }
  1336. void CEmptyMesh::ModifyBegin( int firstVertex, int numVerts, int firstIndex, int numIndices, MeshDesc_t& desc )
  1337. {
  1338. ModifyBeginEx( false, firstVertex, numVerts, firstIndex, numIndices, desc );
  1339. }
  1340. void CEmptyMesh::ModifyEnd( MeshDesc_t& desc )
  1341. {
  1342. }
  1343. // returns the # of vertices (static meshes only)
  1344. int CEmptyMesh::VertexCount() const
  1345. {
  1346. return 0;
  1347. }
  1348. // Sets the primitive type
  1349. void CEmptyMesh::SetPrimitiveType( MaterialPrimitiveType_t type )
  1350. {
  1351. }
  1352. // Draws the entire mesh
  1353. void CEmptyMesh::Draw( int firstIndex, int numIndices )
  1354. {
  1355. }
  1356. void CEmptyMesh::Draw(CPrimList *pPrims, int nPrims)
  1357. {
  1358. }
  1359. // Copy verts and/or indices to a mesh builder. This only works for temp meshes!
  1360. void CEmptyMesh::CopyToMeshBuilder(
  1361. int iStartVert, // Which vertices to copy.
  1362. int nVerts,
  1363. int iStartIndex, // Which indices to copy.
  1364. int nIndices,
  1365. int indexOffset, // This is added to each index.
  1366. CMeshBuilder &builder )
  1367. {
  1368. }
  1369. // Spews the mesh data
  1370. void CEmptyMesh::Spew( int numVerts, int numIndices, const MeshDesc_t & desc )
  1371. {
  1372. }
  1373. void CEmptyMesh::ValidateData( int numVerts, int numIndices, const MeshDesc_t & desc )
  1374. {
  1375. }
  1376. // gets the associated material
  1377. IMaterial* CEmptyMesh::GetMaterial()
  1378. {
  1379. // umm. this don't work none
  1380. Assert(0);
  1381. return 0;
  1382. }
  1383. //-----------------------------------------------------------------------------
  1384. // The shader shadow interface
  1385. //-----------------------------------------------------------------------------
  1386. CShaderShadowEmpty::CShaderShadowEmpty()
  1387. {
  1388. m_IsTranslucent = false;
  1389. m_ForceOpaque = false;
  1390. m_IsAlphaTested = false;
  1391. m_bIsDepthWriteEnabled = true;
  1392. m_bUsesVertexAndPixelShaders = false;
  1393. }
  1394. CShaderShadowEmpty::~CShaderShadowEmpty()
  1395. {
  1396. }
  1397. // Sets the default *shadow* state
  1398. void CShaderShadowEmpty::SetDefaultState()
  1399. {
  1400. m_IsTranslucent = false;
  1401. m_ForceOpaque = false;
  1402. m_IsAlphaTested = false;
  1403. m_bIsDepthWriteEnabled = true;
  1404. m_bUsesVertexAndPixelShaders = false;
  1405. }
  1406. // Methods related to depth buffering
  1407. void CShaderShadowEmpty::DepthFunc( ShaderDepthFunc_t depthFunc )
  1408. {
  1409. }
  1410. void CShaderShadowEmpty::EnableDepthWrites( bool bEnable )
  1411. {
  1412. m_bIsDepthWriteEnabled = bEnable;
  1413. }
  1414. void CShaderShadowEmpty::EnableDepthTest( bool bEnable )
  1415. {
  1416. }
  1417. void CShaderShadowEmpty::EnablePolyOffset( PolygonOffsetMode_t nOffsetMode )
  1418. {
  1419. }
  1420. // Suppresses/activates color writing
  1421. void CShaderShadowEmpty::EnableColorWrites( bool bEnable )
  1422. {
  1423. }
  1424. // Suppresses/activates alpha writing
  1425. void CShaderShadowEmpty::EnableAlphaWrites( bool bEnable )
  1426. {
  1427. }
  1428. // Methods related to alpha blending
  1429. void CShaderShadowEmpty::EnableBlending( bool bEnable )
  1430. {
  1431. m_IsTranslucent = bEnable;
  1432. m_ForceOpaque = false;
  1433. }
  1434. void CShaderShadowEmpty::EnableBlendingForceOpaque( bool bEnable )
  1435. {
  1436. m_IsTranslucent = bEnable;
  1437. m_ForceOpaque = true;
  1438. }
  1439. void CShaderShadowEmpty::BlendFunc( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor )
  1440. {
  1441. }
  1442. // Alpha testing
  1443. void CShaderShadowEmpty::EnableAlphaTest( bool bEnable )
  1444. {
  1445. m_IsAlphaTested = bEnable;
  1446. }
  1447. void CShaderShadowEmpty::AlphaFunc( ShaderAlphaFunc_t alphaFunc, float alphaRef /* [0-1] */ )
  1448. {
  1449. }
  1450. // Wireframe/filled polygons
  1451. void CShaderShadowEmpty::PolyMode( ShaderPolyModeFace_t face, ShaderPolyMode_t polyMode )
  1452. {
  1453. }
  1454. // Back face culling
  1455. void CShaderShadowEmpty::EnableCulling( bool bEnable )
  1456. {
  1457. }
  1458. // Alpha to coverage
  1459. void CShaderShadowEmpty::EnableAlphaToCoverage( bool bEnable )
  1460. {
  1461. }
  1462. // Indicates the vertex format for use with a vertex shader
  1463. // The flags to pass in here come from the VertexFormatFlags_t enum
  1464. // If pTexCoordDimensions is *not* specified, we assume all coordinates
  1465. // are 2-dimensional
  1466. void CShaderShadowEmpty::VertexShaderVertexFormat( unsigned int nFlags,
  1467. int nTexCoordCount,
  1468. int* pTexCoordDimensions,
  1469. int nUserDataSize )
  1470. {
  1471. }
  1472. // Sets the vertex and pixel shaders
  1473. void CShaderShadowEmpty::SetVertexShader( const char *pShaderName, int vshIndex )
  1474. {
  1475. m_bUsesVertexAndPixelShaders = ( pShaderName != NULL );
  1476. }
  1477. void CShaderShadowEmpty::EnableBlendingSeparateAlpha( bool bEnable )
  1478. {
  1479. }
  1480. void CShaderShadowEmpty::SetPixelShader( const char *pShaderName, int pshIndex )
  1481. {
  1482. m_bUsesVertexAndPixelShaders = ( pShaderName != NULL );
  1483. }
  1484. void CShaderShadowEmpty::BlendFuncSeparateAlpha( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor )
  1485. {
  1486. }
  1487. //-----------------------------------------------------------------------------
  1488. //
  1489. // Shader API Empty
  1490. //
  1491. //-----------------------------------------------------------------------------
  1492. //-----------------------------------------------------------------------------
  1493. // Constructor, destructor
  1494. //-----------------------------------------------------------------------------
  1495. CShaderAPIEmpty::CShaderAPIEmpty() : m_Mesh( false )
  1496. {
  1497. }
  1498. CShaderAPIEmpty::~CShaderAPIEmpty()
  1499. {
  1500. }
  1501. bool CShaderAPIEmpty::DoRenderTargetsNeedSeparateDepthBuffer() const
  1502. {
  1503. return false;
  1504. }
  1505. // Can we download textures?
  1506. bool CShaderAPIEmpty::CanDownloadTextures() const
  1507. {
  1508. return false;
  1509. }
  1510. // Used to clear the transition table when we know it's become invalid.
  1511. void CShaderAPIEmpty::ClearSnapshots()
  1512. {
  1513. }
  1514. // Members of IMaterialSystemHardwareConfig
  1515. bool CShaderAPIEmpty::HasDestAlphaBuffer() const
  1516. {
  1517. return false;
  1518. }
  1519. bool CShaderAPIEmpty::HasStencilBuffer() const
  1520. {
  1521. return false;
  1522. }
  1523. int CShaderAPIEmpty::MaxViewports() const
  1524. {
  1525. return 1;
  1526. }
  1527. ShadowFilterMode_t CShaderAPIEmpty::GetShadowFilterMode( bool bForceLowQualityShadows, bool bPS30 ) const
  1528. {
  1529. bForceLowQualityShadows;
  1530. bPS30;
  1531. return SHADOWFILTERMODE_DEFAULT;
  1532. }
  1533. int CShaderAPIEmpty::StencilBufferBits() const
  1534. {
  1535. return 0;
  1536. }
  1537. int CShaderAPIEmpty::GetFrameBufferColorDepth() const
  1538. {
  1539. return 0;
  1540. }
  1541. int CShaderAPIEmpty::GetSamplerCount() const
  1542. {
  1543. return 4;
  1544. }
  1545. int CShaderAPIEmpty::GetVertexSamplerCount() const
  1546. {
  1547. return 0;
  1548. }
  1549. bool CShaderAPIEmpty::HasSetDeviceGammaRamp() const
  1550. {
  1551. return false;
  1552. }
  1553. bool CShaderAPIEmpty::SupportsCompressedTextures() const
  1554. {
  1555. return false;
  1556. }
  1557. bool CShaderAPIEmpty::SupportsStaticControlFlow() const
  1558. {
  1559. // Yes, unconditionally unless we're on POSIX
  1560. return !IsOpenGL();
  1561. }
  1562. VertexCompressionType_t CShaderAPIEmpty::SupportsCompressedVertices() const
  1563. {
  1564. return VERTEX_COMPRESSION_NONE;
  1565. }
  1566. int CShaderAPIEmpty::MaximumAnisotropicLevel() const
  1567. {
  1568. return 0;
  1569. }
  1570. void CShaderAPIEmpty::SetAnisotropicLevel( int nAnisotropyLevel )
  1571. {
  1572. }
  1573. int CShaderAPIEmpty::MaxTextureWidth() const
  1574. {
  1575. // Should be big enough to cover all cases
  1576. return 16384;
  1577. }
  1578. int CShaderAPIEmpty::MaxTextureHeight() const
  1579. {
  1580. // Should be big enough to cover all cases
  1581. return 16384;
  1582. }
  1583. int CShaderAPIEmpty::MaxTextureAspectRatio() const
  1584. {
  1585. // Should be big enough to cover all cases
  1586. return 16384;
  1587. }
  1588. int CShaderAPIEmpty::TextureMemorySize() const
  1589. {
  1590. // fake it
  1591. return 1024 * 1024 * 1024;
  1592. }
  1593. int CShaderAPIEmpty::GetDXSupportLevel() const
  1594. {
  1595. return 95;
  1596. }
  1597. bool CShaderAPIEmpty::SupportsMipmappedCubemaps() const
  1598. {
  1599. return true;
  1600. }
  1601. int CShaderAPIEmpty::NumVertexShaderConstants() const
  1602. {
  1603. return 128;
  1604. }
  1605. int CShaderAPIEmpty::NumBooleanVertexShaderConstants() const
  1606. {
  1607. return 0;
  1608. }
  1609. int CShaderAPIEmpty::NumIntegerVertexShaderConstants() const
  1610. {
  1611. return 0;
  1612. }
  1613. int CShaderAPIEmpty::NumPixelShaderConstants() const
  1614. {
  1615. return 8;
  1616. }
  1617. int CShaderAPIEmpty::MaxNumLights() const
  1618. {
  1619. return 4;
  1620. }
  1621. // This is the max dx support level supported by the card
  1622. int CShaderAPIEmpty::GetMaxDXSupportLevel() const
  1623. {
  1624. return 90;
  1625. }
  1626. int CShaderAPIEmpty::MaxVertexShaderBlendMatrices() const
  1627. {
  1628. return 0;
  1629. }
  1630. int CShaderAPIEmpty::MaxUserClipPlanes() const
  1631. {
  1632. return 0;
  1633. }
  1634. bool CShaderAPIEmpty::SpecifiesFogColorInLinearSpace() const
  1635. {
  1636. return false;
  1637. }
  1638. bool CShaderAPIEmpty::SupportsSRGB() const
  1639. {
  1640. return false;
  1641. }
  1642. bool CShaderAPIEmpty::FakeSRGBWrite() const
  1643. {
  1644. return false;
  1645. }
  1646. bool CShaderAPIEmpty::CanDoSRGBReadFromRTs() const
  1647. {
  1648. return true;
  1649. }
  1650. bool CShaderAPIEmpty::SupportsGLMixedSizeTargets() const
  1651. {
  1652. return false;
  1653. }
  1654. const char *CShaderAPIEmpty::GetHWSpecificShaderDLLName() const
  1655. {
  1656. return 0;
  1657. }
  1658. // Sets the default *dynamic* state
  1659. void CShaderAPIEmpty::SetDefaultState()
  1660. {
  1661. }
  1662. // Returns the snapshot id for the shader state
  1663. StateSnapshot_t CShaderAPIEmpty::TakeSnapshot( )
  1664. {
  1665. StateSnapshot_t id = 0;
  1666. if (g_ShaderShadow.m_IsTranslucent && !g_ShaderShadow.m_ForceOpaque)
  1667. id |= TRANSLUCENT;
  1668. if (g_ShaderShadow.m_IsAlphaTested)
  1669. id |= ALPHATESTED;
  1670. if (g_ShaderShadow.m_bUsesVertexAndPixelShaders)
  1671. id |= VERTEX_AND_PIXEL_SHADERS;
  1672. if (g_ShaderShadow.m_bIsDepthWriteEnabled)
  1673. id |= DEPTHWRITE;
  1674. return id;
  1675. }
  1676. // Returns true if the state snapshot is transparent
  1677. bool CShaderAPIEmpty::IsTranslucent( StateSnapshot_t id ) const
  1678. {
  1679. return (id & TRANSLUCENT) != 0;
  1680. }
  1681. bool CShaderAPIEmpty::IsAlphaTested( StateSnapshot_t id ) const
  1682. {
  1683. return (id & ALPHATESTED) != 0;
  1684. }
  1685. bool CShaderAPIEmpty::IsDepthWriteEnabled( StateSnapshot_t id ) const
  1686. {
  1687. return (id & DEPTHWRITE) != 0;
  1688. }
  1689. bool CShaderAPIEmpty::UsesVertexAndPixelShaders( StateSnapshot_t id ) const
  1690. {
  1691. return (id & VERTEX_AND_PIXEL_SHADERS) != 0;
  1692. }
  1693. // Gets the vertex format for a set of snapshot ids
  1694. VertexFormat_t CShaderAPIEmpty::ComputeVertexFormat( int numSnapshots, StateSnapshot_t* pIds ) const
  1695. {
  1696. return 0;
  1697. }
  1698. // Gets the vertex format for a set of snapshot ids
  1699. VertexFormat_t CShaderAPIEmpty::ComputeVertexUsage( int numSnapshots, StateSnapshot_t* pIds ) const
  1700. {
  1701. return 0;
  1702. }
  1703. // Uses a state snapshot
  1704. void CShaderAPIEmpty::UseSnapshot( StateSnapshot_t snapshot )
  1705. {
  1706. }
  1707. // The shade mode
  1708. void CShaderAPIEmpty::ShadeMode( ShaderShadeMode_t mode )
  1709. {
  1710. }
  1711. // Binds a particular material to render with
  1712. void CShaderAPIEmpty::Bind( IMaterial* pMaterial )
  1713. {
  1714. }
  1715. // Cull mode
  1716. void CShaderAPIEmpty::CullMode( MaterialCullMode_t cullMode )
  1717. {
  1718. }
  1719. void CShaderAPIEmpty::FlipCullMode( void )
  1720. {
  1721. }
  1722. void CShaderAPIEmpty::ForceDepthFuncEquals( bool bEnable )
  1723. {
  1724. }
  1725. // Forces Z buffering on or off
  1726. void CShaderAPIEmpty::OverrideDepthEnable( bool bEnable, bool bDepthWriteEnable, bool bDepthTestEnable )
  1727. {
  1728. }
  1729. void CShaderAPIEmpty::OverrideAlphaWriteEnable( bool bOverrideEnable, bool bAlphaWriteEnable )
  1730. {
  1731. }
  1732. void CShaderAPIEmpty::OverrideColorWriteEnable( bool bOverrideEnable, bool bColorWriteEnable )
  1733. {
  1734. }
  1735. //legacy fast clipping linkage
  1736. void CShaderAPIEmpty::SetHeightClipZ( float z )
  1737. {
  1738. }
  1739. void CShaderAPIEmpty::SetHeightClipMode( enum MaterialHeightClipMode_t heightClipMode )
  1740. {
  1741. }
  1742. // Sets the lights
  1743. void CShaderAPIEmpty::SetLights( int nCount, const LightDesc_t *pDesc )
  1744. {
  1745. }
  1746. // Sets lighting origin for the current model
  1747. void CShaderAPIEmpty::SetLightingOrigin( Vector vLightingOrigin )
  1748. {
  1749. }
  1750. void CShaderAPIEmpty::SetAmbientLightCube( Vector4D cube[6] )
  1751. {
  1752. }
  1753. // Gets the lightmap dimensions
  1754. void CShaderAPIEmpty::GetLightmapDimensions( int *w, int *h )
  1755. {
  1756. g_pShaderUtil->GetLightmapDimensions( w, h );
  1757. }
  1758. // Gets the dynamic mesh; note that you've got to render the mesh
  1759. // before calling this function a second time. Clients should *not*
  1760. // call DestroyStaticMesh on the mesh returned by this call.
  1761. IMesh* CShaderAPIEmpty::GetDynamicMesh( IMaterial* pMaterial, int nHWSkinBoneCount, bool buffered, IMesh* pVertexOverride, IMesh* pIndexOverride )
  1762. {
  1763. return &m_Mesh;
  1764. }
  1765. IMesh* CShaderAPIEmpty::GetDynamicMeshEx( IMaterial* pMaterial, VertexFormat_t fmt, int nHWSkinBoneCount, bool buffered, IMesh* pVertexOverride, IMesh* pIndexOverride )
  1766. {
  1767. return &m_Mesh;
  1768. }
  1769. IMesh* CShaderAPIEmpty::GetFlexMesh()
  1770. {
  1771. return &m_Mesh;
  1772. }
  1773. // Begins a rendering pass that uses a state snapshot
  1774. void CShaderAPIEmpty::BeginPass( StateSnapshot_t snapshot )
  1775. {
  1776. }
  1777. // Renders a single pass of a material
  1778. void CShaderAPIEmpty::RenderPass( const unsigned char *pInstanceCommandBuffer, int nPass, int nPassCount )
  1779. {
  1780. }
  1781. // stuff related to matrix stacks
  1782. void CShaderAPIEmpty::MatrixMode( MaterialMatrixMode_t matrixMode )
  1783. {
  1784. }
  1785. void CShaderAPIEmpty::PushMatrix()
  1786. {
  1787. }
  1788. void CShaderAPIEmpty::PopMatrix()
  1789. {
  1790. }
  1791. void CShaderAPIEmpty::LoadMatrix( float *m )
  1792. {
  1793. }
  1794. void CShaderAPIEmpty::MultMatrix( float *m )
  1795. {
  1796. }
  1797. void CShaderAPIEmpty::MultMatrixLocal( float *m )
  1798. {
  1799. }
  1800. void CShaderAPIEmpty::GetActualProjectionMatrix( float *pMatrix )
  1801. {
  1802. }
  1803. void CShaderAPIEmpty::GetMatrix( MaterialMatrixMode_t matrixMode, float *dst )
  1804. {
  1805. }
  1806. void CShaderAPIEmpty::LoadIdentity( void )
  1807. {
  1808. }
  1809. void CShaderAPIEmpty::LoadCameraToWorld( void )
  1810. {
  1811. }
  1812. void CShaderAPIEmpty::Ortho( double left, double top, double right, double bottom, double zNear, double zFar )
  1813. {
  1814. }
  1815. void CShaderAPIEmpty::PerspectiveX( double fovx, double aspect, double zNear, double zFar )
  1816. {
  1817. }
  1818. void CShaderAPIEmpty::PerspectiveOffCenterX( double fovx, double aspect, double zNear, double zFar, double bottom, double top, double left, double right )
  1819. {
  1820. }
  1821. void CShaderAPIEmpty::PickMatrix( int x, int y, int width, int height )
  1822. {
  1823. }
  1824. void CShaderAPIEmpty::Rotate( float angle, float x, float y, float z )
  1825. {
  1826. }
  1827. void CShaderAPIEmpty::Translate( float x, float y, float z )
  1828. {
  1829. }
  1830. void CShaderAPIEmpty::Scale( float x, float y, float z )
  1831. {
  1832. }
  1833. void CShaderAPIEmpty::ScaleXY( float x, float y )
  1834. {
  1835. }
  1836. // Fog methods...
  1837. void CShaderAPIEmpty::FogMode( MaterialFogMode_t fogMode )
  1838. {
  1839. }
  1840. void CShaderAPIEmpty::FogStart( float fStart )
  1841. {
  1842. }
  1843. void CShaderAPIEmpty::FogEnd( float fEnd )
  1844. {
  1845. }
  1846. void CShaderAPIEmpty::SetFogZ( float fogZ )
  1847. {
  1848. }
  1849. void CShaderAPIEmpty::FogMaxDensity( float flMaxDensity )
  1850. {
  1851. }
  1852. void CShaderAPIEmpty::GetFogDistances( float *fStart, float *fEnd, float *fFogZ )
  1853. {
  1854. }
  1855. void CShaderAPIEmpty::SceneFogColor3ub( unsigned char r, unsigned char g, unsigned char b )
  1856. {
  1857. }
  1858. void CShaderAPIEmpty::SceneFogMode( MaterialFogMode_t fogMode )
  1859. {
  1860. }
  1861. void CShaderAPIEmpty::GetSceneFogColor( unsigned char *rgb )
  1862. {
  1863. }
  1864. MaterialFogMode_t CShaderAPIEmpty::GetSceneFogMode( )
  1865. {
  1866. return MATERIAL_FOG_NONE;
  1867. }
  1868. int CShaderAPIEmpty::GetPixelFogCombo( )
  1869. {
  1870. return 0;
  1871. }
  1872. void CShaderAPIEmpty::FogColor3f( float r, float g, float b )
  1873. {
  1874. }
  1875. void CShaderAPIEmpty::FogColor3fv( float const* rgb )
  1876. {
  1877. }
  1878. void CShaderAPIEmpty::FogColor3ub( unsigned char r, unsigned char g, unsigned char b )
  1879. {
  1880. }
  1881. void CShaderAPIEmpty::FogColor3ubv( unsigned char const* rgb )
  1882. {
  1883. }
  1884. void CShaderAPIEmpty::SetViewports( int nCount, const ShaderViewport_t* pViewports, bool setImmediately /* = false*/ )
  1885. {
  1886. }
  1887. int CShaderAPIEmpty::GetViewports( ShaderViewport_t* pViewports, int nMax ) const
  1888. {
  1889. return 1;
  1890. }
  1891. // Sets the vertex and pixel shaders
  1892. void CShaderAPIEmpty::SetVertexShaderIndex( int vshIndex )
  1893. {
  1894. }
  1895. void CShaderAPIEmpty::SetPixelShaderIndex( int pshIndex )
  1896. {
  1897. }
  1898. // Sets the constant registers for vertex and pixel shaders
  1899. void CShaderAPIEmpty::SetVertexShaderConstant( int var, float const* pVec, int numConst, bool bForce )
  1900. {
  1901. }
  1902. void CShaderAPIEmpty::SetBooleanVertexShaderConstant( int var, BOOL const* pVec, int numConst, bool bForce )
  1903. {
  1904. }
  1905. void CShaderAPIEmpty::SetIntegerVertexShaderConstant( int var, int const* pVec, int numConst, bool bForce )
  1906. {
  1907. }
  1908. void CShaderAPIEmpty::SetPixelShaderConstant( int var, float const* pVec, int numConst, bool bForce )
  1909. {
  1910. }
  1911. void CShaderAPIEmpty::SetBooleanPixelShaderConstant( int var, BOOL const* pVec, int numBools, bool bForce )
  1912. {
  1913. }
  1914. void CShaderAPIEmpty::SetIntegerPixelShaderConstant( int var, int const* pVec, int numIntVecs, bool bForce )
  1915. {
  1916. }
  1917. void CShaderAPIEmpty::InvalidateDelayedShaderConstants( void )
  1918. {
  1919. }
  1920. float CShaderAPIEmpty::GammaToLinear_HardwareSpecific( float fGamma ) const
  1921. {
  1922. return 0.0f;
  1923. }
  1924. float CShaderAPIEmpty::LinearToGamma_HardwareSpecific( float fLinear ) const
  1925. {
  1926. return 0.0f;
  1927. }
  1928. void CShaderAPIEmpty::SetLinearToGammaConversionTextures( ShaderAPITextureHandle_t hSRGBWriteEnabledTexture, ShaderAPITextureHandle_t hIdentityTexture )
  1929. {
  1930. }
  1931. // Returns the nearest supported format
  1932. ImageFormat CShaderAPIEmpty::GetNearestSupportedFormat( ImageFormat fmt, bool bFilteringRequired /* = true */ ) const
  1933. {
  1934. return fmt;
  1935. }
  1936. ImageFormat CShaderAPIEmpty::GetNearestRenderTargetFormat( ImageFormat fmt ) const
  1937. {
  1938. return fmt;
  1939. }
  1940. // Sets the texture state
  1941. void CShaderAPIEmpty::BindTexture( Sampler_t stage, TextureBindFlags_t nBindFlags, ShaderAPITextureHandle_t textureHandle )
  1942. {
  1943. }
  1944. void CShaderAPIEmpty::BindVertexTexture( VertexTextureSampler_t vtSampler, ShaderAPITextureHandle_t textureHandle )
  1945. {
  1946. }
  1947. void CShaderAPIEmpty::ClearColor3ub( unsigned char r, unsigned char g, unsigned char b )
  1948. {
  1949. }
  1950. void CShaderAPIEmpty::ClearColor4ub( unsigned char r, unsigned char g, unsigned char b, unsigned char a )
  1951. {
  1952. }
  1953. // Indicates we're going to be modifying this texture
  1954. // TexImage2D, TexSubImage2D, TexWrap, TexMinFilter, and TexMagFilter
  1955. // all use the texture specified by this function.
  1956. void CShaderAPIEmpty::ModifyTexture( ShaderAPITextureHandle_t textureHandle )
  1957. {
  1958. }
  1959. // Texture management methods
  1960. void CShaderAPIEmpty::TexImage2D( int level, int cubeFace, ImageFormat dstFormat, int zOffset, int width, int height,
  1961. ImageFormat srcFormat, bool bSrcIsTiled, void *imageData )
  1962. {
  1963. }
  1964. void CShaderAPIEmpty::TexSubImage2D( int level, int cubeFace, int xOffset, int yOffset, int zOffset, int width, int height,
  1965. ImageFormat srcFormat, int srcStride, bool bSrcIsTiled, void *imageData )
  1966. {
  1967. }
  1968. bool CShaderAPIEmpty::TexLock( int level, int cubeFaceID, int xOffset, int yOffset,
  1969. int width, int height, CPixelWriter& writer )
  1970. {
  1971. return false;
  1972. }
  1973. void CShaderAPIEmpty::TexUnlock( )
  1974. {
  1975. }
  1976. void CShaderAPIEmpty::UpdateTexture( int xOffset, int yOffset, int w, int h, ShaderAPITextureHandle_t hDstTexture, ShaderAPITextureHandle_t hSrcTexture )
  1977. {
  1978. }
  1979. void *CShaderAPIEmpty::LockTex( ShaderAPITextureHandle_t hTexture )
  1980. {
  1981. return NULL;
  1982. }
  1983. void CShaderAPIEmpty::UnlockTex( ShaderAPITextureHandle_t hTexture )
  1984. {
  1985. }
  1986. // These are bound to the texture, not the texture environment
  1987. void CShaderAPIEmpty::TexMinFilter( ShaderTexFilterMode_t texFilterMode )
  1988. {
  1989. }
  1990. void CShaderAPIEmpty::TexMagFilter( ShaderTexFilterMode_t texFilterMode )
  1991. {
  1992. }
  1993. void CShaderAPIEmpty::TexWrap( ShaderTexCoordComponent_t coord, ShaderTexWrapMode_t wrapMode )
  1994. {
  1995. }
  1996. void CShaderAPIEmpty::TexSetPriority( int priority )
  1997. {
  1998. }
  1999. ShaderAPITextureHandle_t CShaderAPIEmpty::CreateTexture(
  2000. int width,
  2001. int height,
  2002. int depth,
  2003. ImageFormat dstImageFormat,
  2004. int numMipLevels,
  2005. int numCopies,
  2006. int flags,
  2007. const char *pDebugName,
  2008. const char *pTextureGroupName )
  2009. {
  2010. return 0;
  2011. }
  2012. // Create a multi-frame texture (equivalent to calling "CreateTexture" multiple times, but more efficient)
  2013. void CShaderAPIEmpty::CreateTextures(
  2014. ShaderAPITextureHandle_t *pHandles,
  2015. int count,
  2016. int width,
  2017. int height,
  2018. int depth,
  2019. ImageFormat dstImageFormat,
  2020. int numMipLevels,
  2021. int numCopies,
  2022. int flags,
  2023. const char *pDebugName,
  2024. const char *pTextureGroupName )
  2025. {
  2026. for ( int k = 0; k < count; ++ k )
  2027. pHandles[ k ] = 0;
  2028. }
  2029. ShaderAPITextureHandle_t CShaderAPIEmpty::CreateDepthTexture( ImageFormat renderFormat, int width, int height, const char *pDebugName, bool bTexture, bool bAliasDepthTextureOverSceneDepthX360 )
  2030. {
  2031. return 0;
  2032. }
  2033. void CShaderAPIEmpty::DeleteTexture( ShaderAPITextureHandle_t textureHandle )
  2034. {
  2035. }
  2036. bool CShaderAPIEmpty::IsTexture( ShaderAPITextureHandle_t textureHandle )
  2037. {
  2038. return true;
  2039. }
  2040. bool CShaderAPIEmpty::IsTextureResident( ShaderAPITextureHandle_t textureHandle )
  2041. {
  2042. return false;
  2043. }
  2044. // stuff that isn't to be used from within a shader
  2045. void CShaderAPIEmpty::ClearBuffers( bool bClearColor, bool bClearDepth, bool bClearStencil, int renderTargetWidth, int renderTargetHeight )
  2046. {
  2047. }
  2048. void CShaderAPIEmpty::ClearBuffersEx( bool bClearRed, bool bClearGreen, bool bClearBlue, bool bClearAlpha,
  2049. unsigned char r, unsigned char g, unsigned char b, unsigned char a )
  2050. {
  2051. }
  2052. void CShaderAPIEmpty::ClearBuffersObeyStencil( bool bClearColor, bool bClearDepth )
  2053. {
  2054. }
  2055. void CShaderAPIEmpty::ClearBuffersObeyStencilEx( bool bClearColor, bool bClearAlpha, bool bClearDepth )
  2056. {
  2057. }
  2058. void CShaderAPIEmpty::PerformFullScreenStencilOperation( void )
  2059. {
  2060. }
  2061. void CShaderAPIEmpty::SetScissorRect( const int nLeft, const int nTop, const int nRight, const int nBottom, const bool bEnableScissor )
  2062. {
  2063. }
  2064. void CShaderAPIEmpty::ReadPixels( int x, int y, int width, int height, unsigned char *data, ImageFormat dstFormat, ITexture *pRenderTargetTexture )
  2065. {
  2066. }
  2067. void CShaderAPIEmpty::ReadPixelsAsync( int x, int y, int width, int height, unsigned char *data, ImageFormat dstFormat, ITexture *pRenderTargetTexture, CThreadEvent *pPixelsReadEvent )
  2068. {
  2069. }
  2070. void CShaderAPIEmpty::ReadPixelsAsyncGetResult( int x, int y, int width, int height, unsigned char *data, ImageFormat dstFormat, CThreadEvent *pGetResultEvent )
  2071. {
  2072. }
  2073. void CShaderAPIEmpty::ReadPixels( Rect_t *pSrcRect, Rect_t *pDstRect, unsigned char *data, ImageFormat dstFormat, int nDstStride )
  2074. {
  2075. }
  2076. void CShaderAPIEmpty::FlushHardware()
  2077. {
  2078. }
  2079. void CShaderAPIEmpty::ResetRenderState( bool bFullReset )
  2080. {
  2081. }
  2082. // Set the number of bone weights
  2083. void CShaderAPIEmpty::SetNumBoneWeights( int numBones )
  2084. {
  2085. }
  2086. void CShaderAPIEmpty::EnableHWMorphing( bool bEnable )
  2087. {
  2088. }
  2089. // Selection mode methods
  2090. int CShaderAPIEmpty::SelectionMode( bool selectionMode )
  2091. {
  2092. return 0;
  2093. }
  2094. void CShaderAPIEmpty::SelectionBuffer( unsigned int* pBuffer, int size )
  2095. {
  2096. }
  2097. void CShaderAPIEmpty::ClearSelectionNames( )
  2098. {
  2099. }
  2100. void CShaderAPIEmpty::LoadSelectionName( int name )
  2101. {
  2102. }
  2103. void CShaderAPIEmpty::PushSelectionName( int name )
  2104. {
  2105. }
  2106. void CShaderAPIEmpty::PopSelectionName()
  2107. {
  2108. }
  2109. // Use this to get the mesh builder that allows us to modify vertex data
  2110. CMeshBuilder* CShaderAPIEmpty::GetVertexModifyBuilder()
  2111. {
  2112. return 0;
  2113. }
  2114. // Board-independent calls, here to unify how shaders set state
  2115. // Implementations should chain back to IShaderUtil->BindTexture(), etc.
  2116. // Use this to begin and end the frame
  2117. void CShaderAPIEmpty::BeginFrame()
  2118. {
  2119. }
  2120. void CShaderAPIEmpty::EndFrame()
  2121. {
  2122. }
  2123. // returns the current time in seconds....
  2124. double CShaderAPIEmpty::CurrentTime() const
  2125. {
  2126. return Sys_FloatTime();
  2127. }
  2128. // Get the current camera position in world space.
  2129. void CShaderAPIEmpty::GetWorldSpaceCameraPosition( float* pPos ) const
  2130. {
  2131. }
  2132. void CShaderAPIEmpty::GetWorldSpaceCameraDirection( float* pDir ) const
  2133. {
  2134. }
  2135. void CShaderAPIEmpty::ForceHardwareSync( void )
  2136. {
  2137. }
  2138. void CShaderAPIEmpty::SetClipPlane( int index, const float *pPlane )
  2139. {
  2140. }
  2141. void CShaderAPIEmpty::EnableClipPlane( int index, bool bEnable )
  2142. {
  2143. }
  2144. void CShaderAPIEmpty::SetFastClipPlane( const float *pPlane )
  2145. {
  2146. }
  2147. void CShaderAPIEmpty::EnableFastClip( bool bEnable )
  2148. {
  2149. }
  2150. int CShaderAPIEmpty::GetCurrentNumBones( void ) const
  2151. {
  2152. return 0;
  2153. }
  2154. bool CShaderAPIEmpty::IsHWMorphingEnabled( void ) const
  2155. {
  2156. return false;
  2157. }
  2158. void CShaderAPIEmpty::GetDX9LightState( LightState_t *state ) const
  2159. {
  2160. state->m_nNumLights = 0;
  2161. state->m_bAmbientLight = false;
  2162. state->m_bStaticLight = false;
  2163. state->m_bStaticLightIndirectOnly = false;
  2164. }
  2165. MaterialFogMode_t CShaderAPIEmpty::GetCurrentFogType( void ) const
  2166. {
  2167. Assert( 0 ); // deprecated
  2168. return MATERIAL_FOG_NONE;
  2169. }
  2170. void CShaderAPIEmpty::RecordString( const char *pStr )
  2171. {
  2172. }
  2173. bool CShaderAPIEmpty::ReadPixelsFromFrontBuffer() const
  2174. {
  2175. return true;
  2176. }
  2177. bool CShaderAPIEmpty::PreferDynamicTextures() const
  2178. {
  2179. return false;
  2180. }
  2181. int CShaderAPIEmpty::GetCurrentDynamicVBSize( void )
  2182. {
  2183. return 0;
  2184. }
  2185. int CShaderAPIEmpty::GetCurrentDynamicVBSize( int nIndex )
  2186. {
  2187. return 0;
  2188. }
  2189. void CShaderAPIEmpty::DestroyVertexBuffers( bool bExitingLevel )
  2190. {
  2191. }
  2192. void CShaderAPIEmpty::EvictManagedResources()
  2193. {
  2194. }
  2195. void CShaderAPIEmpty::GetGPUMemoryStats( GPUMemoryStats &stats )
  2196. {
  2197. }
  2198. void CShaderAPIEmpty::SyncToken( const char *pToken )
  2199. {
  2200. }