aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llagpmempoolnv.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llrender/llagpmempoolnv.cpp')
-rw-r--r--linden/indra/llrender/llagpmempoolnv.cpp320
1 files changed, 0 insertions, 320 deletions
diff --git a/linden/indra/llrender/llagpmempoolnv.cpp b/linden/indra/llrender/llagpmempoolnv.cpp
deleted file mode 100644
index 8bbaef9..0000000
--- a/linden/indra/llrender/llagpmempoolnv.cpp
+++ /dev/null
@@ -1,320 +0,0 @@
1/**
2 * @file llagpmempoolnv.cpp
3 * @brief LLAGPMemPoolNV 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#ifndef LL_LINUX
31
32#include "llagpmempoolnv.h"
33#include "llgl.h"
34
35#include "llglheaders.h"
36
37#if LL_WINDOWS
38//#define LL_USE_NEW_MEM_OPS 1
39#endif
40#if LL_USE_NEW_MEM_OPS
41#include "new_mem_ops.h"
42#endif
43
44BOOL LLAGPMemPoolNV::sWriteOK = TRUE;
45
46LLAGPMemPoolNV::LLAGPMemPoolNV(int request) : LLAGPMemPool()
47{
48 llinfos << "Creating LLAGPMemPoolNV" << llendl;
49 stop_glerror();
50 if (!gGLManager.mHasNVFence)
51 {
52 llerrs << "wglAllocateMemoryNV not defined!" << llendl;
53 }
54
55 mBase = 0;
56
57 if (!mBase)
58 {
59 // More than 4MB of AGP available
60 while (!mBase && (request > 0))
61 {
62 // Stupid arbitrary nVidia magic numbers.
63 // read freq, write freq, priority
64 // AGP: 0.0, 0.1, 0.5
65 // Video: 0.0, 0.1, 1.0
66 mBase = (U8*)wglAllocateMemoryNV(request, 0.0f, 0.1f, 0.5f);
67 mSize = request;
68 request >>= 1;
69 }
70 }
71
72 if (mBase)
73 {
74 mFreeList.append(*(new LLFreeBlock(0,mSize)));
75 }
76 else
77 {
78 mSize = 0;
79 }
80
81 sWriteOK = TRUE;
82 flush_glerror();
83}
84
85
86LLAGPMemBlock *LLAGPMemPoolNV::createBlock(const U32 offset, const U32 size)
87{
88 return new LLAGPMemBlockNV(this, mBase, offset, size);
89}
90
91LLAGPMemPoolNV::~LLAGPMemPoolNV()
92{
93 if (mBase)
94 {
95 wglFreeMemoryNV(mBase);
96 }
97}
98
99void LLAGPMemPoolNV::bind()
100{
101 glVertexArrayRangeNV(mSize, mBase);
102}
103
104void LLAGPMemPoolNV::enable()
105{
106 glEnableClientState(GL_VERTEX_ARRAY_RANGE_NV);
107 sWriteOK = FALSE;
108}
109
110void LLAGPMemPoolNV::disable()
111{
112 glDisableClientState(GL_VERTEX_ARRAY_RANGE_NV);
113 sWriteOK = TRUE;
114}
115
116void LLAGPMemPoolNV::flush()
117{
118 glFlushVertexArrayRangeNV();
119}
120
121U32 LLAGPMemPoolNV::createFence()
122{
123 U32 fence;
124 glGenFencesNV(1, &fence);
125 glSetFenceNV(fence, GL_ALL_COMPLETED_NV);
126 glFinishFenceNV(fence);
127 return fence;
128}
129
130void LLAGPMemPoolNV::deleteFence(const U32 fence)
131{
132 glDeleteFencesNV(1, &fence);
133}
134
135void LLAGPMemPoolNV::sendFence(U32 fence)
136{
137 glSetFenceNV(fence, GL_ALL_COMPLETED_NV);
138}
139
140void LLAGPMemPoolNV::waitFence(U32 fence)
141{
142 if(!glTestFenceNV(fence))
143 {
144 glFinishFenceNV(fence);
145 }
146}
147
148
149//static
150BOOL LLAGPMemPoolNV::isWriteOK()
151{
152 return sWriteOK;
153}
154
155void LLAGPMemPoolNV::dump()
156{
157 LLFreeBlock *prev = 0;
158 LLFreeBlock *block = mFreeList.getFirst();
159
160 int d=0;
161
162 int i=0;
163 while (block)
164 {
165 i++;
166 if (prev)
167 {
168 d = (S32)block->mOffset - ((S32)prev->mOffset + prev->mSize);
169 }
170 else d = 0;
171
172 prev = block;
173 block = block->getNext();
174 }
175}
176
177
178LLAGPMemBlockNV::LLAGPMemBlockNV(LLAGPMemPool *mem_poolp, U8 *baseptr, S32 offset, const U32 size) : LLAGPMemBlock(mem_poolp)
179{
180 mMemp = baseptr + offset;
181 mOffset = offset;
182 mSize = size;
183}
184
185extern U8* gAGPVertices;
186
187void LLAGPMemBlockNV::bindGLVertexPointer(const U32 stride, const U32 offset)
188{
189 if (!mMemp)
190 {
191 llerrs << "Binding empty vertex array" << llendl;
192 }
193 glVertexPointer(3, GL_FLOAT, stride, mMemp + offset);
194}
195
196void LLAGPMemBlockNV::bindGLNormalPointer(const U32 stride, const U32 offset)
197{
198 if (!mMemp)
199 {
200 llerrs << "Binding empty normal array" << llendl;
201 }
202 glNormalPointer(GL_FLOAT, stride, mMemp + offset);
203}
204
205
206void LLAGPMemBlockNV::bindGLColorPointer(const U32 stride, const U32 offset)
207{
208 if (!mMemp)
209 {
210 llerrs << "Binding empty color array" << llendl;
211 }
212 glColorPointer(4, GL_UNSIGNED_BYTE, stride, mMemp + offset);
213}
214
215
216void LLAGPMemBlockNV::bindGLTexCoordPointer(const U32 stride, const U32 offset)
217{
218 if (!mMemp)
219 {
220 llerrs << "Binding empty texcoord array" << llendl;
221 }
222 glTexCoordPointer(2, GL_FLOAT, stride, mMemp + offset);
223}
224
225
226void LLAGPMemBlockNV::bindGLBinormalPointer(const S32 index, const U32 stride, const U32 offset)
227{
228 if (!mMemp)
229 {
230 llerrs << "Binding empty vertex weight array" << llendl;
231 }
232
233 glVertexAttribPointerARB(index, 3, GL_FLOAT, FALSE, stride, (F32 *)(mMemp + offset));
234}
235
236void LLAGPMemBlockNV::bindGLVertexWeightPointer(const S32 index, const U32 stride, const U32 offset)
237{
238 if (!mMemp)
239 {
240 llerrs << "Binding empty vertex weight array" << llendl;
241 }
242
243 glVertexAttribPointerARB(index, 1, GL_FLOAT, FALSE, 0, (F32 *)(mMemp + offset));
244}
245
246void LLAGPMemBlockNV::bindGLVertexClothingWeightPointer(const S32 index, const U32 stride, const U32 offset)
247{
248 if (!mMemp)
249 {
250 llerrs << "Binding empty vertex weight array" << llendl;
251 }
252 set_vertex_clothing_weights(index, stride, (LLVector4 *)(mMemp + offset));
253}
254
255U8* LLAGPMemBlockNV::getMappedMem()
256{
257 return mMemp;
258}
259
260void LLAGPMemBlockNV::copy(void *mem, const U32 size)
261{
262 if (!mMemp || !mem)
263 {
264 return;
265 }
266 llassert(LLAGPMemPoolNV::isWriteOK());
267 llassert(size <= mSize);
268
269#if LL_USE_NEW_MEM_OPS
270 inline_new_memcpy( mMemp, mem, size );
271#else
272 memcpy( mMemp, mem, size );
273#endif
274}
275
276void LLAGPMemBlockNV::copyColor(void *mem, const U32 size)
277{
278 if (!mMemp || !mem)
279 {
280 return;
281 }
282 llassert(LLAGPMemPoolNV::isWriteOK());
283 llassert(size <= mSize);
284
285#if LL_USE_NEW_MEM_OPS
286 inline_new_memcpy( mMemp, mem, size );
287#else
288 memcpy( mMemp, mem, size );
289#endif
290}
291
292
293U32 LLAGPMemBlockNV::createFence()
294{
295 U32 fence;
296 glGenFencesNV(1, &fence);
297 glSetFenceNV(fence, GL_ALL_COMPLETED_NV);
298 glFinishFenceNV(fence);
299 return fence;
300}
301
302void LLAGPMemBlockNV::deleteFence(const U32 fence)
303{
304 glDeleteFencesNV(1, &fence);
305}
306
307void LLAGPMemBlockNV::sendFence(U32 fence)
308{
309 glSetFenceNV(fence, GL_ALL_COMPLETED_NV);
310}
311
312void LLAGPMemBlockNV::waitFence(U32 fence)
313{
314 if(!glTestFenceNV(fence))
315 {
316 glFinishFenceNV(fence);
317 }
318}
319
320#endif //LL_LINUX