PageRenderTime 30ms CodeModel.GetById 17ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

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