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.

128 lines
3.4 KiB

  1. //========== Copyright � Valve Corporation, All rights reserved. ========
  2. #if !defined( JOB_FPCPATCH_SHARED_HDR ) && defined( _PS3 )
  3. #define JOB_FPCPATCH_SHARED_HDR
  4. #include "ps3/spu_job_shared.h"
  5. #include "ps3/ps3_gcm_config.h"
  6. namespace job_fpcpatch
  7. {
  8. // On PS/3, fragment programs have a maximum of 256 constant patch-ups that can be applied to each shader
  9. // PS 2.0 defines 96 as minimum, but I'm not sure how many we are actually using
  10. enum GlobalConstEnum_t
  11. {
  12. MAX_VIRTUAL_CONST_COUNT = MAX_FPCP_VIRTUAL_CONST_COUNT,
  13. FLAG_PUT_STATE = 1, // DMA the new state out when done; must be synchronized by vjobs code running at PPU
  14. FLAG_BREAK_JOB = 2,
  15. FLAG_DEFER_STATE = 4,
  16. FLAG_UNDEFER_STATE = 8 // this flag must fit in the lower 4 bits, because deferred state may be 16-byte aligned, not 128-byte aligned
  17. };
  18. union ConstRangeHeader_t
  19. {
  20. fltx4 m_f4;
  21. struct
  22. {
  23. uint32 m_nStart;
  24. uint32 m_nCount;
  25. } m_u32;
  26. };
  27. struct ALIGN16 FpcPatchStateHeader_t
  28. {
  29. #ifndef SPU
  30. volatile // there's no need to treat this as volatile on SPU
  31. #endif
  32. uint32 m_nStartRanges; // the start index of ConstRangeHeader_t
  33. uint32 m_nBufferMask; // the number of Qwords in the buffer - 1
  34. FpcPatchStateHeader_t * m_eaThis;
  35. uint32 m_nThisStatePatchCounter; // the patch counter corresponding to this state (the job at which it was up to date)
  36. uint32 m_eaThisStateJobDescriptor;
  37. uint32 m_nDebuggerBreak;
  38. }
  39. ALIGN16_POST;
  40. struct ALIGN128 FpcPatchState_t: FpcPatchStateHeader_t
  41. {
  42. // virtual const register states
  43. fltx4 m_reg[MAX_VIRTUAL_CONST_COUNT];
  44. fltx4 * GetBufferStart()
  45. {
  46. return ( fltx4* )( this + 1 ) ; // the buffer start address
  47. }
  48. }
  49. ALIGN128_POST;
  50. }
  51. namespace job_fpcpatch2
  52. {
  53. using job_fpcpatch::MAX_VIRTUAL_CONST_COUNT;
  54. using job_fpcpatch::FLAG_PUT_STATE;
  55. using job_fpcpatch::FLAG_BREAK_JOB;
  56. using job_fpcpatch::FLAG_DEFER_STATE;
  57. using job_fpcpatch::FLAG_UNDEFER_STATE;
  58. using job_fpcpatch::ConstRangeHeader_t;
  59. using job_fpcpatch::FpcPatchStateHeader_t;
  60. using job_fpcpatch::FpcPatchState_t;
  61. struct ALIGN16 FpHeader_t
  62. {
  63. uint32 m_nUcodeSize;
  64. // patches follow Ucode; patch is struct{ uint16 nConstIndex; uint16 nConstOffset; }
  65. // the offset is a qword index ( offset from the start of Ucode div 16 )
  66. uint32 m_nPatchCount;
  67. uint32 m_nShaderControl0;
  68. uint32 m_nTexControls; // Always <= 16; 1 tex control corresponds to 2 words in the tex control table
  69. // the dma size without the texcontrols
  70. uint GetDmaSize() const
  71. {
  72. return sizeof( *this ) + m_nUcodeSize + m_nPatchCount * sizeof( uint32 );
  73. }
  74. static uintp GetUcodeEa( uint eaFpHeader )
  75. {
  76. return eaFpHeader + sizeof( FpHeader_t );
  77. }
  78. uintp GetPatchTableEa( uint eaFpHeader )const
  79. {
  80. return GetUcodeEa( eaFpHeader ) + m_nUcodeSize;
  81. }
  82. uintp GetTexControlsEa( uint eaFpHeader )const
  83. {
  84. return GetPatchTableEa( eaFpHeader ) + AlignValue( m_nPatchCount * sizeof( uint32 ), 16 );
  85. }
  86. uintp GetTexControlsBytes( )const
  87. {
  88. return sizeof( uint32 ) * 2 * m_nTexControls;
  89. }
  90. #if !defined( SPU )
  91. const void * GetUcode()const
  92. {
  93. return ( void* )GetUcodeEa( ( uintp ) this );
  94. }
  95. const uint32 * GetPatchTable( )const
  96. {
  97. return ( uint32* )( uintp( GetUcode() ) + m_nUcodeSize );
  98. }
  99. const uint32 * GetTexControls()const
  100. {
  101. return ( uint32* )GetTexControlsEa( ( uintp )this );
  102. }
  103. #endif
  104. }
  105. ALIGN16_POST;
  106. }
  107. #endif