Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.2 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //===========================================================================//
  9. // HDRFIXME: reduce the number of include files here.
  10. #include "buildindices_PS3.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. CPS3BuildIndicesJob g_BuildIndicesJob;
  14. CPS3BuildIndicesJob* g_pBuildIndicesJob = &g_BuildIndicesJob;
  15. job_buildindices::JobDescriptor_t g_buildIndicesJobDescriptor ALIGN128;
  16. //-----------------------------------------------------------------------------
  17. // Purpose:
  18. //-----------------------------------------------------------------------------
  19. void CPS3BuildIndicesJob::Init( void )
  20. {
  21. m_bEnabled = false;
  22. m_buildIndicesJobData.EnsureCapacity(256);
  23. m_buildIndicesJobCount = 0;
  24. // requires a SPURS instance, so register with VJobs
  25. if( g_pVJobs )
  26. {
  27. g_pVJobs->Register( this );
  28. }
  29. }
  30. //-----------------------------------------------------------------------------
  31. // Purpose:
  32. //-----------------------------------------------------------------------------
  33. void CPS3BuildIndicesJob::Shutdown()
  34. {
  35. g_pVJobs->Unregister( this );
  36. }
  37. //-----------------------------------------------------------------------------
  38. // Purpose:
  39. //-----------------------------------------------------------------------------
  40. void CPS3BuildIndicesJob::OnVjobsInit()
  41. {
  42. m_bEnabled = true;
  43. g_buildIndicesJobDescriptor.header = *m_pRoot->m_pJobBuildIndices;
  44. g_buildIndicesJobDescriptor.header.useInOutBuffer = 1;
  45. g_buildIndicesJobDescriptor.header.sizeStack = (32*1024)/8;
  46. g_buildIndicesJobDescriptor.header.sizeInOrInOut = 0;
  47. }
  48. //-----------------------------------------------------------------------------
  49. // Purpose:
  50. //-----------------------------------------------------------------------------
  51. void CPS3BuildIndicesJob::OnVjobsShutdown()
  52. {
  53. m_bEnabled = false;
  54. }
  55. //-----------------------------------------------------------------------------
  56. // Purpose:
  57. //-----------------------------------------------------------------------------
  58. void CPS3BuildIndicesJob::Push( job_buildindices::JobDescriptor_t *pJobDescriptor )
  59. {
  60. CELL_VERIFY( m_pRoot->m_queuePortBuildIndices.pushJob( &pJobDescriptor->header, sizeof(*pJobDescriptor), 0, CELL_SPURS_JOBQUEUE_FLAG_SYNC_JOB ) );
  61. }
  62. //-----------------------------------------------------------------------------
  63. // Purpose:
  64. //-----------------------------------------------------------------------------
  65. void CPS3BuildIndicesJob::Sync( void )
  66. {
  67. CELL_VERIFY( m_pRoot->m_queuePortBuildIndices.sync( 0 ) );
  68. // reset job count
  69. m_buildIndicesJobCount = 0;
  70. }
  71. //-----------------------------------------------------------------------------
  72. // Purpose:
  73. //-----------------------------------------------------------------------------
  74. PS3BuildIndicesJobData *CPS3BuildIndicesJob::GetJobData( void )
  75. {
  76. if( m_buildIndicesJobCount > 255 )
  77. {
  78. m_buildIndicesJobCount = 0;
  79. g_pBuildIndicesJob->Sync();
  80. }
  81. return &m_buildIndicesJobData[ m_buildIndicesJobCount++ ];
  82. }
  83. //-----------------------------------------------------------------------------
  84. // Purpose:
  85. //-----------------------------------------------------------------------------