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.

121 lines
3.6 KiB

  1. //========== Copyright � 2010, Valve Corporation, All rights reserved. ========
  2. #ifndef MATERIALSYSTEM_PS3GCM_RSXFLIP_HDR
  3. #define MATERIALSYSTEM_PS3GCM_RSXFLIP_HDR
  4. #ifndef _CERT
  5. #define GCM_ALLOW_TIMESTAMPS 1
  6. void OnFrameTimestampAvailableFlip( float ms );
  7. void OnFrameTimestampAvailableRsx( float ms );
  8. void OnFrameTimestampAvailableMain( float ms );
  9. void OnFrameTimestampAvailableMST( float ms );
  10. extern int32 g_ps3_timestampBeginIdx;
  11. #endif
  12. #include "ps3/ps3gcmmemory.h"
  13. class RsxInterruptFifo
  14. {
  15. public:
  16. struct Event_t
  17. {
  18. uint8 m_nCause;
  19. uint8 m_nSurfaceFlipIdx;
  20. };
  21. protected:
  22. enum { MAX_EVENT_COUNT = 0x80 };
  23. volatile uint m_nGet;
  24. uint m_nPut;
  25. Event_t m_queue[MAX_EVENT_COUNT];
  26. public:
  27. void Init();
  28. uint Queue( uint8 nCause, uint8 nSurfaceFlipIdx );
  29. uint Queue( const Event_t &event );
  30. uint GetPutMarker()const;
  31. int HasEvents( uint nMarker );
  32. bool IsIdle()const { return m_nPut == m_nGet;}
  33. bool IsValidMarker( uint nMarker );
  34. Event_t & PeekEvent();
  35. const Event_t DequeueEvent( );
  36. void QueueRsxInterrupt();
  37. };
  38. class CFlipHandler
  39. {
  40. public:
  41. void Init();
  42. void Shutdown();
  43. void Flip();
  44. void BeginScene();
  45. void EndScene(){}
  46. bool OnRsxInterrupt( const RsxInterruptFifo::Event_t event );
  47. void TryFlipVblank();
  48. void TryPumpEvents( uint nMarker, uint isVblank );
  49. void QmsPrepareFlipSubmit( GcmUserCommandEnum_t nEvent, uint surfaceFlipIdx );
  50. bool QmsAdviceBeforeDrawPrevFramebuffer();
  51. void DisableMlaa(){ m_nMlaaFlagsThisFrame = 0; }
  52. void DisableMlaaPermannetly(){ m_nMlaaFlagMaskNextFrame = 0; }
  53. void EnableMlaaPermannetly(){ m_nMlaaFlagMaskNextFrame = ~0u; }
  54. //void DisableMlaaForTwoFrames(){ m_nMlaaFlagsThisFrame = m_nMlaaFlagMaskNextFrame = 0; }
  55. int IsMlaaEnabled()const { return m_nMlaaFlagsThisFrame; }
  56. enum DebugStateEnum_t
  57. {
  58. RENDERING_SURFACE,
  59. DISPLAYING_SURFACE,
  60. DEBUG_STATE_COUNT
  61. };
  62. //void OnState( int nState, int nValue );
  63. public:
  64. static void INTERRUPT_VBlankHandler( const uint32 head );
  65. static void INTERRUPT_UserHandler( const uint32 cause );
  66. void PumpEventsUnsafe( uint nMarker );
  67. bool TryFlipSurface( uint isVblank );
  68. protected:
  69. void TransferMlaaResultIfNecessary( uint nSurfacePrevFlipIdx );
  70. public:
  71. //int m_nDebugStates[DEBUG_STATE_COUNT];
  72. // How often to present in terms of vblanks?
  73. // (@60Hz scanout TV: 1 = 60 Hz = every vblank, 2 = 30 Hz = every other vblank, 3 = 20 Hz = every 3rd vblank)
  74. // (@50Hz PAL TV: 1 = 50 Hz = every vblank, 2 = 25 Hz = every other vblank, 3 = 17 Hz = every 3rd vblank)
  75. int m_nPresentFrequency;
  76. // Interrupt-driven data
  77. #ifdef GCM_ALLOW_TIMESTAMPS
  78. double m_flFlipImmediateTimestamp;
  79. #endif
  80. double m_flVBlankTimestamp, m_flVBlankTimestamp0;
  81. // Mutex to sync with interrupt thread
  82. CThreadMutex m_mutexOfInterruptThread;
  83. CThreadManualEvent m_evFlipReady[ CPs3gcmDisplay::SURFACE_COUNT ];
  84. uint m_nFlipSurfaceIdx, m_nFlipSurfaceCount; // the next surface to flip, count of surfaces to flip
  85. uint m_nSystemFlipId[ CPs3gcmDisplay::SURFACE_COUNT ];
  86. //uint m_nLastFlippedSurfaceIdx; // used to check for duplicate TryFlip callbacks
  87. uint m_nVblankCounter;
  88. uint32 * m_pLastInterruptGet;
  89. RsxInterruptFifo m_interruptFifo;
  90. uint8 m_surfaceEdgePost[CPs3gcmDisplay::SURFACE_COUNT]; // true when the corresponding surface must be post-processed
  91. // VSync enabled?
  92. // true = Syncronize with VSync = true
  93. // false = Syncronize with every HSync scanline
  94. bool m_bVSync;
  95. bool m_bEdgePostResultAlreadyInLocalMemory;
  96. int m_nMlaaFlagsThisFrame;
  97. int m_nMlaaFlagMaskNextFrame;
  98. };
  99. extern CFlipHandler g_flipHandler;
  100. #endif