Team Fortress 2 Source Code as on 22/4/2020
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.

2956 lines
76 KiB

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