/opengles/src/arm/FunctionCache.h

http://ftk.googlecode.com/ · C Header · 89 lines · 41 code · 13 blank · 35 comment · 0 complexity · 239ba3f841499cb19cb60dcb9bdc3833 MD5 · raw file

  1. #ifndef EGL_FUNCTION_CACHE_H
  2. #define EGL_FUNCTION_CACHE_H 1
  3. // ==========================================================================
  4. //
  5. // FunctionCache.h Cache of compiled functions for 3D Rendering Library
  6. //
  7. // --------------------------------------------------------------------------
  8. //
  9. // 03-08-2004 Hans-Martin Will initial version
  10. //
  11. // --------------------------------------------------------------------------
  12. //
  13. // Copyright (c) 2004, Hans-Martin Will. All rights reserved.
  14. //
  15. // Redistribution and use in source and binary forms, with or without
  16. // modification, are permitted provided that the following conditions are
  17. // met:
  18. //
  19. // * Redistributions of source code must retain the above copyright
  20. // notice, this list of conditions and the following disclaimer.
  21. // * Redistributions in binary form must reproduce the above copyright
  22. // notice, this list of conditions and the following disclaimer in the
  23. // documentation and/or other materials provided with the distribution.
  24. //
  25. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  29. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  30. // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  31. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  32. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  33. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  34. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  35. // THE POSSIBILITY OF SUCH DAMAGE.
  36. //
  37. // ==========================================================================
  38. #include "OGLES.h"
  39. #include "RasterizerState.h"
  40. #include "Rasterizer.h"
  41. namespace EGL {
  42. struct FunctionInfo;
  43. class CodeGenerator;
  44. class OGLES_API FunctionCache {
  45. #if defined(EGL_ON_LINUX)
  46. friend class CodeGenerator;
  47. #else
  48. friend CodeGenerator;
  49. #endif
  50. public:
  51. enum FunctionType {
  52. FunctionTypeScanline,
  53. FunctionTypePoint,
  54. FunctionTypeLine,
  55. FunctionTypeTriangle
  56. };
  57. public:
  58. FunctionCache(size_t totalSize = 65536, float percentageKeep = 0.6);
  59. ~FunctionCache();
  60. void * GetFunction(FunctionType type, const RasterizerState & state);
  61. private:
  62. void * AddFunction(FunctionType type, const RasterizerState & state, size_t size);
  63. void CompactCode();
  64. private:
  65. U8 * m_Code;
  66. size_t m_Used;
  67. size_t m_Total;
  68. FunctionInfo * m_Functions;
  69. FunctionInfo * m_MostRecentlyUsed;
  70. FunctionInfo * m_LeastRecentlyUsed;
  71. size_t m_UsedFunctions;
  72. size_t m_MaxFunctions;
  73. float m_PercentageKeep;
  74. };
  75. }
  76. #endif //ndef EGL_FUNCTION_CACHE_H