diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llrender/llagpmempool.cpp | 194 |
1 files changed, 0 insertions, 194 deletions
diff --git a/linden/indra/llrender/llagpmempool.cpp b/linden/indra/llrender/llagpmempool.cpp deleted file mode 100644 index 39cd3e8..0000000 --- a/linden/indra/llrender/llagpmempool.cpp +++ /dev/null | |||
@@ -1,194 +0,0 @@ | |||
1 | /** | ||
2 | * @file llagpmempool.cpp | ||
3 | * @brief LLAGPMemPool base class | ||
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 | #include "linden_common.h" | ||
29 | |||
30 | #include "llagpmempool.h" | ||
31 | #include "llgl.h" | ||
32 | |||
33 | #include "llagpmempoolarb.h" | ||
34 | #include "llagpmempoolnv.h" | ||
35 | #include "llagpmempoolati.h" | ||
36 | |||
37 | #if LL_DARWIN | ||
38 | #include "llagpmempoolapple.h" | ||
39 | #endif // LL_DARWIN | ||
40 | |||
41 | //static | ||
42 | S32 LLAGPMemPool::LLFreeBlock::sNumBlocks = 0; | ||
43 | |||
44 | LLAGPMemPool::LLAGPMemPool() | ||
45 | { | ||
46 | mSize = 0; | ||
47 | mTotalAllocated = 0; | ||
48 | } | ||
49 | |||
50 | LLAGPMemPool::~LLAGPMemPool() | ||
51 | { | ||
52 | mFreeList.deleteAll(); | ||
53 | } | ||
54 | |||
55 | LLAGPMemPool *LLAGPMemPool::createPool(const U32 size, const BOOL use_vbo) | ||
56 | { | ||
57 | if (gGLManager.mHasVertexBufferObject && use_vbo) | ||
58 | { | ||
59 | return new LLAGPMemPoolARB(size); | ||
60 | } | ||
61 | #if LL_WINDOWS // *FIX: linux can use these, too, with some work. | ||
62 | if (gGLManager.mHasNVFence) | ||
63 | { | ||
64 | return new LLAGPMemPoolNV(size); | ||
65 | } | ||
66 | else if (gGLManager.mHasATIVAO) | ||
67 | { | ||
68 | return new LLAGPMemPoolATI(size); | ||
69 | } | ||
70 | else | ||
71 | #elif LL_DARWIN | ||
72 | if (gGLManager.mHasAPPLEFence && gGLManager.mHasAPPLEVertexArrayRange) | ||
73 | { | ||
74 | return new LLAGPMemPoolAPPLE(size); | ||
75 | } | ||
76 | else | ||
77 | #endif | ||
78 | { | ||
79 | // No AGP memory allocation at all! | ||
80 | return NULL; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | |||
85 | LLAGPMemBlock *LLAGPMemPool::allocBlock(const S32 size) | ||
86 | { | ||
87 | S32 aligned_size = size; | ||
88 | if (size & 0x0f) | ||
89 | { | ||
90 | aligned_size += 16 - (size & 0x0f); | ||
91 | } | ||
92 | |||
93 | if (aligned_size > (mSize - mTotalAllocated)) | ||
94 | { | ||
95 | // We're totally out of AGP memory, bail. | ||
96 | return NULL; | ||
97 | } | ||
98 | |||
99 | LLFreeBlock *free_block = mFreeList.getFirst(); | ||
100 | |||
101 | while (free_block && free_block->mSize < aligned_size) | ||
102 | { | ||
103 | free_block = free_block->getNext(); | ||
104 | } | ||
105 | |||
106 | U32 offset = 0; | ||
107 | |||
108 | if (free_block) | ||
109 | { | ||
110 | if (free_block->mSize == aligned_size) | ||
111 | { | ||
112 | free_block->unlink(); | ||
113 | offset = free_block->mOffset; | ||
114 | delete free_block; | ||
115 | } | ||
116 | else | ||
117 | { | ||
118 | offset = free_block->mOffset + free_block->mSize - aligned_size; | ||
119 | free_block->mSize -= aligned_size; | ||
120 | if (0 == free_block->mSize) | ||
121 | { | ||
122 | free_block->unlink(); | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | else | ||
127 | { | ||
128 | //llwarns << "LLAGPMemPool unable to allocate " << size << " bytes" << llendl; | ||
129 | return NULL; | ||
130 | } | ||
131 | |||
132 | mTotalAllocated += aligned_size; | ||
133 | return createBlock(offset, aligned_size); | ||
134 | } | ||
135 | |||
136 | |||
137 | void LLAGPMemPool::freeBlock(LLAGPMemBlock *blockp) | ||
138 | { | ||
139 | if (!blockp->getSize()) | ||
140 | { | ||
141 | return; | ||
142 | } | ||
143 | |||
144 | LLFreeBlock *prev_free = NULL; | ||
145 | LLFreeBlock *cur_free = mFreeList.getFirst(); | ||
146 | |||
147 | while (cur_free && blockp->getOffset() > (U32)cur_free->mOffset) | ||
148 | { | ||
149 | prev_free = cur_free; | ||
150 | cur_free = cur_free->getNext(); | ||
151 | } | ||
152 | |||
153 | LLFreeBlock *new_free = new LLFreeBlock(blockp->getOffset(), blockp->getSize()); | ||
154 | |||
155 | if (prev_free) | ||
156 | { | ||
157 | prev_free->append(*new_free); | ||
158 | coalesce(new_free); | ||
159 | coalesce(prev_free); | ||
160 | } | ||
161 | else | ||
162 | { | ||
163 | mFreeList.append(*new_free); | ||
164 | coalesce(new_free); | ||
165 | } | ||
166 | mTotalAllocated -= blockp->getSize(); | ||
167 | } | ||
168 | |||
169 | void LLAGPMemPool::coalesce(LLFreeBlock *free_block) | ||
170 | { | ||
171 | LLFreeBlock *next = free_block->getNext(); | ||
172 | |||
173 | if (next && (free_block->mOffset + free_block->mSize == next->mOffset)) | ||
174 | { | ||
175 | free_block->mSize += next->mSize; | ||
176 | |||
177 | next->unlink(); | ||
178 | delete next; | ||
179 | |||
180 | coalesce(free_block); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | void LLAGPMemPool::printFreeList() | ||
185 | { | ||
186 | LLFreeBlock *cur_block = mFreeList.getFirst(); | ||
187 | while (cur_block) | ||
188 | { | ||
189 | llinfos << "Cur block begin: " << cur_block->mOffset << llendl; | ||
190 | llinfos << "Cur block end: " << cur_block->mOffset + cur_block->mSize << llendl; | ||
191 | cur_block = cur_block->getNext(); | ||
192 | } | ||
193 | } | ||
194 | |||