pipeline.h
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:24k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file pipeline.h
  3.  * @brief Rendering pipeline definitions
  4.  *
  5.  * $LicenseInfo:firstyear=2001&license=viewergpl$
  6.  * 
  7.  * Copyright (c) 2001-2010, 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_PIPELINE_H
  33. #define LL_PIPELINE_H
  34. #include "llcamera.h"
  35. #include "llerror.h"
  36. #include "lldarrayptr.h"
  37. #include "lldqueueptr.h"
  38. #include "lldrawpool.h"
  39. #include "llspatialpartition.h"
  40. #include "m4math.h"
  41. #include "llpointer.h"
  42. #include "lldrawpool.h"
  43. #include "llgl.h"
  44. #include "lldrawable.h"
  45. #include "llrendertarget.h"
  46. class LLViewerTexture;
  47. class LLEdge;
  48. class LLFace;
  49. class LLViewerObject;
  50. class LLAgent;
  51. class LLDisplayPrimitive;
  52. class LLTextureEntry;
  53. class LLRenderFunc;
  54. class LLCubeMap;
  55. class LLCullResult;
  56. class LLVOAvatar;
  57. class LLGLSLShader;
  58. typedef enum e_avatar_skinning_method
  59. {
  60. SKIN_METHOD_SOFTWARE,
  61. SKIN_METHOD_VERTEX_PROGRAM
  62. } EAvatarSkinningMethod;
  63. BOOL compute_min_max(LLMatrix4& box, LLVector2& min, LLVector2& max); // Shouldn't be defined here!
  64. bool LLRayAABB(const LLVector3 &center, const LLVector3 &size, const LLVector3& origin, const LLVector3& dir, LLVector3 &coord, F32 epsilon = 0);
  65. BOOL setup_hud_matrices(); // use whole screen to render hud
  66. BOOL setup_hud_matrices(const LLRect& screen_region); // specify portion of screen (in pixels) to render hud attachments from (for picking)
  67. glh::matrix4f glh_copy_matrix(GLdouble* src);
  68. glh::matrix4f glh_get_current_modelview();
  69. void glh_set_current_modelview(const glh::matrix4f& mat);
  70. glh::matrix4f glh_get_current_projection();
  71. void glh_set_current_projection(glh::matrix4f& mat);
  72. glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat znear, GLfloat zfar);
  73. glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar);
  74. glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up);
  75. extern LLFastTimer::DeclareTimer FTM_RENDER_GEOMETRY;
  76. extern LLFastTimer::DeclareTimer FTM_RENDER_GRASS;
  77. extern LLFastTimer::DeclareTimer FTM_RENDER_INVISIBLE;
  78. extern LLFastTimer::DeclareTimer FTM_RENDER_OCCLUSION;
  79. extern LLFastTimer::DeclareTimer FTM_RENDER_SHINY;
  80. extern LLFastTimer::DeclareTimer FTM_RENDER_SIMPLE;
  81. extern LLFastTimer::DeclareTimer FTM_RENDER_TERRAIN;
  82. extern LLFastTimer::DeclareTimer FTM_RENDER_TREES;
  83. extern LLFastTimer::DeclareTimer FTM_RENDER_UI;
  84. extern LLFastTimer::DeclareTimer FTM_RENDER_WATER;
  85. extern LLFastTimer::DeclareTimer FTM_RENDER_WL_SKY;
  86. extern LLFastTimer::DeclareTimer FTM_RENDER_ALPHA;
  87. extern LLFastTimer::DeclareTimer FTM_RENDER_CHARACTERS;
  88. extern LLFastTimer::DeclareTimer FTM_RENDER_BUMP;
  89. extern LLFastTimer::DeclareTimer FTM_RENDER_FULLBRIGHT;
  90. extern LLFastTimer::DeclareTimer FTM_RENDER_GLOW;
  91. extern LLFastTimer::DeclareTimer FTM_STATESORT;
  92. extern LLFastTimer::DeclareTimer FTM_PIPELINE;
  93. extern LLFastTimer::DeclareTimer FTM_CLIENT_COPY;
  94. class LLPipeline
  95. {
  96. public:
  97. LLPipeline();
  98. ~LLPipeline();
  99. void destroyGL();
  100. void restoreGL();
  101. void resetVertexBuffers();
  102. void resizeScreenTexture();
  103. void releaseGLBuffers();
  104. void createGLBuffers();
  105. void allocateScreenBuffer(U32 resX, U32 resY);
  106. void resetVertexBuffers(LLDrawable* drawable);
  107. void setUseVBO(BOOL use_vbo);
  108. void generateImpostor(LLVOAvatar* avatar);
  109. void bindScreenToTexture();
  110. void renderBloom(BOOL for_snapshot, F32 zoom_factor = 1.f, int subfield = 0);
  111. void init();
  112. void cleanup();
  113. BOOL isInit() { return mInitialized; };
  114. /// @brief Get a draw pool from pool type (POOL_SIMPLE, POOL_MEDIA) and texture.
  115. /// @return Draw pool, or NULL if not found.
  116. LLDrawPool *findPool(const U32 pool_type, LLViewerTexture *tex0 = NULL);
  117. /// @brief Get a draw pool for faces of the appropriate type and texture.  Create if necessary.
  118. /// @return Always returns a draw pool.
  119. LLDrawPool *getPool(const U32 pool_type, LLViewerTexture *tex0 = NULL);
  120. /// @brief Figures out draw pool type from texture entry. Creates pool if necessary.
  121. static LLDrawPool* getPoolFromTE(const LLTextureEntry* te, LLViewerTexture* te_image);
  122. static U32 getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* imagep);
  123. void  addPool(LLDrawPool *poolp); // Only to be used by LLDrawPool classes for splitting pools!
  124. void  removePool( LLDrawPool* poolp );
  125. void  allocDrawable(LLViewerObject *obj);
  126. void  unlinkDrawable(LLDrawable*);
  127. // Object related methods
  128. void        markVisible(LLDrawable *drawablep, LLCamera& camera);
  129. void markOccluder(LLSpatialGroup* group);
  130. void doOcclusion(LLCamera& camera);
  131. void markNotCulled(LLSpatialGroup* group, LLCamera &camera);
  132. void        markMoved(LLDrawable *drawablep, BOOL damped_motion = FALSE);
  133. void        markShift(LLDrawable *drawablep);
  134. void        markTextured(LLDrawable *drawablep);
  135. void markGLRebuild(LLGLUpdate* glu);
  136. void markRebuild(LLSpatialGroup* group, BOOL priority = FALSE);
  137. void        markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag = LLDrawable::REBUILD_ALL, BOOL priority = FALSE);
  138. //get the object between start and end that's closest to start.
  139. LLViewerObject* lineSegmentIntersectInWorld(const LLVector3& start, const LLVector3& end,
  140. BOOL pick_transparent,
  141. S32* face_hit,                          // return the face hit
  142. LLVector3* intersection = NULL,         // return the intersection point
  143. LLVector2* tex_coord = NULL,            // return the texture coordinates of the intersection point
  144. LLVector3* normal = NULL,               // return the surface normal at the intersection point
  145. LLVector3* bi_normal = NULL             // return the surface bi-normal at the intersection point  
  146. );
  147. LLViewerObject* lineSegmentIntersectInHUD(const LLVector3& start, const LLVector3& end,
  148.   BOOL pick_transparent,
  149.   S32* face_hit,                          // return the face hit
  150.   LLVector3* intersection = NULL,         // return the intersection point
  151.   LLVector2* tex_coord = NULL,            // return the texture coordinates of the intersection point
  152.   LLVector3* normal = NULL,               // return the surface normal at the intersection point
  153.   LLVector3* bi_normal = NULL             // return the surface bi-normal at the intersection point
  154. );
  155. // Something about these textures has changed.  Dirty them.
  156. void        dirtyPoolObjectTextures(const std::set<LLViewerFetchedTexture*>& textures);
  157. void        resetDrawOrders();
  158. U32         addObject(LLViewerObject *obj);
  159. void enableShadows(const BOOL enable_shadows);
  160. //  void setLocalLighting(const BOOL local_lighting);
  161. //  BOOL isLocalLightingEnabled() const;
  162. S32 setLightingDetail(S32 level);
  163. S32 getLightingDetail() const { return mLightingDetail; }
  164. S32 getMaxLightingDetail() const;
  165. void setUseVertexShaders(BOOL use_shaders);
  166. BOOL getUseVertexShaders() const { return mVertexShadersEnabled; }
  167. BOOL canUseVertexShaders();
  168. BOOL canUseWindLightShaders() const;
  169. BOOL canUseWindLightShadersOnObjects() const;
  170. // phases
  171. void resetFrameStats();
  172. void updateMoveDampedAsync(LLDrawable* drawablep);
  173. void updateMoveNormalAsync(LLDrawable* drawablep);
  174. void updateMovedList(LLDrawable::drawable_vector_t& move_list);
  175. void updateMove();
  176. BOOL visibleObjectsInFrustum(LLCamera& camera);
  177. BOOL getVisibleExtents(LLCamera& camera, LLVector3 &min, LLVector3& max);
  178. BOOL getVisiblePointCloud(LLCamera& camera, LLVector3 &min, LLVector3& max, std::vector<LLVector3>& fp, LLVector3 light_dir = LLVector3(0,0,0));
  179. void updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip = 0);  //if water_clip is 0, ignore water plane, 1, cull to above plane, -1, cull to below plane
  180. void createObjects(F32 max_dtime);
  181. void createObject(LLViewerObject* vobj);
  182. void updateGeom(F32 max_dtime);
  183. void updateGL();
  184. void rebuildPriorityGroups();
  185. void rebuildGroups();
  186. //calculate pixel area of given box from vantage point of given camera
  187. static F32 calcPixelArea(LLVector3 center, LLVector3 size, LLCamera& camera);
  188. void stateSort(LLCamera& camera, LLCullResult& result);
  189. void stateSort(LLSpatialGroup* group, LLCamera& camera);
  190. void stateSort(LLSpatialBridge* bridge, LLCamera& camera);
  191. void stateSort(LLDrawable* drawablep, LLCamera& camera);
  192. void postSort(LLCamera& camera);
  193. void forAllVisibleDrawables(void (*func)(LLDrawable*));
  194. void renderObjects(U32 type, U32 mask, BOOL texture = TRUE);
  195. void renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL texture);
  196. void grabReferences(LLCullResult& result);
  197. void renderGeom(LLCamera& camera, BOOL forceVBOUpdate = FALSE);
  198. void renderGeomDeferred(LLCamera& camera);
  199. void renderGeomPostDeferred(LLCamera& camera);
  200. void renderGeomShadow(LLCamera& camera);
  201. void bindDeferredShader(LLGLSLShader& shader, U32 light_index = 0, LLRenderTarget* gi_source = NULL, LLRenderTarget* last_gi_post = NULL, U32 noise_map = 0xFFFFFFFF);
  202. void setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep);
  203. void unbindDeferredShader(LLGLSLShader& shader);
  204. void renderDeferredLighting();
  205. void generateWaterReflection(LLCamera& camera);
  206. void generateSunShadow(LLCamera& camera);
  207. void generateHighlight(LLCamera& camera);
  208. void renderHighlight(const LLViewerObject* obj, F32 fade);
  209. void setHighlightObject(LLDrawable* obj) { mHighlightObject = obj; }
  210. void renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera& camera, LLCullResult& result, BOOL use_shader = TRUE, BOOL use_occlusion = TRUE);
  211. void generateGI(LLCamera& camera, LLVector3& lightDir, std::vector<LLVector3>& vpc);
  212. void renderHighlights();
  213. void renderDebug();
  214. void renderForSelect(std::set<LLViewerObject*>& objects, BOOL render_transparent, const LLRect& screen_rect);
  215. void rebuildPools(); // Rebuild pools
  216. void findReferences(LLDrawable *drawablep); // Find the lists which have references to this object
  217. BOOL verify(); // Verify that all data in the pipeline is "correct"
  218. S32  getLightCount() const { return mLights.size(); }
  219. void calcNearbyLights(LLCamera& camera);
  220. void setupHWLights(LLDrawPool* pool);
  221. void setupAvatarLights(BOOL for_edit = FALSE);
  222. void enableLights(U32 mask);
  223. void enableLightsStatic();
  224. void enableLightsDynamic();
  225. void enableLightsAvatar();
  226. void enableLightsAvatarEdit(const LLColor4& color);
  227. void enableLightsFullbright(const LLColor4& color);
  228. void disableLights();
  229. void shiftObjects(const LLVector3 &offset);
  230. void setLight(LLDrawable *drawablep, BOOL is_light);
  231. void setActive(LLDrawable *drawablep, BOOL active);
  232. BOOL hasRenderBatches(const U32 type) const;
  233. LLCullResult::drawinfo_list_t::iterator beginRenderMap(U32 type);
  234. LLCullResult::drawinfo_list_t::iterator endRenderMap(U32 type);
  235. LLCullResult::sg_list_t::iterator beginAlphaGroups();
  236. LLCullResult::sg_list_t::iterator endAlphaGroups();
  237. void addTrianglesDrawn(S32 count);
  238. BOOL hasRenderType(const U32 type) const { return (type && (mRenderTypeMask & (1<<type))) ? TRUE : FALSE; }
  239. BOOL hasRenderDebugFeatureMask(const U32 mask) const { return (mRenderDebugFeatureMask & mask) ? TRUE : FALSE; }
  240. BOOL hasRenderDebugMask(const U32 mask) const { return (mRenderDebugMask & mask) ? TRUE : FALSE; }
  241. void setRenderTypeMask(const U32 mask) { mRenderTypeMask = mask; }
  242. U32  getRenderTypeMask() const { return mRenderTypeMask; }
  243. static void toggleRenderType(U32 type);
  244. // For UI control of render features
  245. static BOOL hasRenderTypeControl(void* data);
  246. static void toggleRenderDebug(void* data);
  247. static void toggleRenderDebugFeature(void* data);
  248. static void toggleRenderTypeControl(void* data);
  249. static BOOL toggleRenderTypeControlNegated(void* data);
  250. static BOOL toggleRenderDebugControl(void* data);
  251. static BOOL toggleRenderDebugFeatureControl(void* data);
  252. static void setRenderParticleBeacons(BOOL val);
  253. static void toggleRenderParticleBeacons(void* data);
  254. static BOOL getRenderParticleBeacons(void* data);
  255. static void setRenderSoundBeacons(BOOL val);
  256. static void toggleRenderSoundBeacons(void* data);
  257. static BOOL getRenderSoundBeacons(void* data);
  258. static void setRenderPhysicalBeacons(BOOL val);
  259. static void toggleRenderPhysicalBeacons(void* data);
  260. static BOOL getRenderPhysicalBeacons(void* data);
  261. static void setRenderScriptedBeacons(BOOL val);
  262. static void toggleRenderScriptedBeacons(void* data);
  263. static BOOL getRenderScriptedBeacons(void* data);
  264. static void setRenderScriptedTouchBeacons(BOOL val);
  265. static void toggleRenderScriptedTouchBeacons(void* data);
  266. static BOOL getRenderScriptedTouchBeacons(void* data);
  267. static void setRenderBeacons(BOOL val);
  268. static void toggleRenderBeacons(void* data);
  269. static BOOL getRenderBeacons(void* data);
  270. static void setRenderHighlights(BOOL val);
  271. static void toggleRenderHighlights(void* data);
  272. static BOOL getRenderHighlights(void* data);
  273. static void updateRenderDeferred();
  274. private:
  275. void unloadShaders();
  276. void addToQuickLookup( LLDrawPool* new_poolp );
  277. void removeFromQuickLookup( LLDrawPool* poolp );
  278. BOOL updateDrawableGeom(LLDrawable* drawable, BOOL priority);
  279. void assertInitializedDoError();
  280. bool assertInitialized() { const bool is_init = isInit(); if (!is_init) assertInitializedDoError(); return is_init; };
  281. public:
  282. enum {GPU_CLASS_MAX = 3 };
  283. enum LLRenderTypeMask
  284. {
  285. // Following are pool types (some are also object types)
  286. RENDER_TYPE_SKY = LLDrawPool::POOL_SKY,
  287. RENDER_TYPE_WL_SKY = LLDrawPool::POOL_WL_SKY,
  288. RENDER_TYPE_GROUND = LLDrawPool::POOL_GROUND,
  289. RENDER_TYPE_TERRAIN = LLDrawPool::POOL_TERRAIN,
  290. RENDER_TYPE_SIMPLE = LLDrawPool::POOL_SIMPLE,
  291. RENDER_TYPE_GRASS = LLDrawPool::POOL_GRASS,
  292. RENDER_TYPE_FULLBRIGHT = LLDrawPool::POOL_FULLBRIGHT,
  293. RENDER_TYPE_BUMP = LLDrawPool::POOL_BUMP,
  294. RENDER_TYPE_AVATAR = LLDrawPool::POOL_AVATAR,
  295. RENDER_TYPE_TREE = LLDrawPool::POOL_TREE,
  296. RENDER_TYPE_INVISIBLE = LLDrawPool::POOL_INVISIBLE,
  297. RENDER_TYPE_WATER = LLDrawPool::POOL_WATER,
  298.   RENDER_TYPE_ALPHA = LLDrawPool::POOL_ALPHA,
  299. RENDER_TYPE_GLOW = LLDrawPool::POOL_GLOW,
  300. RENDER_TYPE_PASS_SIMPLE  = LLRenderPass::PASS_SIMPLE,
  301. RENDER_TYPE_PASS_GRASS = LLRenderPass::PASS_GRASS,
  302. RENDER_TYPE_PASS_FULLBRIGHT = LLRenderPass::PASS_FULLBRIGHT,
  303. RENDER_TYPE_PASS_INVISIBLE = LLRenderPass::PASS_INVISIBLE,
  304. RENDER_TYPE_PASS_INVISI_SHINY = LLRenderPass::PASS_INVISI_SHINY,
  305. RENDER_TYPE_PASS_FULLBRIGHT_SHINY = LLRenderPass::PASS_FULLBRIGHT_SHINY,
  306. RENDER_TYPE_PASS_SHINY = LLRenderPass::PASS_SHINY,
  307. RENDER_TYPE_PASS_BUMP = LLRenderPass::PASS_BUMP,
  308. RENDER_TYPE_PASS_GLOW = LLRenderPass::PASS_GLOW,
  309. RENDER_TYPE_PASS_ALPHA = LLRenderPass::PASS_ALPHA,
  310. RENDER_TYPE_PASS_ALPHA_MASK = LLRenderPass::PASS_ALPHA_MASK,
  311. RENDER_TYPE_PASS_FULLBRIGHT_ALPHA_MASK = LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK,
  312. RENDER_TYPE_PASS_ALPHA_SHADOW = LLRenderPass::PASS_ALPHA_SHADOW,
  313. // Following are object types (only used in drawable mRenderType)
  314. RENDER_TYPE_HUD = LLRenderPass::NUM_RENDER_TYPES,
  315. RENDER_TYPE_VOLUME,
  316. RENDER_TYPE_PARTICLES,
  317. RENDER_TYPE_CLOUDS,
  318. RENDER_TYPE_HUD_PARTICLES
  319. };
  320. enum LLRenderDebugFeatureMask
  321. {
  322. RENDER_DEBUG_FEATURE_UI = 0x0001,
  323. RENDER_DEBUG_FEATURE_SELECTED = 0x0002,
  324. RENDER_DEBUG_FEATURE_HIGHLIGHTED = 0x0004,
  325. RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES = 0x0008,
  326. //  RENDER_DEBUG_FEATURE_HW_LIGHTING = 0x0010,
  327. RENDER_DEBUG_FEATURE_FLEXIBLE = 0x0010,
  328. RENDER_DEBUG_FEATURE_FOG = 0x0020,
  329. RENDER_DEBUG_FEATURE_FR_INFO = 0x0080,
  330. RENDER_DEBUG_FEATURE_FOOT_SHADOWS = 0x0100,
  331. };
  332. enum LLRenderDebugMask
  333. {
  334. RENDER_DEBUG_COMPOSITION = 0x0000001,
  335. RENDER_DEBUG_VERIFY = 0x0000002,
  336. RENDER_DEBUG_BBOXES = 0x0000004,
  337. RENDER_DEBUG_OCTREE = 0x0000008,
  338. RENDER_DEBUG_PICKING = 0x0000010,
  339. RENDER_DEBUG_OCCLUSION = 0x0000020,
  340. RENDER_DEBUG_POINTS = 0x0000040,
  341. RENDER_DEBUG_TEXTURE_PRIORITY = 0x0000080,
  342. RENDER_DEBUG_TEXTURE_AREA = 0x0000100,
  343. RENDER_DEBUG_FACE_AREA = 0x0000200,
  344. RENDER_DEBUG_PARTICLES = 0x0000400,
  345. RENDER_DEBUG_GLOW = 0x0000800,
  346. RENDER_DEBUG_TEXTURE_ANIM = 0x0001000,
  347. RENDER_DEBUG_LIGHTS = 0x0002000,
  348. RENDER_DEBUG_BATCH_SIZE = 0x0004000,
  349. RENDER_DEBUG_ALPHA_BINS = 0x0008000,
  350. RENDER_DEBUG_RAYCAST            = 0x0010000,
  351. RENDER_DEBUG_SHAME = 0x0020000,
  352. RENDER_DEBUG_SHADOW_FRUSTA = 0x0040000,
  353. RENDER_DEBUG_SCULPTED           = 0x0080000,
  354. RENDER_DEBUG_AVATAR_VOLUME      = 0x0100000,
  355. RENDER_DEBUG_BUILD_QUEUE = 0x0200000,
  356. RENDER_DEBUG_AGENT_TARGET       = 0x0400000,
  357. };
  358. public:
  359. LLSpatialPartition* getSpatialPartition(LLViewerObject* vobj);
  360. void updateCamera(BOOL reset = FALSE);
  361. LLVector3 mFlyCamPosition;
  362. LLQuaternion mFlyCamRotation;
  363. BOOL  mBackfaceCull;
  364. S32  mBatchCount;
  365. S32  mMatrixOpCount;
  366. S32  mTextureMatrixOps;
  367. S32  mMaxBatchSize;
  368. S32  mMinBatchSize;
  369. S32  mMeanBatchSize;
  370. S32  mTrianglesDrawn;
  371. S32  mNumVisibleNodes;
  372. S32  mVerticesRelit;
  373. S32  mLightingChanges;
  374. S32  mGeometryChanges;
  375. S32  mNumVisibleFaces;
  376. static S32 sCompiles;
  377. static BOOL sShowHUDAttachments;
  378. static BOOL sForceOldBakedUpload; // If true will not use capabilities to upload baked textures.
  379. static S32 sUseOcclusion;  // 0 = no occlusion, 1 = read only, 2 = read/write
  380. static BOOL sDelayVBUpdate;
  381. static BOOL sFastAlpha;
  382. static BOOL sDisableShaders; // if TRUE, rendering will be done without shaders
  383. static BOOL sRenderBump;
  384. static BOOL sUseFBO;
  385. static BOOL sUseFarClip;
  386. static BOOL sShadowRender;
  387. static BOOL sWaterReflections;
  388. static BOOL sDynamicLOD;
  389. static BOOL sPickAvatar;
  390. static BOOL sReflectionRender;
  391. static BOOL sImpostorRender;
  392. static BOOL sUnderWaterRender;
  393. static BOOL sRenderGlow;
  394. static BOOL sTextureBindTest;
  395. static BOOL sRenderFrameTest;
  396. static BOOL sRenderAttachedLights;
  397. static BOOL sRenderAttachedParticles;
  398. static BOOL sRenderDeferred;
  399. static S32 sVisibleLightCount;
  400. static F32 sMinRenderSize;
  401. //screen texture
  402. U32  mScreenWidth;
  403. U32  mScreenHeight;
  404. LLRenderTarget mScreen;
  405. LLRenderTarget mUIScreen;
  406. LLRenderTarget mDeferredScreen;
  407. LLRenderTarget mEdgeMap;
  408. LLRenderTarget mDeferredDepth;
  409. LLRenderTarget mDeferredLight[3];
  410. LLMultisampleBuffer mSampleBuffer;
  411. LLRenderTarget mGIMap;
  412. LLRenderTarget mGIMapPost[2];
  413. LLRenderTarget mLuminanceMap;
  414. LLRenderTarget mHighlight;
  415. //sun shadow map
  416. LLRenderTarget mShadow[6];
  417. std::vector<LLVector3> mShadowFrustPoints[4];
  418. LLVector4 mShadowError;
  419. LLVector4 mShadowFOV;
  420. LLVector3 mShadowFrustOrigin[4];
  421. LLCamera mShadowCamera[8];
  422. LLVector3 mShadowExtents[4][2];
  423. glh::matrix4f mSunShadowMatrix[6];
  424. glh::matrix4f mShadowModelview[6];
  425. glh::matrix4f mShadowProjection[6];
  426. glh::matrix4f mGIMatrix;
  427. glh::matrix4f mGIMatrixProj;
  428. glh::matrix4f mGIModelview;
  429. glh::matrix4f mGIProjection;
  430. glh::matrix4f mGINormalMatrix;
  431. glh::matrix4f mGIInvProj;
  432. LLVector2 mGIRange;
  433. F32 mGILightRadius;
  434. LLPointer<LLDrawable> mShadowSpotLight[2];
  435. F32 mSpotLightFade[2];
  436. LLPointer<LLDrawable> mTargetShadowSpotLight[2];
  437. LLVector4 mSunClipPlanes;
  438. LLVector4 mSunOrthoClipPlanes;
  439. LLVector2 mScreenScale;
  440. //water reflection texture
  441. LLRenderTarget mWaterRef;
  442. //water distortion texture (refraction)
  443. LLRenderTarget mWaterDis;
  444. //texture for making the glow
  445. LLRenderTarget mGlow[3];
  446. //noise map
  447. U32 mNoiseMap;
  448. U32 mTrueNoiseMap;
  449. U32 mLightFunc;
  450. LLColor4 mSunDiffuse;
  451. LLVector3 mSunDir;
  452. BOOL mInitialized;
  453. BOOL mVertexShadersEnabled;
  454. S32 mVertexShadersLoaded; // 0 = no, 1 = yes, -1 = failed
  455. protected:
  456. U32 mRenderTypeMask;
  457. U32 mRenderDebugFeatureMask;
  458. U32 mRenderDebugMask;
  459. U32 mOldRenderDebugMask;
  460. /////////////////////////////////////////////
  461. //
  462. //
  463. LLDrawable::drawable_vector_t mMovedList;
  464. LLDrawable::drawable_vector_t mMovedBridge;
  465. LLDrawable::drawable_vector_t mShiftList;
  466. /////////////////////////////////////////////
  467. //
  468. //
  469. struct Light
  470. {
  471. Light(LLDrawable* ptr, F32 d, F32 f = 0.0f)
  472. : drawable(ptr),
  473.   dist(d),
  474.   fade(f)
  475. {}
  476. LLPointer<LLDrawable> drawable;
  477. F32 dist;
  478. F32 fade;
  479. struct compare
  480. {
  481. bool operator()(const Light& a, const Light& b) const
  482. {
  483. if ( a.dist < b.dist )
  484. return true;
  485. else if ( a.dist > b.dist )
  486. return false;
  487. else
  488. return a.drawable < b.drawable;
  489. }
  490. };
  491. };
  492. typedef std::set< Light, Light::compare > light_set_t;
  493. LLDrawable::drawable_set_t mLights;
  494. light_set_t mNearbyLights; // lights near camera
  495. LLColor4 mHWLightColors[8];
  496. /////////////////////////////////////////////
  497. //
  498. // Different queues of drawables being processed.
  499. //
  500. LLDrawable::drawable_list_t  mBuildQ1; // priority
  501. LLDrawable::drawable_list_t  mBuildQ2; // non-priority
  502. LLSpatialGroup::sg_list_t mGroupQ1; //priority
  503. LLSpatialGroup::sg_vector_t mGroupQ2; // non-priority
  504. LLViewerObject::vobj_list_t mCreateQ;
  505. LLDrawable::drawable_set_t mActiveQ;
  506. LLDrawable::drawable_set_t mRetexturedList;
  507. class HighlightItem
  508. {
  509. public:
  510. const LLPointer<LLDrawable> mItem;
  511. mutable F32 mFade;
  512. HighlightItem(LLDrawable* item)
  513. : mItem(item), mFade(0)
  514. {
  515. }
  516. bool operator<(const HighlightItem& rhs) const
  517. {
  518. return mItem < rhs.mItem;
  519. }
  520. bool operator==(const HighlightItem& rhs) const
  521. {
  522. return mItem == rhs.mItem;
  523. }
  524. void incrFade(F32 val) const
  525. {
  526. mFade = llclamp(mFade+val, 0.f, 1.f);
  527. }
  528. };
  529. std::set<HighlightItem> mHighlightSet;
  530. LLPointer<LLDrawable> mHighlightObject;
  531. //////////////////////////////////////////////////
  532. //
  533. // Draw pools are responsible for storing all rendered data,
  534. // and performing the actual rendering of objects.
  535. //
  536. struct compare_pools
  537. {
  538. bool operator()(const LLDrawPool* a, const LLDrawPool* b) const
  539. {
  540. if (!a)
  541. return true;
  542. else if (!b)
  543. return false;
  544. else
  545. {
  546. S32 atype = a->getType();
  547. S32 btype = b->getType();
  548. if (atype < btype)
  549. return true;
  550. else if (atype > btype)
  551. return false;
  552. else
  553. return a->getId() < b->getId();
  554. }
  555. }
  556. };
  557.   typedef std::set<LLDrawPool*, compare_pools > pool_set_t;
  558. pool_set_t mPools;
  559. LLDrawPool* mLastRebuildPool;
  560. // For quick-lookups into mPools (mapped by texture pointer)
  561. std::map<uintptr_t, LLDrawPool*> mTerrainPools;
  562. std::map<uintptr_t, LLDrawPool*> mTreePools;
  563. LLDrawPool* mAlphaPool;
  564. LLDrawPool* mSkyPool;
  565. LLDrawPool* mTerrainPool;
  566. LLDrawPool* mWaterPool;
  567. LLDrawPool* mGroundPool;
  568. LLRenderPass* mSimplePool;
  569. LLRenderPass* mGrassPool;
  570. LLRenderPass* mFullbrightPool;
  571. LLDrawPool* mInvisiblePool;
  572. LLDrawPool* mGlowPool;
  573. LLDrawPool* mBumpPool;
  574. LLDrawPool* mWLSkyPool;
  575. // Note: no need to keep an quick-lookup to avatar pools, since there's only one per avatar
  576. public:
  577. std::vector<LLFace*> mHighlightFaces; // highlight faces on physical objects
  578. protected:
  579. std::vector<LLFace*> mSelectedFaces;
  580. LLPointer<LLViewerFetchedTexture> mFaceSelectImagep;
  581. U32 mLightMask;
  582. U32 mLightMovingMask;
  583. S32 mLightingDetail;
  584. static BOOL sRenderPhysicalBeacons;
  585. static BOOL sRenderScriptedTouchBeacons;
  586. static BOOL sRenderScriptedBeacons;
  587. static BOOL sRenderParticleBeacons;
  588. static BOOL sRenderSoundBeacons;
  589. public:
  590. static BOOL sRenderBeacons;
  591. static BOOL sRenderHighlight;
  592. };
  593. void render_bbox(const LLVector3 &min, const LLVector3 &max);
  594. void render_hud_elements();
  595. extern LLPipeline gPipeline;
  596. extern BOOL gRenderForSelect;
  597. extern BOOL gDebugPipeline;
  598. extern const LLMatrix4* gGLLastMatrix;
  599. #endif