PageRenderTime 38ms CodeModel.GetById 21ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/lldrawpool.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 247 lines | 179 code | 37 blank | 31 comment | 0 complexity | d16ffbcce36239f99381c4d0ad5c74ac MD5 | raw file
  1/** 
  2 * @file lldrawpool.h
  3 * @brief LLDrawPool class definition
  4 *
  5 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLDRAWPOOL_H
 28#define LL_LLDRAWPOOL_H
 29
 30#include "v4coloru.h"
 31#include "v2math.h"
 32#include "v3math.h"
 33#include "llvertexbuffer.h"
 34
 35class LLFace;
 36class LLViewerTexture;
 37class LLViewerFetchedTexture;
 38class LLSpatialGroup;
 39class LLDrawInfo;
 40
 41class LLDrawPool
 42{
 43public:
 44	static S32 sNumDrawPools;
 45
 46	enum
 47	{
 48		// Correspond to LLPipeline render type
 49		POOL_SIMPLE = 1,
 50		POOL_GROUND,
 51		POOL_FULLBRIGHT,
 52		POOL_BUMP,
 53		POOL_TERRAIN,	
 54		POOL_SKY,
 55		POOL_WL_SKY,
 56		POOL_TREE,
 57		POOL_GRASS,
 58		POOL_INVISIBLE, // see below *
 59		POOL_AVATAR,
 60		POOL_VOIDWATER,
 61		POOL_WATER,
 62		POOL_GLOW,
 63		POOL_ALPHA,
 64		NUM_POOL_TYPES,
 65		// * invisiprims work by rendering to the depth buffer but not the color buffer, occluding anything rendered after them
 66		// - and the LLDrawPool types enum controls what order things are rendered in
 67		// - so, it has absolute control over what invisprims block
 68		// ...invisiprims being rendered in pool_invisible
 69		// ...shiny/bump mapped objects in rendered in POOL_BUMP
 70	};
 71	
 72	LLDrawPool(const U32 type);
 73	virtual ~LLDrawPool();
 74
 75	virtual BOOL isDead() = 0;
 76
 77	S32 getId() const { return mId; }
 78	U32 getType() const { return mType; }
 79
 80	virtual LLViewerTexture *getDebugTexture();
 81	virtual void beginRenderPass( S32 pass );
 82	virtual void endRenderPass( S32 pass );
 83	virtual S32	 getNumPasses();
 84	
 85	virtual void beginDeferredPass(S32 pass);
 86	virtual void endDeferredPass(S32 pass);
 87	virtual S32 getNumDeferredPasses();
 88	virtual void renderDeferred(S32 pass = 0);
 89
 90	virtual void beginPostDeferredPass(S32 pass);
 91	virtual void endPostDeferredPass(S32 pass);
 92	virtual S32 getNumPostDeferredPasses();
 93	virtual void renderPostDeferred(S32 pass = 0);
 94
 95	virtual void beginShadowPass(S32 pass);
 96	virtual void endShadowPass(S32 pass);
 97	virtual S32 getNumShadowPasses();
 98	virtual void renderShadow(S32 pass = 0);
 99
100	virtual void render(S32 pass = 0) = 0;
101	virtual void prerender() = 0;
102	virtual U32 getVertexDataMask() = 0;
103	virtual BOOL verify() const { return TRUE; }		// Verify that all data in the draw pool is correct!
104	virtual S32 getVertexShaderLevel() const { return mVertexShaderLevel; }
105	
106	static LLDrawPool* createPool(const U32 type, LLViewerTexture *tex0 = NULL);
107	virtual LLDrawPool *instancePool() = 0;	// Create an empty new instance of the pool.
108	virtual LLViewerTexture* getTexture() = 0;
109	virtual BOOL isFacePool() { return FALSE; }
110	virtual void resetDrawOrders() = 0;
111
112protected:
113	S32 mVertexShaderLevel;
114	S32	mId;
115	U32 mType;				// Type of draw pool
116};
117
118class LLRenderPass : public LLDrawPool
119{
120public:
121	enum
122	{
123		PASS_SIMPLE = NUM_POOL_TYPES,
124		PASS_GRASS,
125		PASS_FULLBRIGHT,
126		PASS_INVISIBLE,
127		PASS_INVISI_SHINY,
128		PASS_FULLBRIGHT_SHINY,
129		PASS_SHINY,
130		PASS_BUMP,
131		PASS_POST_BUMP,
132		PASS_GLOW,
133		PASS_ALPHA,
134		PASS_ALPHA_MASK,
135		PASS_FULLBRIGHT_ALPHA_MASK,
136		NUM_RENDER_TYPES,
137	};
138
139	LLRenderPass(const U32 type);
140	virtual ~LLRenderPass();
141	/*virtual*/ LLDrawPool* instancePool();
142	/*virtual*/ LLViewerTexture* getDebugTexture() { return NULL; }
143	LLViewerTexture* getTexture() { return NULL; }
144	BOOL isDead() { return FALSE; }
145	void resetDrawOrders() { }
146
147	static void applyModelMatrix(LLDrawInfo& params);
148	virtual void pushBatches(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE);
149	virtual void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures = FALSE);
150	virtual void renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE);
151	virtual void renderGroups(U32 type, U32 mask, BOOL texture = TRUE);
152	virtual void renderTexture(U32 type, U32 mask);
153
154};
155
156class LLFacePool : public LLDrawPool
157{
158public:
159	typedef std::vector<LLFace*> face_array_t;
160	
161	enum
162	{
163		SHADER_LEVEL_SCATTERING = 2
164	};
165
166public:
167	LLFacePool(const U32 type);
168	virtual ~LLFacePool();
169	
170	BOOL isDead() { return mReferences.empty(); }
171	
172	virtual LLViewerTexture *getTexture();
173	virtual void dirtyTextures(const std::set<LLViewerFetchedTexture*>& textures);
174
175	virtual void enqueue(LLFace *face);
176	virtual BOOL addFace(LLFace *face);
177	virtual BOOL removeFace(LLFace *face);
178
179	virtual BOOL verify() const;		// Verify that all data in the draw pool is correct!
180	
181	virtual void resetDrawOrders();
182	void resetAll();
183
184	void destroy();
185
186	void buildEdges();
187
188	static S32 drawLoop(face_array_t& face_list);
189	static S32 drawLoopSetTex(face_array_t& face_list, S32 stage);
190	void drawLoop();
191
192	void addFaceReference(LLFace *facep);
193	void removeFaceReference(LLFace *facep);
194
195	void printDebugInfo() const;
196	
197	BOOL isFacePool() { return TRUE; }
198
199	friend class LLFace;
200	friend class LLPipeline;
201public:
202	face_array_t	mDrawFace;
203	face_array_t	mMoveFace;
204	face_array_t	mReferences;
205
206public:
207	class LLOverrideFaceColor
208	{
209	public:
210		LLOverrideFaceColor(LLDrawPool* pool)
211			: mOverride(sOverrideFaceColor), mPool(pool)
212		{
213			sOverrideFaceColor = TRUE;
214		}
215		LLOverrideFaceColor(LLDrawPool* pool, const LLColor4& color)
216			: mOverride(sOverrideFaceColor), mPool(pool)
217		{
218			sOverrideFaceColor = TRUE;
219			setColor(color);
220		}
221		LLOverrideFaceColor(LLDrawPool* pool, const LLColor4U& color)
222			: mOverride(sOverrideFaceColor), mPool(pool)
223		{
224			sOverrideFaceColor = TRUE;
225			setColor(color);
226		}
227		LLOverrideFaceColor(LLDrawPool* pool, F32 r, F32 g, F32 b, F32 a)
228			: mOverride(sOverrideFaceColor), mPool(pool)
229		{
230			sOverrideFaceColor = TRUE;
231			setColor(r, g, b, a);
232		}
233		~LLOverrideFaceColor()
234		{
235			sOverrideFaceColor = mOverride;
236		}
237		void setColor(const LLColor4& color);
238		void setColor(const LLColor4U& color);
239		void setColor(F32 r, F32 g, F32 b, F32 a);
240		BOOL mOverride;
241		LLDrawPool* mPool;
242		static BOOL sOverrideFaceColor;
243	};
244};
245
246
247#endif //LL_LLDRAWPOOL_H