/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. #ifndef LL_LLDRAWPOOL_H
  27. #define LL_LLDRAWPOOL_H
  28. #include "v4coloru.h"
  29. #include "v2math.h"
  30. #include "v3math.h"
  31. #include "llvertexbuffer.h"
  32. class LLFace;
  33. class LLViewerTexture;
  34. class LLViewerFetchedTexture;
  35. class LLSpatialGroup;
  36. class LLDrawInfo;
  37. class LLDrawPool
  38. {
  39. public:
  40. static S32 sNumDrawPools;
  41. enum
  42. {
  43. // Correspond to LLPipeline render type
  44. POOL_SIMPLE = 1,
  45. POOL_GROUND,
  46. POOL_FULLBRIGHT,
  47. POOL_BUMP,
  48. POOL_TERRAIN,
  49. POOL_SKY,
  50. POOL_WL_SKY,
  51. POOL_TREE,
  52. POOL_GRASS,
  53. POOL_INVISIBLE, // see below *
  54. POOL_AVATAR,
  55. POOL_VOIDWATER,
  56. POOL_WATER,
  57. POOL_GLOW,
  58. POOL_ALPHA,
  59. NUM_POOL_TYPES,
  60. // * invisiprims work by rendering to the depth buffer but not the color buffer, occluding anything rendered after them
  61. // - and the LLDrawPool types enum controls what order things are rendered in
  62. // - so, it has absolute control over what invisprims block
  63. // ...invisiprims being rendered in pool_invisible
  64. // ...shiny/bump mapped objects in rendered in POOL_BUMP
  65. };
  66. LLDrawPool(const U32 type);
  67. virtual ~LLDrawPool();
  68. virtual BOOL isDead() = 0;
  69. S32 getId() const { return mId; }
  70. U32 getType() const { return mType; }
  71. virtual LLViewerTexture *getDebugTexture();
  72. virtual void beginRenderPass( S32 pass );
  73. virtual void endRenderPass( S32 pass );
  74. virtual S32 getNumPasses();
  75. virtual void beginDeferredPass(S32 pass);
  76. virtual void endDeferredPass(S32 pass);
  77. virtual S32 getNumDeferredPasses();
  78. virtual void renderDeferred(S32 pass = 0);
  79. virtual void beginPostDeferredPass(S32 pass);
  80. virtual void endPostDeferredPass(S32 pass);
  81. virtual S32 getNumPostDeferredPasses();
  82. virtual void renderPostDeferred(S32 pass = 0);
  83. virtual void beginShadowPass(S32 pass);
  84. virtual void endShadowPass(S32 pass);
  85. virtual S32 getNumShadowPasses();
  86. virtual void renderShadow(S32 pass = 0);
  87. virtual void render(S32 pass = 0) = 0;
  88. virtual void prerender() = 0;
  89. virtual U32 getVertexDataMask() = 0;
  90. virtual BOOL verify() const { return TRUE; } // Verify that all data in the draw pool is correct!
  91. virtual S32 getVertexShaderLevel() const { return mVertexShaderLevel; }
  92. static LLDrawPool* createPool(const U32 type, LLViewerTexture *tex0 = NULL);
  93. virtual LLDrawPool *instancePool() = 0; // Create an empty new instance of the pool.
  94. virtual LLViewerTexture* getTexture() = 0;
  95. virtual BOOL isFacePool() { return FALSE; }
  96. virtual void resetDrawOrders() = 0;
  97. protected:
  98. S32 mVertexShaderLevel;
  99. S32 mId;
  100. U32 mType; // Type of draw pool
  101. };
  102. class LLRenderPass : public LLDrawPool
  103. {
  104. public:
  105. enum
  106. {
  107. PASS_SIMPLE = NUM_POOL_TYPES,
  108. PASS_GRASS,
  109. PASS_FULLBRIGHT,
  110. PASS_INVISIBLE,
  111. PASS_INVISI_SHINY,
  112. PASS_FULLBRIGHT_SHINY,
  113. PASS_SHINY,
  114. PASS_BUMP,
  115. PASS_POST_BUMP,
  116. PASS_GLOW,
  117. PASS_ALPHA,
  118. PASS_ALPHA_MASK,
  119. PASS_FULLBRIGHT_ALPHA_MASK,
  120. NUM_RENDER_TYPES,
  121. };
  122. LLRenderPass(const U32 type);
  123. virtual ~LLRenderPass();
  124. /*virtual*/ LLDrawPool* instancePool();
  125. /*virtual*/ LLViewerTexture* getDebugTexture() { return NULL; }
  126. LLViewerTexture* getTexture() { return NULL; }
  127. BOOL isDead() { return FALSE; }
  128. void resetDrawOrders() { }
  129. static void applyModelMatrix(LLDrawInfo& params);
  130. virtual void pushBatches(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE);
  131. virtual void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures = FALSE);
  132. virtual void renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE);
  133. virtual void renderGroups(U32 type, U32 mask, BOOL texture = TRUE);
  134. virtual void renderTexture(U32 type, U32 mask);
  135. };
  136. class LLFacePool : public LLDrawPool
  137. {
  138. public:
  139. typedef std::vector<LLFace*> face_array_t;
  140. enum
  141. {
  142. SHADER_LEVEL_SCATTERING = 2
  143. };
  144. public:
  145. LLFacePool(const U32 type);
  146. virtual ~LLFacePool();
  147. BOOL isDead() { return mReferences.empty(); }
  148. virtual LLViewerTexture *getTexture();
  149. virtual void dirtyTextures(const std::set<LLViewerFetchedTexture*>& textures);
  150. virtual void enqueue(LLFace *face);
  151. virtual BOOL addFace(LLFace *face);
  152. virtual BOOL removeFace(LLFace *face);
  153. virtual BOOL verify() const; // Verify that all data in the draw pool is correct!
  154. virtual void resetDrawOrders();
  155. void resetAll();
  156. void destroy();
  157. void buildEdges();
  158. static S32 drawLoop(face_array_t& face_list);
  159. static S32 drawLoopSetTex(face_array_t& face_list, S32 stage);
  160. void drawLoop();
  161. void addFaceReference(LLFace *facep);
  162. void removeFaceReference(LLFace *facep);
  163. void printDebugInfo() const;
  164. BOOL isFacePool() { return TRUE; }
  165. friend class LLFace;
  166. friend class LLPipeline;
  167. public:
  168. face_array_t mDrawFace;
  169. face_array_t mMoveFace;
  170. face_array_t mReferences;
  171. public:
  172. class LLOverrideFaceColor
  173. {
  174. public:
  175. LLOverrideFaceColor(LLDrawPool* pool)
  176. : mOverride(sOverrideFaceColor), mPool(pool)
  177. {
  178. sOverrideFaceColor = TRUE;
  179. }
  180. LLOverrideFaceColor(LLDrawPool* pool, const LLColor4& color)
  181. : mOverride(sOverrideFaceColor), mPool(pool)
  182. {
  183. sOverrideFaceColor = TRUE;
  184. setColor(color);
  185. }
  186. LLOverrideFaceColor(LLDrawPool* pool, const LLColor4U& color)
  187. : mOverride(sOverrideFaceColor), mPool(pool)
  188. {
  189. sOverrideFaceColor = TRUE;
  190. setColor(color);
  191. }
  192. LLOverrideFaceColor(LLDrawPool* pool, F32 r, F32 g, F32 b, F32 a)
  193. : mOverride(sOverrideFaceColor), mPool(pool)
  194. {
  195. sOverrideFaceColor = TRUE;
  196. setColor(r, g, b, a);
  197. }
  198. ~LLOverrideFaceColor()
  199. {
  200. sOverrideFaceColor = mOverride;
  201. }
  202. void setColor(const LLColor4& color);
  203. void setColor(const LLColor4U& color);
  204. void setColor(F32 r, F32 g, F32 b, F32 a);
  205. BOOL mOverride;
  206. LLDrawPool* mPool;
  207. static BOOL sOverrideFaceColor;
  208. };
  209. };
  210. #endif //LL_LLDRAWPOOL_H