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.

71 lines
1.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef HARDWAREMATRIXSTATE_H
  8. #define HARDWAREMATRIXSTATE_H
  9. #pragma once
  10. // This emulates the hardware matrix palette and keeps up with
  11. // matrix usage, LRU's matrices, etc.
  12. class CHardwareMatrixState
  13. {
  14. public:
  15. CHardwareMatrixState();
  16. void Init( int numHardwareMatrices );
  17. // return false if there is no slot for this matrix.
  18. bool AllocateMatrix( int globalMatrixID );
  19. // deallocate the least recently used matrix
  20. void DeallocateLRU( void );
  21. void DeallocateLRU( int n );
  22. // return true if a matrix is allocate.
  23. bool IsMatrixAllocated( int globalMatrixID ) const;
  24. // flush usage flags - signifies that none of the matrices are being used in the current strip
  25. // do this when starting a new strip.
  26. void SetAllUnused();
  27. void DeallocateAll();
  28. // save the complete state of the hardware matrices
  29. void SaveState();
  30. // restore the complete state of the hardware matrices
  31. void RestoreState();
  32. // Returns the number of free + unsed matrices
  33. int AllocatedMatrixCount() const;
  34. int FreeMatrixCount() const;
  35. int GetNthBoneGlobalID( int n ) const;
  36. void DumpState( void );
  37. private:
  38. int FindHardwareMatrix( int globalMatrixID );
  39. int FindLocalLRUIndex( void );
  40. // Increment and return LRU counter.
  41. struct MatrixState_t
  42. {
  43. bool allocated;
  44. int lastUsageID;
  45. int globalMatrixID;
  46. };
  47. int m_LRUCounter;
  48. int m_NumMatrices;
  49. int m_AllocatedMatrices;
  50. MatrixState_t *m_matrixState;
  51. MatrixState_t *m_savedMatrixState;
  52. };
  53. #endif // HARDWAREMATRIXSTATE_H