diff options
Diffstat (limited to 'linden/indra/newview/pipeline.h')
-rw-r--r-- | linden/indra/newview/pipeline.h | 222 |
1 files changed, 35 insertions, 187 deletions
diff --git a/linden/indra/newview/pipeline.h b/linden/indra/newview/pipeline.h index 158c420..a8c92cc 100644 --- a/linden/indra/newview/pipeline.h +++ b/linden/indra/newview/pipeline.h | |||
@@ -4,6 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | 5 | * Copyright (c) 2001-2007, Linden Research, Inc. |
6 | * | 6 | * |
7 | * Second Life Viewer Source Code | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | 8 | * The source code in this file ("Source Code") is provided by Linden Lab |
8 | * to you under the terms of the GNU General Public License, version 2.0 | 9 | * to you under the terms of the GNU General Public License, version 2.0 |
9 | * ("GPL"), unless you have obtained a separate licensing agreement | 10 | * ("GPL"), unless you have obtained a separate licensing agreement |
@@ -62,41 +63,6 @@ bool LLRayAABB(const LLVector3 ¢er, const LLVector3 &size, const LLVector3& | |||
62 | BOOL LLLineSegmentAABB(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size); | 63 | BOOL LLLineSegmentAABB(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size); |
63 | BOOL setup_hud_matrices(BOOL for_select); | 64 | BOOL setup_hud_matrices(BOOL for_select); |
64 | 65 | ||
65 | class LLGLSLShader | ||
66 | { | ||
67 | public: | ||
68 | LLGLSLShader(); | ||
69 | |||
70 | void unload(); | ||
71 | void attachObject(GLhandleARB object); | ||
72 | void attachObjects(GLhandleARB* objects = NULL, S32 count = 0); | ||
73 | BOOL mapAttributes(const char** attrib_names = NULL, S32 count = 0); | ||
74 | BOOL mapUniforms(const char** uniform_names = NULL, S32 count = 0); | ||
75 | void mapUniform(GLint index, const char** uniform_names = NULL, S32 count = 0); | ||
76 | void vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); | ||
77 | void vertexAttrib4fv(U32 index, GLfloat* v); | ||
78 | |||
79 | GLint mapUniformTextureChannel(GLint location, GLenum type); | ||
80 | |||
81 | |||
82 | //enable/disable texture channel for specified uniform | ||
83 | //if given texture uniform is active in the shader, | ||
84 | //the corresponding channel will be active upon return | ||
85 | //returns channel texture is enabled in from [0-MAX) | ||
86 | S32 enableTexture(S32 uniform, S32 mode = GL_TEXTURE_2D); | ||
87 | S32 disableTexture(S32 uniform, S32 mode = GL_TEXTURE_2D); | ||
88 | |||
89 | BOOL link(BOOL suppress_errors = FALSE); | ||
90 | void bind(); | ||
91 | void unbind(); | ||
92 | |||
93 | GLhandleARB mProgramObject; | ||
94 | std::vector<GLint> mAttribute; | ||
95 | std::vector<GLint> mUniform; | ||
96 | std::vector<GLint> mTexture; | ||
97 | S32 mActiveTextureChannels; | ||
98 | }; | ||
99 | |||
100 | class LLPipeline | 66 | class LLPipeline |
101 | { | 67 | { |
102 | public: | 68 | public: |
@@ -106,10 +72,13 @@ public: | |||
106 | void destroyGL(); | 72 | void destroyGL(); |
107 | void restoreGL(); | 73 | void restoreGL(); |
108 | void resetVertexBuffers(); | 74 | void resetVertexBuffers(); |
75 | void releaseGLBuffers(); | ||
109 | void resetVertexBuffers(LLDrawable* drawable); | 76 | void resetVertexBuffers(LLDrawable* drawable); |
110 | void setUseVBO(BOOL use_vbo); | 77 | void setUseVBO(BOOL use_vbo); |
111 | void generateReflectionMap(LLCubeMap* cube_map, LLCamera& camera, GLsizei res); | 78 | void generateReflectionMap(LLCubeMap* cube_map, LLCamera& camera, GLsizei res); |
112 | void blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out, U32 res); | 79 | void blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out, U32 res); |
80 | void bindScreenToTexture(); | ||
81 | void renderBloom(GLuint source, GLuint dest, GLuint buffer, U32 res, LLVector2 tc1, LLVector2 tc2); | ||
113 | 82 | ||
114 | void init(); | 83 | void init(); |
115 | void cleanup(); | 84 | void cleanup(); |
@@ -164,17 +133,7 @@ public: | |||
164 | void setUseVertexShaders(BOOL use_shaders); | 133 | void setUseVertexShaders(BOOL use_shaders); |
165 | BOOL getUseVertexShaders() const { return mVertexShadersEnabled; } | 134 | BOOL getUseVertexShaders() const { return mVertexShadersEnabled; } |
166 | BOOL canUseVertexShaders(); | 135 | BOOL canUseVertexShaders(); |
167 | BOOL setVertexShaderLevel(S32 type, S32 level); | ||
168 | S32 getVertexShaderLevel(S32 type) const { return mVertexShaderLevel[type]; } | ||
169 | S32 getMaxVertexShaderLevel(S32 type) const { return mMaxVertexShaderLevel[type]; } | ||
170 | |||
171 | void setShaders(); | ||
172 | 136 | ||
173 | void dumpObjectLog(GLhandleARB ret, BOOL warns = TRUE); | ||
174 | BOOL linkProgramObject(GLhandleARB obj, BOOL suppress_errors = FALSE); | ||
175 | BOOL validateProgramObject(GLhandleARB obj); | ||
176 | GLhandleARB loadShader(const LLString& filename, S32 cls, GLenum type); | ||
177 | |||
178 | // phases | 137 | // phases |
179 | void resetFrameStats(); | 138 | void resetFrameStats(); |
180 | 139 | ||
@@ -214,7 +173,7 @@ public: | |||
214 | S32 getVisibleCount() const { return mVisibleList.size(); } | 173 | S32 getVisibleCount() const { return mVisibleList.size(); } |
215 | S32 getLightCount() const { return mLights.size(); } | 174 | S32 getLightCount() const { return mLights.size(); } |
216 | 175 | ||
217 | void calcNearbyLights(); | 176 | void calcNearbyLights(LLCamera& camera); |
218 | void setupHWLights(LLDrawPool* pool); | 177 | void setupHWLights(LLDrawPool* pool); |
219 | void setupAvatarLights(BOOL for_edit = FALSE); | 178 | void setupAvatarLights(BOOL for_edit = FALSE); |
220 | void enableLights(U32 mask, F32 shadow_factor); | 179 | void enableLights(U32 mask, F32 shadow_factor); |
@@ -264,11 +223,6 @@ private: | |||
264 | void initShaders(BOOL force); | 223 | void initShaders(BOOL force); |
265 | void unloadShaders(); | 224 | void unloadShaders(); |
266 | BOOL loadShaders(); | 225 | BOOL loadShaders(); |
267 | BOOL loadShadersLighting(); | ||
268 | BOOL loadShadersObject(); | ||
269 | BOOL loadShadersAvatar(); | ||
270 | BOOL loadShadersEnvironment(); | ||
271 | BOOL loadShadersInterface(); | ||
272 | void saveVertexShaderLevel(S32 type, S32 level, S32 max); | 226 | void saveVertexShaderLevel(S32 type, S32 level, S32 max); |
273 | void addToQuickLookup( LLDrawPool* new_poolp ); | 227 | void addToQuickLookup( LLDrawPool* new_poolp ); |
274 | void removeFromQuickLookup( LLDrawPool* poolp ); | 228 | void removeFromQuickLookup( LLDrawPool* poolp ); |
@@ -276,15 +230,7 @@ private: | |||
276 | 230 | ||
277 | public: | 231 | public: |
278 | enum {GPU_CLASS_MAX = 3 }; | 232 | enum {GPU_CLASS_MAX = 3 }; |
279 | enum EShaderClass | 233 | |
280 | { | ||
281 | SHADER_LIGHTING, | ||
282 | SHADER_OBJECT, | ||
283 | SHADER_AVATAR, | ||
284 | SHADER_ENVIRONMENT, | ||
285 | SHADER_INTERFACE, | ||
286 | SHADER_COUNT | ||
287 | }; | ||
288 | enum LLRenderTypeMask | 234 | enum LLRenderTypeMask |
289 | { | 235 | { |
290 | // Following are pool types (some are also object types) | 236 | // Following are pool types (some are also object types) |
@@ -298,6 +244,8 @@ public: | |||
298 | RENDER_TYPE_TREE = LLDrawPool::POOL_TREE, | 244 | RENDER_TYPE_TREE = LLDrawPool::POOL_TREE, |
299 | RENDER_TYPE_WATER = LLDrawPool::POOL_WATER, | 245 | RENDER_TYPE_WATER = LLDrawPool::POOL_WATER, |
300 | RENDER_TYPE_ALPHA = LLDrawPool::POOL_ALPHA, | 246 | RENDER_TYPE_ALPHA = LLDrawPool::POOL_ALPHA, |
247 | RENDER_TYPE_GLOW = LLDrawPool::POOL_GLOW, | ||
248 | |||
301 | // Following are object types (only used in drawable mRenderType) | 249 | // Following are object types (only used in drawable mRenderType) |
302 | RENDER_TYPE_HUD = LLDrawPool::NUM_POOL_TYPES, | 250 | RENDER_TYPE_HUD = LLDrawPool::NUM_POOL_TYPES, |
303 | RENDER_TYPE_VOLUME, | 251 | RENDER_TYPE_VOLUME, |
@@ -344,7 +292,8 @@ public: | |||
344 | RENDER_DEBUG_TEXTURE_AREA = 0x08000, | 292 | RENDER_DEBUG_TEXTURE_AREA = 0x08000, |
345 | RENDER_DEBUG_FACE_AREA = 0x10000, | 293 | RENDER_DEBUG_FACE_AREA = 0x10000, |
346 | RENDER_DEBUG_PARTICLES = 0x20000, | 294 | RENDER_DEBUG_PARTICLES = 0x20000, |
347 | RENDER_DEBUG_TEXTURE_ANIM = 0x40000, | 295 | RENDER_DEBUG_GLOW = 0x40000, |
296 | RENDER_DEBUG_TEXTURE_ANIM = 0x80000, | ||
348 | }; | 297 | }; |
349 | 298 | ||
350 | LLPointer<LLViewerImage> mAlphaSizzleImagep; | 299 | LLPointer<LLViewerImage> mAlphaSizzleImagep; |
@@ -372,6 +321,11 @@ public: | |||
372 | LLSpatialPartition* getSpatialPartition(LLViewerObject* vobj); | 321 | LLSpatialPartition* getSpatialPartition(LLViewerObject* vobj); |
373 | LLSpatialPartition* getSpatialPartition(U32 index); | 322 | LLSpatialPartition* getSpatialPartition(U32 index); |
374 | 323 | ||
324 | void updateCamera(BOOL reset = FALSE); | ||
325 | |||
326 | LLVector3 mFlyCamPosition; | ||
327 | LLQuaternion mFlyCamRotation; | ||
328 | |||
375 | BOOL mBackfaceCull; | 329 | BOOL mBackfaceCull; |
376 | S32 mTrianglesDrawn; | 330 | S32 mTrianglesDrawn; |
377 | LLStat mTrianglesDrawnStat; | 331 | LLStat mTrianglesDrawnStat; |
@@ -395,135 +349,29 @@ public: | |||
395 | static BOOL sUseOcclusion; | 349 | static BOOL sUseOcclusion; |
396 | static BOOL sSkipUpdate; //skip lod updates | 350 | static BOOL sSkipUpdate; //skip lod updates |
397 | static BOOL sDynamicReflections; | 351 | static BOOL sDynamicReflections; |
352 | static BOOL sRenderGlow; | ||
398 | 353 | ||
399 | //cube map for anti-aliasing reflections | 354 | //screen texture |
400 | LLCubeMap* mCubeBuffer; | 355 | GLuint mScreenTex; |
401 | GLuint mCubeList; | 356 | LLVector2 mScreenScale; |
402 | 357 | ||
403 | class LLScatterShader | 358 | //texture for making the glow |
404 | { | 359 | GLuint mGlowMap; |
405 | public: | 360 | GLuint mGlowBuffer; |
406 | static void init(GLhandleARB shader, int map_stage); | ||
407 | }; | ||
408 | |||
409 | //utility shader objects (not shader programs) | ||
410 | GLhandleARB mLightVertex; | ||
411 | GLhandleARB mLightFragment; | ||
412 | GLhandleARB mScatterVertex; | ||
413 | GLhandleARB mScatterFragment; | ||
414 | |||
415 | //global (reserved slot) shader parameters | ||
416 | static const char* sReservedAttribs[]; | ||
417 | static U32 sReservedAttribCount; | ||
418 | 361 | ||
419 | typedef enum | 362 | //framebuffer objects for off-screen scratch space |
420 | { | 363 | GLuint mFramebuffer[2]; |
421 | GLSL_MATERIAL_COLOR = 0, | ||
422 | GLSL_SPECULAR_COLOR, | ||
423 | GLSL_BINORMAL, | ||
424 | GLSL_END_RESERVED_ATTRIBS | ||
425 | } eGLSLReservedAttribs; | ||
426 | |||
427 | static const char* sReservedUniforms[]; | ||
428 | static U32 sReservedUniformCount; | ||
429 | |||
430 | typedef enum | ||
431 | { | ||
432 | GLSL_DIFFUSE_MAP = 0, | ||
433 | GLSL_SPECULAR_MAP, | ||
434 | GLSL_BUMP_MAP, | ||
435 | GLSL_ENVIRONMENT_MAP, | ||
436 | GLSL_END_RESERVED_UNIFORMS | ||
437 | } eGLSLReservedUniforms; | ||
438 | 364 | ||
439 | static const char* sShinyUniforms[]; | 365 | //dynamic cube map scratch space |
440 | static U32 sShinyUniformCount; | 366 | LLCubeMap* mCubeBuffer; |
441 | |||
442 | typedef enum | ||
443 | { | ||
444 | GLSL_SHINY_ORIGIN = GLSL_END_RESERVED_UNIFORMS | ||
445 | } eShinyUniforms; | ||
446 | |||
447 | LLVector4 mShinyOrigin; | ||
448 | |||
449 | //object shaders | ||
450 | LLGLSLShader mObjectSimpleProgram; | ||
451 | LLGLSLShader mObjectAlphaProgram; | ||
452 | LLGLSLShader mObjectBumpProgram; | ||
453 | LLGLSLShader mObjectShinyProgram; | ||
454 | |||
455 | //water parameters | ||
456 | static const char* sWaterUniforms[]; | ||
457 | static U32 sWaterUniformCount; | ||
458 | |||
459 | typedef enum | ||
460 | { | ||
461 | GLSL_WATER_SCREENTEX = GLSL_END_RESERVED_UNIFORMS, | ||
462 | GLSL_WATER_EYEVEC, | ||
463 | GLSL_WATER_TIME, | ||
464 | GLSL_WATER_WAVE_DIR1, | ||
465 | GLSL_WATER_WAVE_DIR2, | ||
466 | GLSL_WATER_LIGHT_DIR, | ||
467 | GLSL_WATER_SPECULAR, | ||
468 | GLSL_WATER_SPECULAR_EXP, | ||
469 | GLSL_WATER_FBSCALE, | ||
470 | GLSL_WATER_REFSCALE | ||
471 | } eWaterUniforms; | ||
472 | |||
473 | |||
474 | //terrain parameters | ||
475 | static const char* sTerrainUniforms[]; | ||
476 | static U32 sTerrainUniformCount; | ||
477 | 367 | ||
478 | typedef enum | 368 | //frambuffer object for rendering dynamic cube maps |
479 | { | 369 | GLuint mCubeFrameBuffer; |
480 | GLSL_TERRAIN_DETAIL0 = GLSL_END_RESERVED_UNIFORMS, | ||
481 | GLSL_TERRAIN_DETAIL1, | ||
482 | GLSL_TERRAIN_ALPHARAMP | ||
483 | } eTerrainUniforms; | ||
484 | |||
485 | //environment shaders | ||
486 | LLGLSLShader mTerrainProgram; | ||
487 | LLGLSLShader mGroundProgram; | ||
488 | LLGLSLShader mWaterProgram; | ||
489 | |||
490 | //interface shaders | ||
491 | LLGLSLShader mHighlightProgram; | ||
492 | 370 | ||
493 | //avatar shader parameter tables | 371 | //depth buffer object for rendering dynamic cube maps |
494 | static const char* sAvatarAttribs[]; | 372 | GLuint mCubeDepth; |
495 | static U32 sAvatarAttribCount; | ||
496 | |||
497 | typedef enum | ||
498 | { | ||
499 | GLSL_AVATAR_WEIGHT = GLSL_END_RESERVED_ATTRIBS, | ||
500 | GLSL_AVATAR_CLOTHING, | ||
501 | GLSL_AVATAR_WIND, | ||
502 | GLSL_AVATAR_SINWAVE, | ||
503 | GLSL_AVATAR_GRAVITY | ||
504 | } eAvatarAttribs; | ||
505 | |||
506 | static const char* sAvatarUniforms[]; | ||
507 | static U32 sAvatarUniformCount; | ||
508 | |||
509 | typedef enum | ||
510 | { | ||
511 | GLSL_AVATAR_MATRIX = GLSL_END_RESERVED_UNIFORMS | ||
512 | } eAvatarUniforms; | ||
513 | |||
514 | //avatar skinning utility shader object | ||
515 | GLhandleARB mAvatarSkinVertex; | ||
516 | 373 | ||
517 | //avatar shader handles | ||
518 | LLGLSLShader mAvatarProgram; | ||
519 | LLGLSLShader mAvatarEyeballProgram; | ||
520 | LLGLSLShader mAvatarPickProgram; | ||
521 | 374 | ||
522 | //current avatar shader parameter pointer | ||
523 | GLint mAvatarMatrixParam; | ||
524 | GLint mMaterialIndex; | ||
525 | GLint mSpecularIndex; | ||
526 | |||
527 | LLColor4 mSunDiffuse; | 375 | LLColor4 mSunDiffuse; |
528 | LLVector3 mSunDir; | 376 | LLVector3 mSunDir; |
529 | 377 | ||
@@ -535,13 +383,12 @@ public: | |||
535 | LLSpatialGroup::sg_vector_t mDrawableGroups; | 383 | LLSpatialGroup::sg_vector_t mDrawableGroups; |
536 | 384 | ||
537 | void clearRenderMap(); | 385 | void clearRenderMap(); |
538 | 386 | ||
539 | protected: | 387 | BOOL mInitialized; |
540 | BOOL mVertexShadersEnabled; | 388 | BOOL mVertexShadersEnabled; |
541 | S32 mVertexShadersLoaded; // 0 = no, 1 = yes, -1 = failed | 389 | S32 mVertexShadersLoaded; // 0 = no, 1 = yes, -1 = failed |
542 | S32 mVertexShaderLevel[SHADER_COUNT]; | 390 | |
543 | S32 mMaxVertexShaderLevel[SHADER_COUNT]; | 391 | protected: |
544 | |||
545 | U32 mRenderTypeMask; | 392 | U32 mRenderTypeMask; |
546 | U32 mRenderFeatureMask; | 393 | U32 mRenderFeatureMask; |
547 | U32 mRenderDebugFeatureMask; | 394 | U32 mRenderDebugFeatureMask; |
@@ -643,6 +490,7 @@ protected: | |||
643 | LLDrawPool* mWaterPool; | 490 | LLDrawPool* mWaterPool; |
644 | LLDrawPool* mGroundPool; | 491 | LLDrawPool* mGroundPool; |
645 | LLRenderPass* mSimplePool; | 492 | LLRenderPass* mSimplePool; |
493 | LLDrawPool* mGlowPool; | ||
646 | LLDrawPool* mBumpPool; | 494 | LLDrawPool* mBumpPool; |
647 | // Note: no need to keep an quick-lookup to avatar pools, since there's only one per avatar | 495 | // Note: no need to keep an quick-lookup to avatar pools, since there's only one per avatar |
648 | 496 | ||