llpipeline.h 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215
  1. /**
  2. * @file llpipeline.h
  3. * @brief Rendering pipeline definitions
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLPIPELINE_H
  33. #define LL_LLPIPELINE_H
  34. #include <stack>
  35. #include "llrendertarget.h"
  36. #include "llstat.h"
  37. #include "llreflectionmapmanager.h"
  38. #include "llspatialpartition.h"
  39. class LLAgent;
  40. class LLCubeMap;
  41. class LLCullResult;
  42. class LLDisplayPrimitive;
  43. class LLDrawPoolAlpha;
  44. class LLEdge;
  45. class LLFace;
  46. class LLGLSLShader;
  47. class LLRenderFunc;
  48. class LLTextureEntry;
  49. class LLViewerObject;
  50. class LLViewerTexture;
  51. class LLVOAvatar;
  52. class LLVOPartGroup;
  53. typedef enum e_avatar_skinning_method
  54. {
  55. SKIN_METHOD_SOFTWARE,
  56. SKIN_METHOD_VERTEX_PROGRAM
  57. } EAvatarSkinningMethod;
  58. bool LLRayAABB(const LLVector3& center, const LLVector3& size,
  59. const LLVector3& origin, const LLVector3& dir,
  60. LLVector3& coord, F32 epsilon = 0);
  61. class LLPipeline
  62. {
  63. friend class LLGLTFPreviewTexture;
  64. protected:
  65. LOG_CLASS(LLPipeline);
  66. public:
  67. LLPipeline();
  68. void destroyGL();
  69. void restoreGL();
  70. void resetVertexBuffers();
  71. void doResetVertexBuffers(bool forced = false);
  72. void resizeScreenTexture();
  73. void resizeShadowTexture();
  74. void releaseGLBuffers();
  75. void releaseLUTBuffers();
  76. void createGLBuffers();
  77. void createLUTBuffers();
  78. void allocateScreenBuffer(U32 res_x, U32 res_y);
  79. bool allocateScreenBuffer(U32 res_x, U32 res_y, U32 samples);
  80. bool allocateShadowBuffer(U32 res_x, U32 res_y);
  81. void allocatePhysicsBuffer();
  82. void resetVertexBuffers(LLDrawable* drawable);
  83. void generateImpostor(LLVOAvatar* avatar);
  84. void previewAvatar(LLVOAvatar* avatar);
  85. // Automatically calls renderFinalizePBR() when in PBR rendering mode. HB
  86. void renderFinalize();
  87. void init();
  88. void cleanup();
  89. void dumpStats();
  90. LL_INLINE bool isInit() { return mInitialized; };
  91. // Gets a draw pool from pool type (POOL_SIMPLE, POOL_MEDIA) and texture.
  92. // Returns the draw pool, or NULL if not found.
  93. LLDrawPool* findPool(U32 pool_type, LLViewerTexture* tex0 = NULL);
  94. // Gets a draw pool for faces of the appropriate type and texture. Creates
  95. // if necessary. Always returns a draw pool.
  96. LLDrawPool* getPool(U32 pool_type, LLViewerTexture* tex0 = NULL);
  97. // Figures out draw pool type from texture entry. Creates a new pool if
  98. // necessary.
  99. static LLDrawPool* getPoolFromTE(const LLTextureEntry* tep,
  100. LLViewerTexture* imagep);
  101. static U32 getPoolTypeFromTE(const LLTextureEntry* tep,
  102. LLViewerTexture* imagep);
  103. // Only to be used by LLDrawPool classes for splitting pools !
  104. void addPool(LLDrawPool* poolp);
  105. void removePool(LLDrawPool* poolp);
  106. void allocDrawable(LLViewerObject* objp);
  107. void unlinkDrawable(LLDrawable*);
  108. // Object related methods
  109. void markVisible(LLDrawable* drawablep, LLCamera& camera);
  110. void markOccluder(LLSpatialGroup* groupp);
  111. // Only used by the EE renderer
  112. void doOcclusion(LLCamera& camera, LLRenderTarget& source,
  113. LLRenderTarget& dest, LLRenderTarget* scratch = NULL);
  114. void doOcclusion(LLCamera& camera);
  115. void markNotCulled(LLSpatialGroup* groupp, LLCamera& camera);
  116. void markMoved(LLDrawable* drawablep, bool damped_motion = false);
  117. void markShift(LLDrawable* drawablep);
  118. void markTextured(LLDrawable* drawablep);
  119. void markGLRebuild(LLGLUpdate* glup);
  120. void markRebuild(LLSpatialGroup* group);
  121. void markRebuild(LLDrawable* drawablep,
  122. LLDrawable::EDrawableFlags flag = LLDrawable::REBUILD_ALL);
  123. void markPartitionMove(LLDrawable* drawablep);
  124. void markMeshDirty(LLSpatialGroup* groupp);
  125. // Rebuild all LLVOVolume render batches
  126. void rebuildDrawInfo();
  127. // Gets the object between start and end that is closest to start.
  128. LLViewerObject* lineSegmentIntersectInWorld(const LLVector4a& start,
  129. const LLVector4a& end,
  130. bool pick_transparent,
  131. bool pick_rigged,
  132. // Returns the face hit
  133. S32* face_hitp,
  134. // Returns the GLTF node hit
  135. S32* gltf_node_hitp = NULL,
  136. // Returns the GLTF prim hit
  137. S32* gltf_prim_hitp = NULL,
  138. // Returns the intersection pt
  139. LLVector4a* intersectp = NULL,
  140. // Returns texture coordinates
  141. LLVector2* tcoordp = NULL,
  142. // Returns the surface normal
  143. LLVector4a* normalp = NULL,
  144. // Return the surface tangent
  145. LLVector4a* tangentp = NULL);
  146. // Gets the closest particle to start between start and end, returns the
  147. // LLVOPartGroup and particle index:
  148. LLVOPartGroup* lineSegmentIntersectParticle(const LLVector4a& start,
  149. const LLVector4a& end,
  150. LLVector4a* intersectp,
  151. S32* face_hitp);
  152. LLViewerObject* lineSegmentIntersectInHUD(const LLVector4a& start,
  153. const LLVector4a& end,
  154. bool pick_transparent,
  155. // Returns the face hit
  156. S32* face_hitp,
  157. // Returns the intersection pt
  158. LLVector4a* intersectp = NULL,
  159. // Returns texture coordinates
  160. LLVector2* tcoordp = NULL,
  161. // Returns the surface normal
  162. LLVector4a* normalp = NULL,
  163. // Return the surface tangent
  164. LLVector4a* tangentp = NULL);
  165. // Something about these textures has changed. Dirty them.
  166. void dirtyPoolObjectTextures(const LLViewerTextureList::dirty_list_t& textures);
  167. void resetDrawOrders();
  168. U32 addObject(LLViewerObject* obj);
  169. LL_INLINE bool canUseShaders() const { return mVertexShadersLoaded != -1; }
  170. LL_INLINE bool shadersLoaded() const { return mVertexShadersLoaded == 1; }
  171. bool canUseWindLightShaders() const;
  172. // Phases
  173. void resetFrameStats();
  174. void updateMoveDampedAsync(LLDrawable* drawablep);
  175. void updateMoveNormalAsync(LLDrawable* drawablep);
  176. void updateMovedList(LLDrawable::draw_vec_t& move_list);
  177. void updateMove(bool balance_vo_cache);
  178. bool getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3& max);
  179. bool getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector3& max,
  180. std::vector<LLVector3>& fp,
  181. LLVector3 light_dir = LLVector3::zero);
  182. // Note: for the PBR renderer, planp and hud_attachments are ignored.
  183. void updateCull(LLCamera& camera, LLCullResult& result,
  184. LLPlane* planep = NULL, bool hud_attachments = false);
  185. void createObjects(F32 max_dtime);
  186. void createObject(LLViewerObject* objp);
  187. void processPartitionQ();
  188. void updateGeom(F32 max_dtime);
  189. void updateGL();
  190. void rebuildPriorityGroups();
  191. void clearRebuildGroups();
  192. void clearRebuildDrawables();
  193. // Calculates pixel area of given box from vantage point of given camera
  194. static F32 calcPixelArea(LLVector3 center, LLVector3 size,
  195. LLCamera& camera);
  196. static F32 calcPixelArea(const LLVector4a& center, const LLVector4a& size,
  197. LLCamera& camera);
  198. void stateSort(LLCamera& camera, LLCullResult& result);
  199. void stateSort(LLSpatialGroup* group, LLCamera& camera);
  200. void stateSort(LLSpatialBridge* bridge, LLCamera& camera,
  201. bool fov_changed = false);
  202. void stateSort(LLDrawable* drawablep, LLCamera& camera);
  203. // Updates stats for textures in given DrawInfo
  204. void touchTextures(LLDrawInfo* info);
  205. void touchTexture(LLViewerTexture* tex, F32 vsize);
  206. void postSort(LLCamera& camera);
  207. void forAllVisibleDrawables(void (*func)(LLDrawable*));
  208. void renderObjects(U32 type, U32 mask, bool texture = true,
  209. bool batch_texture = false, bool rigged = false);
  210. // Used only by the PBR renderer
  211. void renderGLTFObjects(U32 type, bool texture = true, bool rigged = false);
  212. void renderAlphaObjects(bool rigged);
  213. void renderMaskedObjects(U32 type, U32 mask, bool texture = true,
  214. bool batch_texture = false, bool rigged = false);
  215. void renderFullbrightMaskedObjects(U32 type, U32 mask, bool texture = true,
  216. bool batch_texture = false, bool rigged = false);
  217. void renderGroups(LLRenderPass* pass, U32 type, U32 mask, bool texture);
  218. void renderRiggedGroups(LLRenderPass* pass, U32 type, U32 mask,
  219. bool texture);
  220. void grabReferences(LLCullResult& result);
  221. void clearReferences();
  222. #if LL_DEBUG
  223. // Checks references and asserts that there are no references in sCull
  224. // results to the provided data
  225. void checkReferences(LLFace* facep);
  226. void checkReferences(LLDrawable* drawablep);
  227. void checkReferences(LLDrawInfo* draw_infop);
  228. void checkReferences(LLSpatialGroup* groupp);
  229. #endif
  230. // For EE rendering only
  231. void renderGeom(LLCamera& camera);
  232. // For EE rendering only
  233. void renderGeomDeferred(LLCamera& camera);
  234. // For PBR rendering only
  235. void renderGeomDeferred(LLCamera& camera, bool do_occlusion);
  236. // Note: 'do_occlusion' is ignored (always false) for PBR rendering. HB
  237. void renderGeomPostDeferred(LLCamera& camera, bool do_occlusion = true);
  238. void renderGeomShadow(LLCamera& camera);
  239. void bindDeferredShader(LLGLSLShader& shader,
  240. LLRenderTarget* light_targetp = NULL,
  241. LLRenderTarget* depth_targetp = NULL);
  242. // Fast path for shaders that have already been bound once. Used only by
  243. // the PBR renderer, for now (but could likely be used by EE too). HB
  244. void bindDeferredShaderFast(LLGLSLShader& shader);
  245. void unbindDeferredShader(LLGLSLShader& shader);
  246. void setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep);
  247. void renderDeferredLighting();
  248. // For EE rendering only
  249. void generateWaterReflection();
  250. void generateSunShadow();
  251. void renderHighlight(const LLViewerObject* obj, F32 fade);
  252. // For PBE rendering only
  253. void renderShadow(const LLMatrix4a& view, const LLMatrix4a& proj,
  254. LLCamera& shadow_cam, LLCullResult& result,
  255. bool depth_clamp);
  256. // For EE rendering only
  257. void renderShadow(const LLMatrix4a& view, const LLMatrix4a& proj,
  258. LLCamera& camera, LLCullResult& result, bool use_shader,
  259. bool use_occlusion, U32 target_width);
  260. void renderHighlights();
  261. void renderDebug();
  262. void renderPhysicsDisplay();
  263. // Returns 0 when the object is not to be highlighted, 1 when it can be
  264. // both highlighted and marked with a beacon, and 2 when it may can be
  265. // highlighted only. HB
  266. static U32 highlightable(const LLViewerObject* objp);
  267. void rebuildPools(); // Rebuild pools
  268. #if LL_DEBUG && 0
  269. // Debugging method.
  270. // Find the lists which have references to this object
  271. void findReferences(LLDrawable* drawablep);
  272. #endif
  273. // Verify that all data in the pipeline is "correct":
  274. bool verify();
  275. // This must be called each time the sky is updated to cache the current
  276. // values which will be reused during the frame rendering. Called by
  277. // LLEnvironment::update(). HB
  278. void cacheEnvironment();
  279. LL_INLINE S32 getLightCount() const { return mLights.size(); }
  280. void calcNearbyLights(LLCamera& camera);
  281. void setupHWLights();
  282. void setupAvatarLights(bool for_edit = false);
  283. void enableLights(U32 mask);
  284. void enableLightsStatic();
  285. void enableLightsDynamic();
  286. void enableLightsAvatar();
  287. void enableLightsPreview();
  288. void enableLightsAvatarEdit();
  289. void enableLightsFullbright();
  290. void disableLights();
  291. void shiftObjects(const LLVector3& offset);
  292. void setLight(LLDrawable* drawablep, bool is_light);
  293. #if 0 // Not currently used
  294. LL_INLINE bool hasRenderBatches(U32 type) const
  295. {
  296. return sCull && sCull->hasRenderMap(type);
  297. }
  298. #endif
  299. LL_INLINE LLCullResult::drawinfo_list_t& getRenderMap(U32 type)
  300. {
  301. return sCull->getRenderMap(type);
  302. }
  303. LL_INLINE LLCullResult::sg_list_t& getAlphaGroups()
  304. {
  305. return sCull->getAlphaGroups();
  306. }
  307. LL_INLINE LLCullResult::sg_list_t& getRiggedAlphaGroups()
  308. {
  309. return sCull->getRiggedAlphaGroups();
  310. }
  311. void addTrianglesDrawn(U32 index_count);
  312. LL_INLINE bool hasRenderDebugFeatureMask(U32 mask) const
  313. {
  314. return (mRenderDebugFeatureMask & mask) != 0;
  315. }
  316. LL_INLINE bool hasRenderDebugMask(U32 mask) const
  317. {
  318. return (mRenderDebugMask & mask) != 0;
  319. }
  320. LL_INLINE void setRenderDebugMask(U32 mask)
  321. {
  322. mRenderDebugMask = mask;
  323. }
  324. LL_INLINE bool hasRenderType(U32 type) const
  325. {
  326. // STORM-365: LLViewerJointAttachment::setAttachmentVisibility() is
  327. // setting type to 0 to actually mean "do not render". We then need to
  328. // test that value here and return false to prevent attachment to
  329. // render (in mouselook for instance).
  330. // *TODO: reintroduce RENDER_TYPE_NONE in LLRenderTypeMask and
  331. // initialize its mRenderTypeEnabled[RENDER_TYPE_NONE] to false
  332. // explicitely
  333. return type != 0 && mRenderTypeEnabled[type];
  334. }
  335. bool hasAnyRenderType(U32 type, ...) const;
  336. void setRenderTypeMask(U32 type, ...);
  337. void orRenderTypeMask(U32 type, ...);
  338. void andRenderTypeMask(U32 type, ...);
  339. void clearRenderTypeMask(U32 type, ...);
  340. void setAllRenderTypes();
  341. void pushRenderTypeMask();
  342. void popRenderTypeMask();
  343. static void toggleRenderType(U32 type);
  344. // For UI control of render features
  345. static bool hasRenderTypeControl(void* data);
  346. static void toggleRenderDebug(void* data);
  347. static void toggleRenderDebugFeature(void* data);
  348. static void toggleRenderTypeControl(void* data);
  349. static bool toggleRenderTypeControlNegated(void* data);
  350. static bool toggleRenderDebugControl(void* data);
  351. static bool toggleRenderDebugFeatureControl(void* data);
  352. static void setRenderDebugFeatureControl(U32 bit, bool value);
  353. // Sets which UV setup to display in highlight overlay
  354. static void setRenderHighlightTextureChannel(LLRender::eTexIndex channel)
  355. {
  356. sRenderHighlightTextureChannel = channel;
  357. }
  358. // Used by the PBR renderer only.
  359. static bool isWaterClip();
  360. // Use this instead of the RenderWaterReflectionType (EE renderer) or the
  361. // RenderTransparentWater (PBR renderer) variables, when determining what
  362. // should actually be renderered. For EE, beyond opaque or transparent
  363. // water, it accounts for the camera distance to the water, and avoids
  364. // renderingreflections that would not even be seen. HB
  365. static U32 waterReflectionType();
  366. static void updateRenderDeferred();
  367. static void refreshCachedSettings();
  368. static void throttleNewMemoryAllocation(bool disable);
  369. void addDebugBlip(const LLVector3& position, const LLColor4& color);
  370. LLSpatialPartition* getSpatialPartition(LLViewerObject* objp);
  371. // Used to toggle between EE and PBR renderers.
  372. void toggleRenderer();
  373. // Used only by the PBR renderer
  374. void setEnvMat(LLGLSLShader& shader);
  375. void bindReflectionProbes(LLGLSLShader& shader);
  376. void unbindReflectionProbes(LLGLSLShader& shader);
  377. struct RenderTargetPack; // Must be declared public
  378. private:
  379. void releasePackBuffers(RenderTargetPack* packp);
  380. void connectRefreshCachedSettingsSafe(const char* name);
  381. void unloadShaders();
  382. void createAuxVBs();
  383. void releaseScreenBuffers();
  384. void releaseShadowTargets();
  385. // For EE rendering only
  386. void releaseShadowTarget(U32 index);
  387. // For PBR rendering only
  388. void releaseSunShadowTargets();
  389. void releaseSpotShadowTargets();
  390. void addToQuickLookup(LLDrawPool* new_poolp);
  391. void removeFromQuickLookup(LLDrawPool* poolp);
  392. bool updateDrawableGeom(LLDrawable* drawablep);
  393. // Downsample source to dest, taking the maximum depth value per pixel in
  394. // source and writing to dest. If source's depth buffer cannot be bound for
  395. // reading, a scratch space depth buffer must be provided. Only used by the
  396. // EE renderer.
  397. void downsampleDepthBuffer(LLRenderTarget& sourcep, LLRenderTarget& destp,
  398. LLRenderTarget* scratchp = NULL);
  399. // PBR version of culling, called by updateCull(). HB
  400. void updateCullPBR(LLCamera& camera, LLCullResult& result);
  401. // PBR version of occluding, called by doOcclusion(). HB
  402. void doOcclusionPBR(LLCamera& camera);
  403. // PBR version, called by renderAlphaObjects(). HB
  404. void renderAlphaObjectsPBR(bool rigged);
  405. // PBR buffers visualization.
  406. void visualizeBuffers(LLRenderTarget* srcp, LLRenderTarget* dstp,
  407. U32 buff_idx);
  408. void copyRenderTarget(LLRenderTarget* srcp, LLRenderTarget* dstp);
  409. // PBR samples and mipmaps generation.
  410. void generateLuminance(LLRenderTarget* srcp, LLRenderTarget* dstp);
  411. void generateExposure(LLRenderTarget* srcp, LLRenderTarget* dstp,
  412. bool use_history = true);
  413. void generateGlow(LLRenderTarget* srcp);
  414. void combineGlow(LLRenderTarget* srcp, LLRenderTarget* dstp);
  415. // Other PBR rendering methods
  416. void gammaCorrect(LLRenderTarget* srcp, LLRenderTarget* dstp);
  417. bool applyFXAA(LLRenderTarget* srcp, LLRenderTarget* dstp);
  418. bool applySMAA(LLRenderTarget* srcp, LLRenderTarget* dstp);
  419. void applyCAS(LLRenderTarget* srcp, LLRenderTarget* dstp);
  420. bool renderDoF(LLRenderTarget* srcp, LLRenderTarget* dstp);
  421. void copyScreenSpaceReflections(LLRenderTarget* srcp,
  422. LLRenderTarget* dstp);
  423. void renderFinalizePBR();
  424. void renderDeferredLightingPBR();
  425. void generateSunShadowPBR();
  426. void bindLightFunc(LLGLSLShader& shader);
  427. void bindShadowMaps(LLGLSLShader& shader);
  428. // Applies atmospheric haze based on contents of color and depth buffer;
  429. // should be called just before rendering water when camera is under water
  430. // and just before rendering alpha when camera is above water.
  431. void doAtmospherics();
  432. // Applies water haze based on contents of color and depth buffer; should
  433. // be called just before rendering pre-water alpha objects.
  434. void doWaterHaze();
  435. public:
  436. enum { GPU_CLASS_MAX = 3 };
  437. enum LLRenderTypeMask : U32
  438. {
  439. // Following are pool types (some are also object types)
  440. RENDER_TYPE_SKY = LLDrawPool::POOL_SKY,
  441. RENDER_TYPE_WL_SKY = LLDrawPool::POOL_WL_SKY,
  442. RENDER_TYPE_TERRAIN = LLDrawPool::POOL_TERRAIN,
  443. RENDER_TYPE_SIMPLE = LLDrawPool::POOL_SIMPLE,
  444. RENDER_TYPE_GRASS = LLDrawPool::POOL_GRASS,
  445. RENDER_TYPE_ALPHA_MASK = LLDrawPool::POOL_ALPHA_MASK,
  446. RENDER_TYPE_FULLBRIGHT_ALPHA_MASK = LLDrawPool::POOL_FULLBRIGHT_ALPHA_MASK,
  447. RENDER_TYPE_FULLBRIGHT = LLDrawPool::POOL_FULLBRIGHT,
  448. RENDER_TYPE_BUMP = LLDrawPool::POOL_BUMP,
  449. RENDER_TYPE_MATERIALS = LLDrawPool::POOL_MATERIALS,
  450. RENDER_TYPE_AVATAR = LLDrawPool::POOL_AVATAR,
  451. RENDER_TYPE_PUPPET = LLDrawPool::POOL_PUPPET,
  452. RENDER_TYPE_TREE = LLDrawPool::POOL_TREE,
  453. // EE only
  454. RENDER_TYPE_INVISIBLE = LLDrawPool::POOL_INVISIBLE,
  455. RENDER_TYPE_VOIDWATER = LLDrawPool::POOL_VOIDWATER,
  456. RENDER_TYPE_WATER = LLDrawPool::POOL_WATER,
  457. // PBR only
  458. RENDER_TYPE_MAT_PBR = LLDrawPool::POOL_MAT_PBR,
  459. // PBR only
  460. RENDER_TYPE_MAT_PBR_ALPHA_MASK = LLDrawPool::POOL_MAT_PBR_ALPHA_MASK,
  461. RENDER_TYPE_ALPHA = LLDrawPool::POOL_ALPHA,
  462. // PBR only
  463. RENDER_TYPE_ALPHA_PRE_WATER = LLDrawPool::POOL_ALPHA_PRE_WATER,
  464. // PBR only
  465. RENDER_TYPE_ALPHA_POST_WATER = LLDrawPool::POOL_ALPHA_POST_WATER,
  466. RENDER_TYPE_GLOW = LLDrawPool::POOL_GLOW,
  467. RENDER_TYPE_PASS_SIMPLE = LLRenderPass::PASS_SIMPLE,
  468. RENDER_TYPE_PASS_SIMPLE_RIGGED = LLRenderPass::PASS_SIMPLE_RIGGED,
  469. RENDER_TYPE_PASS_GRASS = LLRenderPass::PASS_GRASS,
  470. RENDER_TYPE_PASS_FULLBRIGHT = LLRenderPass::PASS_FULLBRIGHT,
  471. RENDER_TYPE_PASS_FULLBRIGHT_RIGGED = LLRenderPass::PASS_FULLBRIGHT_RIGGED,
  472. RENDER_TYPE_PASS_INVISIBLE = LLRenderPass::PASS_INVISIBLE,
  473. RENDER_TYPE_PASS_INVISIBLE_RIGGED = LLRenderPass::PASS_INVISIBLE_RIGGED,
  474. RENDER_TYPE_PASS_INVISI_SHINY = LLRenderPass::PASS_INVISI_SHINY,
  475. RENDER_TYPE_PASS_INVISI_SHINY_RIGGED = LLRenderPass::PASS_INVISI_SHINY_RIGGED,
  476. RENDER_TYPE_PASS_FULLBRIGHT_SHINY = LLRenderPass::PASS_FULLBRIGHT_SHINY,
  477. RENDER_TYPE_PASS_FULLBRIGHT_SHINY_RIGGED= LLRenderPass::PASS_FULLBRIGHT_SHINY_RIGGED,
  478. RENDER_TYPE_PASS_SHINY = LLRenderPass::PASS_SHINY,
  479. RENDER_TYPE_PASS_SHINY_RIGGED = LLRenderPass::PASS_SHINY_RIGGED,
  480. RENDER_TYPE_PASS_BUMP = LLRenderPass::PASS_BUMP,
  481. RENDER_TYPE_PASS_BUMP_RIGGED = LLRenderPass::PASS_BUMP_RIGGED,
  482. RENDER_TYPE_PASS_POST_BUMP = LLRenderPass::PASS_POST_BUMP,
  483. RENDER_TYPE_PASS_POST_BUMP_RIGGED = LLRenderPass::PASS_POST_BUMP_RIGGED,
  484. RENDER_TYPE_PASS_GLOW = LLRenderPass::PASS_GLOW,
  485. RENDER_TYPE_PASS_GLOW_RIGGED = LLRenderPass::PASS_GLOW_RIGGED,
  486. RENDER_TYPE_PASS_PBR_GLOW = LLRenderPass::PASS_PBR_GLOW,
  487. RENDER_TYPE_PASS_PBR_GLOW_RIGGED = LLRenderPass::PASS_PBR_GLOW_RIGGED,
  488. RENDER_TYPE_PASS_ALPHA = LLRenderPass::PASS_ALPHA,
  489. RENDER_TYPE_PASS_ALPHA_MASK = LLRenderPass::PASS_ALPHA_MASK,
  490. RENDER_TYPE_PASS_ALPHA_MASK_RIGGED = LLRenderPass::PASS_ALPHA_MASK_RIGGED,
  491. RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK = LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK,
  492. RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK_RIGGED= LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK_RIGGED,
  493. RENDER_TYPE_PASS_MATERIAL = LLRenderPass::PASS_MATERIAL,
  494. RENDER_TYPE_PASS_MATERIAL_RIGGED = LLRenderPass::PASS_MATERIAL_RIGGED,
  495. RENDER_TYPE_PASS_MATERIAL_ALPHA = LLRenderPass::PASS_MATERIAL_ALPHA,
  496. RENDER_TYPE_PASS_MATERIAL_ALPHA_RIGGED = LLRenderPass::PASS_MATERIAL_ALPHA_RIGGED,
  497. RENDER_TYPE_PASS_MATERIAL_ALPHA_MASK = LLRenderPass::PASS_MATERIAL_ALPHA_MASK,
  498. RENDER_TYPE_PASS_MATERIAL_ALPHA_MASK_RIGGED= LLRenderPass::PASS_MATERIAL_ALPHA_MASK_RIGGED,
  499. RENDER_TYPE_PASS_MATERIAL_ALPHA_EMISSIVE= LLRenderPass::PASS_MATERIAL_ALPHA_EMISSIVE,
  500. RENDER_TYPE_PASS_MATERIAL_ALPHA_EMISSIVE_RIGGED= LLRenderPass::PASS_MATERIAL_ALPHA_EMISSIVE_RIGGED,
  501. RENDER_TYPE_PASS_SPECMAP = LLRenderPass::PASS_SPECMAP,
  502. RENDER_TYPE_PASS_SPECMAP_RIGGED = LLRenderPass::PASS_SPECMAP_RIGGED,
  503. RENDER_TYPE_PASS_SPECMAP_BLEND = LLRenderPass::PASS_SPECMAP_BLEND,
  504. RENDER_TYPE_PASS_SPECMAP_BLEND_RIGGED = LLRenderPass::PASS_SPECMAP_BLEND_RIGGED,
  505. RENDER_TYPE_PASS_SPECMAP_MASK = LLRenderPass::PASS_SPECMAP_MASK,
  506. RENDER_TYPE_PASS_SPECMAP_MASK_RIGGED = LLRenderPass::PASS_SPECMAP_MASK_RIGGED,
  507. RENDER_TYPE_PASS_SPECMAP_EMISSIVE = LLRenderPass::PASS_SPECMAP_EMISSIVE,
  508. RENDER_TYPE_PASS_SPECMAP_EMISSIVE_RIGGED= LLRenderPass::PASS_SPECMAP_EMISSIVE_RIGGED,
  509. RENDER_TYPE_PASS_NORMMAP = LLRenderPass::PASS_NORMMAP,
  510. RENDER_TYPE_PASS_NORMMAP_RIGGED = LLRenderPass::PASS_NORMMAP_RIGGED,
  511. RENDER_TYPE_PASS_NORMMAP_BLEND = LLRenderPass::PASS_NORMMAP_BLEND,
  512. RENDER_TYPE_PASS_NORMMAP_BLEND_RIGGED = LLRenderPass::PASS_NORMMAP_BLEND_RIGGED,
  513. RENDER_TYPE_PASS_NORMMAP_MASK = LLRenderPass::PASS_NORMMAP_MASK,
  514. RENDER_TYPE_PASS_NORMMAP_MASK_RIGGED = LLRenderPass::PASS_NORMMAP_MASK_RIGGED,
  515. RENDER_TYPE_PASS_NORMMAP_EMISSIVE = LLRenderPass::PASS_NORMMAP_EMISSIVE,
  516. RENDER_TYPE_PASS_NORMMAP_EMISSIVE_RIGGED= LLRenderPass::PASS_NORMMAP_EMISSIVE_RIGGED,
  517. RENDER_TYPE_PASS_NORMSPEC = LLRenderPass::PASS_NORMSPEC,
  518. RENDER_TYPE_PASS_NORMSPEC_RIGGED = LLRenderPass::PASS_NORMSPEC_RIGGED,
  519. RENDER_TYPE_PASS_NORMSPEC_BLEND = LLRenderPass::PASS_NORMSPEC_BLEND,
  520. RENDER_TYPE_PASS_NORMSPEC_BLEND_RIGGED = LLRenderPass::PASS_NORMSPEC_BLEND_RIGGED,
  521. RENDER_TYPE_PASS_NORMSPEC_MASK = LLRenderPass::PASS_NORMSPEC_MASK,
  522. RENDER_TYPE_PASS_NORMSPEC_MASK_RIGGED = LLRenderPass::PASS_NORMSPEC_MASK_RIGGED,
  523. RENDER_TYPE_PASS_NORMSPEC_EMISSIVE = LLRenderPass::PASS_NORMSPEC_EMISSIVE,
  524. RENDER_TYPE_PASS_NORMSPEC_EMISSIVE_RIGGED= LLRenderPass::PASS_NORMSPEC_EMISSIVE_RIGGED,
  525. RENDER_TYPE_PASS_MAT_PBR = LLRenderPass::PASS_MAT_PBR,
  526. RENDER_TYPE_PASS_MAT_PBR_RIGGED = LLRenderPass::PASS_MAT_PBR_RIGGED,
  527. RENDER_TYPE_PASS_MAT_ALPHA_MASK_PBR = LLRenderPass::PASS_MAT_PBR_ALPHA_MASK,
  528. RENDER_TYPE_PASS_MAT_ALPHA_MASK_PBR_RIGGED= LLRenderPass::PASS_MAT_PBR_ALPHA_MASK_RIGGED,
  529. // Following are object types (only used in drawable mRenderType)
  530. RENDER_TYPE_HUD = LLRenderPass::NUM_RENDER_TYPES,
  531. RENDER_TYPE_VOLUME,
  532. RENDER_TYPE_PARTICLES,
  533. RENDER_TYPE_CLOUDS,
  534. RENDER_TYPE_HUD_PARTICLES,
  535. NUM_RENDER_TYPES,
  536. END_RENDER_TYPES = NUM_RENDER_TYPES
  537. };
  538. enum LLRenderDebugFeatureMask
  539. {
  540. RENDER_DEBUG_FEATURE_UI = 0x0001,
  541. RENDER_DEBUG_FEATURE_SELECTED = 0x0002,
  542. RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES = 0x0008,
  543. RENDER_DEBUG_FEATURE_FLEXIBLE = 0x0010,
  544. RENDER_DEBUG_FEATURE_FOG = 0x0020,
  545. };
  546. enum LLRenderDebugMask : U32
  547. {
  548. RENDER_DEBUG_COMPOSITION = 0x00000001,
  549. RENDER_DEBUG_VERIFY = 0x00000002,
  550. RENDER_DEBUG_BBOXES = 0x00000004,
  551. RENDER_DEBUG_OCTREE = 0x00000008,
  552. RENDER_DEBUG_WIND_VECTORS = 0x00000010,
  553. RENDER_DEBUG_OCCLUSION = 0x00000020,
  554. RENDER_DEBUG_POINTS = 0x00000040,
  555. RENDER_DEBUG_TEXTURE_PRIORITY = 0x00000080,
  556. RENDER_DEBUG_TEXTURE_AREA = 0x00000100,
  557. RENDER_DEBUG_FACE_AREA = 0x00000200,
  558. RENDER_DEBUG_PARTICLES = 0x00000400,
  559. RENDER_DEBUG_TEXTURE_ANIM = 0x00000800,
  560. RENDER_DEBUG_LIGHTS = 0x00001000,
  561. RENDER_DEBUG_BATCH_SIZE = 0x00002000,
  562. RENDER_DEBUG_RAYCAST = 0x00004000,
  563. RENDER_DEBUG_AVATAR_DRAW_INFO = 0x00008000,
  564. RENDER_DEBUG_SHADOW_FRUSTA = 0x00010000,
  565. RENDER_DEBUG_SCULPTED = 0x00020000,
  566. RENDER_DEBUG_AVATAR_VOLUME = 0x00040000,
  567. RENDER_DEBUG_AVATAR_JOINTS = 0x00080000,
  568. RENDER_DEBUG_AGENT_TARGET = 0x00100000,
  569. RENDER_DEBUG_UPDATE_TYPE = 0x00200000,
  570. RENDER_DEBUG_PHYSICS_SHAPES = 0x00400000,
  571. RENDER_DEBUG_NORMALS = 0x00800000,
  572. RENDER_DEBUG_LOD_INFO = 0x01000000,
  573. RENDER_DEBUG_RENDER_COMPLEXITY = 0x02000000,
  574. RENDER_DEBUG_ATTACHMENT_INFO = 0x04000000,
  575. RENDER_DEBUG_TEXTURE_SIZE = 0x08000000,
  576. RENDER_DEBUG_REFLECTION_PROBES = 0x10000000,
  577. RENDER_DEBUG_NODES = 0x20000000,
  578. };
  579. public:
  580. // Aligned members
  581. alignas(16) LLMatrix4a mShadowModelview[6];
  582. alignas(16) LLMatrix4a mShadowProjection[6];
  583. alignas(16) LLMatrix4a mSunShadowMatrix[6];
  584. LLMatrix4a mReflectionModelView;
  585. LLVector4a mTransformedSunDir;
  586. LLVector4a mTransformedMoonDir;
  587. LLReflectionMapManager mReflectionMapManager;
  588. LLHeroProbeManager mHeroProbeManager;
  589. U32 mPoissonOffset;
  590. S32 mBatchCount;
  591. S32 mMatrixOpCount;
  592. S32 mTextureMatrixOps;
  593. U32 mMaxBatchSize;
  594. U32 mMinBatchSize;
  595. S32 mTrianglesDrawn;
  596. S32 mNumVisibleNodes;
  597. LLStat mTrianglesDrawnStat;
  598. bool mNeedsDrawStats;
  599. // 0 = no occlusion, 1 = read only, 2 = read/write:
  600. static S32 sUseOcclusion;
  601. static S32 sVisibleLightCount;
  602. static bool sFreezeTime;
  603. static bool sShowHUDAttachments;
  604. static bool sAutoMaskAlphaDeferred;
  605. static bool sAutoMaskAlphaNonDeferred;
  606. static bool sUseFarClip;
  607. static bool sShadowRender;
  608. static bool sDynamicLOD;
  609. static bool sPickAvatar;
  610. static bool sReflectionRender;
  611. static bool sImpostorRender;
  612. static bool sImpostorRenderAlphaDepthPass;
  613. static bool sAvatarPreviewRender;
  614. static bool sUnderWaterRender;
  615. static bool sCanRenderGlow;
  616. static bool sRenderFrameTest;
  617. static bool sRenderAttachedLights;
  618. static bool sRenderAttachedParticles;
  619. static bool sRenderDeferred;
  620. static bool sRenderWater; // Used by llvosky.cpp
  621. static bool sRenderingHUDs;
  622. // Utility buffer for rendering post effects, gets abused by
  623. // renderDeferredLighting
  624. LLPointer<LLVertexBuffer> mDeferredVB;
  625. // A single triangle that covers the whole screen.
  626. LLPointer<LLVertexBuffer> mScreenTriangleVB;
  627. // Utility buffer for glow combine. Used for EE rendering.
  628. LLPointer<LLVertexBuffer> mGlowCombineVB;
  629. // Utility buffer for rendering cubes, 8 vertices are corners of a cube
  630. // [-1, 1]
  631. LLPointer<LLVertexBuffer> mCubeVB;
  632. struct RenderTargetPack
  633. {
  634. RenderTargetPack()
  635. : mWidth(0),
  636. mHeight(0)
  637. {
  638. }
  639. LLRenderTarget mScreen;
  640. LLRenderTarget mDeferredScreen;
  641. LLRenderTarget mDeferredLight;
  642. // PBR renderer only
  643. LLRenderTarget mSunShadow[4];
  644. U32 mWidth;
  645. U32 mHeight;
  646. };
  647. // Main, full resolution render targets pack
  648. RenderTargetPack mMainRT;
  649. // Auxillary reflection probes (at 4 * probe resolution) render target
  650. // pack, for PBR only.
  651. RenderTargetPack mAuxillaryRT;
  652. // Auxillary render target pack scaled to the hero probe's per-face size,
  653. // for PBR only.
  654. RenderTargetPack mHeroProbeRT;
  655. // Pointer on the active render targets pack
  656. RenderTargetPack* mRT;
  657. // For FXAA, SMAA and CAS shaders (for deferred modes only).
  658. LLRenderTarget mFXAABuffer;
  659. LLRenderTarget mSMAAEdgeBuffer;
  660. LLRenderTarget mSMAABlendBuffer;
  661. LLRenderTarget mScratchBuffer;
  662. // Texture for making the glow
  663. LLRenderTarget mGlow[3];
  664. // Water distortion texture (refraction)
  665. LLRenderTarget mWaterDis;
  666. // EE render targets
  667. LLRenderTarget mWaterRef; // Water reflection
  668. LLRenderTarget mShadow[6];
  669. LLRenderTarget mShadowOcclusion[6];
  670. LLRenderTarget mDeferredDepth;
  671. LLRenderTarget mOcclusionDepth;
  672. LLRenderTarget mPhysicsDisplay;
  673. // PBR render targets
  674. LLRenderTarget mSpotShadow[2];
  675. LLRenderTarget mSceneMap;
  676. LLRenderTarget mLuminanceMap;
  677. LLRenderTarget mExposureMap;
  678. LLRenderTarget mLastExposure;
  679. LLRenderTarget mPostMap;
  680. LLRenderTarget mPbrBrdfLut;
  681. // Sun shadow map
  682. std::vector<LLVector3> mShadowFrustPoints[4];
  683. LLCamera mShadowCamera[8];
  684. LLVector3 mShadowExtents[4][2];
  685. LLPointer<LLDrawable> mTargetShadowSpotLight[2];
  686. LLPointer<LLDrawable> mShadowSpotLight[2];
  687. F32 mSpotLightFade[2];
  688. LLVector4 mSunClipPlanes;
  689. LLCullResult mSky;
  690. LLCullResult mReflectedObjects;
  691. LLCullResult mRefractedObjects;
  692. U32 mLightFunc;
  693. // Noise maps
  694. U32 mNoiseMap;
  695. U32 mTrueNoiseMap;
  696. // SMAA maps
  697. U32 mAreaMap;
  698. U32 mSearchMap;
  699. // -1 = failed, 0 = unloaded, 1 = loaded
  700. S32 mVertexShadersLoaded;
  701. // Cached sky environment and water height/camera values. HB
  702. LLColor4 mSunLightColor;
  703. LLColor4 mSunLightColorScaled;
  704. LLColor4 mMoonLightColor;
  705. LLVector4 mSunDir;
  706. LLVector4 mMoonDir;
  707. LLColor4 mTotalAmbient;
  708. F32 mProbeAmbiance;
  709. F32 mSkyGamma;
  710. F32 mEyeAboveWater;
  711. F32 mWaterHeight;
  712. bool mIsSunUp;
  713. bool mIsMoonUp;
  714. private:
  715. bool mInitialized;
  716. bool mRenderTypeEnabled[NUM_RENDER_TYPES];
  717. std::stack<std::string> mRenderTypeEnableStack;
  718. U32 mRenderDebugMask;
  719. U32 mOldRenderDebugMask;
  720. U32 mRenderDebugFeatureMask;
  721. // Screen texture
  722. U32 mScreenWidth;
  723. U32 mScreenHeight;
  724. LLDrawable::draw_vec_t mMovedList;
  725. LLDrawable::draw_vec_t mMovedBridge;
  726. LLDrawable::draw_vec_t mShiftList;
  727. struct Light
  728. {
  729. LL_INLINE Light(LLDrawable* drawablep, F32 d, F32 f = 0.f)
  730. : drawable(drawablep),
  731. dist(d),
  732. fade(f)
  733. {
  734. }
  735. LLPointer<LLDrawable> drawable;
  736. F32 dist;
  737. F32 fade;
  738. struct compare
  739. {
  740. LL_INLINE bool operator()(const Light& a, const Light& b) const
  741. {
  742. if (a.dist < b.dist)
  743. {
  744. return true;
  745. }
  746. if (a.dist > b.dist)
  747. {
  748. return false;
  749. }
  750. return a.drawable < b.drawable;
  751. }
  752. };
  753. };
  754. typedef std::set<Light, Light::compare> light_set_t;
  755. LLDrawable::draw_set_t mLights;
  756. light_set_t mNearbyLights; // Lights near camera
  757. LLColor4 mHWLightColors[8];
  758. /////////////////////////////////////////////
  759. // Different queues of drawables being processed.
  760. LLDrawable::draw_list_t mBuildQ;
  761. LLSpatialGroup::sg_vector_t mGroupQ;
  762. // A place to save mGroupQ until it is safe to unref
  763. LLSpatialGroup::sg_vector_t mGroupSaveQ;
  764. // Drawables that need to update their spatial partition radius
  765. LLDrawable::draw_vec_t mPartitionQ;
  766. // Groups that need rebuildMesh called
  767. LLSpatialGroup::sg_vector_t mMeshDirtyGroup;
  768. U32 mMeshDirtyQueryObject;
  769. bool mGroupQLocked;
  770. // If true, clear vertex buffers on next update
  771. bool mResetVertexBuffers;
  772. LLViewerObject::vobj_list_t mCreateQ;
  773. LLDrawable::draw_set_t mRetexturedList;
  774. //////////////////////////////////////////////////
  775. // Draw pools are responsible for storing all rendered data and performing
  776. // the actual rendering of objects.
  777. struct compare_pools
  778. {
  779. LL_INLINE bool operator()(const LLDrawPool* a,
  780. const LLDrawPool* b) const
  781. {
  782. if (!a)
  783. {
  784. return true;
  785. }
  786. if (!b)
  787. {
  788. return false;
  789. }
  790. S32 atype = a->getType();
  791. S32 btype = b->getType();
  792. if (atype < btype)
  793. {
  794. return true;
  795. }
  796. if (atype > btype)
  797. {
  798. return false;
  799. }
  800. return a->getId() < b->getId();
  801. }
  802. };
  803. typedef std::set<LLDrawPool*, compare_pools> pool_set_t;
  804. pool_set_t mPools;
  805. LLDrawPool* mLastRebuildPool;
  806. // For quick-lookups into mPools (mapped by texture pointer). Note: no need
  807. // to keep an quick-lookup to avatar pools, since there is only one per
  808. // avatar.
  809. typedef fast_hmap<uintptr_t, LLDrawPool*> pool_tex_map_t;
  810. pool_tex_map_t mTerrainPools;
  811. pool_tex_map_t mTreePools;
  812. LLDrawPool* mSkyPool;
  813. LLDrawPool* mTerrainPool;
  814. LLDrawPool* mWaterPool;
  815. LLRenderPass* mSimplePool;
  816. LLRenderPass* mGrassPool;
  817. LLRenderPass* mAlphaMaskPool;
  818. LLRenderPass* mFullbrightAlphaMaskPool;
  819. LLRenderPass* mFullbrightPool;
  820. LLDrawPool* mGlowPool;
  821. LLDrawPool* mBumpPool;
  822. LLDrawPool* mMaterialsPool;
  823. LLDrawPool* mWLSkyPool;
  824. // EE renderer only
  825. LLDrawPoolAlpha* mAlphaPool;
  826. LLDrawPool* mInvisiblePool;
  827. // PBR renderer only
  828. LLDrawPoolAlpha* mAlphaPoolPreWater;
  829. LLDrawPoolAlpha* mAlphaPoolPostWater;
  830. LLDrawPool* mPBROpaquePool;
  831. LLDrawPool* mPBRAlphaMaskPool;
  832. std::vector<LLFace*> mSelectedFaces;
  833. class DebugBlip
  834. {
  835. public:
  836. DebugBlip(const LLVector3& position, const LLColor4& color)
  837. : mColor(color),
  838. mPosition(position),
  839. mAge(0.f)
  840. {
  841. }
  842. public:
  843. LLColor4 mColor;
  844. LLVector3 mPosition;
  845. F32 mAge;
  846. };
  847. std::list<DebugBlip> mDebugBlips;
  848. LLPointer<LLViewerFetchedTexture> mFaceSelectImagep;
  849. U32 mLightMask;
  850. public:
  851. // Set in llenvsettings.cpp so that LLPipeline and LLDrawPoolAlpha have
  852. // quick access to the water plane in eye space.
  853. static LLVector4a sWaterPlane;
  854. // Beacon highlights
  855. std::vector<LLFace*> mHighlightFaces;
  856. static LLCullResult* sCull;
  857. // Debug use
  858. static U32 sCurRenderPoolType;
  859. static LLRender::eTexIndex sRenderHighlightTextureChannel;
  860. // Cached settings:
  861. static LLColor4 PreviewAmbientColor;
  862. static LLColor4 PreviewDiffuse0;
  863. static LLColor4 PreviewSpecular0;
  864. static LLColor4 PreviewDiffuse1;
  865. static LLColor4 PreviewSpecular1;
  866. static LLColor4 PreviewDiffuse2;
  867. static LLColor4 PreviewSpecular2;
  868. static LLVector3 PreviewDirection0;
  869. static LLVector3 PreviewDirection1;
  870. static LLVector3 PreviewDirection2;
  871. static LLVector3 RenderGlowLumWeights;
  872. static LLVector3 RenderGlowWarmthWeights;
  873. static LLVector3 RenderSSAOEffect;
  874. static LLVector3 RenderShadowGaussian;
  875. static LLVector3 RenderShadowClipPlanes;
  876. static LLVector3 RenderShadowOrthoClipPlanes;
  877. static LLVector3 RenderShadowSplitExponent;
  878. static U32 sRenderByOwner;
  879. static F32 RenderDeferredSunWash;
  880. static F32 RenderDeferredDisplayGamma;
  881. static U32 RenderFSAASamples;
  882. static S32 RenderDeferredAAQuality;
  883. static U32 RenderResolutionDivisor;
  884. static U32 RenderShadowDetail;
  885. static F32 RenderShadowResolutionScale;
  886. static U32 RenderLocalLightCount;
  887. static U32 DebugBeaconLineWidth;
  888. static F32 RenderGlowMinLuminance;
  889. static F32 RenderGlowMaxExtractAlpha;
  890. static F32 RenderGlowWarmthAmount;
  891. static U32 RenderGlowResolutionPow;
  892. static U32 RenderGlowIterations;
  893. static F32 RenderGlowWidth;
  894. static F32 RenderGlowStrength;
  895. static F32 RenderShadowNoise;
  896. static F32 RenderShadowBlurSize;
  897. static F32 RenderSSAOScale;
  898. static U32 RenderSSAOMaxScale;
  899. static F32 RenderSSAOFactor;
  900. static F32 RenderShadowBiasError;
  901. static F32 RenderShadowOffset;
  902. static F32 RenderShadowOffsetNoSSAO;
  903. static F32 RenderShadowBias;
  904. static F32 RenderSpotShadowOffset;
  905. static F32 RenderSpotShadowBias;
  906. static F32 RenderShadowBlurDistFactor;
  907. static U32 RenderWaterReflectionType;
  908. static F32 RenderFarClip;
  909. static F32 RenderShadowErrorCutoff;
  910. static F32 RenderShadowFOVCutoff;
  911. static F32 CameraMaxCoF;
  912. static F32 CameraDoFResScale;
  913. static U32 RenderAutoHideGeometryMemoryLimit;
  914. static F32 RenderAutoHideSurfaceAreaLimit;
  915. static S32 RenderBufferVisualization;
  916. static U32 RenderScreenSpaceReflectionIterations;
  917. static F32 RenderScreenSpaceReflectionRayStep;
  918. static F32 RenderScreenSpaceReflectionDistanceBias;
  919. static F32 RenderScreenSpaceReflectionDepthRejectBias;
  920. static F32 RenderScreenSpaceReflectionAdaptiveStepMultiplier;
  921. static U32 RenderScreenSpaceReflectionGlossySamples;
  922. static S32 sRenderPBRTerrainDetail;
  923. static bool sRenderPBRTerrain;
  924. static bool RenderScreenSpaceReflections;
  925. static bool RenderDeferred;
  926. static bool RenderDeferredSSAO;
  927. static bool RenderShadowSoften;
  928. static bool RenderDelayCreation;
  929. static bool RenderAnimateRes;
  930. static bool RenderSpotLightsInNondeferred;
  931. static bool RenderDepthOfField;
  932. static bool RenderDepthOfFieldInEditMode;
  933. static bool RenderDeferredAASharpen;
  934. static bool RenderDeferredAtmospheric;
  935. static bool RenderGlow;
  936. static bool CameraOffset;
  937. // Only for use by the PBR renderer (EE uses RenderWaterReflectionType). HB
  938. static bool RenderTransparentWater;
  939. static bool sRenderMirrors;
  940. static bool sRenderScriptedBeacons;
  941. static bool sRenderScriptedTouchBeacons;
  942. static bool sRenderPhysicalBeacons;
  943. static bool sRenderPermanentBeacons;
  944. static bool sRenderCharacterBeacons;
  945. static bool sRenderSoundBeacons;
  946. static bool sRenderInvisibleSoundBeacons;
  947. static bool sRenderParticleBeacons;
  948. static bool sRenderMOAPBeacons;
  949. static bool sRenderHighlight;
  950. static bool sRenderBeacons;
  951. static bool sRenderAttachments;
  952. static bool sRenderBeaconsFloaterOpen;
  953. // IMPORTANT: this MUST always be false while in EE rendering mode. HB
  954. static bool sReflectionProbesEnabled;
  955. // We collect per-frame statistics of rendered materials, so to inform the
  956. // user when some materials are around (and which type) and display an
  957. // indicator in the status bar to let them know if they are using a
  958. // rendering mode allowing to see these materials or not. HB
  959. static bool sUsingALM;
  960. static bool sUsingPBR;
  961. static bool sLacksLegacyFallback;
  962. static bool sLacksBaseColorFallback;
  963. };
  964. extern LLPipeline gPipeline;
  965. extern bool gShiftFrame;
  966. extern const LLMatrix4* gGLLastMatrix;
  967. // Helper class for disabling occlusion culling for the current stack frame
  968. class LLDisableOcclusionCulling
  969. {
  970. public:
  971. LL_INLINE LLDisableOcclusionCulling()
  972. : mUseOcclusion(LLPipeline::sUseOcclusion)
  973. {
  974. LLPipeline::sUseOcclusion = 0;
  975. }
  976. LL_INLINE ~LLDisableOcclusionCulling()
  977. {
  978. LLPipeline::sUseOcclusion = mUseOcclusion;
  979. }
  980. private:
  981. S32 mUseOcclusion;
  982. };
  983. // Helper class to allow rendering preview scenes (such as for preview avatars,
  984. // materials, etc) with a lighting that is not inluenced by the environment
  985. // settings. HB
  986. class HBPreviewLighting
  987. {
  988. public:
  989. HBPreviewLighting()
  990. : mSavedSunDir(gPipeline.mSunDir),
  991. mSavedTransformedSunDir(gPipeline.mTransformedSunDir),
  992. mSavedSunLightColor(gPipeline.mSunLightColor),
  993. mSavedSunLightColorScaled(gPipeline.mSunLightColorScaled),
  994. mSavedLightCount(LLPipeline::RenderLocalLightCount),
  995. mSavedSunUp(gPipeline.mIsSunUp),
  996. mSavedMoonUp(gPipeline.mIsMoonUp)
  997. {
  998. LLPipeline::RenderLocalLightCount = 0;
  999. gPipeline.mIsSunUp = true;
  1000. gPipeline.mIsMoonUp = false;
  1001. gPipeline.mSunDir.set(1.f, 1.f, 1.f, 1.f);
  1002. gPipeline.mTransformedSunDir.loadua(gPipeline.mSunDir.mV);
  1003. gGLModelView.rotate(gPipeline.mTransformedSunDir,
  1004. gPipeline.mTransformedSunDir);
  1005. gPipeline.mSunLightColor.set(1.f, 1.f, 1.f, 1.f);
  1006. gPipeline.setupHWLights();
  1007. LLLightState* lightp = gGL.getLight(0);
  1008. lightp->setPosition(gPipeline.mSunDir);
  1009. gPipeline.enableLightsPreview();
  1010. gGL.freezeLightState(true);
  1011. LLPipeline::sAvatarPreviewRender = true;
  1012. }
  1013. ~HBPreviewLighting()
  1014. {
  1015. gGL.freezeLightState(false);
  1016. LLPipeline::sAvatarPreviewRender = false;
  1017. gPipeline.mIsSunUp = mSavedSunUp;
  1018. gPipeline.mIsMoonUp = mSavedMoonUp;
  1019. gPipeline.mSunDir = mSavedSunDir;
  1020. gPipeline.mTransformedSunDir = mSavedTransformedSunDir;
  1021. gPipeline.mSunLightColor = mSavedSunLightColor;
  1022. gPipeline.mSunLightColorScaled = mSavedSunLightColorScaled;
  1023. LLPipeline::RenderLocalLightCount = mSavedLightCount;
  1024. }
  1025. private:
  1026. LLVector4a mSavedTransformedSunDir;
  1027. LLVector4 mSavedSunDir;
  1028. LLColor4 mSavedSunLightColor;
  1029. LLColor4 mSavedSunLightColorScaled;
  1030. U32 mSavedLightCount;
  1031. bool mSavedSunUp;
  1032. bool mSavedMoonUp;
  1033. };
  1034. void render_bbox(const LLVector3& min, const LLVector3& max);
  1035. void render_hud_elements();
  1036. #endif // LL_LLPIPELINE_H