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.

76 lines
2.4 KiB

  1. //================ Copyright (c) Valve Corporation. All Rights Reserved. ===========================
  2. //
  3. //
  4. //
  5. //==================================================================================================
  6. //--------------------------------------------------------------------------------------------------
  7. // Headers
  8. //--------------------------------------------------------------------------------------------------
  9. #include "Profile.h"
  10. #include <spu_intrinsics.h>
  11. //--------------------------------------------------------------------------------------------------
  12. // Functions
  13. //--------------------------------------------------------------------------------------------------
  14. /*
  15. * Insert a marker that is displayed in Tuner
  16. */
  17. void insert_bookmark( uint32_t bookmark )
  18. {
  19. __asm__ volatile ("wrch $69, %0" :: "r" (bookmark));
  20. // Must wait for 16 cycles
  21. __asm__ volatile ("nop;nop;nop;nop;nop;nop;nop;nop");
  22. __asm__ volatile ("nop;nop;nop;nop;nop;nop;nop;nop");
  23. }
  24. void bookmark_delay( int NumBookmarks )
  25. {
  26. // 400 cycles per bookmark when emitting bookmarks on both SPUs
  27. for ( int i=0; i<NumBookmarks*400/8; i++)
  28. {
  29. __asm__ volatile ("nop;nop;nop;nop;nop;nop;nop;nop");
  30. }
  31. }
  32. /*
  33. * Inserting 6 SPU bookmarks, which will
  34. * be identified by Tuner as a start event
  35. */
  36. void raw_spu_prof_start( int iLevel, uint16_t lsa )
  37. {
  38. typedef union { char c4[4]; uint16_t u16[2]; uint32_t u32; } Module_u;
  39. static Module_u s_mu = { { 't', 'e', 's', 't' } };
  40. insert_bookmark( 0xffaa ); // start marker 1
  41. insert_bookmark( s_mu.u16[0] ); // name
  42. insert_bookmark( s_mu.u16[1] ); // name
  43. insert_bookmark( iLevel ); // level
  44. insert_bookmark( lsa >> 2 ); // LSA is shifted by 2 as per the SPURS spec.
  45. insert_bookmark( 0xffab ); // start marker 2
  46. bookmark_delay( NUM_BOOKMARKS_IN_EVENT );
  47. }
  48. /*
  49. * Inserting 6 SPU bookmarks, which will
  50. * be identified by Tuner as a stop event
  51. */
  52. void raw_spu_prof_stop( uint16_t lsa )
  53. {
  54. typedef union { uint16_t u16[4]; uint64_t u64; } GUID_u;
  55. GUID_u guid;
  56. qword insn = si_roti(*(qword*)(0x80 + lsa), 7);
  57. qword pattern = (qword)(vec_uchar16){0,1,4,5,8,9,12,13,0,1,4,5,8,9,12,13};
  58. guid.u64 = si_to_ullong(si_shufb(insn, insn, pattern));
  59. insert_bookmark( 0xffac ); // start marker 1
  60. insert_bookmark( guid.u16[0] ); // guid
  61. insert_bookmark( guid.u16[1] ); // guid
  62. insert_bookmark( guid.u16[2] ); // guid
  63. insert_bookmark( guid.u16[3] ); // guid
  64. insert_bookmark( 0xffad ); // start marker 2
  65. bookmark_delay( NUM_BOOKMARKS_IN_EVENT );
  66. }