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.3 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include "HardwareVertexCache.h"
  10. CHardwareVertexCache::CHardwareVertexCache()
  11. {
  12. m_Fifo = NULL;
  13. m_Size = 0;
  14. Flush();
  15. }
  16. void CHardwareVertexCache::Init( int size )
  17. {
  18. m_Size = size;
  19. m_Fifo = new int[size];
  20. Flush();
  21. }
  22. void CHardwareVertexCache::Flush( void )
  23. {
  24. m_HeadIndex = 0;
  25. m_NumEntries = 0;
  26. }
  27. bool CHardwareVertexCache::IsPresent( int index )
  28. {
  29. int i;
  30. // printf( "testing if %d is present\n", index );
  31. for( i = 0; i < m_NumEntries; i++ )
  32. {
  33. if( m_Fifo[( m_HeadIndex + i ) % m_Size] == index )
  34. {
  35. // printf( "yes!\n" );
  36. return true;
  37. }
  38. }
  39. // printf( "no!\n" );
  40. // Print();
  41. return false;
  42. }
  43. void CHardwareVertexCache::Insert( int index )
  44. {
  45. // printf( "Inserting: %d\n", index );
  46. m_Fifo[( m_HeadIndex + m_NumEntries ) % m_Size] = index;
  47. if( m_NumEntries == m_Size )
  48. {
  49. m_HeadIndex = ( m_HeadIndex + 1 ) % m_Size;
  50. }
  51. else
  52. {
  53. m_NumEntries++;
  54. }
  55. // Print();
  56. }
  57. void CHardwareVertexCache::Print( void )
  58. {
  59. int i;
  60. for( i = 0; i < m_NumEntries; i++ )
  61. {
  62. printf( "fifo entry %d: %d\n", i, ( int )m_Fifo[( m_HeadIndex + i ) % m_Size] );
  63. }
  64. }