aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lldrawpool.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lldrawpool.h336
1 files changed, 101 insertions, 235 deletions
diff --git a/linden/indra/newview/lldrawpool.h b/linden/indra/newview/lldrawpool.h
index 2ce13fb..6cd5f8e 100644
--- a/linden/indra/newview/lldrawpool.h
+++ b/linden/indra/newview/lldrawpool.h
@@ -28,270 +28,168 @@
28#ifndef LL_LLDRAWPOOL_H 28#ifndef LL_LLDRAWPOOL_H
29#define LL_LLDRAWPOOL_H 29#define LL_LLDRAWPOOL_H
30 30
31#include "llagparray.h"
32#include "lldarray.h"
33#include "lldlinked.h"
34#include "llstrider.h"
35#include "llviewerimage.h"
36#include "v4coloru.h" 31#include "v4coloru.h"
37#include "v2math.h" 32#include "v2math.h"
38#include "v3math.h" 33#include "v3math.h"
39#include "llstrider.h" 34#include "llvertexbuffer.h"
40 35
41class LLFace; 36class LLFace;
42class LLImageGL; 37class LLImageGL;
43class LLViewerImage; 38class LLViewerImage;
39class LLSpatialGroup;
40class LLDrawInfo;
44 41
45#define DEFAULT_MAX_VERTICES 65535 42#define DEFAULT_MAX_VERTICES 65535
46 43
47class LLDrawPool 44class LLDrawPool
48{ 45{
49public: 46public:
50 typedef LLDynamicArray<LLFace*, 128> face_array_t; 47 static S32 sNumDrawPools;
51 48
52 enum 49 enum
53 { 50 {
54 SHADER_LEVEL_SCATTERING = 2 51 // Correspond to LLPipeline render type
52 POOL_SKY = 1,
53 POOL_STARS,
54 POOL_GROUND,
55 POOL_TERRAIN,
56 POOL_SIMPLE,
57 POOL_BUMP,
58 POOL_AVATAR,
59 POOL_TREE,
60 POOL_ALPHA,
61 POOL_WATER,
62 POOL_ALPHA_POST_WATER,
63 NUM_POOL_TYPES,
55 }; 64 };
56 65
57public: 66 LLDrawPool(const U32 type);
58 LLDrawPool(const U32 type, const U32 data_mask_il, const U32 data_mask_nil);
59 virtual ~LLDrawPool(); 67 virtual ~LLDrawPool();
60 68
61 static LLDrawPool* createPool(const U32 type, LLViewerImage *tex0 = NULL); 69 virtual BOOL isDead() = 0;
62 70
63 void flushAGP(); // Flush the AGP buffers so they can be repacked and reallocated. 71 S32 getId() const { return mId; }
64 void syncAGP(); 72 U32 getType() const { return mType; }
65 73
66 virtual LLDrawPool *instancePool() = 0; // Create an empty new instance of the pool. 74 virtual LLViewerImage *getDebugTexture();
67 virtual void beginRenderPass( S32 pass ); 75 virtual void beginRenderPass( S32 pass );
68 virtual void endRenderPass( S32 pass ); 76 virtual void endRenderPass( S32 pass );
69 virtual S32 getNumPasses() { return 1; } 77 virtual S32 getNumPasses() { return 1; }
70 virtual void render(S32 pass = 0) = 0; 78 virtual void render(S32 pass = 0) = 0;
79 virtual void prerender() = 0;
80 virtual S32 getMaterialAttribIndex() = 0;
81 virtual U32 getVertexDataMask() = 0;
82 virtual BOOL verify() const { return TRUE; } // Verify that all data in the draw pool is correct!
83 virtual S32 getVertexShaderLevel() const { return mVertexShaderLevel; }
84
85 static LLDrawPool* createPool(const U32 type, LLViewerImage *tex0 = NULL);
86 virtual LLDrawPool *instancePool() = 0; // Create an empty new instance of the pool.
87 virtual LLViewerImage* getTexture() = 0;
88 virtual BOOL isFacePool() { return FALSE; }
89 virtual void resetDrawOrders() = 0;
90
91 U32 getTrianglesDrawn() const;
92 void resetTrianglesDrawn();
93 void addIndicesDrawn(const U32 indices);
94
95protected:
96 S32 mVertexShaderLevel;
97 S32 mId;
98 U32 mType; // Type of draw pool
99 S32 mIndicesDrawn;
100};
101
102class LLRenderPass : public LLDrawPool
103{
104public:
105 enum
106 {
107 PASS_SIMPLE = NUM_POOL_TYPES,
108 PASS_FULLBRIGHT,
109 PASS_GLOW,
110 PASS_INVISIBLE,
111 PASS_SHINY,
112 PASS_BUMP,
113 PASS_GRASS,
114 PASS_ALPHA,
115 NUM_RENDER_TYPES,
116 };
117
118 LLRenderPass(const U32 type);
119 virtual ~LLRenderPass();
120 /*virtual*/ LLDrawPool* instancePool();
121 /*vritual*/ S32 getMaterialAttribIndex() { return -1; }
122 /*virtual*/ LLViewerImage* getDebugTexture() { return NULL; }
123 LLViewerImage* getTexture() { return NULL; }
124 BOOL isDead() { return FALSE; }
125 void resetDrawOrders() { }
126
127 virtual void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture);
128 virtual void renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE);
129 virtual void renderStatic(U32 type, U32 mask, BOOL texture = TRUE);
130 virtual void renderActive(U32 type, U32 mask, BOOL texture = TRUE);
131 virtual void renderInvisible(U32 mask);
132 virtual void renderTexture(U32 type, U32 mask);
133
134};
135
136class LLFacePool : public LLDrawPool
137{
138public:
139 typedef std::vector<LLFace*> face_array_t;
140
141 enum
142 {
143 SHADER_LEVEL_SCATTERING = 2
144 };
145
146public:
147 LLFacePool(const U32 type);
148 virtual ~LLFacePool();
149
71 virtual void renderForSelect() = 0; 150 virtual void renderForSelect() = 0;
72 virtual BOOL match(LLFace* last_face, LLFace* facep) { return FALSE; } 151 BOOL isDead() { return mReferences.empty(); }
73 virtual void renderFaceSelected(LLFace *facep, LLImageGL *image, const LLColor4 &color, 152 virtual void renderFaceSelected(LLFace *facep, LLImageGL *image, const LLColor4 &color,
74 const S32 index_offset = 0, const S32 index_count = 0); 153 const S32 index_offset = 0, const S32 index_count = 0);
75 154
76 virtual void prerender() = 0;
77 virtual S32 rebuild();
78
79 virtual S32 getMaterialAttribIndex() = 0;
80
81 virtual LLViewerImage *getTexture(); 155 virtual LLViewerImage *getTexture();
82 virtual LLViewerImage *getDebugTexture(); 156 virtual void dirtyTextures(const std::set<LLViewerImage*>& textures);
83 virtual void dirtyTexture(const LLViewerImage* texturep);
84 157
85 virtual void enqueue(LLFace *face); 158 virtual void enqueue(LLFace *face);
86 virtual BOOL addFace(LLFace *face); 159 virtual BOOL addFace(LLFace *face);
87 virtual BOOL removeFace(LLFace *face); 160 virtual BOOL removeFace(LLFace *face);
88 161
89 virtual BOOL verify() const; // Verify that all data in the draw pool is correct! 162 virtual BOOL verify() const; // Verify that all data in the draw pool is correct!
90 virtual LLColor3 getDebugColor() const; // For AGP debug display 163
91
92 virtual void resetDrawOrders(); 164 virtual void resetDrawOrders();
93 virtual void resetVertexData(S32 reserve_count);
94 virtual void resetIndices(S32 num_indices);
95 void resetAll(); 165 void resetAll();
96 166
97 BOOL moveFace(LLFace *face, LLDrawPool *poolp, BOOL copy_data = FALSE); 167 BOOL moveFace(LLFace *face, LLDrawPool *poolp, BOOL copy_data = FALSE);
98 168
99
100 S32 getId() const { return mId; }
101 U32 getType() const { return mType; }
102
103 const U32 getStride() const;
104 inline const U32 getStride(const U32 data_type) const;
105 inline const U32 getOffset(const U32 data_type) const;
106
107 S32 reserveGeom(U32 count);
108 S32 reserveInd (U32 count);
109 S32 unReserveGeom(const S32 index, const U32 count);
110 S32 unReserveInd(const S32 index, const U32 count);
111
112 void bindGLVertexPointer();
113 void bindGLTexCoordPointer(const U32 pass=0);
114 void bindGLNormalPointer();
115 void bindGLBinormalPointer(S32 index);
116 void bindGLColorPointer();
117 void bindGLVertexWeightPointer(S32 index);
118 void bindGLVertexClothingWeightPointer(S32 index);
119
120 const U32 getIndexCount() const;
121 const U32 getTexCoordCount(const U32 pass=0) const;
122 const U32 getVertexCount() const;
123 const U32 getNormalCount() const;
124 const U32 getBinormalCount() const;
125 const U32 getColorCount() const;
126 const U32 getVertexWeightCount() const;
127
128 void setDirty();
129 void setDirtyMemory() { mMemory.setDirty(); }
130 void setDirtyWeights() { mWeights.setDirty(); }
131
132 const U32* getRawIndices() const { return mIndices.getMem(); }
133
134 U32 getIndex(const S32 index) { return mIndices[index]; } // Use to get one index
135 U32 *getIndices(const S32 index); // Used to get an array of indices for reading/writing
136 void CheckIntegrity(); // DEBUG
137
138 const LLVector3& getVertex(const S32 index);
139 const LLVector2& getTexCoord(const S32 index, const U32 pass);
140 const LLVector3& getNormal(const S32 index);
141 const LLVector3& getBinormal(const S32 index);
142 const LLColor4U& getColor(const S32 index);
143 const F32& getVertexWeight(const S32 index);
144 const LLVector4& getClothingWeight(const S32 index);
145
146 void setRebuild(const BOOL rebuild);
147
148 void destroy(); 169 void destroy();
149 170
150 void buildEdges(); 171 void buildEdges();
151 172
152 static S32 drawLoop(face_array_t& face_list, const U32* index_array); 173 static S32 drawLoop(face_array_t& face_list);
153 static S32 drawLoopSetTex(face_array_t& face_list, const U32* index_array, S32 stage); 174 static S32 drawLoopSetTex(face_array_t& face_list, S32 stage);
154 void drawLoop(); 175 void drawLoop();
155 176
156 void renderVisibility(); 177 void renderVisibility();
157 178
158 void addFaceReference(LLFace *facep); 179 void addFaceReference(LLFace *facep);
159 void removeFaceReference(LLFace *facep); 180 void removeFaceReference(LLFace *facep);
160 U32 getTrianglesDrawn() const;
161 void resetTrianglesDrawn();
162 void addIndicesDrawn(const U32 indices);
163 181
164 void printDebugInfo() const; 182 void printDebugInfo() const;
165 S32 getMemUsage(const BOOL print = FALSE);
166 183
167 BOOL setUseAGP(BOOL use_agp); 184 BOOL isFacePool() { return TRUE; }
168 BOOL canUseAGP() const { return mMemory.isAGP(); } // Return TRUE if this pool can use AGP
169 185
170 S32 getMaxVertices() const { return mMaxVertices; }
171 S32 getVertexShaderLevel() const { return mVertexShaderLevel; }
172
173 friend class LLFace; 186 friend class LLFace;
174 friend class LLPipeline; 187 friend class LLPipeline;
175public: 188public:
176
177 enum
178 {
179 // Correspond to LLPipeline render type
180 POOL_SKY = 1,
181 POOL_STARS,
182 POOL_GROUND,
183 POOL_TERRAIN,
184 POOL_SIMPLE,
185 POOL_MEDIA, // unused
186 POOL_BUMP,
187 POOL_AVATAR,
188 POOL_TREE,
189 POOL_TREE_NEW,
190 POOL_WATER,
191 POOL_CLOUDS,
192 POOL_ALPHA,
193 POOL_HUD,
194 };
195
196
197 // If you change the order or add params to these, you also need to adjust the sizes in the
198 // mDataSizes array defined in lldrawpool.cpp
199 typedef enum e_data_type
200 {
201 DATA_VERTICES = 0,
202 DATA_TEX_COORDS0 = 1,
203 DATA_TEX_COORDS1 = 2,
204 DATA_TEX_COORDS2 = 3,
205 DATA_TEX_COORDS3 = 4,
206 DATA_NORMALS = 5,
207 DATA_VERTEX_WEIGHTS = 6,
208 DATA_CLOTHING_WEIGHTS = 7,
209 DATA_BINORMALS = 8,
210 DATA_COLORS = 9,
211 DATA_MAX_TYPES = 10
212 } EDataType;
213
214 typedef enum e_data_mask
215 {
216 DATA_VERTICES_MASK = 1 << DATA_VERTICES,
217 DATA_TEX_COORDS0_MASK = 1 << DATA_TEX_COORDS0,
218 DATA_TEX_COORDS1_MASK = 1 << DATA_TEX_COORDS1,
219 DATA_TEX_COORDS2_MASK = 1 << DATA_TEX_COORDS2,
220 DATA_TEX_COORDS3_MASK = 1 << DATA_TEX_COORDS3,
221 DATA_NORMALS_MASK = 1 << DATA_NORMALS,
222 DATA_VERTEX_WEIGHTS_MASK = 1 << DATA_VERTEX_WEIGHTS,
223 DATA_CLOTHING_WEIGHTS_MASK = 1 << DATA_CLOTHING_WEIGHTS,
224 DATA_BINORMALS_MASK = 1 << DATA_BINORMALS,
225 DATA_COLORS_MASK = 1 << DATA_COLORS,
226
227 // Masks for standard types.
228 // IL for interleaved, NIL for non-interleaved.
229 DATA_SIMPLE_IL_MASK = DATA_VERTICES_MASK | DATA_TEX_COORDS0_MASK | DATA_NORMALS_MASK,
230 DATA_SIMPLE_NIL_MASK = 0,
231 DATA_BUMP_IL_MASK = DATA_SIMPLE_IL_MASK | DATA_BINORMALS_MASK | DATA_TEX_COORDS1_MASK,
232 } EDataMask;
233
234 face_array_t mDrawFace; 189 face_array_t mDrawFace;
235 face_array_t mMoveFace; 190 face_array_t mMoveFace;
236 face_array_t mReferences; 191 face_array_t mReferences;
237 192
238 U32 mDataMaskIL; // Interleaved data
239 U32 mDataMaskNIL; // Non-interleaved data
240 U32 mDataOffsets[DATA_MAX_TYPES];
241 S32 mStride;
242
243 S32 mRebuildFreq;
244 S32 mRebuildTime;
245 S32 mGeneration;
246
247
248 S32 mSkippedVertices;
249
250 static U32 sDataSizes[DATA_MAX_TYPES];
251 static S32 sNumDrawPools;
252
253protected:
254 LLAGPArray<U8> mMemory;
255 LLAGPArray<F32> mWeights;
256 LLAGPArray<LLVector4> mClothingWeights;
257 LLAGPArray<U32> mIndices;
258
259public:
260
261 BOOL getVertexStrider (LLStrider<LLVector3> &vertices, const U32 index = 0);
262 BOOL getTexCoordStrider (LLStrider<LLVector2> &tex_coords, const U32 index = 0, const U32 pass=0);
263 BOOL getNormalStrider (LLStrider<LLVector3> &normals, const U32 index = 0);
264 BOOL getBinormalStrider (LLStrider<LLVector3> &binormals, const U32 index = 0);
265 BOOL getColorStrider (LLStrider<LLColor4U> &colors, const U32 index = 0);
266 BOOL getVertexWeightStrider(LLStrider<F32> &vertex_weights, const U32 index = 0);
267 BOOL getClothingWeightStrider(LLStrider<LLVector4> &clothing_weights, const U32 index = 0);
268
269public:
270 enum { NUM_BUCKETS = 8 }; // Need to change freeListBucket() if NUM_BUCKETS changes
271 struct FreeListNode
272 {
273 U32 count;
274 S32 next;
275 };
276protected:
277 int freeListBucket(U32 count);
278 void freeListAddGeom(S32 index, U32 count);
279 void freeListAddInd(S32 index, U32 count);
280 S32 freeListFindGeom(U32 count);
281 S32 freeListFindInd(U32 count);
282
283protected:
284 BOOL mUseAGP;
285 S32 mVertexShaderLevel;
286 S32 mId;
287 U32 mType; // Type of draw pool
288 S32 mMaxVertices;
289 S32 mIndicesDrawn;
290 BOOL mCleanupUnused; // Cleanup unused data when too full
291
292 S32 mFreeListGeomHead[8];
293 S32 mFreeListIndHead[8];
294
295public: 193public:
296 class LLOverrideFaceColor 194 class LLOverrideFaceColor
297 { 195 {
@@ -330,38 +228,6 @@ public:
330 LLDrawPool* mPool; 228 LLDrawPool* mPool;
331 static BOOL sOverrideFaceColor; 229 static BOOL sOverrideFaceColor;
332 }; 230 };
333
334 virtual void enableShade();
335 virtual void disableShade();
336 virtual void setShade(F32 shade);
337
338}; 231};
339 232
340inline const U32 LLDrawPool::getStride() const
341{
342 return mStride;
343}
344
345inline const U32 LLDrawPool::getOffset(const U32 data_type) const
346{
347 return mDataOffsets[data_type];
348}
349
350inline const U32 LLDrawPool::getStride(const U32 data_type) const
351{
352 if (mDataMaskIL & (1 << data_type))
353 {
354 return mStride;
355 }
356 else if (mDataMaskNIL & (1 << data_type))
357 {
358 return 0;
359 }
360 else
361 {
362 llerrs << "Getting stride for unsupported data type " << data_type << llendl;
363 return 0;
364 }
365}
366
367#endif //LL_LLDRAWPOOL_H 233#endif //LL_LLDRAWPOOL_H