diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llagparray.h | 215 |
1 files changed, 0 insertions, 215 deletions
diff --git a/linden/indra/newview/llagparray.h b/linden/indra/newview/llagparray.h deleted file mode 100644 index 2569d95..0000000 --- a/linden/indra/newview/llagparray.h +++ /dev/null | |||
@@ -1,215 +0,0 @@ | |||
1 | /** | ||
2 | * @file llagparray.h | ||
3 | * @brief LLAGPArray - arrays used for rendering w/ AGP memory (if on) | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_LLAGPARRAY_H | ||
29 | #define LL_LLAGPARRAY_H | ||
30 | |||
31 | #include <stdlib.h> | ||
32 | #include "llagpmempool.h" | ||
33 | |||
34 | class LLAGPMemBlock; | ||
35 | |||
36 | template <class Type> class LLAGPArray | ||
37 | { | ||
38 | public: | ||
39 | enum | ||
40 | { | ||
41 | OKAY = 0, | ||
42 | FAIL = -1 | ||
43 | }; | ||
44 | |||
45 | inline LLAGPArray(const S32 size=0, const U32 target=0); | ||
46 | inline ~LLAGPArray(); | ||
47 | |||
48 | inline void init(); | ||
49 | inline void destroy(); | ||
50 | |||
51 | inline void flushAGP(); | ||
52 | inline void setDirty() { mDirty = TRUE; } | ||
53 | inline BOOL isDirty() const { return mDirty; } | ||
54 | |||
55 | inline BOOL setUseAGP(const BOOL on = TRUE); // Returns false if AGP memory is not available | ||
56 | inline BOOL isAGP() const { return mAGPp ? TRUE : FALSE; } | ||
57 | LLAGPMemBlock *getAGPMemBlock() const { return mAGPp; } | ||
58 | |||
59 | inline BOOL realloc(U32 newsize); | ||
60 | inline S32 getMax() const { return mMaxObj; } | ||
61 | inline S32 count() const; | ||
62 | inline S32 shrinkTo(S32 newcount); | ||
63 | inline void reset(S32 reserve_count); | ||
64 | |||
65 | inline S32 find (const Type &obj) const; | ||
66 | inline S32 fastRemove(const S32 i); | ||
67 | inline S32 safeRemove(const S32 r); | ||
68 | inline S32 remove (const S32 i); | ||
69 | inline S32 removeObj (const Type &obj); | ||
70 | inline S32 removeLast() { return (mNumObj > 0 ? mNumObj-- : 0); } | ||
71 | |||
72 | inline Type* reserve_block(const U32 num); | ||
73 | |||
74 | inline S32 put(const Type &obj); | ||
75 | inline const Type& get(const S32 i) const; | ||
76 | inline Type& get(const S32 i); | ||
77 | |||
78 | inline BOOL sync (); | ||
79 | inline BOOL syncColor(); | ||
80 | |||
81 | inline const Type* getMem () const; | ||
82 | inline const S32 getIndex(const Type *objp) const { return objp - mMemp; } | ||
83 | inline const Type& operator[](const S32 i) const; | ||
84 | inline Type& operator[](const S32 i); | ||
85 | |||
86 | void bindGLVertexPointer(const U32 stride, const U32 offset); | ||
87 | void bindGLTexCoordPointer(const U32 stride, const U32 offset); | ||
88 | void bindGLNormalPointer(const U32 stride, const U32 offset); | ||
89 | void bindGLBinormalPointer(const S32 index, const U32 stride, const U32 offset); | ||
90 | void bindGLColorPointer(const U32 stride, const U32 offset); | ||
91 | void bindGLVertexWeightPointer(const S32 index, const U32 stride, const U32 offset); | ||
92 | void bindGLVertexClothingWeightPointer(const S32 index, const U32 stride, const U32 offset); | ||
93 | |||
94 | void copyToMem(const S32 offset, const U8 *source, const S32 size); | ||
95 | |||
96 | U8* getScratchMemory(); | ||
97 | |||
98 | U32 createFence() { return (mAGPp ? mAGPp->createFence() : 0); } | ||
99 | void deleteFence(const U32 fence) { if (mAGPp) { mAGPp->deleteFence(fence); } } | ||
100 | void sendFence(U32 fence) { if (mAGPp) mAGPp->sendFence(fence); } | ||
101 | void waitFence(U32 fence) { if (mAGPp) mAGPp->waitFence(fence); } | ||
102 | |||
103 | S32 getSysMemUsage() { return sizeof(Type)*mMaxObj; } | ||
104 | |||
105 | protected: | ||
106 | BOOL mDirty; | ||
107 | BOOL mUseAGP; | ||
108 | U32 mNumObj; | ||
109 | U32 mMaxObj; | ||
110 | U8 *mUnalignedMemp; | ||
111 | Type *mMemp; | ||
112 | U32 mTarget; //for VBO implementations of this class, store the type of buffer this is | ||
113 | |||
114 | LLAGPMemBlock *mAGPp; | ||
115 | |||
116 | public: | ||
117 | BOOL mSynced; // for graph only -- not critical | ||
118 | |||
119 | public: | ||
120 | static S32 sNumRealloced; | ||
121 | static S32 sBytesRealloced; | ||
122 | static char* sTypeName; | ||
123 | }; | ||
124 | |||
125 | template <class Type> S32 LLAGPArray<Type>::sNumRealloced = 0; | ||
126 | template <class Type> S32 LLAGPArray<Type>::sBytesRealloced = 0; | ||
127 | |||
128 | // constructor is in .inl file because it calls realloc() | ||
129 | // which access gPipeline (yuck!) | ||
130 | |||
131 | template <class Type> | ||
132 | LLAGPArray<Type>::~LLAGPArray() | ||
133 | { | ||
134 | destroy(); | ||
135 | } | ||
136 | |||
137 | template <class Type> void | ||
138 | LLAGPArray<Type>::destroy() | ||
139 | { | ||
140 | realloc(0); | ||
141 | delete mAGPp; | ||
142 | mAGPp = NULL; | ||
143 | } | ||
144 | |||
145 | template <class Type> | ||
146 | const Type *LLAGPArray<Type>::getMem() const | ||
147 | { | ||
148 | return mMemp; | ||
149 | } | ||
150 | |||
151 | template <class Type> | ||
152 | const Type& LLAGPArray<Type>::get(const S32 i) const | ||
153 | { | ||
154 | llassert(i < (S32)mNumObj); | ||
155 | return mMemp[i]; | ||
156 | } | ||
157 | |||
158 | template <class Type> | ||
159 | Type& LLAGPArray<Type>::get(const S32 i) | ||
160 | { | ||
161 | setDirty(); | ||
162 | llassert(i < (S32)mNumObj); | ||
163 | return mMemp[i]; | ||
164 | } | ||
165 | |||
166 | template <class Type> | ||
167 | const Type& LLAGPArray<Type>::operator[](const S32 i) const | ||
168 | { | ||
169 | return get(i); | ||
170 | } | ||
171 | |||
172 | template <class Type> | ||
173 | Type& LLAGPArray<Type>::operator[](const S32 i) | ||
174 | { | ||
175 | return get(i); | ||
176 | } | ||
177 | |||
178 | template <class Type> | ||
179 | S32 LLAGPArray<Type>::fastRemove(const S32 i) | ||
180 | { | ||
181 | if (i < 0 || mNumObj <= 0) return FAIL; | ||
182 | setDirty(); | ||
183 | mMemp[i] = mMemp[--mNumObj]; | ||
184 | |||
185 | return OKAY; | ||
186 | } | ||
187 | |||
188 | template <class Type> | ||
189 | S32 LLAGPArray<Type>::remove(const S32 i) | ||
190 | { | ||
191 | setDirty(); | ||
192 | return fastRemove(i); | ||
193 | } | ||
194 | |||
195 | template <class Type> | ||
196 | S32 LLAGPArray<Type>::removeObj(const Type& obj) | ||
197 | { | ||
198 | setDirty(); | ||
199 | |||
200 | S32 ind = find(obj); | ||
201 | if (ind >= 0) | ||
202 | { | ||
203 | return fastRemove(ind); | ||
204 | } | ||
205 | return FAIL; | ||
206 | } | ||
207 | |||
208 | template <class Type> | ||
209 | S32 LLAGPArray<Type>::count() const | ||
210 | { | ||
211 | return mNumObj; | ||
212 | } | ||
213 | |||
214 | |||
215 | #endif // LL_LLAGPARRAY_H | ||