PageRenderTime 42ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/pipeline.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 857 lines | 659 code | 130 blank | 68 comment | 11 complexity | a2ab19e7eb332a43d620799085c96869 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file pipeline.h
  3. * @brief Rendering pipeline definitions
  4. *
  5. * $LicenseInfo:firstyear=2001&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_PIPELINE_H
  27. #define LL_PIPELINE_H
  28. #include "llcamera.h"
  29. #include "llerror.h"
  30. #include "lldarrayptr.h"
  31. #include "lldqueueptr.h"
  32. #include "lldrawpool.h"
  33. #include "llspatialpartition.h"
  34. #include "m4math.h"
  35. #include "llpointer.h"
  36. #include "lldrawpool.h"
  37. #include "llgl.h"
  38. #include "lldrawable.h"
  39. #include "llrendertarget.h"
  40. #include <stack>
  41. #include <stack>
  42. #include <stack>
  43. class LLViewerTexture;
  44. class LLEdge;
  45. class LLFace;
  46. class LLViewerObject;
  47. class LLAgent;
  48. class LLDisplayPrimitive;
  49. class LLTextureEntry;
  50. class LLRenderFunc;
  51. class LLCubeMap;
  52. class LLCullResult;
  53. class LLVOAvatar;
  54. class LLGLSLShader;
  55. class LLCurlRequest;
  56. class LLMeshResponder;
  57. typedef enum e_avatar_skinning_method
  58. {
  59. SKIN_METHOD_SOFTWARE,
  60. SKIN_METHOD_VERTEX_PROGRAM
  61. } EAvatarSkinningMethod;
  62. BOOL compute_min_max(LLMatrix4& box, LLVector2& min, LLVector2& max); // Shouldn't be defined here!
  63. bool LLRayAABB(const LLVector3 &center, const LLVector3 &size, const LLVector3& origin, const LLVector3& dir, LLVector3 &coord, F32 epsilon = 0);
  64. BOOL setup_hud_matrices(); // use whole screen to render hud
  65. BOOL setup_hud_matrices(const LLRect& screen_region); // specify portion of screen (in pixels) to render hud attachments from (for picking)
  66. glh::matrix4f glh_copy_matrix(F32* src);
  67. glh::matrix4f glh_get_current_modelview();
  68. void glh_set_current_modelview(const glh::matrix4f& mat);
  69. glh::matrix4f glh_get_current_projection();
  70. void glh_set_current_projection(glh::matrix4f& mat);
  71. glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat znear, GLfloat zfar);
  72. glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar);
  73. glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up);
  74. extern LLFastTimer::DeclareTimer FTM_RENDER_GEOMETRY;
  75. extern LLFastTimer::DeclareTimer FTM_RENDER_GRASS;
  76. extern LLFastTimer::DeclareTimer FTM_RENDER_INVISIBLE;
  77. extern LLFastTimer::DeclareTimer FTM_RENDER_OCCLUSION;
  78. extern LLFastTimer::DeclareTimer FTM_RENDER_SHINY;
  79. extern LLFastTimer::DeclareTimer FTM_RENDER_SIMPLE;
  80. extern LLFastTimer::DeclareTimer FTM_RENDER_TERRAIN;
  81. extern LLFastTimer::DeclareTimer FTM_RENDER_TREES;
  82. extern LLFastTimer::DeclareTimer FTM_RENDER_UI;
  83. extern LLFastTimer::DeclareTimer FTM_RENDER_WATER;
  84. extern LLFastTimer::DeclareTimer FTM_RENDER_WL_SKY;
  85. extern LLFastTimer::DeclareTimer FTM_RENDER_ALPHA;
  86. extern LLFastTimer::DeclareTimer FTM_RENDER_CHARACTERS;
  87. extern LLFastTimer::DeclareTimer FTM_RENDER_BUMP;
  88. extern LLFastTimer::DeclareTimer FTM_RENDER_FULLBRIGHT;
  89. extern LLFastTimer::DeclareTimer FTM_RENDER_GLOW;
  90. extern LLFastTimer::DeclareTimer FTM_STATESORT;
  91. extern LLFastTimer::DeclareTimer FTM_PIPELINE;
  92. extern LLFastTimer::DeclareTimer FTM_CLIENT_COPY;
  93. class LLPipeline
  94. {
  95. public:
  96. LLPipeline();
  97. ~LLPipeline();
  98. void destroyGL();
  99. void restoreGL();
  100. void resetVertexBuffers();
  101. void resizeScreenTexture();
  102. void releaseGLBuffers();
  103. void releaseScreenBuffers();
  104. void createGLBuffers();
  105. void allocateScreenBuffer(U32 resX, U32 resY);
  106. bool allocateScreenBuffer(U32 resX, U32 resY, U32 samples);
  107. void allocatePhysicsBuffer();
  108. void resetVertexBuffers(LLDrawable* drawable);
  109. void generateImpostor(LLVOAvatar* avatar);
  110. void bindScreenToTexture();
  111. void renderBloom(BOOL for_snapshot, F32 zoom_factor = 1.f, int subfield = 0);
  112. void init();
  113. void cleanup();
  114. BOOL isInit() { return mInitialized; };
  115. /// @brief Get a draw pool from pool type (POOL_SIMPLE, POOL_MEDIA) and texture.
  116. /// @return Draw pool, or NULL if not found.
  117. LLDrawPool *findPool(const U32 pool_type, LLViewerTexture *tex0 = NULL);
  118. /// @brief Get a draw pool for faces of the appropriate type and texture. Create if necessary.
  119. /// @return Always returns a draw pool.
  120. LLDrawPool *getPool(const U32 pool_type, LLViewerTexture *tex0 = NULL);
  121. /// @brief Figures out draw pool type from texture entry. Creates pool if necessary.
  122. static LLDrawPool* getPoolFromTE(const LLTextureEntry* te, LLViewerTexture* te_image);
  123. static U32 getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* imagep);
  124. void addPool(LLDrawPool *poolp); // Only to be used by LLDrawPool classes for splitting pools!
  125. void removePool( LLDrawPool* poolp );
  126. void allocDrawable(LLViewerObject *obj);
  127. void unlinkDrawable(LLDrawable*);
  128. // Object related methods
  129. void markVisible(LLDrawable *drawablep, LLCamera& camera);
  130. void markOccluder(LLSpatialGroup* group);
  131. void doOcclusion(LLCamera& camera);
  132. void markNotCulled(LLSpatialGroup* group, LLCamera &camera);
  133. void markMoved(LLDrawable *drawablep, BOOL damped_motion = FALSE);
  134. void markShift(LLDrawable *drawablep);
  135. void markTextured(LLDrawable *drawablep);
  136. void markGLRebuild(LLGLUpdate* glu);
  137. void markRebuild(LLSpatialGroup* group, BOOL priority = FALSE);
  138. void markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag = LLDrawable::REBUILD_ALL, BOOL priority = FALSE);
  139. void markPartitionMove(LLDrawable* drawablep);
  140. //get the object between start and end that's closest to start.
  141. LLViewerObject* lineSegmentIntersectInWorld(const LLVector3& start, const LLVector3& end,
  142. BOOL pick_transparent,
  143. S32* face_hit, // return the face hit
  144. LLVector3* intersection = NULL, // return the intersection point
  145. LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
  146. LLVector3* normal = NULL, // return the surface normal at the intersection point
  147. LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point
  148. );
  149. LLViewerObject* lineSegmentIntersectInHUD(const LLVector3& start, const LLVector3& end,
  150. BOOL pick_transparent,
  151. S32* face_hit, // return the face hit
  152. LLVector3* intersection = NULL, // return the intersection point
  153. LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
  154. LLVector3* normal = NULL, // return the surface normal at the intersection point
  155. LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point
  156. );
  157. // Something about these textures has changed. Dirty them.
  158. void dirtyPoolObjectTextures(const std::set<LLViewerFetchedTexture*>& textures);
  159. void resetDrawOrders();
  160. U32 addObject(LLViewerObject *obj);
  161. void enableShadows(const BOOL enable_shadows);
  162. // void setLocalLighting(const BOOL local_lighting);
  163. // BOOL isLocalLightingEnabled() const;
  164. S32 setLightingDetail(S32 level);
  165. S32 getLightingDetail() const { return mLightingDetail; }
  166. S32 getMaxLightingDetail() const;
  167. void setUseVertexShaders(BOOL use_shaders);
  168. BOOL getUseVertexShaders() const { return mVertexShadersEnabled; }
  169. BOOL canUseVertexShaders();
  170. BOOL canUseWindLightShaders() const;
  171. BOOL canUseWindLightShadersOnObjects() const;
  172. BOOL canUseAntiAliasing() const;
  173. // phases
  174. void resetFrameStats();
  175. void updateMoveDampedAsync(LLDrawable* drawablep);
  176. void updateMoveNormalAsync(LLDrawable* drawablep);
  177. void updateMovedList(LLDrawable::drawable_vector_t& move_list);
  178. void updateMove();
  179. BOOL visibleObjectsInFrustum(LLCamera& camera);
  180. BOOL getVisibleExtents(LLCamera& camera, LLVector3 &min, LLVector3& max);
  181. BOOL getVisiblePointCloud(LLCamera& camera, LLVector3 &min, LLVector3& max, std::vector<LLVector3>& fp, LLVector3 light_dir = LLVector3(0,0,0));
  182. void updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip = 0, LLPlane* plane = NULL); //if water_clip is 0, ignore water plane, 1, cull to above plane, -1, cull to below plane
  183. void createObjects(F32 max_dtime);
  184. void createObject(LLViewerObject* vobj);
  185. void processPartitionQ();
  186. void updateGeom(F32 max_dtime);
  187. void updateGL();
  188. void rebuildPriorityGroups();
  189. void rebuildGroups();
  190. //calculate pixel area of given box from vantage point of given camera
  191. static F32 calcPixelArea(LLVector3 center, LLVector3 size, LLCamera& camera);
  192. static F32 calcPixelArea(const LLVector4a& center, const LLVector4a& size, LLCamera &camera);
  193. void stateSort(LLCamera& camera, LLCullResult& result);
  194. void stateSort(LLSpatialGroup* group, LLCamera& camera);
  195. void stateSort(LLSpatialBridge* bridge, LLCamera& camera);
  196. void stateSort(LLDrawable* drawablep, LLCamera& camera);
  197. void postSort(LLCamera& camera);
  198. void forAllVisibleDrawables(void (*func)(LLDrawable*));
  199. void renderObjects(U32 type, U32 mask, BOOL texture = TRUE, BOOL batch_texture = FALSE);
  200. void renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL texture);
  201. void grabReferences(LLCullResult& result);
  202. void clearReferences();
  203. //check references will assert that there are no references in sCullResult to the provided data
  204. void checkReferences(LLFace* face);
  205. void checkReferences(LLDrawable* drawable);
  206. void checkReferences(LLDrawInfo* draw_info);
  207. void checkReferences(LLSpatialGroup* group);
  208. void renderGeom(LLCamera& camera, BOOL forceVBOUpdate = FALSE);
  209. void renderGeomDeferred(LLCamera& camera);
  210. void renderGeomPostDeferred(LLCamera& camera);
  211. void renderGeomShadow(LLCamera& camera);
  212. void bindDeferredShader(LLGLSLShader& shader, U32 light_index = 0, U32 noise_map = 0xFFFFFFFF);
  213. void setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep);
  214. void unbindDeferredShader(LLGLSLShader& shader);
  215. void renderDeferredLighting();
  216. void generateWaterReflection(LLCamera& camera);
  217. void generateSunShadow(LLCamera& camera);
  218. void generateHighlight(LLCamera& camera);
  219. void renderHighlight(const LLViewerObject* obj, F32 fade);
  220. void setHighlightObject(LLDrawable* obj) { mHighlightObject = obj; }
  221. void renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera& camera, LLCullResult& result, BOOL use_shader = TRUE, BOOL use_occlusion = TRUE);
  222. void renderHighlights();
  223. void renderDebug();
  224. void renderPhysicsDisplay();
  225. void rebuildPools(); // Rebuild pools
  226. void findReferences(LLDrawable *drawablep); // Find the lists which have references to this object
  227. BOOL verify(); // Verify that all data in the pipeline is "correct"
  228. S32 getLightCount() const { return mLights.size(); }
  229. void calcNearbyLights(LLCamera& camera);
  230. void setupHWLights(LLDrawPool* pool);
  231. void setupAvatarLights(BOOL for_edit = FALSE);
  232. void enableLights(U32 mask);
  233. void enableLightsStatic();
  234. void enableLightsDynamic();
  235. void enableLightsAvatar();
  236. void enableLightsPreview();
  237. void enableLightsAvatarEdit(const LLColor4& color);
  238. void enableLightsFullbright(const LLColor4& color);
  239. void disableLights();
  240. void shiftObjects(const LLVector3 &offset);
  241. void setLight(LLDrawable *drawablep, BOOL is_light);
  242. BOOL hasRenderBatches(const U32 type) const;
  243. LLCullResult::drawinfo_list_t::iterator beginRenderMap(U32 type);
  244. LLCullResult::drawinfo_list_t::iterator endRenderMap(U32 type);
  245. LLCullResult::sg_list_t::iterator beginAlphaGroups();
  246. LLCullResult::sg_list_t::iterator endAlphaGroups();
  247. void addTrianglesDrawn(S32 index_count, U32 render_type = LLRender::TRIANGLES);
  248. BOOL hasRenderDebugFeatureMask(const U32 mask) const { return (mRenderDebugFeatureMask & mask) ? TRUE : FALSE; }
  249. BOOL hasRenderDebugMask(const U32 mask) const { return (mRenderDebugMask & mask) ? TRUE : FALSE; }
  250. BOOL hasRenderType(const U32 type) const;
  251. BOOL hasAnyRenderType(const U32 type, ...) const;
  252. void setRenderTypeMask(U32 type, ...);
  253. void orRenderTypeMask(U32 type, ...);
  254. void andRenderTypeMask(U32 type, ...);
  255. void clearRenderTypeMask(U32 type, ...);
  256. void pushRenderTypeMask();
  257. void popRenderTypeMask();
  258. static void toggleRenderType(U32 type);
  259. // For UI control of render features
  260. static BOOL hasRenderTypeControl(void* data);
  261. static void toggleRenderDebug(void* data);
  262. static void toggleRenderDebugFeature(void* data);
  263. static void toggleRenderTypeControl(void* data);
  264. static BOOL toggleRenderTypeControlNegated(void* data);
  265. static BOOL toggleRenderDebugControl(void* data);
  266. static BOOL toggleRenderDebugFeatureControl(void* data);
  267. static void setRenderDebugFeatureControl(U32 bit, bool value);
  268. static void setRenderParticleBeacons(BOOL val);
  269. static void toggleRenderParticleBeacons(void* data);
  270. static BOOL getRenderParticleBeacons(void* data);
  271. static void setRenderSoundBeacons(BOOL val);
  272. static void toggleRenderSoundBeacons(void* data);
  273. static BOOL getRenderSoundBeacons(void* data);
  274. static void setRenderMOAPBeacons(BOOL val);
  275. static void toggleRenderMOAPBeacons(void * data);
  276. static BOOL getRenderMOAPBeacons(void * data);
  277. static void setRenderPhysicalBeacons(BOOL val);
  278. static void toggleRenderPhysicalBeacons(void* data);
  279. static BOOL getRenderPhysicalBeacons(void* data);
  280. static void setRenderScriptedBeacons(BOOL val);
  281. static void toggleRenderScriptedBeacons(void* data);
  282. static BOOL getRenderScriptedBeacons(void* data);
  283. static void setRenderScriptedTouchBeacons(BOOL val);
  284. static void toggleRenderScriptedTouchBeacons(void* data);
  285. static BOOL getRenderScriptedTouchBeacons(void* data);
  286. static void setRenderBeacons(BOOL val);
  287. static void toggleRenderBeacons(void* data);
  288. static BOOL getRenderBeacons(void* data);
  289. static void setRenderHighlights(BOOL val);
  290. static void toggleRenderHighlights(void* data);
  291. static BOOL getRenderHighlights(void* data);
  292. static void updateRenderDeferred();
  293. static void refreshCachedSettings();
  294. static void throttleNewMemoryAllocation(BOOL disable);
  295. void addDebugBlip(const LLVector3& position, const LLColor4& color);
  296. private:
  297. void unloadShaders();
  298. void addToQuickLookup( LLDrawPool* new_poolp );
  299. void removeFromQuickLookup( LLDrawPool* poolp );
  300. BOOL updateDrawableGeom(LLDrawable* drawable, BOOL priority);
  301. void assertInitializedDoError();
  302. bool assertInitialized() { const bool is_init = isInit(); if (!is_init) assertInitializedDoError(); return is_init; };
  303. public:
  304. enum {GPU_CLASS_MAX = 3 };
  305. enum LLRenderTypeMask
  306. {
  307. // Following are pool types (some are also object types)
  308. RENDER_TYPE_SKY = LLDrawPool::POOL_SKY,
  309. RENDER_TYPE_WL_SKY = LLDrawPool::POOL_WL_SKY,
  310. RENDER_TYPE_GROUND = LLDrawPool::POOL_GROUND,
  311. RENDER_TYPE_TERRAIN = LLDrawPool::POOL_TERRAIN,
  312. RENDER_TYPE_SIMPLE = LLDrawPool::POOL_SIMPLE,
  313. RENDER_TYPE_GRASS = LLDrawPool::POOL_GRASS,
  314. RENDER_TYPE_FULLBRIGHT = LLDrawPool::POOL_FULLBRIGHT,
  315. RENDER_TYPE_BUMP = LLDrawPool::POOL_BUMP,
  316. RENDER_TYPE_AVATAR = LLDrawPool::POOL_AVATAR,
  317. RENDER_TYPE_TREE = LLDrawPool::POOL_TREE,
  318. RENDER_TYPE_INVISIBLE = LLDrawPool::POOL_INVISIBLE,
  319. RENDER_TYPE_VOIDWATER = LLDrawPool::POOL_VOIDWATER,
  320. RENDER_TYPE_WATER = LLDrawPool::POOL_WATER,
  321. RENDER_TYPE_ALPHA = LLDrawPool::POOL_ALPHA,
  322. RENDER_TYPE_GLOW = LLDrawPool::POOL_GLOW,
  323. RENDER_TYPE_PASS_SIMPLE = LLRenderPass::PASS_SIMPLE,
  324. RENDER_TYPE_PASS_GRASS = LLRenderPass::PASS_GRASS,
  325. RENDER_TYPE_PASS_FULLBRIGHT = LLRenderPass::PASS_FULLBRIGHT,
  326. RENDER_TYPE_PASS_INVISIBLE = LLRenderPass::PASS_INVISIBLE,
  327. RENDER_TYPE_PASS_INVISI_SHINY = LLRenderPass::PASS_INVISI_SHINY,
  328. RENDER_TYPE_PASS_FULLBRIGHT_SHINY = LLRenderPass::PASS_FULLBRIGHT_SHINY,
  329. RENDER_TYPE_PASS_SHINY = LLRenderPass::PASS_SHINY,
  330. RENDER_TYPE_PASS_BUMP = LLRenderPass::PASS_BUMP,
  331. RENDER_TYPE_PASS_POST_BUMP = LLRenderPass::PASS_POST_BUMP,
  332. RENDER_TYPE_PASS_GLOW = LLRenderPass::PASS_GLOW,
  333. RENDER_TYPE_PASS_ALPHA = LLRenderPass::PASS_ALPHA,
  334. RENDER_TYPE_PASS_ALPHA_MASK = LLRenderPass::PASS_ALPHA_MASK,
  335. RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK = LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK,
  336. // Following are object types (only used in drawable mRenderType)
  337. RENDER_TYPE_HUD = LLRenderPass::NUM_RENDER_TYPES,
  338. RENDER_TYPE_VOLUME,
  339. RENDER_TYPE_PARTICLES,
  340. RENDER_TYPE_CLOUDS,
  341. RENDER_TYPE_HUD_PARTICLES,
  342. NUM_RENDER_TYPES,
  343. END_RENDER_TYPES = NUM_RENDER_TYPES
  344. };
  345. enum LLRenderDebugFeatureMask
  346. {
  347. RENDER_DEBUG_FEATURE_UI = 0x0001,
  348. RENDER_DEBUG_FEATURE_SELECTED = 0x0002,
  349. RENDER_DEBUG_FEATURE_HIGHLIGHTED = 0x0004,
  350. RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES = 0x0008,
  351. // RENDER_DEBUG_FEATURE_HW_LIGHTING = 0x0010,
  352. RENDER_DEBUG_FEATURE_FLEXIBLE = 0x0010,
  353. RENDER_DEBUG_FEATURE_FOG = 0x0020,
  354. RENDER_DEBUG_FEATURE_FR_INFO = 0x0080,
  355. RENDER_DEBUG_FEATURE_FOOT_SHADOWS = 0x0100,
  356. };
  357. enum LLRenderDebugMask
  358. {
  359. RENDER_DEBUG_COMPOSITION = 0x0000001,
  360. RENDER_DEBUG_VERIFY = 0x0000002,
  361. RENDER_DEBUG_BBOXES = 0x0000004,
  362. RENDER_DEBUG_OCTREE = 0x0000008,
  363. RENDER_DEBUG_WIND_VECTORS = 0x0000010,
  364. RENDER_DEBUG_OCCLUSION = 0x0000020,
  365. RENDER_DEBUG_POINTS = 0x0000040,
  366. RENDER_DEBUG_TEXTURE_PRIORITY = 0x0000080,
  367. RENDER_DEBUG_TEXTURE_AREA = 0x0000100,
  368. RENDER_DEBUG_FACE_AREA = 0x0000200,
  369. RENDER_DEBUG_PARTICLES = 0x0000400,
  370. RENDER_DEBUG_GLOW = 0x0000800,
  371. RENDER_DEBUG_TEXTURE_ANIM = 0x0001000,
  372. RENDER_DEBUG_LIGHTS = 0x0002000,
  373. RENDER_DEBUG_BATCH_SIZE = 0x0004000,
  374. RENDER_DEBUG_ALPHA_BINS = 0x0008000,
  375. RENDER_DEBUG_RAYCAST = 0x0010000,
  376. RENDER_DEBUG_SHAME = 0x0020000,
  377. RENDER_DEBUG_SHADOW_FRUSTA = 0x0040000,
  378. RENDER_DEBUG_SCULPTED = 0x0080000,
  379. RENDER_DEBUG_AVATAR_VOLUME = 0x0100000,
  380. RENDER_DEBUG_BUILD_QUEUE = 0x0200000,
  381. RENDER_DEBUG_AGENT_TARGET = 0x0400000,
  382. RENDER_DEBUG_UPDATE_TYPE = 0x0800000,
  383. RENDER_DEBUG_PHYSICS_SHAPES = 0x1000000,
  384. RENDER_DEBUG_NORMALS = 0x2000000,
  385. RENDER_DEBUG_LOD_INFO = 0x4000000,
  386. RENDER_DEBUG_RENDER_COMPLEXITY = 0x8000000
  387. };
  388. public:
  389. LLSpatialPartition* getSpatialPartition(LLViewerObject* vobj);
  390. void updateCamera(BOOL reset = FALSE);
  391. LLVector3 mFlyCamPosition;
  392. LLQuaternion mFlyCamRotation;
  393. BOOL mBackfaceCull;
  394. S32 mBatchCount;
  395. S32 mMatrixOpCount;
  396. S32 mTextureMatrixOps;
  397. S32 mMaxBatchSize;
  398. S32 mMinBatchSize;
  399. S32 mMeanBatchSize;
  400. S32 mTrianglesDrawn;
  401. S32 mNumVisibleNodes;
  402. S32 mVerticesRelit;
  403. S32 mDebugTextureUploadCost;
  404. S32 mDebugSculptUploadCost;
  405. S32 mDebugMeshUploadCost;
  406. S32 mLightingChanges;
  407. S32 mGeometryChanges;
  408. S32 mNumVisibleFaces;
  409. static S32 sCompiles;
  410. static BOOL sShowHUDAttachments;
  411. static BOOL sForceOldBakedUpload; // If true will not use capabilities to upload baked textures.
  412. static S32 sUseOcclusion; // 0 = no occlusion, 1 = read only, 2 = read/write
  413. static BOOL sDelayVBUpdate;
  414. static BOOL sAutoMaskAlphaDeferred;
  415. static BOOL sAutoMaskAlphaNonDeferred;
  416. static BOOL sDisableShaders; // if TRUE, rendering will be done without shaders
  417. static BOOL sRenderBump;
  418. static BOOL sBakeSunlight;
  419. static BOOL sNoAlpha;
  420. static BOOL sUseTriStrips;
  421. static BOOL sUseFarClip;
  422. static BOOL sShadowRender;
  423. static BOOL sWaterReflections;
  424. static BOOL sDynamicLOD;
  425. static BOOL sPickAvatar;
  426. static BOOL sReflectionRender;
  427. static BOOL sImpostorRender;
  428. static BOOL sUnderWaterRender;
  429. static BOOL sRenderGlow;
  430. static BOOL sTextureBindTest;
  431. static BOOL sRenderFrameTest;
  432. static BOOL sRenderAttachedLights;
  433. static BOOL sRenderAttachedParticles;
  434. static BOOL sRenderDeferred;
  435. static BOOL sMemAllocationThrottled;
  436. static S32 sVisibleLightCount;
  437. static F32 sMinRenderSize;
  438. //screen texture
  439. U32 mScreenWidth;
  440. U32 mScreenHeight;
  441. LLRenderTarget mScreen;
  442. LLRenderTarget mUIScreen;
  443. LLRenderTarget mDeferredScreen;
  444. LLRenderTarget mFXAABuffer;
  445. LLRenderTarget mEdgeMap;
  446. LLRenderTarget mDeferredDepth;
  447. LLRenderTarget mDeferredLight;
  448. LLRenderTarget mHighlight;
  449. LLRenderTarget mPhysicsDisplay;
  450. //utility buffer for rendering post effects, gets abused by renderDeferredLighting
  451. LLPointer<LLVertexBuffer> mDeferredVB;
  452. //sun shadow map
  453. LLRenderTarget mShadow[6];
  454. std::vector<LLVector3> mShadowFrustPoints[4];
  455. LLVector4 mShadowError;
  456. LLVector4 mShadowFOV;
  457. LLVector3 mShadowFrustOrigin[4];
  458. LLCamera mShadowCamera[8];
  459. LLVector3 mShadowExtents[4][2];
  460. glh::matrix4f mSunShadowMatrix[6];
  461. glh::matrix4f mShadowModelview[6];
  462. glh::matrix4f mShadowProjection[6];
  463. glh::matrix4f mGIMatrix;
  464. glh::matrix4f mGIMatrixProj;
  465. glh::matrix4f mGIModelview;
  466. glh::matrix4f mGIProjection;
  467. glh::matrix4f mGINormalMatrix;
  468. glh::matrix4f mGIInvProj;
  469. LLVector2 mGIRange;
  470. F32 mGILightRadius;
  471. LLPointer<LLDrawable> mShadowSpotLight[2];
  472. F32 mSpotLightFade[2];
  473. LLPointer<LLDrawable> mTargetShadowSpotLight[2];
  474. LLVector4 mSunClipPlanes;
  475. LLVector4 mSunOrthoClipPlanes;
  476. LLVector2 mScreenScale;
  477. //water reflection texture
  478. LLRenderTarget mWaterRef;
  479. //water distortion texture (refraction)
  480. LLRenderTarget mWaterDis;
  481. //texture for making the glow
  482. LLRenderTarget mGlow[3];
  483. //noise map
  484. U32 mNoiseMap;
  485. U32 mTrueNoiseMap;
  486. U32 mLightFunc;
  487. LLColor4 mSunDiffuse;
  488. LLVector3 mSunDir;
  489. LLVector3 mTransformedSunDir;
  490. BOOL mInitialized;
  491. BOOL mVertexShadersEnabled;
  492. S32 mVertexShadersLoaded; // 0 = no, 1 = yes, -1 = failed
  493. protected:
  494. BOOL mRenderTypeEnabled[NUM_RENDER_TYPES];
  495. std::stack<std::string> mRenderTypeEnableStack;
  496. U32 mRenderDebugFeatureMask;
  497. U32 mRenderDebugMask;
  498. U32 mOldRenderDebugMask;
  499. /////////////////////////////////////////////
  500. //
  501. //
  502. LLDrawable::drawable_vector_t mMovedList;
  503. LLDrawable::drawable_vector_t mMovedBridge;
  504. LLDrawable::drawable_vector_t mShiftList;
  505. /////////////////////////////////////////////
  506. //
  507. //
  508. struct Light
  509. {
  510. Light(LLDrawable* ptr, F32 d, F32 f = 0.0f)
  511. : drawable(ptr),
  512. dist(d),
  513. fade(f)
  514. {}
  515. LLPointer<LLDrawable> drawable;
  516. F32 dist;
  517. F32 fade;
  518. struct compare
  519. {
  520. bool operator()(const Light& a, const Light& b) const
  521. {
  522. if ( a.dist < b.dist )
  523. return true;
  524. else if ( a.dist > b.dist )
  525. return false;
  526. else
  527. return a.drawable < b.drawable;
  528. }
  529. };
  530. };
  531. typedef std::set< Light, Light::compare > light_set_t;
  532. LLDrawable::drawable_set_t mLights;
  533. light_set_t mNearbyLights; // lights near camera
  534. LLColor4 mHWLightColors[8];
  535. /////////////////////////////////////////////
  536. //
  537. // Different queues of drawables being processed.
  538. //
  539. LLDrawable::drawable_list_t mBuildQ1; // priority
  540. LLDrawable::drawable_list_t mBuildQ2; // non-priority
  541. LLSpatialGroup::sg_vector_t mGroupQ1; //priority
  542. LLSpatialGroup::sg_vector_t mGroupQ2; // non-priority
  543. LLDrawable::drawable_list_t mPartitionQ; //drawables that need to update their spatial partition radius
  544. bool mGroupQ2Locked;
  545. bool mGroupQ1Locked;
  546. LLViewerObject::vobj_list_t mCreateQ;
  547. LLDrawable::drawable_set_t mRetexturedList;
  548. class HighlightItem
  549. {
  550. public:
  551. const LLPointer<LLDrawable> mItem;
  552. mutable F32 mFade;
  553. HighlightItem(LLDrawable* item)
  554. : mItem(item), mFade(0)
  555. {
  556. }
  557. bool operator<(const HighlightItem& rhs) const
  558. {
  559. return mItem < rhs.mItem;
  560. }
  561. bool operator==(const HighlightItem& rhs) const
  562. {
  563. return mItem == rhs.mItem;
  564. }
  565. void incrFade(F32 val) const
  566. {
  567. mFade = llclamp(mFade+val, 0.f, 1.f);
  568. }
  569. };
  570. std::set<HighlightItem> mHighlightSet;
  571. LLPointer<LLDrawable> mHighlightObject;
  572. //////////////////////////////////////////////////
  573. //
  574. // Draw pools are responsible for storing all rendered data,
  575. // and performing the actual rendering of objects.
  576. //
  577. struct compare_pools
  578. {
  579. bool operator()(const LLDrawPool* a, const LLDrawPool* b) const
  580. {
  581. if (!a)
  582. return true;
  583. else if (!b)
  584. return false;
  585. else
  586. {
  587. S32 atype = a->getType();
  588. S32 btype = b->getType();
  589. if (atype < btype)
  590. return true;
  591. else if (atype > btype)
  592. return false;
  593. else
  594. return a->getId() < b->getId();
  595. }
  596. }
  597. };
  598. typedef std::set<LLDrawPool*, compare_pools > pool_set_t;
  599. pool_set_t mPools;
  600. LLDrawPool* mLastRebuildPool;
  601. // For quick-lookups into mPools (mapped by texture pointer)
  602. std::map<uintptr_t, LLDrawPool*> mTerrainPools;
  603. std::map<uintptr_t, LLDrawPool*> mTreePools;
  604. LLDrawPool* mAlphaPool;
  605. LLDrawPool* mSkyPool;
  606. LLDrawPool* mTerrainPool;
  607. LLDrawPool* mWaterPool;
  608. LLDrawPool* mGroundPool;
  609. LLRenderPass* mSimplePool;
  610. LLRenderPass* mGrassPool;
  611. LLRenderPass* mFullbrightPool;
  612. LLDrawPool* mInvisiblePool;
  613. LLDrawPool* mGlowPool;
  614. LLDrawPool* mBumpPool;
  615. LLDrawPool* mWLSkyPool;
  616. // Note: no need to keep an quick-lookup to avatar pools, since there's only one per avatar
  617. public:
  618. std::vector<LLFace*> mHighlightFaces; // highlight faces on physical objects
  619. protected:
  620. std::vector<LLFace*> mSelectedFaces;
  621. class DebugBlip
  622. {
  623. public:
  624. LLColor4 mColor;
  625. LLVector3 mPosition;
  626. F32 mAge;
  627. DebugBlip(const LLVector3& position, const LLColor4& color)
  628. : mColor(color), mPosition(position), mAge(0.f)
  629. { }
  630. };
  631. std::list<DebugBlip> mDebugBlips;
  632. LLPointer<LLViewerFetchedTexture> mFaceSelectImagep;
  633. U32 mLightMask;
  634. U32 mLightMovingMask;
  635. S32 mLightingDetail;
  636. static BOOL sRenderPhysicalBeacons;
  637. static BOOL sRenderMOAPBeacons;
  638. static BOOL sRenderScriptedTouchBeacons;
  639. static BOOL sRenderScriptedBeacons;
  640. static BOOL sRenderParticleBeacons;
  641. static BOOL sRenderSoundBeacons;
  642. public:
  643. static BOOL sRenderBeacons;
  644. static BOOL sRenderHighlight;
  645. //debug use
  646. static U32 sCurRenderPoolType ;
  647. //cached settings
  648. static BOOL WindLightUseAtmosShaders;
  649. static BOOL VertexShaderEnable;
  650. static BOOL RenderAvatarVP;
  651. static BOOL RenderDeferred;
  652. static F32 RenderDeferredSunWash;
  653. static U32 RenderFSAASamples;
  654. static U32 RenderResolutionDivisor;
  655. static BOOL RenderUIBuffer;
  656. static S32 RenderShadowDetail;
  657. static BOOL RenderDeferredSSAO;
  658. static F32 RenderShadowResolutionScale;
  659. static BOOL RenderLocalLights;
  660. static BOOL RenderDelayCreation;
  661. static BOOL RenderAnimateRes;
  662. static BOOL FreezeTime;
  663. static S32 DebugBeaconLineWidth;
  664. static F32 RenderHighlightBrightness;
  665. static LLColor4 RenderHighlightColor;
  666. static F32 RenderHighlightThickness;
  667. static BOOL RenderSpotLightsInNondeferred;
  668. static LLColor4 PreviewAmbientColor;
  669. static LLColor4 PreviewDiffuse0;
  670. static LLColor4 PreviewSpecular0;
  671. static LLColor4 PreviewDiffuse1;
  672. static LLColor4 PreviewSpecular1;
  673. static LLColor4 PreviewDiffuse2;
  674. static LLColor4 PreviewSpecular2;
  675. static LLVector3 PreviewDirection0;
  676. static LLVector3 PreviewDirection1;
  677. static LLVector3 PreviewDirection2;
  678. static F32 RenderGlowMinLuminance;
  679. static F32 RenderGlowMaxExtractAlpha;
  680. static F32 RenderGlowWarmthAmount;
  681. static LLVector3 RenderGlowLumWeights;
  682. static LLVector3 RenderGlowWarmthWeights;
  683. static S32 RenderGlowResolutionPow;
  684. static S32 RenderGlowIterations;
  685. static F32 RenderGlowWidth;
  686. static F32 RenderGlowStrength;
  687. static BOOL RenderDepthOfField;
  688. static F32 CameraFocusTransitionTime;
  689. static F32 CameraFNumber;
  690. static F32 CameraFocalLength;
  691. static F32 CameraFieldOfView;
  692. static F32 RenderShadowNoise;
  693. static F32 RenderShadowBlurSize;
  694. static F32 RenderSSAOScale;
  695. static U32 RenderSSAOMaxScale;
  696. static F32 RenderSSAOFactor;
  697. static LLVector3 RenderSSAOEffect;
  698. static F32 RenderShadowOffsetError;
  699. static F32 RenderShadowBiasError;
  700. static F32 RenderShadowOffset;
  701. static F32 RenderShadowBias;
  702. static F32 RenderSpotShadowOffset;
  703. static F32 RenderSpotShadowBias;
  704. static F32 RenderEdgeDepthCutoff;
  705. static F32 RenderEdgeNormCutoff;
  706. static LLVector3 RenderShadowGaussian;
  707. static F32 RenderShadowBlurDistFactor;
  708. static BOOL RenderDeferredAtmospheric;
  709. static S32 RenderReflectionDetail;
  710. static F32 RenderHighlightFadeTime;
  711. static LLVector3 RenderShadowClipPlanes;
  712. static LLVector3 RenderShadowOrthoClipPlanes;
  713. static LLVector3 RenderShadowNearDist;
  714. static F32 RenderFarClip;
  715. static LLVector3 RenderShadowSplitExponent;
  716. static F32 RenderShadowErrorCutoff;
  717. static F32 RenderShadowFOVCutoff;
  718. static BOOL CameraOffset;
  719. static F32 CameraMaxCoF;
  720. static F32 CameraDoFResScale;
  721. };
  722. void render_bbox(const LLVector3 &min, const LLVector3 &max);
  723. void render_hud_elements();
  724. extern LLPipeline gPipeline;
  725. extern BOOL gDebugPipeline;
  726. extern const LLMatrix4* gGLLastMatrix;
  727. #endif