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.

88 lines
2.4 KiB

  1. //========== Copyright � Valve Corporation, All rights reserved. ========
  2. #ifndef VJOB_SPURS_UTILS_HDR
  3. #define VJOB_SPURS_UTILS_HDR
  4. #ifndef _PS3
  5. #error "This is PS3 specific header"
  6. #endif
  7. #include "vjobs_interface.h"
  8. #include "ps3/vjobutils_shared.h"
  9. #ifdef VJOBS_ON_SPURS
  10. #include "tier0/logging.h"
  11. #include "tier0/dbg.h"
  12. #include "spu_printf.h"
  13. #include "tier0/memalloc.h"
  14. #include <cell/spurs.h>
  15. #include <cell/spurs/system_workload.h>
  16. using namespace ::cell::Spurs;
  17. DECLARE_LOGGING_CHANNEL( LOG_VJOBS );
  18. extern const char * HumanReadableCellResult( int nCellResult );
  19. inline int CellVerify( int nResult, const char * pCmd, LoggingSeverity_t severity )
  20. {
  21. Assert( nResult == CELL_OK );
  22. if( nResult != CELL_OK )
  23. {
  24. InternalMsg( LOG_VJOBS, severity, "Cell error %08X (%s) in\n\t%s\n", nResult, HumanReadableCellResult(nResult), pCmd );
  25. }
  26. return nResult;
  27. }
  28. inline int CellVerify2( int nResult, const char * pCmd, const char * pFile, const int nLine, LoggingSeverity_t severity )
  29. {
  30. Assert( nResult == CELL_OK );
  31. if( nResult != CELL_OK )
  32. {
  33. InternalMsg( LOG_VJOBS, severity, "Cell error %08X (%s) in\n\t%s\n\t%s:%d", nResult, HumanReadableCellResult(nResult), pCmd, pFile, nLine );
  34. }
  35. return nResult;
  36. }
  37. #define CELL_VERIFY( CMD ) CellVerify2( CMD, #CMD, __FILE__, __LINE__, LS_ASSERT )
  38. #define CELL_MUST_SUCCEED( CMD ) CellVerify2( CMD, #CMD, __FILE__, __LINE__, LS_ERROR )
  39. #define CELL_MUST_SUCCEED2( CMD, DESC ) CellVerify2( CMD, DESC, __FILE__, __LINE__, LS_ERROR )
  40. inline CellSpursJob64* NewJob64( const CellSpursJobHeader & jobHeader )
  41. {
  42. CellSpursJob64 * pJob = (CellSpursJob64 *)MemAlloc_AllocAligned( sizeof(CellSpursJob64), sizeof(CellSpursJob64) );
  43. pJob->header = jobHeader;
  44. pJob->workArea.dmaList[0] = 0;
  45. pJob->workArea.dmaList[1] = 0;
  46. return pJob;
  47. };
  48. inline CellSpursJob128* NewJob128( const CellSpursJobHeader & jobHeader )
  49. {
  50. CellSpursJob128 * pJob = (CellSpursJob128 *)MemAlloc_AllocAligned( sizeof(CellSpursJob128), sizeof(CellSpursJob128) );
  51. __dcbz( pJob );
  52. pJob->header = jobHeader;
  53. return pJob;
  54. };
  55. inline CellSpursJob256* NewJob256( const CellSpursJobHeader & jobHeader )
  56. {
  57. CellSpursJob256 * pJob = (CellSpursJob256 *)MemAlloc_AllocAligned( sizeof(CellSpursJob256), sizeof(CellSpursJob256) );
  58. __dcbz( pJob );
  59. __dcbz( ((uint8*)pJob) + 128 );
  60. pJob->header = jobHeader;
  61. return pJob;
  62. };
  63. template <typename T>
  64. inline void DeleteJob( T * pJob )
  65. {
  66. MemAlloc_FreeAligned( pJob );
  67. }
  68. #endif // VJOBS_ON_SPURS
  69. DECLARE_LOGGING_CHANNEL(LOG_VJOBS);
  70. #endif