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.

1461 lines
38 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #include "shaderapidx10.h"
  9. #include "shaderapibase.h"
  10. #include "shaderapi/ishaderutil.h"
  11. #include "materialsystem/idebugtextureinfo.h"
  12. #include "materialsystem/materialsystem_config.h"
  13. #include "meshdx10.h"
  14. #include "shadershadowdx10.h"
  15. #include "shaderdevicedx10.h"
  16. #include "shaderapidx10_global.h"
  17. #include "imaterialinternal.h"
  18. //-----------------------------------------------------------------------------
  19. // Methods related to queuing functions to be called prior to rendering
  20. //-----------------------------------------------------------------------------
  21. CFunctionCommit::CFunctionCommit()
  22. {
  23. m_pCommitFlags = NULL;
  24. m_nCommitBufferSize = 0;
  25. }
  26. CFunctionCommit::~CFunctionCommit()
  27. {
  28. if ( m_pCommitFlags )
  29. {
  30. delete[] m_pCommitFlags;
  31. m_pCommitFlags = NULL;
  32. }
  33. }
  34. void CFunctionCommit::Init( int nFunctionCount )
  35. {
  36. m_nCommitBufferSize = ( nFunctionCount + 7 ) >> 3;
  37. Assert( !m_pCommitFlags );
  38. m_pCommitFlags = new unsigned char[ m_nCommitBufferSize ];
  39. memset( m_pCommitFlags, 0, m_nCommitBufferSize );
  40. }
  41. //-----------------------------------------------------------------------------
  42. // Methods related to queuing functions to be called per-(pMesh->Draw call) or per-pass
  43. //-----------------------------------------------------------------------------
  44. inline bool CFunctionCommit::IsCommitFuncInUse( int nFunc ) const
  45. {
  46. Assert( nFunc >> 3 < m_nCommitBufferSize );
  47. return ( m_pCommitFlags[ nFunc >> 3 ] & ( 1 << ( nFunc & 0x7 ) ) ) != 0;
  48. }
  49. inline void CFunctionCommit::MarkCommitFuncInUse( int nFunc )
  50. {
  51. Assert( nFunc >> 3 < m_nCommitBufferSize );
  52. m_pCommitFlags[ nFunc >> 3 ] |= 1 << ( nFunc & 0x7 );
  53. }
  54. inline void CFunctionCommit::AddCommitFunc( StateCommitFunc_t f )
  55. {
  56. m_CommitFuncs.AddToTail( f );
  57. }
  58. //-----------------------------------------------------------------------------
  59. // Clears all commit functions
  60. //-----------------------------------------------------------------------------
  61. inline void CFunctionCommit::ClearAllCommitFuncs( )
  62. {
  63. memset( m_pCommitFlags, 0, m_nCommitBufferSize );
  64. m_CommitFuncs.RemoveAll();
  65. }
  66. //-----------------------------------------------------------------------------
  67. // Calls all commit functions in a particular list
  68. //-----------------------------------------------------------------------------
  69. void CFunctionCommit::CallCommitFuncs( ID3D10Device *pDevice, const ShaderStateDx10_t &desiredState, ShaderStateDx10_t &currentState, bool bForce )
  70. {
  71. int nCount = m_CommitFuncs.Count();
  72. for ( int i = 0; i < nCount; ++i )
  73. {
  74. m_CommitFuncs[i]( pDevice, desiredState, currentState, bForce );
  75. }
  76. ClearAllCommitFuncs( );
  77. }
  78. //-----------------------------------------------------------------------------
  79. // Helpers for commit functions
  80. //-----------------------------------------------------------------------------
  81. #define ADD_COMMIT_FUNC( _func_name ) \
  82. if ( !m_Commit.IsCommitFuncInUse( COMMIT_FUNC_ ## _func_name ) ) \
  83. { \
  84. m_Commit.AddCommitFunc( _func_name ); \
  85. m_Commit.MarkCommitFuncInUse( COMMIT_FUNC_ ## _func_name ); \
  86. }
  87. #define ADD_RENDERSTATE_FUNC( _func_name, _state, _val ) \
  88. if ( m_bResettingRenderState || ( m_DesiredState. ## _state != _val ) ) \
  89. { \
  90. m_DesiredState. ## _state = _val; \
  91. ADD_COMMIT_FUNC( _func_name ) \
  92. }
  93. #define IMPLEMENT_RENDERSTATE_FUNC( _func_name, _state, _d3dFunc ) \
  94. static void _func_name( ID3D10Device *pDevice, const ShaderStateDx10_t &desiredState, ShaderStateDx10_t &currentState, bool bForce ) \
  95. { \
  96. if ( bForce || ( desiredState. ## _state != currentState. ## _state ) ) \
  97. { \
  98. pDevice->_d3dFunc( desiredState. ## _state ); \
  99. currentState. ## _state = desiredState. ## _state; \
  100. } \
  101. }
  102. //-----------------------------------------------------------------------------
  103. // D3D state setting methods
  104. //-----------------------------------------------------------------------------
  105. // NOTE: For each commit func you create, add to this enumeration.
  106. enum CommitFunc_t
  107. {
  108. COMMIT_FUNC_CommitSetViewports = 0,
  109. COMMIT_FUNC_CommitSetVertexShader,
  110. COMMIT_FUNC_CommitSetGeometryShader,
  111. COMMIT_FUNC_CommitSetPixelShader,
  112. COMMIT_FUNC_CommitSetVertexBuffer,
  113. COMMIT_FUNC_CommitSetIndexBuffer,
  114. COMMIT_FUNC_CommitSetInputLayout,
  115. COMMIT_FUNC_CommitSetTopology,
  116. COMMIT_FUNC_CommitSetRasterState,
  117. COMMIT_FUNC_COUNT,
  118. };
  119. IMPLEMENT_RENDERSTATE_FUNC( CommitSetTopology, m_Topology, IASetPrimitiveTopology )
  120. IMPLEMENT_RENDERSTATE_FUNC( CommitSetVertexShader, m_pVertexShader, VSSetShader )
  121. IMPLEMENT_RENDERSTATE_FUNC( CommitSetGeometryShader, m_pGeometryShader, GSSetShader )
  122. IMPLEMENT_RENDERSTATE_FUNC( CommitSetPixelShader, m_pPixelShader, PSSetShader )
  123. static void CommitSetInputLayout( ID3D10Device *pDevice, const ShaderStateDx10_t &desiredState, ShaderStateDx10_t &currentState, bool bForce )
  124. {
  125. const ShaderInputLayoutStateDx10_t& newState = desiredState.m_InputLayout;
  126. if ( bForce || memcmp( &newState, &currentState.m_InputLayout, sizeof(ShaderInputLayoutStateDx10_t) ) )
  127. {
  128. // FIXME: Deal with multiple streams
  129. ID3D10InputLayout *pInputLayout = g_pShaderDeviceDx10->GetInputLayout(
  130. newState.m_hVertexShader, newState.m_pVertexDecl[0] );
  131. pDevice->IASetInputLayout( pInputLayout );
  132. currentState.m_InputLayout = newState;
  133. }
  134. }
  135. static void CommitSetViewports( ID3D10Device *pDevice, const ShaderStateDx10_t &desiredState, ShaderStateDx10_t &currentState, bool bForce )
  136. {
  137. bool bChanged = bForce || ( desiredState.m_nViewportCount != currentState.m_nViewportCount );
  138. if ( !bChanged && desiredState.m_nViewportCount > 0 )
  139. {
  140. bChanged = memcmp( desiredState.m_pViewports, currentState.m_pViewports,
  141. desiredState.m_nViewportCount * sizeof( D3D10_VIEWPORT ) ) != 0;
  142. }
  143. if ( !bChanged )
  144. return;
  145. pDevice->RSSetViewports( desiredState.m_nViewportCount, desiredState.m_pViewports );
  146. currentState.m_nViewportCount = desiredState.m_nViewportCount;
  147. #ifdef _DEBUG
  148. memset( currentState.m_pViewports, 0xDD, sizeof( currentState.m_pViewports ) );
  149. #endif
  150. memcpy( currentState.m_pViewports, desiredState.m_pViewports,
  151. desiredState.m_nViewportCount * sizeof( D3D10_VIEWPORT ) );
  152. }
  153. static void CommitSetIndexBuffer( ID3D10Device *pDevice, const ShaderStateDx10_t &desiredState, ShaderStateDx10_t &currentState, bool bForce )
  154. {
  155. const ShaderIndexBufferStateDx10_t &newState = desiredState.m_IndexBuffer;
  156. bool bChanged = bForce || memcmp( &newState, &currentState.m_IndexBuffer, sizeof(ShaderIndexBufferStateDx10_t) );
  157. if ( !bChanged )
  158. return;
  159. pDevice->IASetIndexBuffer( newState.m_pBuffer, newState.m_Format, newState.m_nOffset );
  160. memcpy( &currentState.m_IndexBuffer, &newState, sizeof( ShaderIndexBufferStateDx10_t ) );
  161. }
  162. static void CommitSetVertexBuffer( ID3D10Device *pDevice, const ShaderStateDx10_t &desiredState, ShaderStateDx10_t &currentState, bool bForce )
  163. {
  164. ID3D10Buffer *ppVertexBuffers[ MAX_DX10_STREAMS ];
  165. UINT pStrides[ MAX_DX10_STREAMS ];
  166. UINT pOffsets[ MAX_DX10_STREAMS ];
  167. UINT nFirstBuffer = 0;
  168. UINT nBufferCount = 0;
  169. bool bInMatch = true;
  170. for ( int i = 0; i < MAX_DX10_STREAMS; ++i )
  171. {
  172. const ShaderVertexBufferStateDx10_t &newState = desiredState.m_pVertexBuffer[i];
  173. bool bMatch = !bForce && !memcmp( &newState, &currentState.m_pVertexBuffer[i], sizeof(ShaderVertexBufferStateDx10_t) );
  174. if ( !bMatch )
  175. {
  176. ppVertexBuffers[i] = newState.m_pBuffer;
  177. pStrides[i] = newState.m_nStride;
  178. pOffsets[i] = newState.m_nOffset;
  179. ++nBufferCount;
  180. memcpy( &currentState.m_pVertexBuffer[i], &newState, sizeof( ShaderVertexBufferStateDx10_t ) );
  181. }
  182. if ( bInMatch )
  183. {
  184. if ( !bMatch )
  185. {
  186. bInMatch = false;
  187. nFirstBuffer = i;
  188. }
  189. continue;
  190. }
  191. if ( bMatch )
  192. {
  193. bInMatch = true;
  194. pDevice->IASetVertexBuffers( nFirstBuffer, nBufferCount,
  195. &ppVertexBuffers[nFirstBuffer], &pStrides[nFirstBuffer], &pOffsets[nFirstBuffer] );
  196. nBufferCount = 0;
  197. }
  198. }
  199. if ( !bInMatch )
  200. {
  201. pDevice->IASetVertexBuffers( nFirstBuffer, nBufferCount,
  202. &ppVertexBuffers[nFirstBuffer], &pStrides[nFirstBuffer], &pOffsets[nFirstBuffer] );
  203. }
  204. }
  205. static void GenerateRasterizerDesc( D3D10_RASTERIZER_DESC* pDesc, const ShaderRasterState_t& state )
  206. {
  207. pDesc->FillMode = ( state.m_FillMode == SHADER_FILL_WIREFRAME ) ? D3D10_FILL_WIREFRAME : D3D10_FILL_SOLID;
  208. // Cull state
  209. if ( state.m_bCullEnable )
  210. {
  211. pDesc->CullMode = D3D10_CULL_NONE;
  212. }
  213. else
  214. {
  215. pDesc->CullMode = ( state.m_CullMode == MATERIAL_CULLMODE_CW ) ? D3D10_CULL_BACK : D3D10_CULL_FRONT;
  216. }
  217. pDesc->FrontCounterClockwise = TRUE;
  218. // Depth bias state
  219. if ( !state.m_bDepthBias )
  220. {
  221. pDesc->DepthBias = 0;
  222. pDesc->DepthBiasClamp = 0.0f;
  223. pDesc->SlopeScaledDepthBias = 0.0f;
  224. pDesc->DepthClipEnable = FALSE;
  225. }
  226. else
  227. {
  228. // FIXME: Implement! Read ConVars
  229. }
  230. pDesc->ScissorEnable = state.m_bScissorEnable ? TRUE : FALSE;
  231. pDesc->MultisampleEnable = state.m_bMultisampleEnable ? TRUE : FALSE;
  232. pDesc->AntialiasedLineEnable = FALSE;
  233. }
  234. static void CommitSetRasterState( ID3D10Device *pDevice, const ShaderStateDx10_t &desiredState, ShaderStateDx10_t &currentState, bool bForce )
  235. {
  236. const ShaderRasterState_t& newState = desiredState.m_RasterState;
  237. if ( bForce || memcmp( &newState, &currentState.m_RasterState, sizeof(ShaderRasterState_t) ) )
  238. {
  239. // Clear out the existing state
  240. if ( currentState.m_pRasterState )
  241. {
  242. currentState.m_pRasterState->Release();
  243. }
  244. D3D10_RASTERIZER_DESC desc;
  245. GenerateRasterizerDesc( &desc, newState );
  246. // NOTE: This does a search for existing matching state objects
  247. ID3D10RasterizerState *pState = NULL;
  248. HRESULT hr = pDevice->CreateRasterizerState( &desc, &pState );
  249. if ( !FAILED(hr) )
  250. {
  251. Warning( "Unable to create rasterizer state object!\n" );
  252. }
  253. pDevice->RSSetState( pState );
  254. currentState.m_pRasterState = pState;
  255. memcpy( &currentState.m_RasterState, &newState, sizeof( ShaderRasterState_t ) );
  256. }
  257. }
  258. //-----------------------------------------------------------------------------
  259. //
  260. // Shader API Dx10
  261. //
  262. //-----------------------------------------------------------------------------
  263. //-----------------------------------------------------------------------------
  264. // Class Factory
  265. //-----------------------------------------------------------------------------
  266. static CShaderAPIDx10 s_ShaderAPIDx10;
  267. CShaderAPIDx10* g_pShaderAPIDx10 = &s_ShaderAPIDx10;
  268. EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CShaderAPIDx10, IShaderAPI,
  269. SHADERAPI_INTERFACE_VERSION, s_ShaderAPIDx10 )
  270. EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CShaderAPIDx10, IDebugTextureInfo,
  271. DEBUG_TEXTURE_INFO_VERSION, s_ShaderAPIDx10 )
  272. //-----------------------------------------------------------------------------
  273. // Constructor, destructor
  274. //-----------------------------------------------------------------------------
  275. CShaderAPIDx10::CShaderAPIDx10()
  276. {
  277. m_bResettingRenderState = false;
  278. m_Commit.Init( COMMIT_FUNC_COUNT );
  279. ClearShaderState( &m_DesiredState );
  280. ClearShaderState( &m_CurrentState );
  281. }
  282. CShaderAPIDx10::~CShaderAPIDx10()
  283. {
  284. }
  285. //-----------------------------------------------------------------------------
  286. // Clears the shader state to a well-defined value
  287. //-----------------------------------------------------------------------------
  288. void CShaderAPIDx10::ClearShaderState( ShaderStateDx10_t* pState )
  289. {
  290. memset( pState, 0, sizeof( ShaderStateDx10_t ) );
  291. }
  292. //-----------------------------------------------------------------------------
  293. // Resets the render state
  294. //-----------------------------------------------------------------------------
  295. void CShaderAPIDx10::ResetRenderState( bool bFullReset )
  296. {
  297. D3D10_RASTERIZER_DESC rDesc;
  298. memset( &rDesc, 0, sizeof(rDesc) );
  299. rDesc.FillMode = D3D10_FILL_SOLID;
  300. rDesc.CullMode = D3D10_CULL_NONE;
  301. rDesc.FrontCounterClockwise = TRUE; // right-hand rule
  302. ID3D10RasterizerState *pRasterizerState;
  303. HRESULT hr = D3D10Device()->CreateRasterizerState( &rDesc, &pRasterizerState );
  304. Assert( !FAILED(hr) );
  305. D3D10Device()->RSSetState( pRasterizerState );
  306. D3D10_DEPTH_STENCIL_DESC dsDesc;
  307. memset( &dsDesc, 0, sizeof(dsDesc) );
  308. ID3D10DepthStencilState *pDepthStencilState;
  309. hr = D3D10Device()->CreateDepthStencilState( &dsDesc, &pDepthStencilState );
  310. Assert( !FAILED(hr) );
  311. D3D10Device()->OMSetDepthStencilState( pDepthStencilState, 0 );
  312. D3D10_BLEND_DESC bDesc;
  313. memset( &bDesc, 0, sizeof(bDesc) );
  314. bDesc.SrcBlend = D3D10_BLEND_ONE;
  315. bDesc.DestBlend = D3D10_BLEND_ZERO;
  316. bDesc.BlendOp = D3D10_BLEND_OP_ADD;
  317. bDesc.SrcBlendAlpha = D3D10_BLEND_ONE;
  318. bDesc.DestBlendAlpha = D3D10_BLEND_ZERO;
  319. bDesc.BlendOpAlpha = D3D10_BLEND_OP_ADD;
  320. bDesc.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL;
  321. FLOAT pBlendFactor[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
  322. ID3D10BlendState *pBlendState;
  323. hr = D3D10Device()->CreateBlendState( &bDesc, &pBlendState );
  324. Assert( !FAILED(hr) );
  325. D3D10Device()->OMSetBlendState( pBlendState, pBlendFactor, 0xFFFFFFFF );
  326. }
  327. //-----------------------------------------------------------------------------
  328. // Commits queued-up state change requests
  329. //-----------------------------------------------------------------------------
  330. void CShaderAPIDx10::CommitStateChanges( bool bForce )
  331. {
  332. // Don't bother committing anything if we're deactivated
  333. if ( g_pShaderDevice->IsDeactivated() )
  334. return;
  335. m_Commit.CallCommitFuncs( D3D10Device(), m_DesiredState, m_CurrentState, bForce );
  336. }
  337. //-----------------------------------------------------------------------------
  338. // Methods of IShaderDynamicAPI
  339. //-----------------------------------------------------------------------------
  340. void CShaderAPIDx10::GetBackBufferDimensions( int& nWidth, int& nHeight ) const
  341. {
  342. g_pShaderDeviceDx10->GetBackBufferDimensions( nWidth, nHeight );
  343. }
  344. //-----------------------------------------------------------------------------
  345. // Viewport-related methods
  346. //-----------------------------------------------------------------------------
  347. void CShaderAPIDx10::SetViewports( int nCount, const ShaderViewport_t* pViewports )
  348. {
  349. nCount = min( nCount, MAX_DX10_VIEWPORTS );
  350. m_DesiredState.m_nViewportCount = nCount;
  351. for ( int i = 0; i < nCount; ++i )
  352. {
  353. Assert( pViewports[i].m_nVersion == SHADER_VIEWPORT_VERSION );
  354. D3D10_VIEWPORT& viewport = m_DesiredState.m_pViewports[i];
  355. viewport.TopLeftX = pViewports[i].m_nTopLeftX;
  356. viewport.TopLeftY = pViewports[i].m_nTopLeftY;
  357. viewport.Width = pViewports[i].m_nWidth;
  358. viewport.Height = pViewports[i].m_nHeight;
  359. viewport.MinDepth = pViewports[i].m_flMinZ;
  360. viewport.MaxDepth = pViewports[i].m_flMaxZ;
  361. }
  362. ADD_COMMIT_FUNC( CommitSetViewports );
  363. }
  364. int CShaderAPIDx10::GetViewports( ShaderViewport_t* pViewports, int nMax ) const
  365. {
  366. int nCount = m_DesiredState.m_nViewportCount;
  367. if ( pViewports && nMax )
  368. {
  369. nCount = min( nCount, nMax );
  370. memcpy( pViewports, m_DesiredState.m_pViewports, nCount * sizeof( ShaderViewport_t ) );
  371. }
  372. return nCount;
  373. }
  374. //-----------------------------------------------------------------------------
  375. // Methods related to state objects
  376. //-----------------------------------------------------------------------------
  377. void CShaderAPIDx10::SetRasterState( const ShaderRasterState_t& state )
  378. {
  379. if ( memcmp( &state, &m_DesiredState.m_RasterState, sizeof(ShaderRasterState_t) ) )
  380. {
  381. memcpy( &m_DesiredState.m_RasterState, &state, sizeof(ShaderRasterState_t) );
  382. ADD_COMMIT_FUNC( CommitSetRasterState );
  383. }
  384. }
  385. //-----------------------------------------------------------------------------
  386. // Methods related to clearing buffers
  387. //-----------------------------------------------------------------------------
  388. void CShaderAPIDx10::ClearColor3ub( unsigned char r, unsigned char g, unsigned char b )
  389. {
  390. m_DesiredState.m_ClearColor[0] = r / 255.0f;
  391. m_DesiredState.m_ClearColor[1] = g / 255.0f;
  392. m_DesiredState.m_ClearColor[2] = b / 255.0f;
  393. m_DesiredState.m_ClearColor[3] = 1.0f;
  394. }
  395. void CShaderAPIDx10::ClearColor4ub( unsigned char r, unsigned char g, unsigned char b, unsigned char a )
  396. {
  397. m_DesiredState.m_ClearColor[0] = r / 255.0f;
  398. m_DesiredState.m_ClearColor[1] = g / 255.0f;
  399. m_DesiredState.m_ClearColor[2] = b / 255.0f;
  400. m_DesiredState.m_ClearColor[3] = a / 255.0f;
  401. }
  402. void CShaderAPIDx10::ClearBuffers( bool bClearColor, bool bClearDepth, bool bClearStencil, int renderTargetWidth, int renderTargetHeight )
  403. {
  404. // NOTE: State change commit isn't necessary since clearing doesn't use state
  405. // CommitStateChanges();
  406. // FIXME: This implementation is totally bust0red [doesn't guarantee exact color specified]
  407. if ( bClearColor )
  408. {
  409. D3D10Device()->ClearRenderTargetView( D3D10RenderTargetView(), m_DesiredState.m_ClearColor );
  410. }
  411. }
  412. //-----------------------------------------------------------------------------
  413. // Methods related to binding shaders
  414. //-----------------------------------------------------------------------------
  415. void CShaderAPIDx10::BindVertexShader( VertexShaderHandle_t hVertexShader )
  416. {
  417. ID3D10VertexShader *pVertexShader = g_pShaderDeviceDx10->GetVertexShader( hVertexShader );
  418. ADD_RENDERSTATE_FUNC( CommitSetVertexShader, m_pVertexShader, pVertexShader );
  419. if ( m_bResettingRenderState || ( m_DesiredState.m_InputLayout.m_hVertexShader != hVertexShader ) )
  420. {
  421. m_DesiredState.m_InputLayout.m_hVertexShader = hVertexShader;
  422. ADD_COMMIT_FUNC( CommitSetInputLayout );
  423. }
  424. }
  425. void CShaderAPIDx10::BindGeometryShader( GeometryShaderHandle_t hGeometryShader )
  426. {
  427. ID3D10GeometryShader *pGeometryShader = g_pShaderDeviceDx10->GetGeometryShader( hGeometryShader );
  428. ADD_RENDERSTATE_FUNC( CommitSetGeometryShader, m_pGeometryShader, pGeometryShader );
  429. }
  430. void CShaderAPIDx10::BindPixelShader( PixelShaderHandle_t hPixelShader )
  431. {
  432. ID3D10PixelShader *pPixelShader = g_pShaderDeviceDx10->GetPixelShader( hPixelShader );
  433. ADD_RENDERSTATE_FUNC( CommitSetPixelShader, m_pPixelShader, pPixelShader );
  434. }
  435. void CShaderAPIDx10::BindVertexBuffer( int nStreamID, IVertexBuffer *pVertexBuffer, int nOffsetInBytes, int nFirstVertex, int nVertexCount, VertexFormat_t fmt, int nRepetitions )
  436. {
  437. // FIXME: What to do about repetitions?
  438. CVertexBufferDx10 *pVertexBufferDx10 = static_cast<CVertexBufferDx10 *>( pVertexBuffer );
  439. ShaderVertexBufferStateDx10_t state;
  440. if ( pVertexBufferDx10 )
  441. {
  442. state.m_pBuffer = pVertexBufferDx10->GetDx10Buffer();
  443. state.m_nStride = pVertexBufferDx10->VertexSize();
  444. }
  445. else
  446. {
  447. state.m_pBuffer = NULL;
  448. state.m_nStride = 0;
  449. }
  450. state.m_nOffset = nOffsetInBytes;
  451. if ( m_bResettingRenderState || memcmp( &m_DesiredState.m_pVertexBuffer[ nStreamID ], &state, sizeof( ShaderVertexBufferStateDx10_t ) ) )
  452. {
  453. m_DesiredState.m_pVertexBuffer[ nStreamID ] = state;
  454. ADD_COMMIT_FUNC( CommitSetVertexBuffer );
  455. }
  456. if ( m_bResettingRenderState || ( m_DesiredState.m_InputLayout.m_pVertexDecl[ nStreamID ] != fmt ) )
  457. {
  458. m_DesiredState.m_InputLayout.m_pVertexDecl[ nStreamID ] = fmt;
  459. ADD_COMMIT_FUNC( CommitSetInputLayout );
  460. }
  461. }
  462. void CShaderAPIDx10::BindIndexBuffer( IIndexBuffer *pIndexBuffer, int nOffsetInBytes )
  463. {
  464. CIndexBufferDx10 *pIndexBufferDx10 = static_cast<CIndexBufferDx10 *>( pIndexBuffer );
  465. ShaderIndexBufferStateDx10_t state;
  466. if ( pIndexBufferDx10 )
  467. {
  468. state.m_pBuffer = pIndexBufferDx10->GetDx10Buffer();
  469. state.m_Format = ( pIndexBufferDx10->GetIndexFormat() == MATERIAL_INDEX_FORMAT_16BIT ) ?
  470. DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT;
  471. }
  472. else
  473. {
  474. state.m_pBuffer = NULL;
  475. state.m_Format = DXGI_FORMAT_R16_UINT;
  476. }
  477. state.m_nOffset = nOffsetInBytes;
  478. ADD_RENDERSTATE_FUNC( CommitSetIndexBuffer, m_IndexBuffer, state );
  479. }
  480. //-----------------------------------------------------------------------------
  481. // Unbinds resources because they are about to be deleted
  482. //-----------------------------------------------------------------------------
  483. void CShaderAPIDx10::Unbind( VertexShaderHandle_t hShader )
  484. {
  485. ID3D10VertexShader* pShader = g_pShaderDeviceDx10->GetVertexShader( hShader );
  486. Assert ( pShader );
  487. if ( m_DesiredState.m_pVertexShader == pShader )
  488. {
  489. BindVertexShader( VERTEX_SHADER_HANDLE_INVALID );
  490. }
  491. if ( m_CurrentState.m_pVertexShader == pShader )
  492. {
  493. CommitStateChanges();
  494. }
  495. }
  496. void CShaderAPIDx10::Unbind( GeometryShaderHandle_t hShader )
  497. {
  498. ID3D10GeometryShader* pShader = g_pShaderDeviceDx10->GetGeometryShader( hShader );
  499. Assert ( pShader );
  500. if ( m_DesiredState.m_pGeometryShader == pShader )
  501. {
  502. BindGeometryShader( GEOMETRY_SHADER_HANDLE_INVALID );
  503. }
  504. if ( m_CurrentState.m_pGeometryShader == pShader )
  505. {
  506. CommitStateChanges();
  507. }
  508. }
  509. void CShaderAPIDx10::Unbind( PixelShaderHandle_t hShader )
  510. {
  511. ID3D10PixelShader* pShader = g_pShaderDeviceDx10->GetPixelShader( hShader );
  512. Assert ( pShader );
  513. if ( m_DesiredState.m_pPixelShader == pShader )
  514. {
  515. BindPixelShader( PIXEL_SHADER_HANDLE_INVALID );
  516. }
  517. if ( m_CurrentState.m_pPixelShader == pShader )
  518. {
  519. CommitStateChanges();
  520. }
  521. }
  522. void CShaderAPIDx10::UnbindVertexBuffer( ID3D10Buffer *pBuffer )
  523. {
  524. Assert ( pBuffer );
  525. for ( int i = 0; i < MAX_DX10_STREAMS; ++i )
  526. {
  527. if ( m_DesiredState.m_pVertexBuffer[i].m_pBuffer == pBuffer )
  528. {
  529. BindVertexBuffer( i, NULL, 0, 0, 0, VERTEX_POSITION, 0 );
  530. }
  531. }
  532. for ( int i = 0; i < MAX_DX10_STREAMS; ++i )
  533. {
  534. if ( m_CurrentState.m_pVertexBuffer[i].m_pBuffer == pBuffer )
  535. {
  536. CommitStateChanges();
  537. break;
  538. }
  539. }
  540. }
  541. void CShaderAPIDx10::UnbindIndexBuffer( ID3D10Buffer *pBuffer )
  542. {
  543. Assert ( pBuffer );
  544. if ( m_DesiredState.m_IndexBuffer.m_pBuffer == pBuffer )
  545. {
  546. BindIndexBuffer( NULL, 0 );
  547. }
  548. if ( m_CurrentState.m_IndexBuffer.m_pBuffer == pBuffer )
  549. {
  550. CommitStateChanges();
  551. }
  552. }
  553. //-----------------------------------------------------------------------------
  554. // Sets the topology state
  555. //-----------------------------------------------------------------------------
  556. void CShaderAPIDx10::SetTopology( MaterialPrimitiveType_t topology )
  557. {
  558. D3D10_PRIMITIVE_TOPOLOGY d3dTopology;
  559. switch( topology )
  560. {
  561. case MATERIAL_POINTS:
  562. d3dTopology = D3D10_PRIMITIVE_TOPOLOGY_POINTLIST;
  563. break;
  564. case MATERIAL_LINES:
  565. d3dTopology = D3D10_PRIMITIVE_TOPOLOGY_LINELIST;
  566. break;
  567. case MATERIAL_TRIANGLES:
  568. d3dTopology = D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
  569. break;
  570. case MATERIAL_TRIANGLE_STRIP:
  571. d3dTopology = D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
  572. break;
  573. case MATERIAL_LINE_STRIP:
  574. d3dTopology = D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP;
  575. break;
  576. default:
  577. case MATERIAL_LINE_LOOP:
  578. case MATERIAL_POLYGON:
  579. case MATERIAL_QUADS:
  580. Assert( 0 );
  581. d3dTopology = D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED;
  582. break;
  583. }
  584. ADD_RENDERSTATE_FUNC( CommitSetTopology, m_Topology, d3dTopology );
  585. }
  586. //-----------------------------------------------------------------------------
  587. // Main entry point for rendering
  588. //-----------------------------------------------------------------------------
  589. void CShaderAPIDx10::Draw( MaterialPrimitiveType_t primitiveType, int nFirstIndex, int nIndexCount )
  590. {
  591. SetTopology( primitiveType );
  592. CommitStateChanges();
  593. // FIXME: How do I set the base vertex location!?
  594. D3D10Device()->DrawIndexed( (UINT)nIndexCount, (UINT)nFirstIndex, 0 );
  595. }
  596. //-----------------------------------------------------------------------------
  597. //
  598. // Abandon all hope below this point
  599. //
  600. //-----------------------------------------------------------------------------
  601. bool CShaderAPIDx10::DoRenderTargetsNeedSeparateDepthBuffer() const
  602. {
  603. return false;
  604. }
  605. // Can we download textures?
  606. bool CShaderAPIDx10::CanDownloadTextures() const
  607. {
  608. return false;
  609. }
  610. // Used to clear the transition table when we know it's become invalid.
  611. void CShaderAPIDx10::ClearSnapshots()
  612. {
  613. }
  614. // Sets the default *dynamic* state
  615. void CShaderAPIDx10::SetDefaultState()
  616. {
  617. }
  618. // Returns the snapshot id for the shader state
  619. StateSnapshot_t CShaderAPIDx10::TakeSnapshot( )
  620. {
  621. StateSnapshot_t id = 0;
  622. if (g_pShaderShadowDx10->m_IsTranslucent)
  623. id |= TRANSLUCENT;
  624. if (g_pShaderShadowDx10->m_IsAlphaTested)
  625. id |= ALPHATESTED;
  626. if (g_pShaderShadowDx10->m_bUsesVertexAndPixelShaders)
  627. id |= VERTEX_AND_PIXEL_SHADERS;
  628. if (g_pShaderShadowDx10->m_bIsDepthWriteEnabled)
  629. id |= DEPTHWRITE;
  630. return id;
  631. }
  632. // Returns true if the state snapshot is transparent
  633. bool CShaderAPIDx10::IsTranslucent( StateSnapshot_t id ) const
  634. {
  635. return (id & TRANSLUCENT) != 0;
  636. }
  637. bool CShaderAPIDx10::IsAlphaTested( StateSnapshot_t id ) const
  638. {
  639. return (id & ALPHATESTED) != 0;
  640. }
  641. bool CShaderAPIDx10::IsDepthWriteEnabled( StateSnapshot_t id ) const
  642. {
  643. return (id & DEPTHWRITE) != 0;
  644. }
  645. bool CShaderAPIDx10::UsesVertexAndPixelShaders( StateSnapshot_t id ) const
  646. {
  647. return (id & VERTEX_AND_PIXEL_SHADERS) != 0;
  648. }
  649. // Gets the vertex format for a set of snapshot ids
  650. VertexFormat_t CShaderAPIDx10::ComputeVertexFormat( int numSnapshots, StateSnapshot_t* pIds ) const
  651. {
  652. return 0;
  653. }
  654. // Gets the vertex format for a set of snapshot ids
  655. VertexFormat_t CShaderAPIDx10::ComputeVertexUsage( int numSnapshots, StateSnapshot_t* pIds ) const
  656. {
  657. return 0;
  658. }
  659. // Uses a state snapshot
  660. void CShaderAPIDx10::UseSnapshot( StateSnapshot_t snapshot )
  661. {
  662. }
  663. // Sets the color to modulate by
  664. void CShaderAPIDx10::Color3f( float r, float g, float b )
  665. {
  666. }
  667. void CShaderAPIDx10::Color3fv( float const* pColor )
  668. {
  669. }
  670. void CShaderAPIDx10::Color4f( float r, float g, float b, float a )
  671. {
  672. }
  673. void CShaderAPIDx10::Color4fv( float const* pColor )
  674. {
  675. }
  676. // Faster versions of color
  677. void CShaderAPIDx10::Color3ub( unsigned char r, unsigned char g, unsigned char b )
  678. {
  679. }
  680. void CShaderAPIDx10::Color3ubv( unsigned char const* rgb )
  681. {
  682. }
  683. void CShaderAPIDx10::Color4ub( unsigned char r, unsigned char g, unsigned char b, unsigned char a )
  684. {
  685. }
  686. void CShaderAPIDx10::Color4ubv( unsigned char const* rgba )
  687. {
  688. }
  689. void CShaderAPIDx10::GetStandardTextureDimensions( int *pWidth, int *pHeight, StandardTextureId_t id )
  690. {
  691. ShaderUtil()->GetStandardTextureDimensions( pWidth, pHeight, id );
  692. }
  693. // The shade mode
  694. void CShaderAPIDx10::ShadeMode( ShaderShadeMode_t mode )
  695. {
  696. }
  697. // Binds a particular material to render with
  698. void CShaderAPIDx10::Bind( IMaterial* pMaterial )
  699. {
  700. }
  701. // Cull mode
  702. void CShaderAPIDx10::CullMode( MaterialCullMode_t cullMode )
  703. {
  704. }
  705. void CShaderAPIDx10::ForceDepthFuncEquals( bool bEnable )
  706. {
  707. }
  708. // Forces Z buffering on or off
  709. void CShaderAPIDx10::OverrideDepthEnable( bool bEnable, bool bDepthEnable )
  710. {
  711. }
  712. void CShaderAPIDx10::OverrideAlphaWriteEnable( bool bOverrideEnable, bool bAlphaWriteEnable )
  713. {
  714. }
  715. void CShaderAPIDx10::OverrideColorWriteEnable( bool bOverrideEnable, bool bColorWriteEnable )
  716. {
  717. }
  718. //legacy fast clipping linkage
  719. void CShaderAPIDx10::SetHeightClipZ( float z )
  720. {
  721. }
  722. void CShaderAPIDx10::SetHeightClipMode( enum MaterialHeightClipMode_t heightClipMode )
  723. {
  724. }
  725. // Sets the lights
  726. void CShaderAPIDx10::SetLight( int lightNum, const LightDesc_t& desc )
  727. {
  728. }
  729. void CShaderAPIDx10::SetAmbientLight( float r, float g, float b )
  730. {
  731. }
  732. void CShaderAPIDx10::SetAmbientLightCube( Vector4D cube[6] )
  733. {
  734. }
  735. // Get lights
  736. int CShaderAPIDx10::GetMaxLights( void ) const
  737. {
  738. return 0;
  739. }
  740. const LightDesc_t& CShaderAPIDx10::GetLight( int lightNum ) const
  741. {
  742. static LightDesc_t blah;
  743. return blah;
  744. }
  745. // Render state for the ambient light cube (vertex shaders)
  746. void CShaderAPIDx10::SetVertexShaderStateAmbientLightCube()
  747. {
  748. }
  749. void CShaderAPIDx10::SetSkinningMatrices()
  750. {
  751. }
  752. // Lightmap texture binding
  753. void CShaderAPIDx10::BindLightmap( TextureStage_t stage )
  754. {
  755. }
  756. void CShaderAPIDx10::BindBumpLightmap( TextureStage_t stage )
  757. {
  758. }
  759. void CShaderAPIDx10::BindFullbrightLightmap( TextureStage_t stage )
  760. {
  761. }
  762. void CShaderAPIDx10::BindWhite( TextureStage_t stage )
  763. {
  764. }
  765. void CShaderAPIDx10::BindBlack( TextureStage_t stage )
  766. {
  767. }
  768. void CShaderAPIDx10::BindGrey( TextureStage_t stage )
  769. {
  770. }
  771. // Gets the lightmap dimensions
  772. void CShaderAPIDx10::GetLightmapDimensions( int *w, int *h )
  773. {
  774. g_pShaderUtil->GetLightmapDimensions( w, h );
  775. }
  776. // Special system flat normal map binding.
  777. void CShaderAPIDx10::BindFlatNormalMap( TextureStage_t stage )
  778. {
  779. }
  780. void CShaderAPIDx10::BindNormalizationCubeMap( TextureStage_t stage )
  781. {
  782. }
  783. void CShaderAPIDx10::BindSignedNormalizationCubeMap( TextureStage_t stage )
  784. {
  785. }
  786. void CShaderAPIDx10::BindFBTexture( TextureStage_t stage, int textureIndex )
  787. {
  788. }
  789. // Flushes any primitives that are buffered
  790. void CShaderAPIDx10::FlushBufferedPrimitives()
  791. {
  792. }
  793. // Creates/destroys Mesh
  794. IMesh* CShaderAPIDx10::CreateStaticMesh( VertexFormat_t fmt, const char *pTextureBudgetGroup, IMaterial * pMaterial )
  795. {
  796. return &m_Mesh;
  797. }
  798. void CShaderAPIDx10::DestroyStaticMesh( IMesh* mesh )
  799. {
  800. }
  801. // Gets the dynamic mesh; note that you've got to render the mesh
  802. // before calling this function a second time. Clients should *not*
  803. // call DestroyStaticMesh on the mesh returned by this call.
  804. IMesh* CShaderAPIDx10::GetDynamicMesh( IMaterial* pMaterial, int nHWSkinBoneCount, bool buffered, IMesh* pVertexOverride, IMesh* pIndexOverride )
  805. {
  806. Assert( (pMaterial == NULL) || ((IMaterialInternal *)pMaterial)->IsRealTimeVersion() );
  807. return &m_Mesh;
  808. }
  809. IMesh* CShaderAPIDx10::GetDynamicMeshEx( IMaterial* pMaterial, VertexFormat_t fmt, int nHWSkinBoneCount, bool buffered, IMesh* pVertexOverride, IMesh* pIndexOverride )
  810. {
  811. // UNDONE: support compressed dynamic meshes if needed (pro: less VB memory, con: time spent compressing)
  812. Assert( CompressionType( pVertexOverride->GetVertexFormat() ) != VERTEX_COMPRESSION_NONE );
  813. Assert( (pMaterial == NULL) || ((IMaterialInternal *)pMaterial)->IsRealTimeVersion() );
  814. return &m_Mesh;
  815. }
  816. IMesh* CShaderAPIDx10::GetFlexMesh()
  817. {
  818. return &m_Mesh;
  819. }
  820. // Begins a rendering pass that uses a state snapshot
  821. void CShaderAPIDx10::BeginPass( StateSnapshot_t snapshot )
  822. {
  823. }
  824. // Renders a single pass of a material
  825. void CShaderAPIDx10::RenderPass( int nPass, int nPassCount )
  826. {
  827. }
  828. // stuff related to matrix stacks
  829. void CShaderAPIDx10::MatrixMode( MaterialMatrixMode_t matrixMode )
  830. {
  831. }
  832. void CShaderAPIDx10::PushMatrix()
  833. {
  834. }
  835. void CShaderAPIDx10::PopMatrix()
  836. {
  837. }
  838. void CShaderAPIDx10::LoadMatrix( float *m )
  839. {
  840. }
  841. void CShaderAPIDx10::MultMatrix( float *m )
  842. {
  843. }
  844. void CShaderAPIDx10::MultMatrixLocal( float *m )
  845. {
  846. }
  847. void CShaderAPIDx10::GetMatrix( MaterialMatrixMode_t matrixMode, float *dst )
  848. {
  849. }
  850. void CShaderAPIDx10::LoadIdentity( void )
  851. {
  852. }
  853. void CShaderAPIDx10::LoadCameraToWorld( void )
  854. {
  855. }
  856. void CShaderAPIDx10::Ortho( double left, double top, double right, double bottom, double zNear, double zFar )
  857. {
  858. }
  859. void CShaderAPIDx10::PerspectiveX( double fovx, double aspect, double zNear, double zFar )
  860. {
  861. }
  862. void CShaderAPIDx10::PerspectiveOffCenterX( double fovx, double aspect, double zNear, double zFar, double bottom, double top, double left, double right )
  863. {
  864. }
  865. void CShaderAPIDx10::PickMatrix( int x, int y, int width, int height )
  866. {
  867. }
  868. void CShaderAPIDx10::Rotate( float angle, float x, float y, float z )
  869. {
  870. }
  871. void CShaderAPIDx10::Translate( float x, float y, float z )
  872. {
  873. }
  874. void CShaderAPIDx10::Scale( float x, float y, float z )
  875. {
  876. }
  877. void CShaderAPIDx10::ScaleXY( float x, float y )
  878. {
  879. }
  880. // Fog methods...
  881. void CShaderAPIDx10::FogMode( MaterialFogMode_t fogMode )
  882. {
  883. }
  884. void CShaderAPIDx10::FogStart( float fStart )
  885. {
  886. }
  887. void CShaderAPIDx10::FogEnd( float fEnd )
  888. {
  889. }
  890. void CShaderAPIDx10::SetFogZ( float fogZ )
  891. {
  892. }
  893. void CShaderAPIDx10::FogMaxDensity( float flMaxDensity )
  894. {
  895. }
  896. void CShaderAPIDx10::GetFogDistances( float *fStart, float *fEnd, float *fFogZ )
  897. {
  898. }
  899. void CShaderAPIDx10::SceneFogColor3ub( unsigned char r, unsigned char g, unsigned char b )
  900. {
  901. }
  902. void CShaderAPIDx10::SceneFogMode( MaterialFogMode_t fogMode )
  903. {
  904. }
  905. void CShaderAPIDx10::GetSceneFogColor( unsigned char *rgb )
  906. {
  907. }
  908. MaterialFogMode_t CShaderAPIDx10::GetSceneFogMode( )
  909. {
  910. return MATERIAL_FOG_NONE;
  911. }
  912. int CShaderAPIDx10::GetPixelFogCombo( )
  913. {
  914. return 0; //FIXME
  915. }
  916. void CShaderAPIDx10::FogColor3f( float r, float g, float b )
  917. {
  918. }
  919. void CShaderAPIDx10::FogColor3fv( float const* rgb )
  920. {
  921. }
  922. void CShaderAPIDx10::FogColor3ub( unsigned char r, unsigned char g, unsigned char b )
  923. {
  924. }
  925. void CShaderAPIDx10::FogColor3ubv( unsigned char const* rgb )
  926. {
  927. }
  928. void CShaderAPIDx10::Viewport( int x, int y, int width, int height )
  929. {
  930. }
  931. void CShaderAPIDx10::GetViewport( int& x, int& y, int& width, int& height ) const
  932. {
  933. }
  934. // Sets the vertex and pixel shaders
  935. void CShaderAPIDx10::SetVertexShaderIndex( int vshIndex )
  936. {
  937. }
  938. void CShaderAPIDx10::SetPixelShaderIndex( int pshIndex )
  939. {
  940. }
  941. // Sets the constant register for vertex and pixel shaders
  942. void CShaderAPIDx10::SetVertexShaderConstant( int var, float const* pVec, int numConst, bool bForce )
  943. {
  944. }
  945. void CShaderAPIDx10::SetPixelShaderConstant( int var, float const* pVec, int numConst, bool bForce )
  946. {
  947. }
  948. void CShaderAPIDx10::InvalidateDelayedShaderConstants( void )
  949. {
  950. }
  951. //Set's the linear->gamma conversion textures to use for this hardware for both srgb writes enabled and disabled(identity)
  952. void CShaderAPIDx10::SetLinearToGammaConversionTextures( ShaderAPITextureHandle_t hSRGBWriteEnabledTexture, ShaderAPITextureHandle_t hIdentityTexture )
  953. {
  954. }
  955. // Returns the nearest supported format
  956. ImageFormat CShaderAPIDx10::GetNearestSupportedFormat( ImageFormat fmt, bool bFilteringRequired /* = true */ ) const
  957. {
  958. return fmt;
  959. }
  960. ImageFormat CShaderAPIDx10::GetNearestRenderTargetFormat( ImageFormat fmt ) const
  961. {
  962. return fmt;
  963. }
  964. // Sets the texture state
  965. void CShaderAPIDx10::BindTexture( Sampler_t stage, ShaderAPITextureHandle_t textureHandle )
  966. {
  967. }
  968. // Indicates we're going to be modifying this texture
  969. // TexImage2D, TexSubImage2D, TexWrap, TexMinFilter, and TexMagFilter
  970. // all use the texture specified by this function.
  971. void CShaderAPIDx10::ModifyTexture( ShaderAPITextureHandle_t textureHandle )
  972. {
  973. }
  974. // Texture management methods
  975. void CShaderAPIDx10::TexImage2D( int level, int cubeFace, ImageFormat dstFormat, int zOffset, int width, int height,
  976. ImageFormat srcFormat, bool bSrcIsTiled, void *imageData )
  977. {
  978. }
  979. void CShaderAPIDx10::TexSubImage2D( int level, int cubeFace, int xOffset, int yOffset, int zOffset, int width, int height,
  980. ImageFormat srcFormat, int srcStride, bool bSrcIsTiled, void *imageData )
  981. {
  982. }
  983. void CShaderAPIDx10::TexImageFromVTF( IVTFTexture *pVTF, int iVTFFrame )
  984. {
  985. }
  986. bool CShaderAPIDx10::TexLock( int level, int cubeFaceID, int xOffset, int yOffset,
  987. int width, int height, CPixelWriter& writer )
  988. {
  989. return false;
  990. }
  991. void CShaderAPIDx10::TexUnlock( )
  992. {
  993. }
  994. // These are bound to the texture, not the texture environment
  995. void CShaderAPIDx10::TexMinFilter( ShaderTexFilterMode_t texFilterMode )
  996. {
  997. }
  998. void CShaderAPIDx10::TexMagFilter( ShaderTexFilterMode_t texFilterMode )
  999. {
  1000. }
  1001. void CShaderAPIDx10::TexWrap( ShaderTexCoordComponent_t coord, ShaderTexWrapMode_t wrapMode )
  1002. {
  1003. }
  1004. void CShaderAPIDx10::TexSetPriority( int priority )
  1005. {
  1006. }
  1007. ShaderAPITextureHandle_t CShaderAPIDx10::CreateTexture(
  1008. int width,
  1009. int height,
  1010. int depth,
  1011. ImageFormat dstImageFormat,
  1012. int numMipLevels,
  1013. int numCopies,
  1014. int flags,
  1015. const char *pDebugName,
  1016. const char *pTextureGroupName )
  1017. {
  1018. ShaderAPITextureHandle_t handle;
  1019. CreateTextures( &handle, 1, width, height, depth, dstImageFormat, numMipLevels, numCopies, flags, pDebugName, pTextureGroupName );
  1020. return handle;
  1021. }
  1022. void CShaderAPIDx10::CreateTextures(
  1023. ShaderAPITextureHandle_t *pHandles,
  1024. int count,
  1025. int width,
  1026. int height,
  1027. int depth,
  1028. ImageFormat dstImageFormat,
  1029. int numMipLevels,
  1030. int numCopies,
  1031. int flags,
  1032. const char *pDebugName,
  1033. const char *pTextureGroupName )
  1034. {
  1035. for ( int k = 0; k < count; ++ k )
  1036. {
  1037. pHandles[ k ] = 0;
  1038. }
  1039. }
  1040. ShaderAPITextureHandle_t CShaderAPIDx10::CreateDepthTexture( ImageFormat renderFormat, int width, int height, const char *pDebugName, bool bTexture )
  1041. {
  1042. return 0;
  1043. }
  1044. void CShaderAPIDx10::DeleteTexture( ShaderAPITextureHandle_t textureHandle )
  1045. {
  1046. }
  1047. bool CShaderAPIDx10::IsTexture( ShaderAPITextureHandle_t textureHandle )
  1048. {
  1049. return true;
  1050. }
  1051. bool CShaderAPIDx10::IsTextureResident( ShaderAPITextureHandle_t textureHandle )
  1052. {
  1053. return false;
  1054. }
  1055. // stuff that isn't to be used from within a shader
  1056. void CShaderAPIDx10::ClearBuffersObeyStencil( bool bClearColor, bool bClearDepth )
  1057. {
  1058. }
  1059. void CShaderAPIDx10::ClearBuffersObeyStencilEx( bool bClearColor, bool bClearAlpha, bool bClearDepth )
  1060. {
  1061. }
  1062. void CShaderAPIDx10::PerformFullScreenStencilOperation( void )
  1063. {
  1064. }
  1065. void CShaderAPIDx10::ReadPixels( int x, int y, int width, int height, unsigned char *data, ImageFormat dstFormat )
  1066. {
  1067. }
  1068. void CShaderAPIDx10::ReadPixels( Rect_t *pSrcRect, Rect_t *pDstRect, unsigned char *data, ImageFormat dstFormat, int nDstStride )
  1069. {
  1070. }
  1071. void CShaderAPIDx10::FlushHardware()
  1072. {
  1073. }
  1074. // Set the number of bone weights
  1075. void CShaderAPIDx10::SetNumBoneWeights( int numBones )
  1076. {
  1077. }
  1078. // Selection mode methods
  1079. int CShaderAPIDx10::SelectionMode( bool selectionMode )
  1080. {
  1081. return 0;
  1082. }
  1083. void CShaderAPIDx10::SelectionBuffer( unsigned int* pBuffer, int size )
  1084. {
  1085. }
  1086. void CShaderAPIDx10::ClearSelectionNames( )
  1087. {
  1088. }
  1089. void CShaderAPIDx10::LoadSelectionName( int name )
  1090. {
  1091. }
  1092. void CShaderAPIDx10::PushSelectionName( int name )
  1093. {
  1094. }
  1095. void CShaderAPIDx10::PopSelectionName()
  1096. {
  1097. }
  1098. // Use this to get the mesh builder that allows us to modify vertex data
  1099. CMeshBuilder* CShaderAPIDx10::GetVertexModifyBuilder()
  1100. {
  1101. return 0;
  1102. }
  1103. // Board-independent calls, here to unify how shaders set state
  1104. // Implementations should chain back to IShaderUtil->BindTexture(), etc.
  1105. // Use this to begin and end the frame
  1106. void CShaderAPIDx10::BeginFrame()
  1107. {
  1108. }
  1109. void CShaderAPIDx10::EndFrame()
  1110. {
  1111. }
  1112. // returns the current time in seconds....
  1113. double CShaderAPIDx10::CurrentTime() const
  1114. {
  1115. return Sys_FloatTime();
  1116. }
  1117. // Get the current camera position in world space.
  1118. void CShaderAPIDx10::GetWorldSpaceCameraPosition( float * pPos ) const
  1119. {
  1120. }
  1121. void CShaderAPIDx10::ForceHardwareSync( void )
  1122. {
  1123. }
  1124. void CShaderAPIDx10::SetClipPlane( int index, const float *pPlane )
  1125. {
  1126. }
  1127. void CShaderAPIDx10::EnableClipPlane( int index, bool bEnable )
  1128. {
  1129. }
  1130. void CShaderAPIDx10::SetFastClipPlane( const float *pPlane )
  1131. {
  1132. }
  1133. void CShaderAPIDx10::EnableFastClip( bool bEnable )
  1134. {
  1135. }
  1136. int CShaderAPIDx10::GetCurrentNumBones( void ) const
  1137. {
  1138. return 0;
  1139. }
  1140. // Is hardware morphing enabled?
  1141. bool CShaderAPIDx10::IsHWMorphingEnabled( ) const
  1142. {
  1143. return false;
  1144. }
  1145. int CShaderAPIDx10::GetCurrentLightCombo( void ) const
  1146. {
  1147. return 0;
  1148. }
  1149. int CShaderAPIDx10::MapLightComboToPSLightCombo( int nLightCombo ) const
  1150. {
  1151. return 0;
  1152. }
  1153. MaterialFogMode_t CShaderAPIDx10::GetCurrentFogType( void ) const
  1154. {
  1155. return MATERIAL_FOG_NONE;
  1156. }
  1157. void CShaderAPIDx10::RecordString( const char *pStr )
  1158. {
  1159. }
  1160. void CShaderAPIDx10::DestroyVertexBuffers( bool bExitingLevel )
  1161. {
  1162. }
  1163. int CShaderAPIDx10::GetCurrentDynamicVBSize( void )
  1164. {
  1165. return 0;
  1166. }
  1167. void CShaderAPIDx10::EvictManagedResources()
  1168. {
  1169. }
  1170. void CShaderAPIDx10::ReleaseShaderObjects()
  1171. {
  1172. }
  1173. void CShaderAPIDx10::RestoreShaderObjects()
  1174. {
  1175. }
  1176. void CShaderAPIDx10::SetTextureTransformDimension( TextureStage_t textureStage, int dimension, bool projected )
  1177. {
  1178. }
  1179. void CShaderAPIDx10::SetBumpEnvMatrix( TextureStage_t textureStage, float m00, float m01, float m10, float m11 )
  1180. {
  1181. }
  1182. void CShaderAPIDx10::SyncToken( const char *pToken )
  1183. {
  1184. }