diff options
author | Jacek Antonelli | 2009-01-11 16:10:39 -0600 |
---|---|---|
committer | Jacek Antonelli | 2009-01-11 16:10:43 -0600 |
commit | a87e38229921b48c32187c672a942516722f1b52 (patch) | |
tree | 9e1dc0bc2318a9c6fa454bdb6d873a6af0e0ce3c /linden/indra/llrender | |
parent | Second Life viewer sources 1.22.4-RC (diff) | |
download | meta-impy-a87e38229921b48c32187c672a942516722f1b52.zip meta-impy-a87e38229921b48c32187c672a942516722f1b52.tar.gz meta-impy-a87e38229921b48c32187c672a942516722f1b52.tar.bz2 meta-impy-a87e38229921b48c32187c672a942516722f1b52.tar.xz |
Second Life viewer sources 1.22.5-RC
Diffstat (limited to '')
31 files changed, 229 insertions, 120 deletions
diff --git a/linden/indra/llrender/llcubemap.cpp b/linden/indra/llrender/llcubemap.cpp index 878ae17..60215f0 100644 --- a/linden/indra/llrender/llcubemap.cpp +++ b/linden/indra/llrender/llcubemap.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2002-2008, Linden Research, Inc. | 7 | * Copyright (c) 2002-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llcubemap.h b/linden/indra/llrender/llcubemap.h index 15ca7db..8c83e6e 100644 --- a/linden/indra/llrender/llcubemap.h +++ b/linden/indra/llrender/llcubemap.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2002-2008, Linden Research, Inc. | 7 | * Copyright (c) 2002-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llfont.cpp b/linden/indra/llrender/llfont.cpp index bcd0aca..d7310bd 100644 --- a/linden/indra/llrender/llfont.cpp +++ b/linden/indra/llrender/llfont.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2002-2008, Linden Research, Inc. | 7 | * Copyright (c) 2002-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llfont.h b/linden/indra/llrender/llfont.h index 2054832..bce8d76 100644 --- a/linden/indra/llrender/llfont.h +++ b/linden/indra/llrender/llfont.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2002-2008, Linden Research, Inc. | 7 | * Copyright (c) 2002-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llfontgl.cpp b/linden/indra/llrender/llfontgl.cpp index 2705516..526f1a9 100644 --- a/linden/indra/llrender/llfontgl.cpp +++ b/linden/indra/llrender/llfontgl.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llfontgl.h b/linden/indra/llrender/llfontgl.h index 3f88e62..97bdd1a 100644 --- a/linden/indra/llrender/llfontgl.h +++ b/linden/indra/llrender/llfontgl.h | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 6 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
7 | * | 7 | * |
8 | * Copyright (c) 2001-2008, Linden Research, Inc. | 8 | * Copyright (c) 2001-2009, Linden Research, Inc. |
9 | * | 9 | * |
10 | * Second Life Viewer Source Code | 10 | * Second Life Viewer Source Code |
11 | * The source code in this file ("Source Code") is provided by Linden Lab | 11 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llgl.cpp b/linden/indra/llrender/llgl.cpp index 67d258e..a9cf073 100644 --- a/linden/indra/llrender/llgl.cpp +++ b/linden/indra/llrender/llgl.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llgl.h b/linden/indra/llrender/llgl.h index 8433348..011fd63 100644 --- a/linden/indra/llrender/llgl.h +++ b/linden/indra/llrender/llgl.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llgldbg.cpp b/linden/indra/llrender/llgldbg.cpp index 526215b..27b45a9 100644 --- a/linden/indra/llrender/llgldbg.cpp +++ b/linden/indra/llrender/llgldbg.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llgldbg.h b/linden/indra/llrender/llgldbg.h index 0e1c986..73ab7fc 100644 --- a/linden/indra/llrender/llgldbg.h +++ b/linden/indra/llrender/llgldbg.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llglheaders.h b/linden/indra/llrender/llglheaders.h index f047262..20a420b 100644 --- a/linden/indra/llrender/llglheaders.h +++ b/linden/indra/llrender/llglheaders.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llglimmediate.cpp b/linden/indra/llrender/llglimmediate.cpp index 9b60e49..bade1aa 100644 --- a/linden/indra/llrender/llglimmediate.cpp +++ b/linden/indra/llrender/llglimmediate.cpp | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 8 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
9 | * | 9 | * |
10 | * Copyright (c) 2001-2008, Linden Research, Inc. | 10 | * Copyright (c) 2001-2009, Linden Research, Inc. |
11 | * | 11 | * |
12 | * Second Life Viewer Source Code | 12 | * Second Life Viewer Source Code |
13 | * The source code in this file ("Source Code") is provided by Linden Lab | 13 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llglimmediate.h b/linden/indra/llrender/llglimmediate.h index cd2af8b..690abe0 100644 --- a/linden/indra/llrender/llglimmediate.h +++ b/linden/indra/llrender/llglimmediate.h | |||
@@ -12,7 +12,7 @@ | |||
12 | * | 12 | * |
13 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 13 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
14 | * | 14 | * |
15 | * Copyright (c) 2001-2008, Linden Research, Inc. | 15 | * Copyright (c) 2001-2009, Linden Research, Inc. |
16 | * | 16 | * |
17 | * Second Life Viewer Source Code | 17 | * Second Life Viewer Source Code |
18 | * The source code in this file ("Source Code") is provided by Linden Lab | 18 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llglslshader.cpp b/linden/indra/llrender/llglslshader.cpp index 5d7375c..6683916 100644 --- a/linden/indra/llrender/llglslshader.cpp +++ b/linden/indra/llrender/llglslshader.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2005&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2005&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2005-2008, Linden Research, Inc. | 7 | * Copyright (c) 2005-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llglslshader.h b/linden/indra/llrender/llglslshader.h index cd787cc..66c53df 100644 --- a/linden/indra/llrender/llglslshader.h +++ b/linden/indra/llrender/llglslshader.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llglstates.h b/linden/indra/llrender/llglstates.h index bb8b8df..94d136e 100644 --- a/linden/indra/llrender/llglstates.h +++ b/linden/indra/llrender/llglstates.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llgltypes.h b/linden/indra/llrender/llgltypes.h index d22d5fa..5809b9c 100644 --- a/linden/indra/llrender/llgltypes.h +++ b/linden/indra/llrender/llgltypes.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2006&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2006&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2006-2008, Linden Research, Inc. | 7 | * Copyright (c) 2006-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llimagegl.cpp b/linden/indra/llrender/llimagegl.cpp index 9a392d7..8195eee 100644 --- a/linden/indra/llrender/llimagegl.cpp +++ b/linden/indra/llrender/llimagegl.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -61,8 +61,56 @@ S32 LLImageGL::sCount = 0; | |||
61 | BOOL LLImageGL::sGlobalUseAnisotropic = FALSE; | 61 | BOOL LLImageGL::sGlobalUseAnisotropic = FALSE; |
62 | F32 LLImageGL::sLastFrameTime = 0.f; | 62 | F32 LLImageGL::sLastFrameTime = 0.f; |
63 | 63 | ||
64 | S32 LLImageGL::sMaxTextureSize = 0 ; | ||
65 | |||
64 | std::set<LLImageGL*> LLImageGL::sImageList; | 66 | std::set<LLImageGL*> LLImageGL::sImageList; |
65 | 67 | ||
68 | //************************************************************************************** | ||
69 | //below are functions for debug use | ||
70 | //do not delete them even though they are not currently being used. | ||
71 | void check_all_images() | ||
72 | { | ||
73 | for (std::set<LLImageGL*>::iterator iter = LLImageGL::sImageList.begin(); | ||
74 | iter != LLImageGL::sImageList.end(); iter++) | ||
75 | { | ||
76 | LLImageGL* glimage = *iter; | ||
77 | if (glimage->getTexName() && glimage->isGLTextureCreated()) | ||
78 | { | ||
79 | gGL.getTexUnit(0)->bind(glimage) ; | ||
80 | glimage->checkTexSize() ; | ||
81 | gGL.getTexUnit(0)->unbind(glimage->getTarget()) ; | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | |||
86 | void LLImageGL::checkTexSize() const | ||
87 | { | ||
88 | if (gDebugGL && mTarget == GL_TEXTURE_2D) | ||
89 | { | ||
90 | GLint texname; | ||
91 | glGetIntegerv(GL_TEXTURE_BINDING_2D, &texname); | ||
92 | if (texname != mTexName) | ||
93 | { | ||
94 | llerrs << "Invalid texture bound!" << llendl; | ||
95 | } | ||
96 | stop_glerror() ; | ||
97 | LLGLint x = 0, y = 0 ; | ||
98 | glGetTexLevelParameteriv(mTarget, 0, GL_TEXTURE_WIDTH, (GLint*)&x); | ||
99 | glGetTexLevelParameteriv(mTarget, 0, GL_TEXTURE_HEIGHT, (GLint*)&y) ; | ||
100 | stop_glerror() ; | ||
101 | if(!x || !y) | ||
102 | { | ||
103 | return ; | ||
104 | } | ||
105 | if(x != (mWidth >> mCurrentDiscardLevel) || y != (mHeight >> mCurrentDiscardLevel)) | ||
106 | { | ||
107 | llerrs << "wrong texture size and discard level!" << llendl ; | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | //end of debug functions | ||
112 | //************************************************************************************** | ||
113 | |||
66 | //---------------------------------------------------------------------------- | 114 | //---------------------------------------------------------------------------- |
67 | 115 | ||
68 | //static | 116 | //static |
@@ -148,17 +196,22 @@ void LLImageGL::destroyGL(BOOL save_state) | |||
148 | { | 196 | { |
149 | gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE); | 197 | gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE); |
150 | } | 198 | } |
199 | |||
151 | for (std::set<LLImageGL*>::iterator iter = sImageList.begin(); | 200 | for (std::set<LLImageGL*>::iterator iter = sImageList.begin(); |
152 | iter != sImageList.end(); iter++) | 201 | iter != sImageList.end(); iter++) |
153 | { | 202 | { |
154 | LLImageGL* glimage = *iter; | 203 | LLImageGL* glimage = *iter; |
155 | if (glimage->mTexName && glimage->mComponents) | 204 | if (glimage->mTexName) |
156 | { | 205 | { |
157 | if (save_state && glimage->isInitialized()) | 206 | if (save_state && glimage->isGLTextureCreated() && glimage->mComponents) |
158 | { | 207 | { |
159 | glimage->mSaveData = new LLImageRaw; | 208 | glimage->mSaveData = new LLImageRaw; |
160 | glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData, false); | 209 | if(!glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData, false)) |
210 | { | ||
211 | glimage->mSaveData = NULL ; | ||
212 | } | ||
161 | } | 213 | } |
214 | |||
162 | glimage->destroyGLTexture(); | 215 | glimage->destroyGLTexture(); |
163 | stop_glerror(); | 216 | stop_glerror(); |
164 | } | 217 | } |
@@ -172,9 +225,13 @@ void LLImageGL::restoreGL() | |||
172 | iter != sImageList.end(); iter++) | 225 | iter != sImageList.end(); iter++) |
173 | { | 226 | { |
174 | LLImageGL* glimage = *iter; | 227 | LLImageGL* glimage = *iter; |
175 | if (glimage->mSaveData.notNull() && glimage->mSaveData->getComponents()) | 228 | if(glimage->getTexName()) |
229 | { | ||
230 | llerrs << "tex name is not 0." << llendl ; | ||
231 | } | ||
232 | if (glimage->mSaveData.notNull()) | ||
176 | { | 233 | { |
177 | if (glimage->getComponents()) | 234 | if (glimage->getComponents() && glimage->mSaveData->getComponents()) |
178 | { | 235 | { |
179 | glimage->createGLTexture(glimage->mCurrentDiscardLevel, glimage->mSaveData); | 236 | glimage->createGLTexture(glimage->mCurrentDiscardLevel, glimage->mSaveData); |
180 | stop_glerror(); | 237 | stop_glerror(); |
@@ -282,7 +339,7 @@ void LLImageGL::init(BOOL usemipmaps) | |||
282 | mFormatSwapBytes = FALSE; | 339 | mFormatSwapBytes = FALSE; |
283 | mHasExplicitFormat = FALSE; | 340 | mHasExplicitFormat = FALSE; |
284 | 341 | ||
285 | mInitialized = true; | 342 | mGLTextureCreated = FALSE ; |
286 | } | 343 | } |
287 | 344 | ||
288 | void LLImageGL::cleanup() | 345 | void LLImageGL::cleanup() |
@@ -321,6 +378,16 @@ void LLImageGL::setSize(S32 width, S32 height, S32 ncomponents) | |||
321 | { | 378 | { |
322 | if (width != mWidth || height != mHeight || ncomponents != mComponents) | 379 | if (width != mWidth || height != mHeight || ncomponents != mComponents) |
323 | { | 380 | { |
381 | if(width > 1024 || height > 1024) | ||
382 | { | ||
383 | llwarns << "texture size is big: width: " << width << " height: " << height << llendl ; | ||
384 | if(!sMaxTextureSize) | ||
385 | { | ||
386 | glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint*)&sMaxTextureSize) ; | ||
387 | } | ||
388 | llwarns << "max texture size is: " << sMaxTextureSize << llendl ; | ||
389 | } | ||
390 | |||
324 | // Check if dimensions are a power of two! | 391 | // Check if dimensions are a power of two! |
325 | if (!checkSize(width,height)) | 392 | if (!checkSize(width,height)) |
326 | { | 393 | { |
@@ -644,7 +711,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) | |||
644 | mHasMipMaps = FALSE; | 711 | mHasMipMaps = FALSE; |
645 | } | 712 | } |
646 | stop_glerror(); | 713 | stop_glerror(); |
647 | mInitialized = true; | 714 | mGLTextureCreated = true; |
648 | } | 715 | } |
649 | 716 | ||
650 | BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height) | 717 | BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height) |
@@ -734,9 +801,8 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 | |||
734 | 801 | ||
735 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); | 802 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); |
736 | stop_glerror(); | 803 | stop_glerror(); |
737 | mInitialized = true; | 804 | mGLTextureCreated = true; |
738 | } | 805 | } |
739 | |||
740 | return TRUE; | 806 | return TRUE; |
741 | } | 807 | } |
742 | 808 | ||
@@ -751,7 +817,7 @@ BOOL LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_ | |||
751 | if (gGL.getTexUnit(0)->bind(this, true)) | 817 | if (gGL.getTexUnit(0)->bind(this, true)) |
752 | { | 818 | { |
753 | glCopyTexSubImage2D(GL_TEXTURE_2D, 0, fb_x, fb_y, x_pos, y_pos, width, height); | 819 | glCopyTexSubImage2D(GL_TEXTURE_2D, 0, fb_x, fb_y, x_pos, y_pos, width, height); |
754 | mInitialized = true; | 820 | mGLTextureCreated = true; |
755 | stop_glerror(); | 821 | stop_glerror(); |
756 | return TRUE; | 822 | return TRUE; |
757 | } | 823 | } |
@@ -761,6 +827,36 @@ BOOL LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_ | |||
761 | } | 827 | } |
762 | } | 828 | } |
763 | 829 | ||
830 | //create an empty GL texture: just create a texture name | ||
831 | //the texture is assiciate with some image by calling glTexImage outside LLImageGL | ||
832 | BOOL LLImageGL::createGLTexture() | ||
833 | { | ||
834 | if (gGLManager.mIsDisabled) | ||
835 | { | ||
836 | llwarns << "Trying to create a texture while GL is disabled!" << llendl; | ||
837 | return FALSE; | ||
838 | } | ||
839 | |||
840 | mGLTextureCreated = false ; //do not save this texture when gl is destroyed. | ||
841 | |||
842 | llassert(gGLManager.mInited); | ||
843 | stop_glerror(); | ||
844 | |||
845 | if(mTexName) | ||
846 | { | ||
847 | glDeleteTextures(1, (reinterpret_cast<GLuint*>(&mTexName))) ; | ||
848 | } | ||
849 | |||
850 | glGenTextures(1, (GLuint*)&mTexName); | ||
851 | stop_glerror(); | ||
852 | if (!mTexName) | ||
853 | { | ||
854 | llerrs << "LLImageGL::createGLTexture failed to make an empty texture" << llendl; | ||
855 | } | ||
856 | |||
857 | return TRUE ; | ||
858 | } | ||
859 | |||
764 | BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename/*=0*/) | 860 | BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename/*=0*/) |
765 | { | 861 | { |
766 | if (gGLManager.mIsDisabled) | 862 | if (gGLManager.mIsDisabled) |
@@ -768,6 +864,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S | |||
768 | llwarns << "Trying to create a texture while GL is disabled!" << llendl; | 864 | llwarns << "Trying to create a texture while GL is disabled!" << llendl; |
769 | return FALSE; | 865 | return FALSE; |
770 | } | 866 | } |
867 | mGLTextureCreated = false ; | ||
771 | llassert(gGLManager.mInited); | 868 | llassert(gGLManager.mInited); |
772 | stop_glerror(); | 869 | stop_glerror(); |
773 | 870 | ||
@@ -873,7 +970,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ | |||
873 | #endif | 970 | #endif |
874 | } | 971 | } |
875 | 972 | ||
876 | mCurrentDiscardLevel = discard_level; | 973 | mCurrentDiscardLevel = discard_level; |
877 | 974 | ||
878 | setImage(data_in, data_hasmips); | 975 | setImage(data_in, data_hasmips); |
879 | 976 | ||
@@ -974,7 +1071,7 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre | |||
974 | discard_level = mCurrentDiscardLevel; | 1071 | discard_level = mCurrentDiscardLevel; |
975 | } | 1072 | } |
976 | 1073 | ||
977 | if (mTexName == 0 || discard_level < mCurrentDiscardLevel) | 1074 | if (mTexName == 0 || discard_level < mCurrentDiscardLevel || discard_level > mMaxDiscardLevel ) |
978 | { | 1075 | { |
979 | return FALSE; | 1076 | return FALSE; |
980 | } | 1077 | } |
@@ -985,18 +1082,8 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre | |||
985 | gGL.getTexUnit(0)->unbind(mBindTarget); | 1082 | gGL.getTexUnit(0)->unbind(mBindTarget); |
986 | llverify(gGL.getTexUnit(0)->bind(this)); | 1083 | llverify(gGL.getTexUnit(0)->bind(this)); |
987 | 1084 | ||
988 | if (gDebugGL) | 1085 | //debug code, leave it there commented. |
989 | { | 1086 | //checkTexSize() ; |
990 | if (mTarget == GL_TEXTURE_2D) | ||
991 | { | ||
992 | GLint texname; | ||
993 | glGetIntegerv(GL_TEXTURE_BINDING_2D, &texname); | ||
994 | if (texname != mTexName) | ||
995 | { | ||
996 | llerrs << "Invalid texture bound!" << llendl; | ||
997 | } | ||
998 | } | ||
999 | } | ||
1000 | 1087 | ||
1001 | LLGLint glwidth = 0; | 1088 | LLGLint glwidth = 0; |
1002 | glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_WIDTH, (GLint*)&glwidth); | 1089 | glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_WIDTH, (GLint*)&glwidth); |
@@ -1005,7 +1092,7 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre | |||
1005 | // No mip data smaller than current discard level | 1092 | // No mip data smaller than current discard level |
1006 | return FALSE; | 1093 | return FALSE; |
1007 | } | 1094 | } |
1008 | 1095 | ||
1009 | S32 width = getWidth(discard_level); | 1096 | S32 width = getWidth(discard_level); |
1010 | S32 height = getHeight(discard_level); | 1097 | S32 height = getHeight(discard_level); |
1011 | S32 ncomponents = getComponents(); | 1098 | S32 ncomponents = getComponents(); |
@@ -1013,6 +1100,13 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre | |||
1013 | { | 1100 | { |
1014 | return FALSE; | 1101 | return FALSE; |
1015 | } | 1102 | } |
1103 | if(width < glwidth) | ||
1104 | { | ||
1105 | llwarns << "texture size is smaller than it should be." << llendl ; | ||
1106 | llwarns << "width: " << width << " glwidth: " << glwidth << " mWidth: " << mWidth << | ||
1107 | " mCurrentDiscardLevel: " << (S32)mCurrentDiscardLevel << " discard_level: " << (S32)discard_level << llendl ; | ||
1108 | return FALSE ; | ||
1109 | } | ||
1016 | 1110 | ||
1017 | if (width <= 0 || width > 2048 || height <= 0 || height > 2048 || ncomponents < 1 || ncomponents > 4) | 1111 | if (width <= 0 || width > 2048 || height <= 0 || height > 2048 || ncomponents < 1 || ncomponents > 4) |
1018 | { | 1112 | { |
@@ -1098,7 +1192,7 @@ void LLImageGL::destroyGLTexture() | |||
1098 | 1192 | ||
1099 | glDeleteTextures(1, (GLuint*)&mTexName); | 1193 | glDeleteTextures(1, (GLuint*)&mTexName); |
1100 | mTexName = 0; | 1194 | mTexName = 0; |
1101 | 1195 | mGLTextureCreated = FALSE ; | |
1102 | stop_glerror(); | 1196 | stop_glerror(); |
1103 | } | 1197 | } |
1104 | } | 1198 | } |
diff --git a/linden/indra/llrender/llimagegl.h b/linden/indra/llrender/llimagegl.h index dbe11da..e8c0a4a 100644 --- a/linden/indra/llrender/llimagegl.h +++ b/linden/indra/llrender/llimagegl.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -90,6 +90,7 @@ public: | |||
90 | 90 | ||
91 | void setSize(S32 width, S32 height, S32 ncomponents); | 91 | void setSize(S32 width, S32 height, S32 ncomponents); |
92 | 92 | ||
93 | BOOL createGLTexture() ; | ||
93 | BOOL createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename = 0); | 94 | BOOL createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename = 0); |
94 | BOOL createGLTexture(S32 discard_level, const U8* data, BOOL data_hasmips = FALSE, S32 usename = 0); | 95 | BOOL createGLTexture(S32 discard_level, const U8* data, BOOL data_hasmips = FALSE, S32 usename = 0); |
95 | void setImage(const LLImageRaw* imageraw); | 96 | void setImage(const LLImageRaw* imageraw); |
@@ -113,6 +114,8 @@ public: | |||
113 | S32 getDiscardLevel() const { return mCurrentDiscardLevel; } | 114 | S32 getDiscardLevel() const { return mCurrentDiscardLevel; } |
114 | S32 getMaxDiscardLevel() const { return mMaxDiscardLevel; } | 115 | S32 getMaxDiscardLevel() const { return mMaxDiscardLevel; } |
115 | 116 | ||
117 | S32 getCurrentWidth() const { return mWidth ;} | ||
118 | S32 getCurrentHeight() const { return mHeight ;} | ||
116 | S32 getWidth(S32 discard_level = -1) const; | 119 | S32 getWidth(S32 discard_level = -1) const; |
117 | S32 getHeight(S32 discard_level = -1) const; | 120 | S32 getHeight(S32 discard_level = -1) const; |
118 | U8 getComponents() const { return mComponents; } | 121 | U8 getComponents() const { return mComponents; } |
@@ -134,8 +137,8 @@ public: | |||
134 | void setTarget(const LLGLenum target, const LLTexUnit::eTextureType bind_target); | 137 | void setTarget(const LLGLenum target, const LLTexUnit::eTextureType bind_target); |
135 | 138 | ||
136 | LLTexUnit::eTextureType getTarget(void) const { return mBindTarget; } | 139 | LLTexUnit::eTextureType getTarget(void) const { return mBindTarget; } |
137 | bool isInitialized(void) const { return mInitialized; } | 140 | bool isGLTextureCreated(void) const { return mGLTextureCreated ; } |
138 | void setInitialized (bool initialized) { mInitialized = initialized; } | 141 | void setGLTextureCreated (bool initialized) { mGLTextureCreated = initialized; } |
139 | 142 | ||
140 | BOOL getUseMipMaps() const { return mUseMipMaps; } | 143 | BOOL getUseMipMaps() const { return mUseMipMaps; } |
141 | void setUseMipMaps(BOOL usemips) { mUseMipMaps = usemips; } | 144 | void setUseMipMaps(BOOL usemips) { mUseMipMaps = usemips; } |
@@ -147,6 +150,8 @@ public: | |||
147 | void updatePickMask(S32 width, S32 height, const U8* data_in); | 150 | void updatePickMask(S32 width, S32 height, const U8* data_in); |
148 | BOOL getMask(const LLVector2 &tc); | 151 | BOOL getMask(const LLVector2 &tc); |
149 | 152 | ||
153 | void checkTexSize() const ; | ||
154 | |||
150 | protected: | 155 | protected: |
151 | void init(BOOL usemipmaps); | 156 | void init(BOOL usemipmaps); |
152 | virtual void cleanup(); // Clean up the LLImageGL so it can be reinitialized. Be careful when using this in derived class destructors | 157 | virtual void cleanup(); // Clean up the LLImageGL so it can be reinitialized. Be careful when using this in derived class destructors |
@@ -164,21 +169,20 @@ private: | |||
164 | S8 mHasExplicitFormat; // If false (default), GL format is f(mComponents) | 169 | S8 mHasExplicitFormat; // If false (default), GL format is f(mComponents) |
165 | S8 mAutoGenMips; | 170 | S8 mAutoGenMips; |
166 | 171 | ||
172 | bool mGLTextureCreated ; | ||
173 | LLGLuint mTexName; | ||
174 | U16 mWidth; | ||
175 | U16 mHeight; | ||
176 | S8 mCurrentDiscardLevel; | ||
177 | |||
167 | protected: | 178 | protected: |
168 | LLGLenum mTarget; // Normally GL_TEXTURE2D, sometimes something else (ex. cube maps) | 179 | LLGLenum mTarget; // Normally GL_TEXTURE2D, sometimes something else (ex. cube maps) |
169 | LLTexUnit::eTextureType mBindTarget; // Normally TT_TEXTURE, sometimes something else (ex. cube maps) | 180 | LLTexUnit::eTextureType mBindTarget; // Normally TT_TEXTURE, sometimes something else (ex. cube maps) |
170 | bool mInitialized; | 181 | |
171 | |||
172 | LLGLuint mTexName; | ||
173 | |||
174 | LLGLboolean mIsResident; | 182 | LLGLboolean mIsResident; |
175 | |||
176 | U16 mWidth; | ||
177 | U16 mHeight; | ||
178 | 183 | ||
179 | S8 mComponents; | 184 | S8 mComponents; |
180 | S8 mMaxDiscardLevel; | 185 | S8 mMaxDiscardLevel; |
181 | S8 mCurrentDiscardLevel; | ||
182 | S8 mDontDiscard; // Keep full res version of this image (for UI, etc) | 186 | S8 mDontDiscard; // Keep full res version of this image (for UI, etc) |
183 | 187 | ||
184 | S8 mClampS; // Need to save clamp state | 188 | S8 mClampS; // Need to save clamp state |
@@ -209,6 +213,7 @@ public: | |||
209 | static U32 sUniqueCount; // Tracks number of unique texture binds for current frame | 213 | static U32 sUniqueCount; // Tracks number of unique texture binds for current frame |
210 | static BOOL sGlobalUseAnisotropic; | 214 | static BOOL sGlobalUseAnisotropic; |
211 | 215 | ||
216 | static S32 sMaxTextureSize ; | ||
212 | #if DEBUG_MISS | 217 | #if DEBUG_MISS |
213 | BOOL mMissed; // Missed on last bind? | 218 | BOOL mMissed; // Missed on last bind? |
214 | BOOL getMissed() const { return mMissed; }; | 219 | BOOL getMissed() const { return mMissed; }; |
diff --git a/linden/indra/llrender/llpostprocess.cpp b/linden/indra/llrender/llpostprocess.cpp index 0f1ad5c..92a0854 100644 --- a/linden/indra/llrender/llpostprocess.cpp +++ b/linden/indra/llrender/llpostprocess.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2007-2008, Linden Research, Inc. | 7 | * Copyright (c) 2007-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -51,12 +51,14 @@ static const float LUMINANCE_B = 0.114f; | |||
51 | static const char * const XML_FILENAME = "postprocesseffects.xml"; | 51 | static const char * const XML_FILENAME = "postprocesseffects.xml"; |
52 | 52 | ||
53 | LLPostProcess::LLPostProcess(void) : | 53 | LLPostProcess::LLPostProcess(void) : |
54 | sceneRenderTexture(0), noiseTexture(0), | ||
55 | tempBloomTexture(0), | ||
56 | initialized(false), | 54 | initialized(false), |
57 | mAllEffects(LLSD::emptyMap()), | 55 | mAllEffects(LLSD::emptyMap()), |
58 | screenW(1), screenH(1) | 56 | screenW(1), screenH(1) |
59 | { | 57 | { |
58 | mSceneRenderTexture = NULL ; | ||
59 | mNoiseTexture = NULL ; | ||
60 | mTempBloomTexture = NULL ; | ||
61 | |||
60 | /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. | 62 | /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. |
61 | std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); | 63 | std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); |
62 | LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL; | 64 | LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL; |
@@ -110,9 +112,7 @@ LLPostProcess::LLPostProcess(void) : | |||
110 | 112 | ||
111 | LLPostProcess::~LLPostProcess(void) | 113 | LLPostProcess::~LLPostProcess(void) |
112 | { | 114 | { |
113 | glDeleteTextures(1, &sceneRenderTexture); | 115 | invalidate() ; |
114 | glDeleteTextures(1, &noiseTexture); | ||
115 | glDeleteTextures(1, &tempBloomTexture); | ||
116 | } | 116 | } |
117 | 117 | ||
118 | // static | 118 | // static |
@@ -157,6 +157,13 @@ void LLPostProcess::saveEffect(std::string const & effectName) | |||
157 | formatter->format(mAllEffects, effectsXML); | 157 | formatter->format(mAllEffects, effectsXML); |
158 | */ | 158 | */ |
159 | } | 159 | } |
160 | void LLPostProcess::invalidate() | ||
161 | { | ||
162 | mSceneRenderTexture = NULL ; | ||
163 | mNoiseTexture = NULL ; | ||
164 | mTempBloomTexture = NULL ; | ||
165 | initialized = FALSE ; | ||
166 | } | ||
160 | 167 | ||
161 | void LLPostProcess::apply(unsigned int width, unsigned int height) | 168 | void LLPostProcess::apply(unsigned int width, unsigned int height) |
162 | { | 169 | { |
@@ -172,7 +179,7 @@ void LLPostProcess::initialize(unsigned int width, unsigned int height) | |||
172 | { | 179 | { |
173 | screenW = width; | 180 | screenW = width; |
174 | screenH = height; | 181 | screenH = height; |
175 | createTexture(sceneRenderTexture, screenW, screenH); | 182 | createTexture(mSceneRenderTexture, screenW, screenH); |
176 | initialized = true; | 183 | initialized = true; |
177 | 184 | ||
178 | checkError(); | 185 | checkError(); |
@@ -198,16 +205,20 @@ void LLPostProcess::applyShaders(void) | |||
198 | } | 205 | } |
199 | if (tweaks.useNightVisionShader()){ | 206 | if (tweaks.useNightVisionShader()){ |
200 | /// If any of the above shaders have been called update the frame buffer; | 207 | /// If any of the above shaders have been called update the frame buffer; |
201 | if (tweaks.useColorFilter()){ | 208 | if (tweaks.useColorFilter()) |
202 | copyFrameBuffer(sceneRenderTexture, screenW, screenH); | 209 | { |
210 | GLuint tex = mSceneRenderTexture->getTexName() ; | ||
211 | copyFrameBuffer(tex, screenW, screenH); | ||
203 | } | 212 | } |
204 | applyNightVisionShader(); | 213 | applyNightVisionShader(); |
205 | checkError(); | 214 | checkError(); |
206 | } | 215 | } |
207 | if (tweaks.useBloomShader()){ | 216 | if (tweaks.useBloomShader()){ |
208 | /// If any of the above shaders have been called update the frame buffer; | 217 | /// If any of the above shaders have been called update the frame buffer; |
209 | if (tweaks.useColorFilter().asBoolean() || tweaks.useNightVisionShader().asBoolean()){ | 218 | if (tweaks.useColorFilter().asBoolean() || tweaks.useNightVisionShader().asBoolean()) |
210 | copyFrameBuffer(sceneRenderTexture, screenW, screenH); | 219 | { |
220 | GLuint tex = mSceneRenderTexture->getTexName() ; | ||
221 | copyFrameBuffer(tex, screenW, screenH); | ||
211 | } | 222 | } |
212 | applyBloomShader(); | 223 | applyBloomShader(); |
213 | checkError(); | 224 | checkError(); |
@@ -305,7 +316,7 @@ void LLPostProcess::createNightVisionShader(void) | |||
305 | nightVisionUniforms["noiseStrength"] = 0; | 316 | nightVisionUniforms["noiseStrength"] = 0; |
306 | nightVisionUniforms["lumWeights"] = 0; | 317 | nightVisionUniforms["lumWeights"] = 0; |
307 | 318 | ||
308 | createNoiseTexture(noiseTexture); | 319 | createNoiseTexture(mNoiseTexture); |
309 | } | 320 | } |
310 | 321 | ||
311 | void LLPostProcess::applyBloomShader(void) | 322 | void LLPostProcess::applyBloomShader(void) |
@@ -315,7 +326,7 @@ void LLPostProcess::applyBloomShader(void) | |||
315 | 326 | ||
316 | void LLPostProcess::createBloomShader(void) | 327 | void LLPostProcess::createBloomShader(void) |
317 | { | 328 | { |
318 | createTexture(tempBloomTexture, unsigned(screenW * 0.5), unsigned(screenH * 0.5)); | 329 | createTexture(mTempBloomTexture, unsigned(screenW * 0.5), unsigned(screenH * 0.5)); |
319 | 330 | ||
320 | /// Create Bloom Extract Shader | 331 | /// Create Bloom Extract Shader |
321 | bloomExtractUniforms["RenderTexture"] = 0; | 332 | bloomExtractUniforms["RenderTexture"] = 0; |
@@ -347,7 +358,10 @@ void LLPostProcess::doEffects(void) | |||
347 | glPushClientAttrib(GL_ALL_ATTRIB_BITS); | 358 | glPushClientAttrib(GL_ALL_ATTRIB_BITS); |
348 | 359 | ||
349 | /// Copy the screen buffer to the render texture | 360 | /// Copy the screen buffer to the render texture |
350 | copyFrameBuffer(sceneRenderTexture, screenW, screenH); | 361 | { |
362 | GLuint tex = mSceneRenderTexture->getTexName() ; | ||
363 | copyFrameBuffer(tex, screenW, screenH); | ||
364 | } | ||
351 | 365 | ||
352 | /// Clear the frame buffer. | 366 | /// Clear the frame buffer. |
353 | glClearColor(0.0f, 0.0f, 0.0f, 1.0f); | 367 | glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
@@ -478,43 +492,42 @@ void LLPostProcess::changeOrthogonal(unsigned int width, unsigned int height) | |||
478 | viewOrthogonal(width, height); | 492 | viewOrthogonal(width, height); |
479 | } | 493 | } |
480 | 494 | ||
481 | void LLPostProcess::createTexture(GLuint & texture, unsigned int width, unsigned int height) | 495 | void LLPostProcess::createTexture(LLPointer<LLImageGL>& texture, unsigned int width, unsigned int height) |
482 | { | 496 | { |
483 | if (texture != 0){ | 497 | std::vector<GLubyte> data(width * height * 4, 0) ; |
484 | glDeleteTextures(1, &texture); | ||
485 | } | ||
486 | |||
487 | std::vector<GLubyte> data(width * height * 4, 0); | ||
488 | |||
489 | glGenTextures(1, &texture); | ||
490 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture); | ||
491 | glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, width, height, 0, | ||
492 | GL_RGBA, GL_UNSIGNED_BYTE, &data[0]); | ||
493 | glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_MIN_FILTER,GL_LINEAR); | ||
494 | glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_MAG_FILTER,GL_LINEAR); | ||
495 | glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | ||
496 | glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | ||
497 | } | ||
498 | 498 | ||
499 | void LLPostProcess::createNoiseTexture(GLuint & texture) | 499 | texture = new LLImageGL(FALSE) ; |
500 | { | 500 | if(texture->createGLTexture()) |
501 | if (texture != 0){ | 501 | { |
502 | glDeleteTextures(1, &texture); | 502 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture->getTexName()); |
503 | glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, width, height, 0, | ||
504 | GL_RGBA, GL_UNSIGNED_BYTE, &data[0]); | ||
505 | glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_MIN_FILTER,GL_LINEAR); | ||
506 | glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_MAG_FILTER,GL_LINEAR); | ||
507 | glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | ||
508 | glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | ||
503 | } | 509 | } |
504 | glGenTextures(1, &texture); | 510 | } |
505 | 511 | ||
512 | void LLPostProcess::createNoiseTexture(LLPointer<LLImageGL>& texture) | ||
513 | { | ||
506 | std::vector<GLubyte> buffer(NOISE_SIZE * NOISE_SIZE); | 514 | std::vector<GLubyte> buffer(NOISE_SIZE * NOISE_SIZE); |
507 | for (unsigned int i = 0; i < NOISE_SIZE; i++){ | 515 | for (unsigned int i = 0; i < NOISE_SIZE; i++){ |
508 | for (unsigned int k = 0; k < NOISE_SIZE; k++){ | 516 | for (unsigned int k = 0; k < NOISE_SIZE; k++){ |
509 | buffer[(i * NOISE_SIZE) + k] = (GLubyte)((double) rand() / ((double) RAND_MAX + 1.f) * 255.f); | 517 | buffer[(i * NOISE_SIZE) + k] = (GLubyte)((double) rand() / ((double) RAND_MAX + 1.f) * 255.f); |
510 | } | 518 | } |
511 | } | 519 | } |
512 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture); | 520 | |
513 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, NOISE_SIZE, NOISE_SIZE, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, &buffer[0]); | 521 | texture = new LLImageGL(FALSE) ; |
514 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR); | 522 | if(texture->createGLTexture()) |
515 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR); | 523 | { |
516 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); | 524 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture->getTexName()); |
517 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); | 525 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, NOISE_SIZE, NOISE_SIZE, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, &buffer[0]); |
526 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR); | ||
527 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR); | ||
528 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); | ||
529 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); | ||
530 | } | ||
518 | } | 531 | } |
519 | 532 | ||
520 | bool LLPostProcess::checkError(void) | 533 | bool LLPostProcess::checkError(void) |
diff --git a/linden/indra/llrender/llpostprocess.h b/linden/indra/llrender/llpostprocess.h index cd9f477..b191e9d 100644 --- a/linden/indra/llrender/llpostprocess.h +++ b/linden/indra/llrender/llpostprocess.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2007-2008, Linden Research, Inc. | 7 | * Copyright (c) 2007-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -183,21 +183,24 @@ public: | |||
183 | 183 | ||
184 | }; | 184 | }; |
185 | 185 | ||
186 | GLuint sceneRenderTexture; | ||
187 | GLuint noiseTexture; | ||
188 | GLuint tempBloomTexture; | ||
189 | bool initialized; | 186 | bool initialized; |
190 | PostProcessTweaks tweaks; | 187 | PostProcessTweaks tweaks; |
191 | 188 | ||
192 | // the map of all availible effects | 189 | // the map of all availible effects |
193 | LLSD mAllEffects; | 190 | LLSD mAllEffects; |
194 | 191 | ||
192 | private: | ||
193 | LLPointer<LLImageGL> mSceneRenderTexture ; | ||
194 | LLPointer<LLImageGL> mNoiseTexture ; | ||
195 | LLPointer<LLImageGL> mTempBloomTexture ; | ||
196 | |||
195 | public: | 197 | public: |
196 | LLPostProcess(void); | 198 | LLPostProcess(void); |
197 | 199 | ||
198 | ~LLPostProcess(void); | 200 | ~LLPostProcess(void); |
199 | 201 | ||
200 | void apply(unsigned int width, unsigned int height); | 202 | void apply(unsigned int width, unsigned int height); |
203 | void invalidate() ; | ||
201 | 204 | ||
202 | /// Perform global initialization for this class. | 205 | /// Perform global initialization for this class. |
203 | static void initClass(void); | 206 | static void initClass(void); |
@@ -251,9 +254,9 @@ private: | |||
251 | 254 | ||
252 | /// OpenGL Helper Functions | 255 | /// OpenGL Helper Functions |
253 | void getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog); | 256 | void getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog); |
254 | void createTexture(GLuint & texture, unsigned int width, unsigned int height); | 257 | void createTexture(LLPointer<LLImageGL>& texture, unsigned int width, unsigned int height); |
255 | void copyFrameBuffer(GLuint & texture, unsigned int width, unsigned int height); | 258 | void copyFrameBuffer(GLuint & texture, unsigned int width, unsigned int height); |
256 | void createNoiseTexture(GLuint & texture); | 259 | void createNoiseTexture(LLPointer<LLImageGL>& texture); |
257 | bool checkError(void); | 260 | bool checkError(void); |
258 | void checkShaderError(GLhandleARB shader); | 261 | void checkShaderError(GLhandleARB shader); |
259 | void drawOrthoQuad(unsigned int width, unsigned int height, QuadType type); | 262 | void drawOrthoQuad(unsigned int width, unsigned int height, QuadType type); |
diff --git a/linden/indra/llrender/llrender.cpp b/linden/indra/llrender/llrender.cpp index fcd76d4..ff0a2db 100644 --- a/linden/indra/llrender/llrender.cpp +++ b/linden/indra/llrender/llrender.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -186,17 +186,11 @@ bool LLTexUnit::bind(const LLImageGL* texture, bool forceBind) | |||
186 | llwarns << "NULL LLTexUnit::bind texture" << llendl; | 186 | llwarns << "NULL LLTexUnit::bind texture" << llendl; |
187 | return false; | 187 | return false; |
188 | } | 188 | } |
189 | 189 | ||
190 | if (!texture->isInitialized() && !forceBind) | ||
191 | { | ||
192 | return texture->bindDefaultImage(mIndex); | ||
193 | } | ||
194 | |||
195 | if (!texture->getTexName()) //if texture does not exist | 190 | if (!texture->getTexName()) //if texture does not exist |
196 | { | 191 | { |
197 | return texture->bindDefaultImage(mIndex); | 192 | return texture->bindDefaultImage(mIndex); |
198 | } | 193 | } |
199 | |||
200 | // Disabled caching of binding state. | 194 | // Disabled caching of binding state. |
201 | activate(); | 195 | activate(); |
202 | enable(texture->getTarget()); | 196 | enable(texture->getTarget()); |
diff --git a/linden/indra/llrender/llrender.h b/linden/indra/llrender/llrender.h index 7dcb504..e949190 100644 --- a/linden/indra/llrender/llrender.h +++ b/linden/indra/llrender/llrender.h | |||
@@ -9,7 +9,7 @@ | |||
9 | * | 9 | * |
10 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 10 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
11 | * | 11 | * |
12 | * Copyright (c) 2001-2008, Linden Research, Inc. | 12 | * Copyright (c) 2001-2009, Linden Research, Inc. |
13 | * | 13 | * |
14 | * Second Life Viewer Source Code | 14 | * Second Life Viewer Source Code |
15 | * The source code in this file ("Source Code") is provided by Linden Lab | 15 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llrendersphere.cpp b/linden/indra/llrender/llrendersphere.cpp index 0c3cd19..6aaa03e 100644 --- a/linden/indra/llrender/llrendersphere.cpp +++ b/linden/indra/llrender/llrendersphere.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llrendersphere.h b/linden/indra/llrender/llrendersphere.h index ace57e4..d48b917 100644 --- a/linden/indra/llrender/llrendersphere.h +++ b/linden/indra/llrender/llrendersphere.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=internal$ | 5 | * $LicenseInfo:firstyear=2001&license=internal$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of | 9 | * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of |
10 | * this source code is governed by the Linden Lab Source Code Disclosure | 10 | * this source code is governed by the Linden Lab Source Code Disclosure |
diff --git a/linden/indra/llrender/llrendertarget.cpp b/linden/indra/llrender/llrendertarget.cpp index 9d693a7..392ec24 100644 --- a/linden/indra/llrender/llrendertarget.cpp +++ b/linden/indra/llrender/llrendertarget.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llrendertarget.h b/linden/indra/llrender/llrendertarget.h index 65bab8b..38a41cb 100644 --- a/linden/indra/llrender/llrendertarget.h +++ b/linden/indra/llrender/llrendertarget.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llshadermgr.cpp b/linden/indra/llrender/llshadermgr.cpp index d884c15..3046d19 100644 --- a/linden/indra/llrender/llshadermgr.cpp +++ b/linden/indra/llrender/llshadermgr.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2005&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2005&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2005-2008, Linden Research, Inc. | 7 | * Copyright (c) 2005-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llshadermgr.h b/linden/indra/llrender/llshadermgr.h index 8918416..1f78e30 100644 --- a/linden/indra/llrender/llshadermgr.h +++ b/linden/indra/llrender/llshadermgr.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llvertexbuffer.cpp b/linden/indra/llrender/llvertexbuffer.cpp index 465c4ca..cb7f352 100644 --- a/linden/indra/llrender/llvertexbuffer.cpp +++ b/linden/indra/llrender/llvertexbuffer.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2003&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2003&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2003-2008, Linden Research, Inc. | 7 | * Copyright (c) 2003-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llrender/llvertexbuffer.h b/linden/indra/llrender/llvertexbuffer.h index a97c74e..aa1aafc 100644 --- a/linden/indra/llrender/llvertexbuffer.h +++ b/linden/indra/llrender/llvertexbuffer.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2003&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2003&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2003-2008, Linden Research, Inc. | 7 | * Copyright (c) 2003-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |