aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llrender/CMakeLists.txt83
-rw-r--r--linden/indra/llrender/files.darwin.lst1
-rw-r--r--linden/indra/llrender/files.lst7
-rw-r--r--linden/indra/llrender/llcubemap.cpp (renamed from linden/indra/newview/llcubemap.cpp)33
-rw-r--r--linden/indra/llrender/llcubemap.h (renamed from linden/indra/newview/llcubemap.h)4
-rw-r--r--linden/indra/llrender/llfont.h8
-rw-r--r--linden/indra/llrender/llfontgl.cpp98
-rw-r--r--linden/indra/llrender/llfontgl.h50
-rw-r--r--linden/indra/llrender/llgl.cpp (renamed from linden/indra/llwindow/llgl.cpp)147
-rw-r--r--linden/indra/llrender/llgl.h (renamed from linden/indra/llwindow/llgl.h)21
-rw-r--r--linden/indra/llrender/llgldbg.cpp10
-rw-r--r--linden/indra/llrender/llglheaders.h (renamed from linden/indra/llwindow/llglheaders.h)9
-rw-r--r--linden/indra/llrender/llglimmediate.cpp264
-rw-r--r--linden/indra/llrender/llglimmediate.h97
-rw-r--r--linden/indra/llrender/llglslshader.cpp823
-rw-r--r--linden/indra/llrender/llglslshader.h139
-rw-r--r--linden/indra/llrender/llglstates.h (renamed from linden/indra/llwindow/llglstates.h)0
-rw-r--r--linden/indra/llrender/llgltypes.h (renamed from linden/indra/llwindow/llgltypes.h)0
-rw-r--r--linden/indra/llrender/llimagegl.cpp2
-rw-r--r--linden/indra/llrender/llpostprocess.cpp (renamed from linden/indra/newview/llpostprocess.cpp)19
-rw-r--r--linden/indra/llrender/llpostprocess.h (renamed from linden/indra/newview/llpostprocess.h)4
-rw-r--r--linden/indra/llrender/llrender.cpp12
-rw-r--r--linden/indra/llrender/llrender.h6
-rw-r--r--linden/indra/llrender/llrender.vcproj232
-rw-r--r--linden/indra/llrender/llrender_vc8.vcproj329
-rw-r--r--linden/indra/llrender/llrender_vc9.vcproj330
-rw-r--r--linden/indra/llrender/llrendersphere.cpp (renamed from linden/indra/newview/llrendersphere.cpp)27
-rw-r--r--linden/indra/llrender/llrendersphere.h (renamed from linden/indra/newview/llrendersphere.h)0
-rw-r--r--linden/indra/llrender/llrendertarget.cpp5
-rw-r--r--linden/indra/llrender/llshadermgr.cpp513
-rw-r--r--linden/indra/llrender/llshadermgr.h75
-rw-r--r--linden/indra/llrender/llvertexbuffer.cpp5
-rw-r--r--linden/indra/llrender/llvertexbuffer.h1
33 files changed, 2255 insertions, 1099 deletions
diff --git a/linden/indra/llrender/CMakeLists.txt b/linden/indra/llrender/CMakeLists.txt
new file mode 100644
index 0000000..76858d9
--- /dev/null
+++ b/linden/indra/llrender/CMakeLists.txt
@@ -0,0 +1,83 @@
1# -*- cmake -*-
2
3project(llrender)
4
5include(00-Common)
6include(FreeType)
7include(LLCommon)
8include(LLImage)
9include(LLMath)
10include(LLRender)
11include(LLWindow)
12
13include_directories(
14 ${FREETYPE_INCLUDE_DIRS}
15 ${LLCOMMON_INCLUDE_DIRS}
16 ${LLIMAGE_INCLUDE_DIRS}
17 ${LLMATH_INCLUDE_DIRS}
18 ${LLRENDER_INCLUDE_DIRS}
19 ${LLWINDOW_INCLUDE_DIRS}
20 )
21
22set(llrender_SOURCE_FILES
23 llcubemap.cpp
24 llfont.cpp
25 llfontgl.cpp
26 llgldbg.cpp
27 llglslshader.cpp
28 llimagegl.cpp
29 llpostprocess.cpp
30 llrender.cpp
31 llrendersphere.cpp
32 llrendertarget.cpp
33 llshadermgr.cpp
34 llvertexbuffer.cpp
35 )
36
37set(llrender_HEADER_FILES
38 CMakeLists.txt
39
40 llcubemap.h
41 llfontgl.h
42 llfont.h
43 llgl.h
44 llgldbg.h
45 llglheaders.h
46 llglslshader.h
47 llglstates.h
48 llgltypes.h
49 llimagegl.h
50 llpostprocess.h
51 llrender.h
52 llrendersphere.h
53 llrendertarget.h
54 llshadermgr.h
55 llvertexbuffer.h
56 )
57
58set_source_files_properties(${llrender_HEADER_FILES}
59 PROPERTIES HEADER_FILE_ONLY TRUE)
60
61list(APPEND llrender_SOURCE_FILES ${llrender_HEADER_FILES})
62
63if (SERVER AND NOT WINDOWS AND NOT DARWIN)
64 copy_server_sources(
65 llgl
66 )
67
68
69 set_source_files_properties(
70 ${server_SOURCE_FILES}
71 PROPERTIES
72 COMPILE_FLAGS "-DLL_MESA=1 -DLL_MESA_HEADLESS=1"
73 )
74 add_library (llrenderheadless
75 ${llrender_SOURCE_FILES}
76 ${server_SOURCE_FILES}
77 )
78else (SERVER AND NOT WINDOWS AND NOT DARWIN)
79 list(APPEND llrender_SOURCE_FILES
80 llgl.cpp
81 )
82endif (SERVER AND NOT WINDOWS AND NOT DARWIN)
83add_library (llrender ${llrender_SOURCE_FILES})
diff --git a/linden/indra/llrender/files.darwin.lst b/linden/indra/llrender/files.darwin.lst
deleted file mode 100644
index 2d27570..0000000
--- a/linden/indra/llrender/files.darwin.lst
+++ /dev/null
@@ -1 +0,0 @@
1llrender/llagpmempoolapple.cpp
diff --git a/linden/indra/llrender/files.lst b/linden/indra/llrender/files.lst
deleted file mode 100644
index 5dc9579..0000000
--- a/linden/indra/llrender/files.lst
+++ /dev/null
@@ -1,7 +0,0 @@
1llrender/llfont.cpp
2llrender/llfontgl.cpp
3llrender/llgldbg.cpp
4llrender/llrender.cpp
5llrender/llimagegl.cpp
6llrender/llrendertarget.cpp
7llrender/llvertexbuffer.cpp
diff --git a/linden/indra/newview/llcubemap.cpp b/linden/indra/llrender/llcubemap.cpp
index f79fd0f..563d616 100644
--- a/linden/indra/newview/llcubemap.cpp
+++ b/linden/indra/llrender/llcubemap.cpp
@@ -28,22 +28,21 @@
28 * COMPLETENESS OR PERFORMANCE. 28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$ 29 * $/LicenseInfo$
30 */ 30 */
31#include "linden_common.h"
31 32
32#include "llviewerprecompiledheaders.h"
33#include "llfeaturemanager.h"
34#include "llworkerthread.h" 33#include "llworkerthread.h"
35 34
36#include "llcubemap.h" 35#include "llcubemap.h"
37 36
38#include "v4coloru.h" 37#include "v4coloru.h"
39#include "v3math.h" 38#include "v3math.h"
39#include "v3dmath.h"
40#include "m3math.h"
41#include "m4math.h"
42#include "llcamera.h"
40 43
41#include "llrender.h" 44#include "llrender.h"
42 45
43#include "llviewercamera.h"
44#include "llviewerimage.h"
45#include "llviewerimagelist.h"
46
47#include "llglheaders.h" 46#include "llglheaders.h"
48 47
49const F32 epsilon = 1e-7f; 48const F32 epsilon = 1e-7f;
@@ -57,6 +56,8 @@ const BOOL use_cube_mipmaps = FALSE;
57const BOOL use_cube_mipmaps = FALSE; //current build works best without cube mipmaps 56const BOOL use_cube_mipmaps = FALSE; //current build works best without cube mipmaps
58#endif 57#endif
59 58
59bool LLCubeMap::sUseCubeMaps = true;
60
60LLCubeMap::LLCubeMap() 61LLCubeMap::LLCubeMap()
61 : mTextureStage(0), 62 : mTextureStage(0),
62 mTextureCoordStage(0), 63 mTextureCoordStage(0),
@@ -72,8 +73,7 @@ void LLCubeMap::initGL()
72{ 73{
73 llassert(gGLManager.mInited); 74 llassert(gGLManager.mInited);
74 75
75 if (gGLManager.mHasCubeMap 76 if (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps)
76 && LLFeatureManager::getInstance()->isFeatureAvailable("RenderCubeMap"))
77 { 77 {
78 mTargets[0] = GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB; 78 mTargets[0] = GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB;
79 mTargets[1] = GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB; 79 mTargets[1] = GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB;
@@ -180,9 +180,7 @@ GLuint LLCubeMap::getGLName()
180 180
181void LLCubeMap::bind() 181void LLCubeMap::bind()
182{ 182{
183 if (gGLManager.mHasCubeMap 183 if (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps)
184 //&& LLFeatureManager::getInstance()->isFeatureAvailable("RenderCubeMap")
185 )
186 { 184 {
187 // We assume that if they have cube mapping, they have multitexturing. 185 // We assume that if they have cube mapping, they have multitexturing.
188 if (mTextureStage > 0) 186 if (mTextureStage > 0)
@@ -213,10 +211,7 @@ void LLCubeMap::enable(S32 stage)
213void LLCubeMap::enableTexture(S32 stage) 211void LLCubeMap::enableTexture(S32 stage)
214{ 212{
215 mTextureStage = stage; 213 mTextureStage = stage;
216 if (gGLManager.mHasCubeMap && 214 if (gGLManager.mHasCubeMap && stage >= 0 && LLCubeMap::sUseCubeMaps)
217 stage >= 0
218 //&& LLFeatureManager::getInstance()->isFeatureAvailable("RenderCubeMap")
219 )
220 { 215 {
221 if (stage > 0) 216 if (stage > 0)
222 { 217 {
@@ -235,7 +230,7 @@ void LLCubeMap::enableTexture(S32 stage)
235void LLCubeMap::enableTextureCoords(S32 stage) 230void LLCubeMap::enableTextureCoords(S32 stage)
236{ 231{
237 mTextureCoordStage = stage; 232 mTextureCoordStage = stage;
238 if (gGLManager.mHasCubeMap && stage >= 0) 233 if (gGLManager.mHasCubeMap && stage >= 0 && LLCubeMap::sUseCubeMaps)
239 { 234 {
240 if (stage > 0) 235 if (stage > 0)
241 { 236 {
@@ -265,9 +260,7 @@ void LLCubeMap::disable(void)
265 260
266void LLCubeMap::disableTexture(void) 261void LLCubeMap::disableTexture(void)
267{ 262{
268 if (gGLManager.mHasCubeMap && mTextureStage >= 0 263 if (gGLManager.mHasCubeMap && mTextureStage >= 0 && LLCubeMap::sUseCubeMaps)
269 //&& LLFeatureManager::getInstance()->isFeatureAvailable("RenderCubeMap")
270 )
271 { 264 {
272 if (mTextureStage > 0) 265 if (mTextureStage > 0)
273 { 266 {
@@ -284,7 +277,7 @@ void LLCubeMap::disableTexture(void)
284 277
285void LLCubeMap::disableTextureCoords(void) 278void LLCubeMap::disableTextureCoords(void)
286{ 279{
287 if (gGLManager.mHasCubeMap && mTextureCoordStage >= 0) 280 if (gGLManager.mHasCubeMap && mTextureCoordStage >= 0 && LLCubeMap::sUseCubeMaps)
288 { 281 {
289 if (mTextureCoordStage > 0) 282 if (mTextureCoordStage > 0)
290 { 283 {
diff --git a/linden/indra/newview/llcubemap.h b/linden/indra/llrender/llcubemap.h
index 0b8cf29..45bfa16 100644
--- a/linden/indra/newview/llcubemap.h
+++ b/linden/indra/llrender/llcubemap.h
@@ -33,7 +33,6 @@
33#define LL_LLCUBEMAP_H 33#define LL_LLCUBEMAP_H
34 34
35#include "llgl.h" 35#include "llgl.h"
36#include "llviewerimage.h"
37 36
38#include <vector> 37#include <vector>
39 38
@@ -74,6 +73,9 @@ public:
74 void paintIn(LLVector3 dir[4], const LLColor4U& col); 73 void paintIn(LLVector3 dir[4], const LLColor4U& col);
75 void destroyGL(); 74 void destroyGL();
76 75
76public:
77 static bool sUseCubeMaps;
78
77protected: 79protected:
78 ~LLCubeMap(); 80 ~LLCubeMap();
79 LLGLenum mTargets[6]; 81 LLGLenum mTargets[6];
diff --git a/linden/indra/llrender/llfont.h b/linden/indra/llrender/llfont.h
index 071e508..d937dfd 100644
--- a/linden/indra/llrender/llfont.h
+++ b/linden/indra/llrender/llfont.h
@@ -121,11 +121,11 @@ public:
121// ^ ^ 121// ^ ^
122// | | 122// | |
123// xxx x |Ascender 123// xxx x |Ascender
124// x x | | 124// x x v |
125// --------- xxxx-------------- Baseline 125// --------- xxxx-------------- Baseline
126// ^ x | | 126// ^ x |
127// | descender x | | 127// | Descender x |
128// v xxxx v |LineHeight 128// v xxxx |LineHeight
129// ----------------------- | 129// ----------------------- |
130// v 130// v
131// ------------------------------ 131// ------------------------------
diff --git a/linden/indra/llrender/llfontgl.cpp b/linden/indra/llrender/llfontgl.cpp
index 253bf50..a328196 100644
--- a/linden/indra/llrender/llfontgl.cpp
+++ b/linden/indra/llrender/llfontgl.cpp
@@ -48,7 +48,7 @@ F32 LLFontGL::sHorizDPI = 96.f;
48F32 LLFontGL::sScaleX = 1.f; 48F32 LLFontGL::sScaleX = 1.f;
49F32 LLFontGL::sScaleY = 1.f; 49F32 LLFontGL::sScaleY = 1.f;
50BOOL LLFontGL::sDisplayFont = TRUE ; 50BOOL LLFontGL::sDisplayFont = TRUE ;
51LLString LLFontGL::sAppDir; 51std::string LLFontGL::sAppDir;
52 52
53LLFontGL* LLFontGL::sMonospace = NULL; 53LLFontGL* LLFontGL::sMonospace = NULL;
54LLFontGL* LLFontGL::sSansSerifSmall = NULL; 54LLFontGL* LLFontGL::sSansSerifSmall = NULL;
@@ -93,7 +93,7 @@ F32 llfont_round_y(F32 y)
93} 93}
94 94
95// static 95// static
96U8 LLFontGL::getStyleFromString(const LLString &style) 96U8 LLFontGL::getStyleFromString(const std::string &style)
97{ 97{
98 S32 ret = 0; 98 S32 ret = 0;
99 if (style.find("NORMAL") != style.npos) 99 if (style.find("NORMAL") != style.npos)
@@ -166,9 +166,9 @@ void LLFontGL::reset()
166} 166}
167 167
168// static 168// static
169LLString LLFontGL::getFontPathSystem() 169std::string LLFontGL::getFontPathSystem()
170{ 170{
171 LLString system_path; 171 std::string system_path;
172 172
173 // Try to figure out where the system's font files are stored. 173 // Try to figure out where the system's font files are stored.
174 char *system_root = NULL; 174 char *system_root = NULL;
@@ -199,9 +199,9 @@ LLString LLFontGL::getFontPathSystem()
199 199
200 200
201// static 201// static
202LLString LLFontGL::getFontPathLocal() 202std::string LLFontGL::getFontPathLocal()
203{ 203{
204 LLString local_path; 204 std::string local_path;
205 205
206 // Backup files if we can't load from system fonts directory. 206 // Backup files if we can't load from system fonts directory.
207 // We could store this in an end-user writable directory to allow 207 // We could store this in an end-user writable directory to allow
@@ -220,10 +220,10 @@ LLString LLFontGL::getFontPathLocal()
220} 220}
221 221
222//static 222//static
223bool LLFontGL::loadFaceFallback(LLFontList *fontlistp, const LLString& fontname, const F32 point_size) 223bool LLFontGL::loadFaceFallback(LLFontList *fontlistp, const std::string& fontname, const F32 point_size)
224{ 224{
225 LLString local_path = getFontPathLocal(); 225 std::string local_path = getFontPathLocal();
226 LLString sys_path = getFontPathSystem(); 226 std::string sys_path = getFontPathSystem();
227 227
228 // The fontname string may contain multiple font file names separated by semicolons. 228 // The fontname string may contain multiple font file names separated by semicolons.
229 // Break it apart and try loading each one, in order. 229 // Break it apart and try loading each one, in order.
@@ -235,7 +235,7 @@ bool LLFontGL::loadFaceFallback(LLFontList *fontlistp, const LLString& fontname,
235 for(token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter) 235 for(token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter)
236 { 236 {
237 LLFont *fontp = new LLFont(); 237 LLFont *fontp = new LLFont();
238 LLString font_path = local_path + *token_iter; 238 std::string font_path = local_path + *token_iter;
239 if (!fontp->loadFace(font_path, point_size, sVertDPI, sHorizDPI, 2, TRUE)) 239 if (!fontp->loadFace(font_path, point_size, sVertDPI, sHorizDPI, 2, TRUE))
240 { 240 {
241 font_path = sys_path + *token_iter; 241 font_path = sys_path + *token_iter;
@@ -258,13 +258,13 @@ bool LLFontGL::loadFaceFallback(LLFontList *fontlistp, const LLString& fontname,
258} 258}
259 259
260//static 260//static
261bool LLFontGL::loadFace(LLFontGL *fontp, const LLString& fontname, const F32 point_size, LLFontList *fallback_fontp) 261bool LLFontGL::loadFace(LLFontGL *fontp, const std::string& fontname, const F32 point_size, LLFontList *fallback_fontp)
262{ 262{
263 LLString local_path = getFontPathLocal(); 263 std::string local_path = getFontPathLocal();
264 LLString font_path = local_path + fontname; 264 std::string font_path = local_path + fontname;
265 if (!fontp->loadFace(font_path, point_size, sVertDPI, sHorizDPI, 2, FALSE)) 265 if (!fontp->loadFace(font_path, point_size, sVertDPI, sHorizDPI, 2, FALSE))
266 { 266 {
267 LLString sys_path = getFontPathSystem(); 267 std::string sys_path = getFontPathSystem();
268 font_path = sys_path + fontname; 268 font_path = sys_path + fontname;
269 if (!fontp->loadFace(font_path, point_size, sVertDPI, sHorizDPI, 2, FALSE)) 269 if (!fontp->loadFace(font_path, point_size, sVertDPI, sHorizDPI, 2, FALSE))
270 { 270 {
@@ -280,12 +280,12 @@ bool LLFontGL::loadFace(LLFontGL *fontp, const LLString& fontname, const F32 poi
280 280
281// static 281// static
282BOOL LLFontGL::initDefaultFonts(F32 screen_dpi, F32 x_scale, F32 y_scale, 282BOOL LLFontGL::initDefaultFonts(F32 screen_dpi, F32 x_scale, F32 y_scale,
283 const LLString& monospace_file, F32 monospace_size, 283 const std::string& monospace_file, F32 monospace_size,
284 const LLString& sansserif_file, 284 const std::string& sansserif_file,
285 const LLString& sanserif_fallback_file, F32 ss_fallback_scale, 285 const std::string& sanserif_fallback_file, F32 ss_fallback_scale,
286 F32 small_size, F32 medium_size, F32 big_size, F32 huge_size, 286 F32 small_size, F32 medium_size, F32 big_size, F32 huge_size,
287 const LLString& sansserif_bold_file, F32 bold_size, 287 const std::string& sansserif_bold_file, F32 bold_size,
288 const LLString& app_dir) 288 const std::string& app_dir)
289{ 289{
290 BOOL failed = FALSE; 290 BOOL failed = FALSE;
291 sVertDPI = (F32)llfloor(screen_dpi * y_scale); 291 sVertDPI = (F32)llfloor(screen_dpi * y_scale);
@@ -554,7 +554,7 @@ BOOL LLFontGL::addChar(const llwchar wch)
554} 554}
555 555
556 556
557S32 LLFontGL::renderUTF8(const LLString &text, const S32 offset, 557S32 LLFontGL::renderUTF8(const std::string &text, const S32 offset,
558 const F32 x, const F32 y, 558 const F32 x, const F32 y,
559 const LLColor4 &color, 559 const LLColor4 &color,
560 const HAlign halign, const VAlign valign, 560 const HAlign halign, const VAlign valign,
@@ -726,7 +726,7 @@ S32 LLFontGL::render(const LLWString &wstr,
726 if (getWidthF32(wstr.c_str(), 0, max_chars) * sScaleX > scaled_max_pixels) 726 if (getWidthF32(wstr.c_str(), 0, max_chars) * sScaleX > scaled_max_pixels)
727 { 727 {
728 // use four dots for ellipsis width to generate padding 728 // use four dots for ellipsis width to generate padding
729 const LLWString dots(utf8str_to_wstring(LLString("...."))); 729 const LLWString dots(utf8str_to_wstring(std::string("....")));
730 scaled_max_pixels = llmax(0, scaled_max_pixels - llround(getWidthF32(dots.c_str()))); 730 scaled_max_pixels = llmax(0, scaled_max_pixels - llround(getWidthF32(dots.c_str())));
731 draw_ellipses = TRUE; 731 draw_ellipses = TRUE;
732 } 732 }
@@ -879,7 +879,7 @@ S32 LLFontGL::render(const LLWString &wstr,
879 //glLoadIdentity(); 879 //glLoadIdentity();
880 //gGL.translatef(sCurOrigin.mX, sCurOrigin.mY, 0.0f); 880 //gGL.translatef(sCurOrigin.mX, sCurOrigin.mY, 0.0f);
881 //glScalef(sScaleX, sScaleY, 1.f); 881 //glScalef(sScaleX, sScaleY, 1.f);
882 renderUTF8("...", 882 renderUTF8(std::string("..."),
883 0, 883 0,
884 cur_x / sScaleX, (F32)y, 884 cur_x / sScaleX, (F32)y,
885 color, 885 color,
@@ -902,7 +902,7 @@ LLImageGL *LLFontGL::getImageGL() const
902 return mImageGLp; 902 return mImageGLp;
903} 903}
904 904
905S32 LLFontGL::getWidth(const LLString& utf8text) const 905S32 LLFontGL::getWidth(const std::string& utf8text) const
906{ 906{
907 LLWString wtext = utf8str_to_wstring(utf8text); 907 LLWString wtext = utf8str_to_wstring(utf8text);
908 return getWidth(wtext.c_str(), 0, S32_MAX); 908 return getWidth(wtext.c_str(), 0, S32_MAX);
@@ -913,7 +913,7 @@ S32 LLFontGL::getWidth(const llwchar* wchars) const
913 return getWidth(wchars, 0, S32_MAX); 913 return getWidth(wchars, 0, S32_MAX);
914} 914}
915 915
916S32 LLFontGL::getWidth(const LLString& utf8text, const S32 begin_offset, const S32 max_chars) const 916S32 LLFontGL::getWidth(const std::string& utf8text, const S32 begin_offset, const S32 max_chars) const
917{ 917{
918 LLWString wtext = utf8str_to_wstring(utf8text); 918 LLWString wtext = utf8str_to_wstring(utf8text);
919 return getWidth(wtext.c_str(), begin_offset, max_chars); 919 return getWidth(wtext.c_str(), begin_offset, max_chars);
@@ -925,7 +925,7 @@ S32 LLFontGL::getWidth(const llwchar* wchars, const S32 begin_offset, const S32
925 return llround(width); 925 return llround(width);
926} 926}
927 927
928F32 LLFontGL::getWidthF32(const LLString& utf8text) const 928F32 LLFontGL::getWidthF32(const std::string& utf8text) const
929{ 929{
930 LLWString wtext = utf8str_to_wstring(utf8text); 930 LLWString wtext = utf8str_to_wstring(utf8text);
931 return getWidthF32(wtext.c_str(), 0, S32_MAX); 931 return getWidthF32(wtext.c_str(), 0, S32_MAX);
@@ -936,7 +936,7 @@ F32 LLFontGL::getWidthF32(const llwchar* wchars) const
936 return getWidthF32(wchars, 0, S32_MAX); 936 return getWidthF32(wchars, 0, S32_MAX);
937} 937}
938 938
939F32 LLFontGL::getWidthF32(const LLString& utf8text, const S32 begin_offset, const S32 max_chars ) const 939F32 LLFontGL::getWidthF32(const std::string& utf8text, const S32 begin_offset, const S32 max_chars ) const
940{ 940{
941 LLWString wtext = utf8str_to_wstring(utf8text); 941 LLWString wtext = utf8str_to_wstring(utf8text);
942 return getWidthF32(wtext.c_str(), begin_offset, max_chars); 942 return getWidthF32(wtext.c_str(), begin_offset, max_chars);
@@ -1312,7 +1312,7 @@ void LLFontGL::clearEmbeddedChars()
1312 mEmbeddedChars.clear(); 1312 mEmbeddedChars.clear();
1313} 1313}
1314 1314
1315void LLFontGL::addEmbeddedChar( llwchar wc, LLImageGL* image, const LLString& label ) 1315void LLFontGL::addEmbeddedChar( llwchar wc, LLImageGL* image, const std::string& label )
1316{ 1316{
1317 LLWString wlabel = utf8str_to_wstring(label); 1317 LLWString wlabel = utf8str_to_wstring(label);
1318 addEmbeddedChar(wc, image, wlabel); 1318 addEmbeddedChar(wc, image, wlabel);
@@ -1429,40 +1429,40 @@ void LLFontGL::drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, con
1429} 1429}
1430 1430
1431// static 1431// static
1432LLString LLFontGL::nameFromFont(const LLFontGL* fontp) 1432std::string LLFontGL::nameFromFont(const LLFontGL* fontp)
1433{ 1433{
1434 if (fontp == sSansSerifHuge) 1434 if (fontp == sSansSerifHuge)
1435 { 1435 {
1436 return LLString("SansSerifHuge"); 1436 return std::string("SansSerifHuge");
1437 } 1437 }
1438 else if (fontp == sSansSerifSmall) 1438 else if (fontp == sSansSerifSmall)
1439 { 1439 {
1440 return LLString("SansSerifSmall"); 1440 return std::string("SansSerifSmall");
1441 } 1441 }
1442 else if (fontp == sSansSerif) 1442 else if (fontp == sSansSerif)
1443 { 1443 {
1444 return LLString("SansSerif"); 1444 return std::string("SansSerif");
1445 } 1445 }
1446 else if (fontp == sSansSerifBig) 1446 else if (fontp == sSansSerifBig)
1447 { 1447 {
1448 return LLString("SansSerifBig"); 1448 return std::string("SansSerifBig");
1449 } 1449 }
1450 else if (fontp == sSansSerifBold) 1450 else if (fontp == sSansSerifBold)
1451 { 1451 {
1452 return LLString("SansSerifBold"); 1452 return std::string("SansSerifBold");
1453 } 1453 }
1454 else if (fontp == sMonospace) 1454 else if (fontp == sMonospace)
1455 { 1455 {
1456 return LLString("Monospace"); 1456 return std::string("Monospace");
1457 } 1457 }
1458 else 1458 else
1459 { 1459 {
1460 return LLString(); 1460 return std::string();
1461 } 1461 }
1462} 1462}
1463 1463
1464// static 1464// static
1465LLFontGL* LLFontGL::fontFromName(const LLString& font_name) 1465LLFontGL* LLFontGL::fontFromName(const std::string& font_name)
1466{ 1466{
1467 LLFontGL* gl_font = NULL; 1467 LLFontGL* gl_font = NULL;
1468 if (font_name == "SansSerifHuge") 1468 if (font_name == "SansSerifHuge")
@@ -1493,16 +1493,16 @@ LLFontGL* LLFontGL::fontFromName(const LLString& font_name)
1493} 1493}
1494 1494
1495// static 1495// static
1496LLString LLFontGL::nameFromHAlign(LLFontGL::HAlign align) 1496std::string LLFontGL::nameFromHAlign(LLFontGL::HAlign align)
1497{ 1497{
1498 if (align == LEFT) return LLString("left"); 1498 if (align == LEFT) return std::string("left");
1499 else if (align == RIGHT) return LLString("right"); 1499 else if (align == RIGHT) return std::string("right");
1500 else if (align == HCENTER) return LLString("center"); 1500 else if (align == HCENTER) return std::string("center");
1501 else return LLString(); 1501 else return std::string();
1502} 1502}
1503 1503
1504// static 1504// static
1505LLFontGL::HAlign LLFontGL::hAlignFromName(const LLString& name) 1505LLFontGL::HAlign LLFontGL::hAlignFromName(const std::string& name)
1506{ 1506{
1507 LLFontGL::HAlign gl_hfont_align = LLFontGL::LEFT; 1507 LLFontGL::HAlign gl_hfont_align = LLFontGL::LEFT;
1508 if (name == "left") 1508 if (name == "left")
@@ -1522,17 +1522,17 @@ LLFontGL::HAlign LLFontGL::hAlignFromName(const LLString& name)
1522} 1522}
1523 1523
1524// static 1524// static
1525LLString LLFontGL::nameFromVAlign(LLFontGL::VAlign align) 1525std::string LLFontGL::nameFromVAlign(LLFontGL::VAlign align)
1526{ 1526{
1527 if (align == TOP) return LLString("top"); 1527 if (align == TOP) return std::string("top");
1528 else if (align == VCENTER) return LLString("center"); 1528 else if (align == VCENTER) return std::string("center");
1529 else if (align == BASELINE) return LLString("baseline"); 1529 else if (align == BASELINE) return std::string("baseline");
1530 else if (align == BOTTOM) return LLString("bottom"); 1530 else if (align == BOTTOM) return std::string("bottom");
1531 else return LLString(); 1531 else return std::string();
1532} 1532}
1533 1533
1534// static 1534// static
1535LLFontGL::VAlign LLFontGL::vAlignFromName(const LLString& name) 1535LLFontGL::VAlign LLFontGL::vAlignFromName(const std::string& name)
1536{ 1536{
1537 LLFontGL::VAlign gl_vfont_align = LLFontGL::BASELINE; 1537 LLFontGL::VAlign gl_vfont_align = LLFontGL::BASELINE;
1538 if (name == "top") 1538 if (name == "top")
diff --git a/linden/indra/llrender/llfontgl.h b/linden/indra/llrender/llfontgl.h
index 01046af..3f88e62 100644
--- a/linden/indra/llrender/llfontgl.h
+++ b/linden/indra/llrender/llfontgl.h
@@ -73,7 +73,7 @@ public:
73 }; 73 };
74 74
75 // Takes a string with potentially several flags, i.e. "NORMAL|BOLD|ITALIC" 75 // Takes a string with potentially several flags, i.e. "NORMAL|BOLD|ITALIC"
76 static U8 getStyleFromString(const LLString &style); 76 static U8 getStyleFromString(const std::string &style);
77 77
78 LLFontGL(); 78 LLFontGL();
79 LLFontGL(const LLFontGL &source); 79 LLFontGL(const LLFontGL &source);
@@ -85,24 +85,24 @@ public:
85 LLFontGL &operator=(const LLFontGL &source); 85 LLFontGL &operator=(const LLFontGL &source);
86 86
87 static BOOL initDefaultFonts(F32 screen_dpi, F32 x_scale, F32 y_scale, 87 static BOOL initDefaultFonts(F32 screen_dpi, F32 x_scale, F32 y_scale,
88 const LLString& monospace_file, F32 monospace_size, 88 const std::string& monospace_file, F32 monospace_size,
89 const LLString& sansserif_file, 89 const std::string& sansserif_file,
90 const LLString& sansserif_fallback_file, F32 ss_fallback_scale, 90 const std::string& sansserif_fallback_file, F32 ss_fallback_scale,
91 F32 small_size, F32 medium_size, F32 large_size, F32 huge_size, 91 F32 small_size, F32 medium_size, F32 large_size, F32 huge_size,
92 const LLString& sansserif_bold_file, F32 bold_size, 92 const std::string& sansserif_bold_file, F32 bold_size,
93 const LLString& app_dir = LLString::null); 93 const std::string& app_dir = LLStringUtil::null);
94 94
95 static void destroyDefaultFonts(); 95 static void destroyDefaultFonts();
96 static void destroyGL(); 96 static void destroyGL();
97 97
98 static bool loadFaceFallback(LLFontList *fontp, const LLString& fontname, const F32 point_size); 98 static bool loadFaceFallback(LLFontList *fontp, const std::string& fontname, const F32 point_size);
99 static bool loadFace(LLFontGL *fontp, const LLString& fontname, const F32 point_size, LLFontList *fallback_fontp); 99 static bool loadFace(LLFontGL *fontp, const std::string& fontname, const F32 point_size, LLFontList *fallback_fontp);
100 /* virtual*/ BOOL loadFace(const std::string& filename, 100 /* virtual*/ BOOL loadFace(const std::string& filename,
101 const F32 point_size, const F32 vert_dpi, const F32 horz_dpi, 101 const F32 point_size, const F32 vert_dpi, const F32 horz_dpi,
102 const S32 components, BOOL is_fallback); 102 const S32 components, BOOL is_fallback);
103 103
104 104
105 S32 renderUTF8(const LLString &text, const S32 begin_offset, 105 S32 renderUTF8(const std::string &text, const S32 begin_offset,
106 S32 x, S32 y, 106 S32 x, S32 y,
107 const LLColor4 &color) const 107 const LLColor4 &color) const
108 { 108 {
@@ -111,7 +111,7 @@ public:
111 S32_MAX, S32_MAX, NULL, FALSE); 111 S32_MAX, S32_MAX, NULL, FALSE);
112 } 112 }
113 113
114 S32 renderUTF8(const LLString &text, const S32 begin_offset, 114 S32 renderUTF8(const std::string &text, const S32 begin_offset,
115 S32 x, S32 y, 115 S32 x, S32 y,
116 const LLColor4 &color, 116 const LLColor4 &color,
117 HAlign halign, VAlign valign, U8 style = NORMAL) const 117 HAlign halign, VAlign valign, U8 style = NORMAL) const
@@ -122,7 +122,7 @@ public:
122 } 122 }
123 123
124 // renderUTF8 does a conversion, so is slower! 124 // renderUTF8 does a conversion, so is slower!
125 S32 renderUTF8(const LLString &text, 125 S32 renderUTF8(const std::string &text,
126 S32 begin_offset, 126 S32 begin_offset,
127 F32 x, F32 y, 127 F32 x, F32 y,
128 const LLColor4 &color, 128 const LLColor4 &color,
@@ -162,14 +162,14 @@ public:
162 /*virtual*/ F32 getAscenderHeight() const { return (F32)llround(mAscender / sScaleY); } 162 /*virtual*/ F32 getAscenderHeight() const { return (F32)llround(mAscender / sScaleY); }
163 /*virtual*/ F32 getDescenderHeight() const { return (F32)llround(mDescender / sScaleY); } 163 /*virtual*/ F32 getDescenderHeight() const { return (F32)llround(mDescender / sScaleY); }
164 164
165 virtual S32 getWidth(const LLString& utf8text) const; 165 virtual S32 getWidth(const std::string& utf8text) const;
166 virtual S32 getWidth(const llwchar* wchars) const; 166 virtual S32 getWidth(const llwchar* wchars) const;
167 virtual S32 getWidth(const LLString& utf8text, const S32 offset, const S32 max_chars ) const; 167 virtual S32 getWidth(const std::string& utf8text, const S32 offset, const S32 max_chars ) const;
168 virtual S32 getWidth(const llwchar* wchars, const S32 offset, const S32 max_chars, BOOL use_embedded = FALSE) const; 168 virtual S32 getWidth(const llwchar* wchars, const S32 offset, const S32 max_chars, BOOL use_embedded = FALSE) const;
169 169
170 virtual F32 getWidthF32(const LLString& utf8text) const; 170 virtual F32 getWidthF32(const std::string& utf8text) const;
171 virtual F32 getWidthF32(const llwchar* wchars) const; 171 virtual F32 getWidthF32(const llwchar* wchars) const;
172 virtual F32 getWidthF32(const LLString& text, const S32 offset, const S32 max_chars ) const; 172 virtual F32 getWidthF32(const std::string& text, const S32 offset, const S32 max_chars ) const;
173 virtual F32 getWidthF32(const llwchar* wchars, const S32 offset, const S32 max_chars, BOOL use_embedded = FALSE ) const; 173 virtual F32 getWidthF32(const llwchar* wchars, const S32 offset, const S32 max_chars, BOOL use_embedded = FALSE ) const;
174 174
175 // The following are called often, frequently with large buffers, so do not use a string interface 175 // The following are called often, frequently with large buffers, so do not use a string interface
@@ -191,18 +191,18 @@ public:
191 191
192 LLImageGL *getImageGL() const; 192 LLImageGL *getImageGL() const;
193 193
194 void addEmbeddedChar( llwchar wc, LLImageGL* image, const LLString& label); 194 void addEmbeddedChar( llwchar wc, LLImageGL* image, const std::string& label);
195 void addEmbeddedChar( llwchar wc, LLImageGL* image, const LLWString& label); 195 void addEmbeddedChar( llwchar wc, LLImageGL* image, const LLWString& label);
196 void removeEmbeddedChar( llwchar wc ); 196 void removeEmbeddedChar( llwchar wc );
197 197
198 static LLString nameFromFont(const LLFontGL* fontp); 198 static std::string nameFromFont(const LLFontGL* fontp);
199 static LLFontGL* fontFromName(const LLString& name); 199 static LLFontGL* fontFromName(const std::string& name);
200 200
201 static LLString nameFromHAlign(LLFontGL::HAlign align); 201 static std::string nameFromHAlign(LLFontGL::HAlign align);
202 static LLFontGL::HAlign hAlignFromName(const LLString& name); 202 static LLFontGL::HAlign hAlignFromName(const std::string& name);
203 203
204 static LLString nameFromVAlign(LLFontGL::VAlign align); 204 static std::string nameFromVAlign(LLFontGL::VAlign align);
205 static LLFontGL::VAlign vAlignFromName(const LLString& name); 205 static LLFontGL::VAlign vAlignFromName(const std::string& name);
206 206
207 static void setFontDisplay(BOOL flag) { sDisplayFont = flag ; } 207 static void setFontDisplay(BOOL flag) { sDisplayFont = flag ; }
208 208
@@ -225,7 +225,7 @@ public:
225 static F32 sScaleX; 225 static F32 sScaleX;
226 static F32 sScaleY; 226 static F32 sScaleY;
227 static BOOL sDisplayFont ; 227 static BOOL sDisplayFont ;
228 static LLString sAppDir; // For loading fonts 228 static std::string sAppDir; // For loading fonts
229 229
230 static LLFontGL* sMonospace; // medium 230 static LLFontGL* sMonospace; // medium
231 static LLFontList* sMonospaceFallback; 231 static LLFontList* sMonospaceFallback;
@@ -249,8 +249,8 @@ public:
249 249
250protected: 250protected:
251 /*virtual*/ BOOL addChar(const llwchar wch); 251 /*virtual*/ BOOL addChar(const llwchar wch);
252 static LLString getFontPathLocal(); 252 static std::string getFontPathLocal();
253 static LLString getFontPathSystem(); 253 static std::string getFontPathSystem();
254 254
255protected: 255protected:
256 LLPointer<LLImageRaw> mRawImageGLp; 256 LLPointer<LLImageRaw> mRawImageGLp;
diff --git a/linden/indra/llwindow/llgl.cpp b/linden/indra/llrender/llgl.cpp
index debf2e3..843bc79 100644
--- a/linden/indra/llwindow/llgl.cpp
+++ b/linden/indra/llrender/llgl.cpp
@@ -60,6 +60,8 @@ BOOL gClothRipple = FALSE;
60BOOL gNoRender = FALSE; 60BOOL gNoRender = FALSE;
61LLMatrix4 gGLObliqueProjectionInverse; 61LLMatrix4 gGLObliqueProjectionInverse;
62 62
63#define LL_GL_NAME_POOLING 0
64
63LLGLNamePool::pool_list_t LLGLNamePool::sInstances; 65LLGLNamePool::pool_list_t LLGLNamePool::sInstances;
64 66
65#if (LL_WINDOWS || LL_LINUX) && !LL_MESA_HEADLESS 67#if (LL_WINDOWS || LL_LINUX) && !LL_MESA_HEADLESS
@@ -284,6 +286,7 @@ LLGLManager::LLGLManager() :
284 mIsGF3(FALSE), 286 mIsGF3(FALSE),
285 mIsGFFX(FALSE), 287 mIsGFFX(FALSE),
286 mATIOffsetVerticalLines(FALSE), 288 mATIOffsetVerticalLines(FALSE),
289 mATIOldDriver(FALSE),
287 290
288 mHasRequirements(TRUE), 291 mHasRequirements(TRUE),
289 292
@@ -350,11 +353,11 @@ bool LLGLManager::initGL()
350 353
351 // Extract video card strings and convert to upper case to 354 // Extract video card strings and convert to upper case to
352 // work around driver-to-driver variation in capitalization. 355 // work around driver-to-driver variation in capitalization.
353 mGLVendor = LLString((const char *)glGetString(GL_VENDOR)); 356 mGLVendor = std::string((const char *)glGetString(GL_VENDOR));
354 LLString::toUpper(mGLVendor); 357 LLStringUtil::toUpper(mGLVendor);
355 358
356 mGLRenderer = LLString((const char *)glGetString(GL_RENDERER)); 359 mGLRenderer = std::string((const char *)glGetString(GL_RENDERER));
357 LLString::toUpper(mGLRenderer); 360 LLStringUtil::toUpper(mGLRenderer);
358 361
359 parse_gl_version( &mDriverVersionMajor, 362 parse_gl_version( &mDriverVersionMajor,
360 &mDriverVersionMinor, 363 &mDriverVersionMinor,
@@ -369,7 +372,7 @@ bool LLGLManager::initGL()
369 { 372 {
370 mGLVendorShort = "ATI"; 373 mGLVendorShort = "ATI";
371 BOOL mobile = FALSE; 374 BOOL mobile = FALSE;
372 if (mGLRenderer.find("MOBILITY") != LLString::npos) 375 if (mGLRenderer.find("MOBILITY") != std::string::npos)
373 { 376 {
374 mobile = TRUE; 377 mobile = TRUE;
375 } 378 }
@@ -381,37 +384,48 @@ bool LLGLManager::initGL()
381 mATIOffsetVerticalLines = TRUE; 384 mATIOffsetVerticalLines = TRUE;
382 } 385 }
383#endif // LL_WINDOWS 386#endif // LL_WINDOWS
387
388#if (LL_WINDOWS || LL_LINUX) && !LL_MESA_HEADLESS
389 // release 7277 is a point at which we verify that ATI OpenGL
390 // drivers get pretty stable with SL, ~Catalyst 8.2,
391 // for both Win32 and Linux.
392 if (mDriverVersionRelease < 7277 &&
393 mDriverVersionRelease != 0) // 0 == Undetectable driver version - these get to pretend to be new ATI drivers, though that decision may be revisited.
394 {
395 mATIOldDriver = TRUE;
396 }
397#endif // (LL_WINDOWS || LL_LINUX) && !LL_MESA_HEADLESS
384 } 398 }
385 else if (mGLVendor.find("NVIDIA ") != LLString::npos) 399 else if (mGLVendor.find("NVIDIA ") != std::string::npos)
386 { 400 {
387 mGLVendorShort = "NVIDIA"; 401 mGLVendorShort = "NVIDIA";
388 mIsNVIDIA = TRUE; 402 mIsNVIDIA = TRUE;
389 if ( mGLRenderer.find("GEFORCE4 MX") != LLString::npos 403 if ( mGLRenderer.find("GEFORCE4 MX") != std::string::npos
390 || mGLRenderer.find("GEFORCE2") != LLString::npos 404 || mGLRenderer.find("GEFORCE2") != std::string::npos
391 || mGLRenderer.find("GEFORCE 2") != LLString::npos 405 || mGLRenderer.find("GEFORCE 2") != std::string::npos
392 || mGLRenderer.find("GEFORCE4 460 GO") != LLString::npos 406 || mGLRenderer.find("GEFORCE4 460 GO") != std::string::npos
393 || mGLRenderer.find("GEFORCE4 440 GO") != LLString::npos 407 || mGLRenderer.find("GEFORCE4 440 GO") != std::string::npos
394 || mGLRenderer.find("GEFORCE4 420 GO") != LLString::npos) 408 || mGLRenderer.find("GEFORCE4 420 GO") != std::string::npos)
395 { 409 {
396 mIsGF2or4MX = TRUE; 410 mIsGF2or4MX = TRUE;
397 } 411 }
398 else if (mGLRenderer.find("GEFORCE FX") != LLString::npos 412 else if (mGLRenderer.find("GEFORCE FX") != std::string::npos
399 || mGLRenderer.find("QUADRO FX") != LLString::npos 413 || mGLRenderer.find("QUADRO FX") != std::string::npos
400 || mGLRenderer.find("NV34") != LLString::npos) 414 || mGLRenderer.find("NV34") != std::string::npos)
401 { 415 {
402 mIsGFFX = TRUE; 416 mIsGFFX = TRUE;
403 } 417 }
404 else if(mGLRenderer.find("GEFORCE3") != LLString::npos) 418 else if(mGLRenderer.find("GEFORCE3") != std::string::npos)
405 { 419 {
406 mIsGF3 = TRUE; 420 mIsGF3 = TRUE;
407 } 421 }
408 422
409 } 423 }
410 else if (mGLVendor.find("INTEL") != LLString::npos 424 else if (mGLVendor.find("INTEL") != std::string::npos
411#if LL_LINUX 425#if LL_LINUX
412 // The Mesa-based drivers put this in the Renderer string, 426 // The Mesa-based drivers put this in the Renderer string,
413 // not the Vendor string. 427 // not the Vendor string.
414 || mGLRenderer.find("INTEL") != LLString::npos 428 || mGLRenderer.find("INTEL") != std::string::npos
415#endif //LL_LINUX 429#endif //LL_LINUX
416 ) 430 )
417 { 431 {
@@ -452,12 +466,12 @@ bool LLGLManager::initGL()
452 466
453void LLGLManager::getGLInfo(LLSD& info) 467void LLGLManager::getGLInfo(LLSD& info)
454{ 468{
455 info["GLInfo"]["GLVendor"] = LLString((const char *)glGetString(GL_VENDOR)); 469 info["GLInfo"]["GLVendor"] = std::string((const char *)glGetString(GL_VENDOR));
456 info["GLInfo"]["GLRenderer"] = LLString((const char *)glGetString(GL_RENDERER)); 470 info["GLInfo"]["GLRenderer"] = std::string((const char *)glGetString(GL_RENDERER));
457 info["GLInfo"]["GLVersion"] = LLString((const char *)glGetString(GL_VERSION)); 471 info["GLInfo"]["GLVersion"] = std::string((const char *)glGetString(GL_VERSION));
458 472
459#if !LL_MESA_HEADLESS 473#if !LL_MESA_HEADLESS
460 LLString all_exts = (const char *)gGLHExts.mSysExts; 474 std::string all_exts = ll_safe_string((const char *)gGLHExts.mSysExts);
461 boost::char_separator<char> sep(" "); 475 boost::char_separator<char> sep(" ");
462 boost::tokenizer<boost::char_separator<char> > tok(all_exts, sep); 476 boost::tokenizer<boost::char_separator<char> > tok(all_exts, sep);
463 for(boost::tokenizer<boost::char_separator<char> >::iterator i = tok.begin(); i != tok.end(); ++i) 477 for(boost::tokenizer<boost::char_separator<char> >::iterator i = tok.begin(); i != tok.end(); ++i)
@@ -467,19 +481,19 @@ void LLGLManager::getGLInfo(LLSD& info)
467#endif 481#endif
468} 482}
469 483
470LLString LLGLManager::getGLInfoString() 484std::string LLGLManager::getGLInfoString()
471{ 485{
472 LLString info_str; 486 std::string info_str;
473 LLString all_exts, line; 487 std::string all_exts, line;
474 488
475 info_str += LLString("GL_VENDOR ") + LLString((const char *)glGetString(GL_VENDOR)) + LLString("\n"); 489 info_str += std::string("GL_VENDOR ") + ll_safe_string((const char *)glGetString(GL_VENDOR)) + std::string("\n");
476 info_str += LLString("GL_RENDERER ") + LLString((const char *)glGetString(GL_RENDERER)) + LLString("\n"); 490 info_str += std::string("GL_RENDERER ") + ll_safe_string((const char *)glGetString(GL_RENDERER)) + std::string("\n");
477 info_str += LLString("GL_VERSION ") + LLString((const char *)glGetString(GL_VERSION)) + LLString("\n"); 491 info_str += std::string("GL_VERSION ") + ll_safe_string((const char *)glGetString(GL_VERSION)) + std::string("\n");
478 492
479#if !LL_MESA_HEADLESS 493#if !LL_MESA_HEADLESS
480 all_exts = (const char *)gGLHExts.mSysExts; 494 all_exts = (const char *)gGLHExts.mSysExts;
481 LLString::replaceChar(all_exts, ' ', '\n'); 495 LLStringUtil::replaceChar(all_exts, ' ', '\n');
482 info_str += LLString("GL_EXTENSIONS:\n") + all_exts + LLString("\n"); 496 info_str += std::string("GL_EXTENSIONS:\n") + all_exts + std::string("\n");
483#endif 497#endif
484 498
485 return info_str; 499 return info_str;
@@ -487,26 +501,24 @@ LLString LLGLManager::getGLInfoString()
487 501
488void LLGLManager::printGLInfoString() 502void LLGLManager::printGLInfoString()
489{ 503{
490 LLString info_str; 504 std::string info_str;
491 LLString all_exts, line; 505 std::string all_exts, line;
492 506
493 LL_INFOS("RenderInit") << "GL_VENDOR: " << ((const char *)glGetString(GL_VENDOR)) << LL_ENDL; 507 LL_INFOS("RenderInit") << "GL_VENDOR: " << ((const char *)glGetString(GL_VENDOR)) << LL_ENDL;
494 LL_INFOS("RenderInit") << "GL_RENDERER: " << ((const char *)glGetString(GL_RENDERER)) << LL_ENDL; 508 LL_INFOS("RenderInit") << "GL_RENDERER: " << ((const char *)glGetString(GL_RENDERER)) << LL_ENDL;
495 LL_INFOS("RenderInit") << "GL_VERSION: " << ((const char *)glGetString(GL_VERSION)) << LL_ENDL; 509 LL_INFOS("RenderInit") << "GL_VERSION: " << ((const char *)glGetString(GL_VERSION)) << LL_ENDL;
496 510
497#if !LL_MESA_HEADLESS 511#if !LL_MESA_HEADLESS
498 all_exts = (const char *)gGLHExts.mSysExts; 512 all_exts = std::string(gGLHExts.mSysExts);
499 LLString::replaceChar(all_exts, ' ', '\n'); 513 LLStringUtil::replaceChar(all_exts, ' ', '\n');
500 LL_DEBUGS("RenderInit") << "GL_EXTENSIONS:\n" << all_exts << LL_ENDL; 514 LL_DEBUGS("RenderInit") << "GL_EXTENSIONS:\n" << all_exts << LL_ENDL;
501#endif 515#endif
502} 516}
503 517
504LLString LLGLManager::getRawGLString() 518std::string LLGLManager::getRawGLString()
505{ 519{
506 LLString gl_string; 520 std::string gl_string;
507 gl_string.assign((char*)glGetString(GL_VENDOR)); 521 gl_string = ll_safe_string((char*)glGetString(GL_VENDOR)) + " " + ll_safe_string((char*)glGetString(GL_RENDERER));
508 gl_string.append(" ");
509 gl_string.append((char*)glGetString(GL_RENDERER));
510 return gl_string; 522 return gl_string;
511} 523}
512 524
@@ -991,11 +1003,12 @@ void LLGLState::initClass()
991 sStateMap[GL_DITHER] = GL_TRUE; 1003 sStateMap[GL_DITHER] = GL_TRUE;
992 sStateMap[GL_TEXTURE_2D] = GL_TRUE; 1004 sStateMap[GL_TEXTURE_2D] = GL_TRUE;
993 1005
994 //make sure vertex arrays are enabled 1006 //make sure multisample defaults to disabled
995 glEnableClientState(GL_VERTEX_ARRAY); 1007 sStateMap[GL_MULTISAMPLE_ARB] = GL_FALSE;
996
997 //make sure multi sampling is disabled by default
998 glDisable(GL_MULTISAMPLE_ARB); 1008 glDisable(GL_MULTISAMPLE_ARB);
1009
1010 //default vertex arrays to enabled.
1011 glEnableClientState(GL_VERTEX_ARRAY);
999} 1012}
1000 1013
1001//static 1014//static
@@ -1031,7 +1044,7 @@ void LLGLState::dumpStates()
1031 } 1044 }
1032} 1045}
1033 1046
1034void LLGLState::checkStates() 1047void LLGLState::checkStates(const std::string& msg)
1035{ 1048{
1036 if (!gDebugGL) 1049 if (!gDebugGL)
1037 { 1050 {
@@ -1055,7 +1068,7 @@ void LLGLState::checkStates()
1055 1068
1056 if (src != GL_SRC_ALPHA || dst != GL_ONE_MINUS_SRC_ALPHA) 1069 if (src != GL_SRC_ALPHA || dst != GL_ONE_MINUS_SRC_ALPHA)
1057 { 1070 {
1058 LL_GL_ERRS << "Blend function corrupted: " << std::hex << src << " " << std::hex << dst << LL_ENDL; 1071 LL_GL_ERRS << "Blend function corrupted: " << std::hex << src << " " << std::hex << dst << " " << msg << LL_ENDL;
1059 } 1072 }
1060 1073
1061 for (std::map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin(); 1074 for (std::map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
@@ -1074,7 +1087,7 @@ void LLGLState::checkStates()
1074 stop_glerror(); 1087 stop_glerror();
1075} 1088}
1076 1089
1077void LLGLState::checkTextureChannels() 1090void LLGLState::checkTextureChannels(const std::string& msg)
1078{ 1091{
1079 if (!gDebugGL) 1092 if (!gDebugGL)
1080 { 1093 {
@@ -1175,11 +1188,11 @@ void LLGLState::checkTextureChannels()
1175 1188
1176 if (error) 1189 if (error)
1177 { 1190 {
1178 LL_GL_ERRS << "GL texture state corruption detected." << LL_ENDL; 1191 LL_GL_ERRS << "GL texture state corruption detected. " << msg << LL_ENDL;
1179 } 1192 }
1180} 1193}
1181 1194
1182void LLGLState::checkClientArrays(U32 data_mask) 1195void LLGLState::checkClientArrays(const std::string& msg, U32 data_mask)
1183{ 1196{
1184 if (!gDebugGL) 1197 if (!gDebugGL)
1185 { 1198 {
@@ -1291,7 +1304,7 @@ void LLGLState::checkClientArrays(U32 data_mask)
1291 1304
1292 if (error) 1305 if (error)
1293 { 1306 {
1294 LL_GL_ERRS << "GL client array corruption detected." << LL_ENDL; 1307 LL_GL_ERRS << "GL client array corruption detected. " << msg << LL_ENDL;
1295 } 1308 }
1296} 1309}
1297 1310
@@ -1456,7 +1469,7 @@ void set_palette(U8 *palette_data)
1456} 1469}
1457 1470
1458 1471
1459void parse_gl_version( S32* major, S32* minor, S32* release, LLString* vendor_specific ) 1472void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor_specific )
1460{ 1473{
1461 // GL_VERSION returns a null-terminated string with the format: 1474 // GL_VERSION returns a null-terminated string with the format:
1462 // <major>.<minor>[.<release>] [<vendor specific>] 1475 // <major>.<minor>[.<release>] [<vendor specific>]
@@ -1472,7 +1485,7 @@ void parse_gl_version( S32* major, S32* minor, S32* release, LLString* vendor_sp
1472 return; 1485 return;
1473 } 1486 }
1474 1487
1475 LLString ver_copy( version ); 1488 std::string ver_copy( version );
1476 S32 len = (S32)strlen( version ); /* Flawfinder: ignore */ 1489 S32 len = (S32)strlen( version ); /* Flawfinder: ignore */
1477 S32 i = 0; 1490 S32 i = 0;
1478 S32 start; 1491 S32 start;
@@ -1485,8 +1498,8 @@ void parse_gl_version( S32* major, S32* minor, S32* release, LLString* vendor_sp
1485 break; 1498 break;
1486 } 1499 }
1487 } 1500 }
1488 LLString major_str = ver_copy.substr(start,i-start); 1501 std::string major_str = ver_copy.substr(start,i-start);
1489 LLString::convertToS32(major_str, *major); 1502 LLStringUtil::convertToS32(major_str, *major);
1490 1503
1491 if( '.' == version[i] ) 1504 if( '.' == version[i] )
1492 { 1505 {
@@ -1502,8 +1515,8 @@ void parse_gl_version( S32* major, S32* minor, S32* release, LLString* vendor_sp
1502 break; 1515 break;
1503 } 1516 }
1504 } 1517 }
1505 LLString minor_str = ver_copy.substr(start,i-start); 1518 std::string minor_str = ver_copy.substr(start,i-start);
1506 LLString::convertToS32(minor_str, *minor); 1519 LLStringUtil::convertToS32(minor_str, *minor);
1507 1520
1508 // Find the release number (optional) 1521 // Find the release number (optional)
1509 if( '.' == version[i] ) 1522 if( '.' == version[i] )
@@ -1519,8 +1532,8 @@ void parse_gl_version( S32* major, S32* minor, S32* release, LLString* vendor_sp
1519 } 1532 }
1520 } 1533 }
1521 1534
1522 LLString release_str = ver_copy.substr(start,i-start); 1535 std::string release_str = ver_copy.substr(start,i-start);
1523 LLString::convertToS32(release_str, *release); 1536 LLStringUtil::convertToS32(release_str, *release);
1524 } 1537 }
1525 1538
1526 // Skip over any white space 1539 // Skip over any white space
@@ -1616,6 +1629,7 @@ void LLGLNamePool::cleanup()
1616 1629
1617GLuint LLGLNamePool::allocate() 1630GLuint LLGLNamePool::allocate()
1618{ 1631{
1632#if LL_GL_NAME_POOLING
1619 for (name_list_t::iterator iter = mNameList.begin(); iter != mNameList.end(); ++iter) 1633 for (name_list_t::iterator iter = mNameList.begin(); iter != mNameList.end(); ++iter)
1620 { 1634 {
1621 if (!iter->used) 1635 if (!iter->used)
@@ -1631,18 +1645,33 @@ GLuint LLGLNamePool::allocate()
1631 mNameList.push_back(entry); 1645 mNameList.push_back(entry);
1632 1646
1633 return entry.name; 1647 return entry.name;
1648#else
1649 return allocateName();
1650#endif
1634} 1651}
1635 1652
1636void LLGLNamePool::release(GLuint name) 1653void LLGLNamePool::release(GLuint name)
1637{ 1654{
1655#if LL_GL_NAME_POOLING
1638 for (name_list_t::iterator iter = mNameList.begin(); iter != mNameList.end(); ++iter) 1656 for (name_list_t::iterator iter = mNameList.begin(); iter != mNameList.end(); ++iter)
1639 { 1657 {
1640 if (iter->name == name) 1658 if (iter->name == name)
1641 { 1659 {
1642 iter->used = FALSE; 1660 if (iter->used)
1643 return; 1661 {
1662 iter->used = FALSE;
1663 return;
1664 }
1665 else
1666 {
1667 llerrs << "Attempted to release a pooled name that is not in use!" << llendl;
1668 }
1644 } 1669 }
1645 } 1670 }
1671 llerrs << "Attempted to release a non pooled name!" << llendl;
1672#else
1673 releaseName(name);
1674#endif
1646} 1675}
1647 1676
1648//static 1677//static
diff --git a/linden/indra/llwindow/llgl.h b/linden/indra/llrender/llgl.h
index 2618dca..cb368d7 100644
--- a/linden/indra/llwindow/llgl.h
+++ b/linden/indra/llrender/llgl.h
@@ -65,7 +65,7 @@ public:
65 65
66 void initWGL(); // Initializes stupid WGL extensions 66 void initWGL(); // Initializes stupid WGL extensions
67 67
68 LLString getRawGLString(); // For sending to simulator 68 std::string getRawGLString(); // For sending to simulator
69 69
70 BOOL mInited; 70 BOOL mInited;
71 BOOL mIsDisabled; 71 BOOL mIsDisabled;
@@ -100,6 +100,7 @@ public:
100 BOOL mIsGF3; 100 BOOL mIsGF3;
101 BOOL mIsGFFX; 101 BOOL mIsGFFX;
102 BOOL mATIOffsetVerticalLines; 102 BOOL mATIOffsetVerticalLines;
103 BOOL mATIOldDriver;
103 104
104 // Whether this version of GL is good enough for SL to use 105 // Whether this version of GL is good enough for SL to use
105 BOOL mHasRequirements; 106 BOOL mHasRequirements;
@@ -111,7 +112,7 @@ public:
111 S32 mDriverVersionMinor; 112 S32 mDriverVersionMinor;
112 S32 mDriverVersionRelease; 113 S32 mDriverVersionRelease;
113 F32 mGLVersion; // e.g = 1.4 114 F32 mGLVersion; // e.g = 1.4
114 LLString mDriverVersionVendorString; 115 std::string mDriverVersionVendorString;
115 116
116 S32 mVRAM; // VRAM in MB 117 S32 mVRAM; // VRAM in MB
117 S32 mGLMaxVertexRange; 118 S32 mGLMaxVertexRange;
@@ -119,16 +120,16 @@ public:
119 120
120 void getPixelFormat(); // Get the best pixel format 121 void getPixelFormat(); // Get the best pixel format
121 122
122 LLString getGLInfoString(); 123 std::string getGLInfoString();
123 void printGLInfoString(); 124 void printGLInfoString();
124 void getGLInfo(LLSD& info); 125 void getGLInfo(LLSD& info);
125 126
126 // In ALL CAPS 127 // In ALL CAPS
127 LLString mGLVendor; 128 std::string mGLVendor;
128 LLString mGLVendorShort; 129 std::string mGLVendorShort;
129 130
130 // In ALL CAPS 131 // In ALL CAPS
131 LLString mGLRenderer; 132 std::string mGLRenderer;
132 133
133private: 134private:
134 void initExtensions(); 135 void initExtensions();
@@ -222,9 +223,9 @@ public:
222 223
223 static void resetTextureStates(); 224 static void resetTextureStates();
224 static void dumpStates(); 225 static void dumpStates();
225 static void checkStates(); 226 static void checkStates(const std::string& msg = "");
226 static void checkTextureChannels(); 227 static void checkTextureChannels(const std::string& msg = "");
227 static void checkClientArrays(U32 data_mask = 0x0001); 228 static void checkClientArrays(const std::string& msg = "", U32 data_mask = 0x0001);
228 229
229protected: 230protected:
230 static std::map<LLGLenum, LLGLboolean> sStateMap; 231 static std::map<LLGLenum, LLGLboolean> sStateMap;
@@ -370,7 +371,7 @@ void set_vertex_weights(const S32 index, const U32 stride, const F32 *weights);
370void set_vertex_clothing_weights(const S32 index, const U32 stride, const LLVector4 *weights); 371void set_vertex_clothing_weights(const S32 index, const U32 stride, const LLVector4 *weights);
371void set_binormals(const S32 index, const U32 stride, const LLVector3 *binormals); 372void set_binormals(const S32 index, const U32 stride, const LLVector3 *binormals);
372void set_palette(U8* palette_data); 373void set_palette(U8* palette_data);
373void parse_gl_version( S32* major, S32* minor, S32* release, LLString* vendor_specific ); 374void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor_specific );
374 375
375extern BOOL gClothRipple; 376extern BOOL gClothRipple;
376extern BOOL gNoRender; 377extern BOOL gNoRender;
diff --git a/linden/indra/llrender/llgldbg.cpp b/linden/indra/llrender/llgldbg.cpp
index 953ba3a..526215b 100644
--- a/linden/indra/llrender/llgldbg.cpp
+++ b/linden/indra/llrender/llgldbg.cpp
@@ -43,7 +43,7 @@
43//------------------------------------------------------------------------ 43//------------------------------------------------------------------------
44// cmstr() 44// cmstr()
45//------------------------------------------------------------------------ 45//------------------------------------------------------------------------
46char *cmstr(int i) 46const char *cmstr(int i)
47{ 47{
48 switch( i ) 48 switch( i )
49 { 49 {
@@ -59,7 +59,7 @@ char *cmstr(int i)
59//------------------------------------------------------------------------ 59//------------------------------------------------------------------------
60// facestr() 60// facestr()
61//------------------------------------------------------------------------ 61//------------------------------------------------------------------------
62char *facestr(int i) 62const char *facestr(int i)
63{ 63{
64 switch( i ) 64 switch( i )
65 { 65 {
@@ -81,7 +81,7 @@ const char *boolstr(int b)
81//------------------------------------------------------------------------ 81//------------------------------------------------------------------------
82// fv4() 82// fv4()
83//------------------------------------------------------------------------ 83//------------------------------------------------------------------------
84char *fv4(F32 *f) 84const char *fv4(F32 *f)
85{ 85{
86 static char str[128]; 86 static char str[128];
87 sprintf(str, "%8.3f %8.3f %8.3f %8.3f", f[0], f[1], f[2], f[3]); 87 sprintf(str, "%8.3f %8.3f %8.3f %8.3f", f[0], f[1], f[2], f[3]);
@@ -91,7 +91,7 @@ char *fv4(F32 *f)
91//------------------------------------------------------------------------ 91//------------------------------------------------------------------------
92// fv3() 92// fv3()
93//------------------------------------------------------------------------ 93//------------------------------------------------------------------------
94char *fv3(F32 *f) 94const char *fv3(F32 *f)
95{ 95{
96 static char str[128]; /* Flawfinder: ignore */ 96 static char str[128]; /* Flawfinder: ignore */
97 snprintf(str, sizeof(str), "%8.3f, %8.3f, %8.3f", f[0], f[1], f[2]); /* Flawfinder: ignore */ 97 snprintf(str, sizeof(str), "%8.3f, %8.3f, %8.3f", f[0], f[1], f[2]); /* Flawfinder: ignore */
@@ -101,7 +101,7 @@ char *fv3(F32 *f)
101//------------------------------------------------------------------------ 101//------------------------------------------------------------------------
102// fv1() 102// fv1()
103//------------------------------------------------------------------------ 103//------------------------------------------------------------------------
104char *fv1(F32 *f) 104const char *fv1(F32 *f)
105{ 105{
106 static char str[128]; /* Flawfinder: ignore */ 106 static char str[128]; /* Flawfinder: ignore */
107 snprintf(str, sizeof(str), "%8.3f", f[0]); /* Flawfinder: ignore */ 107 snprintf(str, sizeof(str), "%8.3f", f[0]); /* Flawfinder: ignore */
diff --git a/linden/indra/llwindow/llglheaders.h b/linden/indra/llrender/llglheaders.h
index d66fbe4..f047262 100644
--- a/linden/indra/llwindow/llglheaders.h
+++ b/linden/indra/llrender/llglheaders.h
@@ -32,15 +32,6 @@
32#ifndef LL_LLGLHEADERS_H 32#ifndef LL_LLGLHEADERS_H
33#define LL_LLGLHEADERS_H 33#define LL_LLGLHEADERS_H
34 34
35#if LL_LINUX
36# ifndef LL_MESA
37# define LL_MESA 1 // force MESA
38# endif
39# ifndef LL_MESA_HEADLESS
40# define LL_MESA_HEADLESS 1 // force MESA HEADLESS
41# endif
42#endif
43
44#if LL_MESA 35#if LL_MESA
45//---------------------------------------------------------------------------- 36//----------------------------------------------------------------------------
46// MESA headers 37// MESA headers
diff --git a/linden/indra/llrender/llglimmediate.cpp b/linden/indra/llrender/llglimmediate.cpp
index 17c2182..9b60e49 100644
--- a/linden/indra/llrender/llglimmediate.cpp
+++ b/linden/indra/llrender/llglimmediate.cpp
@@ -1 +1,265 @@
1<<<<<<< .working
1#error This file has been renamed llrender.cpp 2#error This file has been renamed llrender.cpp
3=======
4/**
5 * @file llglimmediate.cpp
6 * @brief LLGLImmediate implementation
7 *
8 * $LicenseInfo:firstyear=2001&license=viewergpl$
9 *
10 * Copyright (c) 2001-2008, Linden Research, Inc.
11 *
12 * Second Life Viewer Source Code
13 * The source code in this file ("Source Code") is provided by Linden Lab
14 * to you under the terms of the GNU General Public License, version 2.0
15 * ("GPL"), unless you have obtained a separate licensing agreement
16 * ("Other License"), formally executed by you and Linden Lab. Terms of
17 * the GPL can be found in doc/GPL-license.txt in this distribution, or
18 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
19 *
20 * There are special exceptions to the terms and conditions of the GPL as
21 * it is applied to this Source Code. View the full text of the exception
22 * in the file doc/FLOSS-exception.txt in this software distribution, or
23 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
24 *
25 * By copying, modifying or distributing this software, you acknowledge
26 * that you have read and understood your obligations described above,
27 * and agree to abide by those obligations.
28 *
29 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
30 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
31 * COMPLETENESS OR PERFORMANCE.
32 * $/LicenseInfo$
33 */
34
35#include "linden_common.h"
36
37#include "llglimmediate.h"
38#include "llvertexbuffer.h"
39
40LLGLImmediate gGL;
41
42const U32 immediate_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXCOORD;
43
44LLGLImmediate::LLGLImmediate()
45{
46 mCount = 0;
47 mMode = LLVertexBuffer::TRIANGLES;
48 mBuffer = new LLVertexBuffer(immediate_mask, 0);
49 mBuffer->allocateBuffer(4096, 0, TRUE);
50 mBuffer->getVertexStrider(mVerticesp);
51 mBuffer->getTexCoordStrider(mTexcoordsp);
52 mBuffer->getColorStrider(mColorsp);
53}
54
55void LLGLImmediate::translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z)
56{
57 flush();
58 glTranslatef(x,y,z);
59}
60
61void LLGLImmediate::scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z)
62{
63 flush();
64 glScalef(x,y,z);
65}
66
67void LLGLImmediate::pushMatrix()
68{
69 flush();
70 glPushMatrix();
71}
72
73void LLGLImmediate::popMatrix()
74{
75 flush();
76 glPopMatrix();
77}
78
79void LLGLImmediate::blendFunc(GLenum sfactor, GLenum dfactor)
80{
81 flush();
82 glBlendFunc(sfactor, dfactor);
83}
84
85void LLGLImmediate::begin(const GLuint& mode)
86{
87 if (mode != mMode)
88 {
89 if (mMode == LLVertexBuffer::QUADS ||
90 mMode == LLVertexBuffer::LINES ||
91 mMode == LLVertexBuffer::TRIANGLES ||
92 mMode == LLVertexBuffer::POINTS)
93 {
94 flush();
95 }
96 else if (mCount != 0)
97 {
98 llerrs << "gGL.begin() called redundantly." << llendl;
99 }
100
101 mMode = mode;
102 }
103}
104
105void LLGLImmediate::end()
106{
107 if (mCount == 0)
108 {
109 return;
110 //IMM_ERRS << "GL begin and end called with no vertices specified." << llendl;
111 }
112
113 if ((mMode != LLVertexBuffer::QUADS &&
114 mMode != LLVertexBuffer::LINES &&
115 mMode != LLVertexBuffer::TRIANGLES &&
116 mMode != LLVertexBuffer::POINTS) ||
117 mCount > 2048)
118 {
119 flush();
120 }
121}
122
123void LLGLImmediate::flush()
124{
125 if (mCount > 0)
126 {
127#if 0
128 if (!glIsEnabled(GL_VERTEX_ARRAY))
129 {
130 llerrs << "foo 1" << llendl;
131 }
132
133 if (!glIsEnabled(GL_COLOR_ARRAY))
134 {
135 llerrs << "foo 2" << llendl;
136 }
137
138 if (!glIsEnabled(GL_TEXTURE_COORD_ARRAY))
139 {
140 llerrs << "foo 3" << llendl;
141 }
142
143 if (glIsEnabled(GL_NORMAL_ARRAY))
144 {
145 llerrs << "foo 7" << llendl;
146 }
147
148 GLvoid* pointer;
149
150 glGetPointerv(GL_VERTEX_ARRAY_POINTER, &pointer);
151 if (pointer != &(mBuffer[0].v))
152 {
153 llerrs << "foo 4" << llendl;
154 }
155
156 glGetPointerv(GL_COLOR_ARRAY_POINTER, &pointer);
157 if (pointer != &(mBuffer[0].c))
158 {
159 llerrs << "foo 5" << llendl;
160 }
161
162 glGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER, &pointer);
163 if (pointer != &(mBuffer[0].uv))
164 {
165 llerrs << "foo 6" << llendl;
166 }
167#endif
168
169 mBuffer->setBuffer(immediate_mask);
170 mBuffer->drawArrays(mMode, 0, mCount);
171
172 mVerticesp[0] = mVerticesp[mCount];
173 mTexcoordsp[0] = mTexcoordsp[mCount];
174 mColorsp[0] = mColorsp[mCount];
175 mCount = 0;
176 }
177}
178
179void LLGLImmediate::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z)
180{
181 if (mCount >= 4096)
182 {
183 // llwarns << "GL immediate mode overflow. Some geometry not drawn." << llendl;
184 return;
185 }
186
187 mVerticesp[mCount] = LLVector3(x,y,z);
188 mCount++;
189 if (mCount < 4096)
190 {
191 mVerticesp[mCount] = mVerticesp[mCount-1];
192 mColorsp[mCount] = mColorsp[mCount-1];
193 mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
194 }
195}
196
197void LLGLImmediate::vertex2i(const GLint& x, const GLint& y)
198{
199 vertex3f((GLfloat) x, (GLfloat) y, 0);
200}
201
202void LLGLImmediate::vertex2f(const GLfloat& x, const GLfloat& y)
203{
204 vertex3f(x,y,0);
205}
206
207void LLGLImmediate::vertex2fv(const GLfloat* v)
208{
209 vertex3f(v[0], v[1], 0);
210}
211
212void LLGLImmediate::vertex3fv(const GLfloat* v)
213{
214 vertex3f(v[0], v[1], v[2]);
215}
216
217void LLGLImmediate::texCoord2f(const GLfloat& x, const GLfloat& y)
218{
219 mTexcoordsp[mCount] = LLVector2(x,y);
220}
221
222void LLGLImmediate::texCoord2i(const GLint& x, const GLint& y)
223{
224 texCoord2f((GLfloat) x, (GLfloat) y);
225}
226
227void LLGLImmediate::texCoord2fv(const GLfloat* tc)
228{
229 texCoord2f(tc[0], tc[1]);
230}
231
232void LLGLImmediate::color4ub(const GLubyte& r, const GLubyte& g, const GLubyte& b, const GLubyte& a)
233{
234 mColorsp[mCount] = LLColor4U(r,g,b,a);
235}
236
237void LLGLImmediate::color4ubv(const GLubyte* c)
238{
239 color4ub(c[0], c[1], c[2], c[3]);
240}
241
242void LLGLImmediate::color4f(const GLfloat& r, const GLfloat& g, const GLfloat& b, const GLfloat& a)
243{
244 color4ub((GLubyte) (llclamp(r, 0.f, 1.f)*255),
245 (GLubyte) (llclamp(g, 0.f, 1.f)*255),
246 (GLubyte) (llclamp(b, 0.f, 1.f)*255),
247 (GLubyte) (llclamp(a, 0.f, 1.f)*255));
248}
249
250void LLGLImmediate::color4fv(const GLfloat* c)
251{
252 color4f(c[0],c[1],c[2],c[3]);
253}
254
255void LLGLImmediate::color3f(const GLfloat& r, const GLfloat& g, const GLfloat& b)
256{
257 color4f(r,g,b,1);
258}
259
260void LLGLImmediate::color3fv(const GLfloat* c)
261{
262 color4f(c[0],c[1],c[2],1);
263}
264
265>>>>>>> .merge-right.r88690
diff --git a/linden/indra/llrender/llglimmediate.h b/linden/indra/llrender/llglimmediate.h
index 4a7a0eb..2d7d768 100644
--- a/linden/indra/llrender/llglimmediate.h
+++ b/linden/indra/llrender/llglimmediate.h
@@ -1 +1,98 @@
1<<<<<<< .working
1#error This file has been renamed llrender.h 2#error This file has been renamed llrender.h
3=======
4/**
5 * @file llglimmediate.h
6 * @brief LLGLImmediate definition
7 *
8 * This class acts as a wrapper for OpenGL immediate calls concerning glBegin and glEnd.
9 * The goal of this class is to minimize the number of api calls due to legacy rendering
10 * code, and to define an interface for a multiple rendering API abstraction of the UI
11 * rendering.
12 *
13 * $LicenseInfo:firstyear=2001&license=viewergpl$
14 *
15 * Copyright (c) 2001-2008, Linden Research, Inc.
16 *
17 * Second Life Viewer Source Code
18 * The source code in this file ("Source Code") is provided by Linden Lab
19 * to you under the terms of the GNU General Public License, version 2.0
20 * ("GPL"), unless you have obtained a separate licensing agreement
21 * ("Other License"), formally executed by you and Linden Lab. Terms of
22 * the GPL can be found in doc/GPL-license.txt in this distribution, or
23 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
24 *
25 * There are special exceptions to the terms and conditions of the GPL as
26 * it is applied to this Source Code. View the full text of the exception
27 * in the file doc/FLOSS-exception.txt in this software distribution, or
28 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
29 *
30 * By copying, modifying or distributing this software, you acknowledge
31 * that you have read and understood your obligations described above,
32 * and agree to abide by those obligations.
33 *
34 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
35 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
36 * COMPLETENESS OR PERFORMANCE.
37 * $/LicenseInfo$
38 */
39
40#ifndef LL_LLGLIMMEDIATE_H
41#define LL_LLGLIMMEDIATE_H
42
43#include "stdtypes.h"
44#include "llgltypes.h"
45#include "llglheaders.h"
46#include "llvertexbuffer.h"
47
48class LLGLImmediate
49{
50public:
51 LLGLImmediate();
52
53 void translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z);
54 void scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z);
55 void pushMatrix();
56 void popMatrix();
57 void blendFunc(GLenum sfactor, GLenum dfactor);
58 void flush();
59
60 void begin(const GLuint& mode);
61 void end();
62 void vertex2i(const GLint& x, const GLint& y);
63 void vertex2f(const GLfloat& x, const GLfloat& y);
64 void vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z);
65 void vertex2fv(const GLfloat* v);
66 void vertex3fv(const GLfloat* v);
67
68 void texCoord2i(const GLint& x, const GLint& y);
69 void texCoord2f(const GLfloat& x, const GLfloat& y);
70 void texCoord2fv(const GLfloat* tc);
71
72 void color4ub(const GLubyte& r, const GLubyte& g, const GLubyte& b, const GLubyte& a);
73 void color4f(const GLfloat& r, const GLfloat& g, const GLfloat& b, const GLfloat& a);
74 void color4fv(const GLfloat* c);
75 void color3f(const GLfloat& r, const GLfloat& g, const GLfloat& b);
76 void color3fv(const GLfloat* c);
77 void color4ubv(const GLubyte* c);
78
79 typedef struct Vertex
80 {
81 GLfloat v[3];
82 GLubyte c[4];
83 GLfloat uv[2];
84 };
85
86private:
87 U32 mCount;
88 U32 mMode;
89 LLPointer<LLVertexBuffer> mBuffer;
90 LLStrider<LLVector3> mVerticesp;
91 LLStrider<LLVector2> mTexcoordsp;
92 LLStrider<LLColor4U> mColorsp;
93};
94
95extern LLGLImmediate gGL;
96
97#endif
98>>>>>>> .merge-right.r88690
diff --git a/linden/indra/llrender/llglslshader.cpp b/linden/indra/llrender/llglslshader.cpp
new file mode 100644
index 0000000..26984e1
--- /dev/null
+++ b/linden/indra/llrender/llglslshader.cpp
@@ -0,0 +1,823 @@
1/**
2 * @file llglslshader.cpp
3 * @brief GLSL helper functions and state.
4 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$
6 *
7 * Copyright (c) 2005-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "linden_common.h"
33
34#include "llglslshader.h"
35
36#include "llshadermgr.h"
37#include "llfile.h"
38#include "llrender.h"
39
40#if LL_DARWIN
41#include "OpenGL/OpenGL.h"
42#endif
43
44#ifdef LL_RELEASE_FOR_DOWNLOAD
45#define UNIFORM_ERRS LL_WARNS_ONCE("Shader")
46#else
47#define UNIFORM_ERRS LL_ERRS("Shader")
48#endif
49
50// Lots of STL stuff in here, using namespace std to keep things more readable
51using std::vector;
52using std::pair;
53using std::make_pair;
54using std::string;
55
56BOOL shouldChange(const LLVector4& v1, const LLVector4& v2)
57{
58 return v1 != v2;
59}
60
61LLShaderFeatures::LLShaderFeatures()
62: calculatesLighting(false), isShiny(false), isFullbright(false), hasWaterFog(false),
63hasTransport(false), hasSkinning(false), hasAtmospherics(false), isSpecular(false),
64hasGamma(false), hasLighting(false), calculatesAtmospherics(false)
65{
66}
67
68//===============================
69// LLGLSL Shader implementation
70//===============================
71LLGLSLShader::LLGLSLShader()
72: mProgramObject(0), mShaderLevel(0), mShaderGroup(SG_DEFAULT)
73{
74}
75
76void LLGLSLShader::unload()
77{
78 stop_glerror();
79 mAttribute.clear();
80 mTexture.clear();
81 mUniform.clear();
82 mShaderFiles.clear();
83
84 if (mProgramObject)
85 {
86 GLhandleARB obj[1024];
87 GLsizei count;
88
89 glGetAttachedObjectsARB(mProgramObject, 1024, &count, obj);
90 for (GLsizei i = 0; i < count; i++)
91 {
92 glDeleteObjectARB(obj[i]);
93 }
94
95 glDeleteObjectARB(mProgramObject);
96
97 mProgramObject = 0;
98 }
99
100 //hack to make apple not complain
101 glGetError();
102
103 stop_glerror();
104}
105
106BOOL LLGLSLShader::createShader(vector<string> * attributes,
107 vector<string> * uniforms)
108{
109 llassert_always(!mShaderFiles.empty());
110 BOOL success = TRUE;
111
112 // Create program
113 mProgramObject = glCreateProgramObjectARB();
114
115 // Attach existing objects
116 if (!LLShaderMgr::instance()->attachShaderFeatures(this))
117 {
118 return FALSE;
119 }
120
121 vector< pair<string,GLenum> >::iterator fileIter = mShaderFiles.begin();
122 for ( ; fileIter != mShaderFiles.end(); fileIter++ )
123 {
124 GLhandleARB shaderhandle = LLShaderMgr::instance()->loadShaderFile((*fileIter).first, mShaderLevel, (*fileIter).second);
125 LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << LL_ENDL;
126 if (mShaderLevel > 0)
127 {
128 attachObject(shaderhandle);
129 }
130 else
131 {
132 success = FALSE;
133 }
134 }
135
136 // Map attributes and uniforms
137 if (success)
138 {
139 success = mapAttributes(attributes);
140 }
141 if (success)
142 {
143 success = mapUniforms(uniforms);
144 }
145 if( !success )
146 {
147 LL_WARNS("ShaderLoading") << "Failed to link shader: " << mName << LL_ENDL;
148
149 // Try again using a lower shader level;
150 if (mShaderLevel > 0)
151 {
152 LL_WARNS("ShaderLoading") << "Failed to link using shader level " << mShaderLevel << " trying again using shader level " << (mShaderLevel - 1) << LL_ENDL;
153 mShaderLevel--;
154 return createShader(attributes,uniforms);
155 }
156 }
157 return success;
158}
159
160BOOL LLGLSLShader::attachObject(std::string object)
161{
162 if (LLShaderMgr::instance()->mShaderObjects.count(object) > 0)
163 {
164 stop_glerror();
165 glAttachObjectARB(mProgramObject, LLShaderMgr::instance()->mShaderObjects[object]);
166 stop_glerror();
167 return TRUE;
168 }
169 else
170 {
171 LL_WARNS("ShaderLoading") << "Attempting to attach shader object that hasn't been compiled: " << object << LL_ENDL;
172 return FALSE;
173 }
174}
175
176void LLGLSLShader::attachObject(GLhandleARB object)
177{
178 if (object != 0)
179 {
180 stop_glerror();
181 glAttachObjectARB(mProgramObject, object);
182 stop_glerror();
183 }
184 else
185 {
186 LL_WARNS("ShaderLoading") << "Attempting to attach non existing shader object. " << LL_ENDL;
187 }
188}
189
190void LLGLSLShader::attachObjects(GLhandleARB* objects, S32 count)
191{
192 for (S32 i = 0; i < count; i++)
193 {
194 attachObject(objects[i]);
195 }
196}
197
198BOOL LLGLSLShader::mapAttributes(const vector<string> * attributes)
199{
200 //link the program
201 BOOL res = link();
202
203 mAttribute.clear();
204 U32 numAttributes = (attributes == NULL) ? 0 : attributes->size();
205 mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size() + numAttributes, -1);
206
207 if (res)
208 { //read back channel locations
209
210 //read back reserved channels first
211 for (U32 i = 0; i < (S32) LLShaderMgr::instance()->mReservedAttribs.size(); i++)
212 {
213 const char* name = LLShaderMgr::instance()->mReservedAttribs[i].c_str();
214 S32 index = glGetAttribLocationARB(mProgramObject, (const GLcharARB *)name);
215 if (index != -1)
216 {
217 mAttribute[i] = index;
218 LL_DEBUGS("ShaderLoading") << "Attribute " << name << " assigned to channel " << index << LL_ENDL;
219 }
220 }
221 if (attributes != NULL)
222 {
223 for (U32 i = 0; i < numAttributes; i++)
224 {
225 const char* name = (*attributes)[i].c_str();
226 S32 index = glGetAttribLocationARB(mProgramObject, name);
227 if (index != -1)
228 {
229 mAttribute[LLShaderMgr::instance()->mReservedAttribs.size() + i] = index;
230 LL_DEBUGS("ShaderLoading") << "Attribute " << name << " assigned to channel " << index << LL_ENDL;
231 }
232 }
233 }
234
235 return TRUE;
236 }
237
238 return FALSE;
239}
240
241void LLGLSLShader::mapUniform(GLint index, const vector<string> * uniforms)
242{
243 if (index == -1)
244 {
245 return;
246 }
247
248 GLenum type;
249 GLsizei length;
250 GLint size;
251 char name[1024]; /* Flawfinder: ignore */
252 name[0] = 0;
253
254 glGetActiveUniformARB(mProgramObject, index, 1024, &length, &size, &type, (GLcharARB *)name);
255 S32 location = glGetUniformLocationARB(mProgramObject, name);
256 if (location != -1)
257 {
258 mUniformMap[name] = location;
259 LL_DEBUGS("ShaderLoading") << "Uniform " << name << " is at location " << location << LL_ENDL;
260
261 //find the index of this uniform
262 for (S32 i = 0; i < (S32) LLShaderMgr::instance()->mReservedUniforms.size(); i++)
263 {
264 if ( (mUniform[i] == -1)
265 && (LLShaderMgr::instance()->mReservedUniforms[i].compare(0, length, name, LLShaderMgr::instance()->mReservedUniforms[i].length()) == 0))
266 {
267 //found it
268 mUniform[i] = location;
269 mTexture[i] = mapUniformTextureChannel(location, type);
270 return;
271 }
272 }
273
274 if (uniforms != NULL)
275 {
276 for (U32 i = 0; i < uniforms->size(); i++)
277 {
278 if ( (mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] == -1)
279 && ((*uniforms)[i].compare(0, length, name, (*uniforms)[i].length()) == 0))
280 {
281 //found it
282 mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] = location;
283 mTexture[i+LLShaderMgr::instance()->mReservedUniforms.size()] = mapUniformTextureChannel(location, type);
284 return;
285 }
286 }
287 }
288 }
289 }
290
291GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type)
292{
293 if (type >= GL_SAMPLER_1D_ARB && type <= GL_SAMPLER_2D_RECT_SHADOW_ARB)
294 { //this here is a texture
295 glUniform1iARB(location, mActiveTextureChannels);
296 LL_DEBUGS("ShaderLoading") << "Assigned to texture channel " << mActiveTextureChannels << LL_ENDL;
297 return mActiveTextureChannels++;
298 }
299 return -1;
300}
301
302BOOL LLGLSLShader::mapUniforms(const vector<string> * uniforms)
303{
304 BOOL res = TRUE;
305
306 mActiveTextureChannels = 0;
307 mUniform.clear();
308 mUniformMap.clear();
309 mTexture.clear();
310 mValue.clear();
311 //initialize arrays
312 U32 numUniforms = (uniforms == NULL) ? 0 : uniforms->size();
313 mUniform.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1);
314 mTexture.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1);
315
316 bind();
317
318 //get the number of active uniforms
319 GLint activeCount;
320 glGetObjectParameterivARB(mProgramObject, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &activeCount);
321
322 for (S32 i = 0; i < activeCount; i++)
323 {
324 mapUniform(i, uniforms);
325 }
326
327 unbind();
328
329 return res;
330}
331
332BOOL LLGLSLShader::link(BOOL suppress_errors)
333{
334 return LLShaderMgr::instance()->linkProgramObject(mProgramObject, suppress_errors);
335}
336
337void LLGLSLShader::bind()
338{
339 if (gGLManager.mHasShaderObjects)
340 {
341 glUseProgramObjectARB(mProgramObject);
342
343 if (mUniformsDirty)
344 {
345 LLShaderMgr::instance()->updateShaderUniforms(this);
346 mUniformsDirty = FALSE;
347 }
348 }
349}
350
351void LLGLSLShader::unbind()
352{
353 if (gGLManager.mHasShaderObjects)
354 {
355 for (U32 i = 0; i < mAttribute.size(); ++i)
356 {
357 vertexAttrib4f(i, 0,0,0,1);
358 }
359 glUseProgramObjectARB(0);
360 }
361}
362
363void LLGLSLShader::bindNoShader(void)
364{
365 glUseProgramObjectARB(0);
366}
367
368S32 LLGLSLShader::enableTexture(S32 uniform, S32 mode)
369{
370 if (uniform < 0 || uniform >= (S32)mTexture.size())
371 {
372 UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL;
373 return -1;
374 }
375 S32 index = mTexture[uniform];
376 if (index != -1)
377 {
378 gGL.getTexUnit(index)->activate();
379 glEnable(mode);
380 }
381 return index;
382}
383
384S32 LLGLSLShader::disableTexture(S32 uniform, S32 mode)
385{
386 if (uniform < 0 || uniform >= (S32)mTexture.size())
387 {
388 UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL;
389 return -1;
390 }
391 S32 index = mTexture[uniform];
392 if (index != -1)
393 {
394 gGL.getTexUnit(index)->activate();
395 glDisable(mode);
396 }
397 return index;
398}
399
400void LLGLSLShader::uniform1f(U32 index, GLfloat x)
401{
402 if (mProgramObject > 0)
403 {
404 if (mUniform.size() <= index)
405 {
406 UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
407 return;
408 }
409
410 if (mUniform[index] >= 0)
411 {
412 std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
413 if (iter == mValue.end() || iter->second.mV[0] != x)
414 {
415 glUniform1fARB(mUniform[index], x);
416 mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f);
417 }
418 }
419 }
420}
421
422void LLGLSLShader::uniform2f(U32 index, GLfloat x, GLfloat y)
423{
424 if (mProgramObject > 0)
425 {
426 if (mUniform.size() <= index)
427 {
428 UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
429 return;
430 }
431
432 if (mUniform[index] >= 0)
433 {
434 std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
435 LLVector4 vec(x,y,0.f,0.f);
436 if (iter == mValue.end() || shouldChange(iter->second,vec))
437 {
438 glUniform2fARB(mUniform[index], x, y);
439 mValue[mUniform[index]] = vec;
440 }
441 }
442 }
443}
444
445void LLGLSLShader::uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z)
446{
447 if (mProgramObject > 0)
448 {
449 if (mUniform.size() <= index)
450 {
451 UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
452 return;
453 }
454
455 if (mUniform[index] >= 0)
456 {
457 std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
458 LLVector4 vec(x,y,z,0.f);
459 if (iter == mValue.end() || shouldChange(iter->second,vec))
460 {
461 glUniform3fARB(mUniform[index], x, y, z);
462 mValue[mUniform[index]] = vec;
463 }
464 }
465 }
466}
467
468void LLGLSLShader::uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
469{
470 if (mProgramObject > 0)
471 {
472 if (mUniform.size() <= index)
473 {
474 UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
475 return;
476 }
477
478 if (mUniform[index] >= 0)
479 {
480 std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
481 LLVector4 vec(x,y,z,w);
482 if (iter == mValue.end() || shouldChange(iter->second,vec))
483 {
484 glUniform4fARB(mUniform[index], x, y, z, w);
485 mValue[mUniform[index]] = vec;
486 }
487 }
488 }
489}
490
491void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v)
492{
493 if (mProgramObject > 0)
494 {
495 if (mUniform.size() <= index)
496 {
497 UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
498 return;
499 }
500
501 if (mUniform[index] >= 0)
502 {
503 std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
504 LLVector4 vec(v[0],0.f,0.f,0.f);
505 if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
506 {
507 glUniform1fvARB(mUniform[index], count, v);
508 mValue[mUniform[index]] = vec;
509 }
510 }
511 }
512}
513
514void LLGLSLShader::uniform2fv(U32 index, U32 count, const GLfloat* v)
515{
516 if (mProgramObject > 0)
517 {
518 if (mUniform.size() <= index)
519 {
520 UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
521 return;
522 }
523
524 if (mUniform[index] >= 0)
525 {
526 std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
527 LLVector4 vec(v[0],v[1],0.f,0.f);
528 if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
529 {
530 glUniform2fvARB(mUniform[index], count, v);
531 mValue[mUniform[index]] = vec;
532 }
533 }
534 }
535}
536
537void LLGLSLShader::uniform3fv(U32 index, U32 count, const GLfloat* v)
538{
539 if (mProgramObject > 0)
540 {
541 if (mUniform.size() <= index)
542 {
543 UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
544 return;
545 }
546
547 if (mUniform[index] >= 0)
548 {
549 std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
550 LLVector4 vec(v[0],v[1],v[2],0.f);
551 if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
552 {
553 glUniform3fvARB(mUniform[index], count, v);
554 mValue[mUniform[index]] = vec;
555 }
556 }
557 }
558}
559
560void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v)
561{
562 if (mProgramObject > 0)
563 {
564 if (mUniform.size() <= index)
565 {
566 UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
567 return;
568 }
569
570 if (mUniform[index] >= 0)
571 {
572 std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
573 LLVector4 vec(v[0],v[1],v[2],v[3]);
574 if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
575 {
576 glUniform4fvARB(mUniform[index], count, v);
577 mValue[mUniform[index]] = vec;
578 }
579 }
580 }
581}
582
583void LLGLSLShader::uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v)
584{
585 if (mProgramObject > 0)
586 {
587 if (mUniform.size() <= index)
588 {
589 UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
590 return;
591 }
592
593 if (mUniform[index] >= 0)
594 {
595 glUniformMatrix2fvARB(mUniform[index], count, transpose, v);
596 }
597 }
598}
599
600void LLGLSLShader::uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v)
601{
602 if (mProgramObject > 0)
603 {
604 if (mUniform.size() <= index)
605 {
606 UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
607 return;
608 }
609
610 if (mUniform[index] >= 0)
611 {
612 glUniformMatrix3fvARB(mUniform[index], count, transpose, v);
613 }
614 }
615}
616
617void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v)
618{
619 if (mProgramObject > 0)
620 {
621 if (mUniform.size() <= index)
622 {
623 UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
624 return;
625 }
626
627 if (mUniform[index] >= 0)
628 {
629 glUniformMatrix4fvARB(mUniform[index], count, transpose, v);
630 }
631 }
632}
633
634GLint LLGLSLShader::getUniformLocation(const string& uniform)
635{
636 if (mProgramObject > 0)
637 {
638 std::map<string, GLint>::iterator iter = mUniformMap.find(uniform);
639 if (iter != mUniformMap.end())
640 {
641 llassert(iter->second == glGetUniformLocationARB(mProgramObject, uniform.c_str()));
642 return iter->second;
643 }
644 }
645
646 return -1;
647}
648
649void LLGLSLShader::uniform1f(const string& uniform, GLfloat v)
650{
651 GLint location = getUniformLocation(uniform);
652
653 if (location >= 0)
654 {
655 std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
656 LLVector4 vec(v,0.f,0.f,0.f);
657 if (iter == mValue.end() || shouldChange(iter->second,vec))
658 {
659 glUniform1fARB(location, v);
660 mValue[location] = vec;
661 }
662 }
663}
664
665void LLGLSLShader::uniform2f(const string& uniform, GLfloat x, GLfloat y)
666{
667 GLint location = getUniformLocation(uniform);
668
669 if (location >= 0)
670 {
671 std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
672 LLVector4 vec(x,y,0.f,0.f);
673 if (iter == mValue.end() || shouldChange(iter->second,vec))
674 {
675 glUniform2fARB(location, x,y);
676 mValue[location] = vec;
677 }
678 }
679
680}
681
682void LLGLSLShader::uniform3f(const string& uniform, GLfloat x, GLfloat y, GLfloat z)
683{
684 GLint location = getUniformLocation(uniform);
685
686 if (location >= 0)
687 {
688 std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
689 LLVector4 vec(x,y,z,0.f);
690 if (iter == mValue.end() || shouldChange(iter->second,vec))
691 {
692 glUniform3fARB(location, x,y,z);
693 mValue[location] = vec;
694 }
695 }
696}
697
698void LLGLSLShader::uniform4f(const string& uniform, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
699{
700 GLint location = getUniformLocation(uniform);
701
702 if (location >= 0)
703 {
704 std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
705 LLVector4 vec(x,y,z,w);
706 if (iter == mValue.end() || shouldChange(iter->second,vec))
707 {
708 glUniform4fARB(location, x,y,z,w);
709 mValue[location] = vec;
710 }
711 }
712}
713
714void LLGLSLShader::uniform1fv(const string& uniform, U32 count, const GLfloat* v)
715{
716 GLint location = getUniformLocation(uniform);
717
718 if (location >= 0)
719 {
720 std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
721 LLVector4 vec(v[0],0.f,0.f,0.f);
722 if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
723 {
724 glUniform1fvARB(location, count, v);
725 mValue[location] = vec;
726 }
727 }
728}
729
730void LLGLSLShader::uniform2fv(const string& uniform, U32 count, const GLfloat* v)
731{
732 GLint location = getUniformLocation(uniform);
733
734 if (location >= 0)
735 {
736 std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
737 LLVector4 vec(v[0],v[1],0.f,0.f);
738 if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
739 {
740 glUniform2fvARB(location, count, v);
741 mValue[location] = vec;
742 }
743 }
744}
745
746void LLGLSLShader::uniform3fv(const string& uniform, U32 count, const GLfloat* v)
747{
748 GLint location = getUniformLocation(uniform);
749
750 if (location >= 0)
751 {
752 std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
753 LLVector4 vec(v[0],v[1],v[2],0.f);
754 if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
755 {
756 glUniform3fvARB(location, count, v);
757 mValue[location] = vec;
758 }
759 }
760}
761
762void LLGLSLShader::uniform4fv(const string& uniform, U32 count, const GLfloat* v)
763{
764 GLint location = getUniformLocation(uniform);
765
766 if (location >= 0)
767 {
768 LLVector4 vec(v);
769 std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
770 if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
771 {
772 glUniform4fvARB(location, count, v);
773 mValue[location] = vec;
774 }
775 }
776}
777
778void LLGLSLShader::uniformMatrix2fv(const string& uniform, U32 count, GLboolean transpose, const GLfloat* v)
779{
780 GLint location = getUniformLocation(uniform);
781
782 if (location >= 0)
783 {
784 glUniformMatrix2fvARB(location, count, transpose, v);
785 }
786}
787
788void LLGLSLShader::uniformMatrix3fv(const string& uniform, U32 count, GLboolean transpose, const GLfloat* v)
789{
790 GLint location = getUniformLocation(uniform);
791
792 if (location >= 0)
793 {
794 glUniformMatrix3fvARB(location, count, transpose, v);
795 }
796}
797
798void LLGLSLShader::uniformMatrix4fv(const string& uniform, U32 count, GLboolean transpose, const GLfloat* v)
799{
800 GLint location = getUniformLocation(uniform);
801
802 if (location >= 0)
803 {
804 glUniformMatrix4fvARB(location, count, transpose, v);
805 }
806}
807
808
809void LLGLSLShader::vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
810{
811 if (mAttribute[index] > 0)
812 {
813 glVertexAttrib4fARB(mAttribute[index], x, y, z, w);
814 }
815}
816
817void LLGLSLShader::vertexAttrib4fv(U32 index, GLfloat* v)
818{
819 if (mAttribute[index] > 0)
820 {
821 glVertexAttrib4fvARB(mAttribute[index], v);
822 }
823}
diff --git a/linden/indra/llrender/llglslshader.h b/linden/indra/llrender/llglslshader.h
new file mode 100644
index 0000000..0fa8e41
--- /dev/null
+++ b/linden/indra/llrender/llglslshader.h
@@ -0,0 +1,139 @@
1/**
2 * @file llglslshader.h
3 * @brief GLSL shader wrappers
4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 *
7 * Copyright (c) 2001-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LL_LLGLSLSHADER_H
33#define LL_LLGLSLSHADER_H
34
35#include "llgl.h"
36
37class LLShaderFeatures
38{
39public:
40 bool calculatesLighting;
41 bool calculatesAtmospherics;
42 bool hasLighting; // implies no transport (it's possible to have neither though)
43 bool isShiny;
44 bool isFullbright; // implies no lighting
45 bool isSpecular;
46 bool hasWaterFog; // implies no gamma
47 bool hasTransport; // implies no lighting (it's possible to have neither though)
48 bool hasSkinning;
49 bool hasAtmospherics;
50 bool hasGamma;
51
52 // char numLights;
53
54 LLShaderFeatures();
55};
56
57class LLGLSLShader
58{
59public:
60
61 enum
62 {
63 SG_DEFAULT = 0,
64 SG_SKY,
65 SG_WATER
66 };
67
68 LLGLSLShader();
69
70 void unload();
71 BOOL createShader(std::vector<std::string> * attributes,
72 std::vector<std::string> * uniforms);
73 BOOL attachObject(std::string object);
74 void attachObject(GLhandleARB object);
75 void attachObjects(GLhandleARB* objects = NULL, S32 count = 0);
76 BOOL mapAttributes(const std::vector<std::string> * attributes);
77 BOOL mapUniforms(const std::vector<std::string> * uniforms);
78 void mapUniform(GLint index, const std::vector<std::string> * uniforms);
79 void uniform1f(U32 index, GLfloat v);
80 void uniform2f(U32 index, GLfloat x, GLfloat y);
81 void uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z);
82 void uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
83 void uniform1fv(U32 index, U32 count, const GLfloat* v);
84 void uniform2fv(U32 index, U32 count, const GLfloat* v);
85 void uniform3fv(U32 index, U32 count, const GLfloat* v);
86 void uniform4fv(U32 index, U32 count, const GLfloat* v);
87 void uniform1f(const std::string& uniform, GLfloat v);
88 void uniform2f(const std::string& uniform, GLfloat x, GLfloat y);
89 void uniform3f(const std::string& uniform, GLfloat x, GLfloat y, GLfloat z);
90 void uniform4f(const std::string& uniform, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
91 void uniform1fv(const std::string& uniform, U32 count, const GLfloat* v);
92 void uniform2fv(const std::string& uniform, U32 count, const GLfloat* v);
93 void uniform3fv(const std::string& uniform, U32 count, const GLfloat* v);
94 void uniform4fv(const std::string& uniform, U32 count, const GLfloat* v);
95 void uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v);
96 void uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v);
97 void uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v);
98 void uniformMatrix2fv(const std::string& uniform, U32 count, GLboolean transpose, const GLfloat *v);
99 void uniformMatrix3fv(const std::string& uniform, U32 count, GLboolean transpose, const GLfloat *v);
100 void uniformMatrix4fv(const std::string& uniform, U32 count, GLboolean transpose, const GLfloat *v);
101
102 void vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
103 void vertexAttrib4fv(U32 index, GLfloat* v);
104
105 GLint getUniformLocation(const std::string& uniform);
106
107 GLint mapUniformTextureChannel(GLint location, GLenum type);
108
109
110 //enable/disable texture channel for specified uniform
111 //if given texture uniform is active in the shader,
112 //the corresponding channel will be active upon return
113 //returns channel texture is enabled in from [0-MAX)
114 S32 enableTexture(S32 uniform, S32 mode = GL_TEXTURE_2D);
115 S32 disableTexture(S32 uniform, S32 mode = GL_TEXTURE_2D);
116
117 BOOL link(BOOL suppress_errors = FALSE);
118 void bind();
119 void unbind();
120
121 // Unbinds any previously bound shader by explicitly binding no shader.
122 static void bindNoShader(void);
123
124 GLhandleARB mProgramObject;
125 std::vector<GLint> mAttribute; //lookup table of attribute enum to attribute channel
126 std::vector<GLint> mUniform; //lookup table of uniform enum to uniform location
127 std::map<std::string, GLint> mUniformMap; //lookup map of uniform name to uniform location
128 std::map<GLint, LLVector4> mValue; //lookup map of uniform location to last known value
129 std::vector<GLint> mTexture;
130 S32 mActiveTextureChannels;
131 S32 mShaderLevel;
132 S32 mShaderGroup;
133 BOOL mUniformsDirty;
134 LLShaderFeatures mFeatures;
135 std::vector< std::pair< std::string, GLenum > > mShaderFiles;
136 std::string mName;
137};
138
139#endif
diff --git a/linden/indra/llwindow/llglstates.h b/linden/indra/llrender/llglstates.h
index e53640c..e53640c 100644
--- a/linden/indra/llwindow/llglstates.h
+++ b/linden/indra/llrender/llglstates.h
diff --git a/linden/indra/llwindow/llgltypes.h b/linden/indra/llrender/llgltypes.h
index d22d5fa..d22d5fa 100644
--- a/linden/indra/llwindow/llgltypes.h
+++ b/linden/indra/llrender/llgltypes.h
diff --git a/linden/indra/llrender/llimagegl.cpp b/linden/indra/llrender/llimagegl.cpp
index a402814..a871758 100644
--- a/linden/indra/llrender/llimagegl.cpp
+++ b/linden/indra/llrender/llimagegl.cpp
@@ -836,7 +836,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S
836 llwarns << "Trying to create a texture while GL is disabled!" << llendl; 836 llwarns << "Trying to create a texture while GL is disabled!" << llendl;
837 return FALSE; 837 return FALSE;
838 } 838 }
839 llassert(gGLManager.mInited || gNoRender); 839 llassert(gGLManager.mInited);
840 stop_glerror(); 840 stop_glerror();
841 841
842 if (discard_level < 0) 842 if (discard_level < 0)
diff --git a/linden/indra/newview/llpostprocess.cpp b/linden/indra/llrender/llpostprocess.cpp
index 7ee7100..c884951 100644
--- a/linden/indra/newview/llpostprocess.cpp
+++ b/linden/indra/llrender/llpostprocess.cpp
@@ -29,9 +29,8 @@
29 * $/LicenseInfo$ 29 * $/LicenseInfo$
30 */ 30 */
31 31
32#include "llviewerprecompiledheaders.h" 32#include "linden_common.h"
33 33
34#include "pipeline.h"
35#include "llpostprocess.h" 34#include "llpostprocess.h"
36#include "llglslshader.h" 35#include "llglslshader.h"
37#include "llsdserialize.h" 36#include "llsdserialize.h"
@@ -58,10 +57,11 @@ LLPostProcess::LLPostProcess(void) :
58 mAllEffects(LLSD::emptyMap()), 57 mAllEffects(LLSD::emptyMap()),
59 screenW(1), screenH(1) 58 screenW(1), screenH(1)
60{ 59{
61 LLString pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); 60 /* 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));
62 LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL; 62 LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL;
63 63
64 llifstream effectsXML(pathName.c_str()); 64 llifstream effectsXML(pathName);
65 65
66 if (effectsXML) 66 if (effectsXML)
67 { 67 {
@@ -105,6 +105,7 @@ LLPostProcess::LLPostProcess(void) :
105 } 105 }
106 106
107 setSelectedEffect("default"); 107 setSelectedEffect("default");
108 */
108} 109}
109 110
110LLPostProcess::~LLPostProcess(void) 111LLPostProcess::~LLPostProcess(void)
@@ -143,16 +144,18 @@ void LLPostProcess::setSelectedEffect(std::string const & effectName)
143 144
144void LLPostProcess::saveEffect(std::string const & effectName) 145void LLPostProcess::saveEffect(std::string const & effectName)
145{ 146{
147 /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.
146 mAllEffects[effectName] = tweaks; 148 mAllEffects[effectName] = tweaks;
147 149
148 LLString pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); 150 std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME));
149 //llinfos << "Saving PostProcess Effects settings to " << pathName << llendl; 151 //llinfos << "Saving PostProcess Effects settings to " << pathName << llendl;
150 152
151 llofstream effectsXML(pathName.c_str()); 153 llofstream effectsXML(pathName);
152 154
153 LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); 155 LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
154 156
155 formatter->format(mAllEffects, effectsXML); 157 formatter->format(mAllEffects, effectsXML);
158 */
156} 159}
157 160
158void LLPostProcess::apply(unsigned int width, unsigned int height) 161void LLPostProcess::apply(unsigned int width, unsigned int height)
@@ -213,6 +216,7 @@ void LLPostProcess::applyShaders(void)
213 216
214void LLPostProcess::applyColorFilterShader(void) 217void LLPostProcess::applyColorFilterShader(void)
215{ 218{
219 /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.
216 gPostColorFilterProgram.bind(); 220 gPostColorFilterProgram.bind();
217 221
218 gGL.getTexUnit(0)->activate(); 222 gGL.getTexUnit(0)->activate();
@@ -240,6 +244,7 @@ void LLPostProcess::applyColorFilterShader(void)
240 /// Draw a screen space quad 244 /// Draw a screen space quad
241 drawOrthoQuad(screenW, screenH, QUAD_NORMAL); 245 drawOrthoQuad(screenW, screenH, QUAD_NORMAL);
242 gPostColorFilterProgram.unbind(); 246 gPostColorFilterProgram.unbind();
247 */
243} 248}
244 249
245void LLPostProcess::createColorFilterShader(void) 250void LLPostProcess::createColorFilterShader(void)
@@ -255,6 +260,7 @@ void LLPostProcess::createColorFilterShader(void)
255 260
256void LLPostProcess::applyNightVisionShader(void) 261void LLPostProcess::applyNightVisionShader(void)
257{ 262{
263 /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.
258 gPostNightVisionProgram.bind(); 264 gPostNightVisionProgram.bind();
259 265
260 gGL.getTexUnit(0)->activate(); 266 gGL.getTexUnit(0)->activate();
@@ -287,6 +293,7 @@ void LLPostProcess::applyNightVisionShader(void)
287 drawOrthoQuad(screenW, screenH, QUAD_NOISE); 293 drawOrthoQuad(screenW, screenH, QUAD_NOISE);
288 gPostNightVisionProgram.unbind(); 294 gPostNightVisionProgram.unbind();
289 gGL.getTexUnit(0)->activate(); 295 gGL.getTexUnit(0)->activate();
296 */
290} 297}
291 298
292void LLPostProcess::createNightVisionShader(void) 299void LLPostProcess::createNightVisionShader(void)
diff --git a/linden/indra/newview/llpostprocess.h b/linden/indra/llrender/llpostprocess.h
index 738d0f0..cd9f477 100644
--- a/linden/indra/newview/llpostprocess.h
+++ b/linden/indra/llrender/llpostprocess.h
@@ -207,7 +207,7 @@ public:
207 207
208 void setSelectedEffect(std::string const & effectName); 208 void setSelectedEffect(std::string const & effectName);
209 209
210 inline LLString const & getSelectedEffect(void) const { 210 inline std::string const & getSelectedEffect(void) const {
211 return mSelectedEffectName; 211 return mSelectedEffectName;
212 } 212 }
213 213
@@ -229,7 +229,7 @@ private:
229 229
230 // the name of currently selected effect in mAllEffects 230 // the name of currently selected effect in mAllEffects
231 // invariant: tweaks == mAllEffects[mSelectedEffectName] 231 // invariant: tweaks == mAllEffects[mSelectedEffectName]
232 LLString mSelectedEffectName; 232 std::string mSelectedEffectName;
233 233
234 /// General functions 234 /// General functions
235 void initialize(unsigned int width, unsigned int height); 235 void initialize(unsigned int width, unsigned int height);
diff --git a/linden/indra/llrender/llrender.cpp b/linden/indra/llrender/llrender.cpp
index e9c1227..13edf8a 100644
--- a/linden/indra/llrender/llrender.cpp
+++ b/linden/indra/llrender/llrender.cpp
@@ -36,6 +36,12 @@
36 36
37LLRender gGL; 37LLRender gGL;
38 38
39// Handy copies of last good GL matrices
40F64 gGLModelView[16];
41F64 gGLLastModelView[16];
42F64 gGLProjection[16];
43S32 gGLViewport[4];
44
39static const U32 LL_NUM_TEXTURE_LAYERS = 8; 45static const U32 LL_NUM_TEXTURE_LAYERS = 8;
40 46
41static GLenum sGLCompareFunc[] = 47static GLenum sGLCompareFunc[] =
@@ -445,6 +451,12 @@ void LLRender::translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z)
445 glTranslatef(x,y,z); 451 glTranslatef(x,y,z);
446} 452}
447 453
454void LLRender::scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z)
455{
456 flush();
457 glScalef(x,y,z);
458}
459
448void LLRender::pushMatrix() 460void LLRender::pushMatrix()
449{ 461{
450 flush(); 462 flush();
diff --git a/linden/indra/llrender/llrender.h b/linden/indra/llrender/llrender.h
index 03280fe..edf46ff 100644
--- a/linden/indra/llrender/llrender.h
+++ b/linden/indra/llrender/llrender.h
@@ -178,6 +178,7 @@ public:
178 ~LLRender(); 178 ~LLRender();
179 179
180 void translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z); 180 void translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z);
181 void scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z);
181 void pushMatrix(); 182 void pushMatrix();
182 void popMatrix(); 183 void popMatrix();
183 184
@@ -232,7 +233,10 @@ private:
232 std::vector<LLTexUnit*> mTexUnits; 233 std::vector<LLTexUnit*> mTexUnits;
233}; 234};
234 235
235 236extern F64 gGLModelView[16];
237extern F64 gGLLastModelView[16];
238extern F64 gGLProjection[16];
239extern S32 gGLViewport[4];
236 240
237extern LLRender gGL; 241extern LLRender gGL;
238 242
diff --git a/linden/indra/llrender/llrender.vcproj b/linden/indra/llrender/llrender.vcproj
deleted file mode 100644
index d9144cb..0000000
--- a/linden/indra/llrender/llrender.vcproj
+++ /dev/null
@@ -1,232 +0,0 @@
1<?xml version="1.0" encoding="Windows-1252"?>
2<VisualStudioProject
3 ProjectType="Visual C++"
4 Version="7.10"
5 Name="llrender"
6 ProjectGUID="{2ADE3C14-94C4-40BF-B033-70F3C954EE90}"
7 Keyword="Win32Proj">
8 <Platforms>
9 <Platform
10 Name="Win32"/>
11 </Platforms>
12 <Configurations>
13 <Configuration
14 Name="Debug|Win32"
15 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
16 IntermediateDirectory="Debug"
17 ConfigurationType="4"
18 CharacterSet="1">
19 <Tool
20 Name="VCCLCompilerTool"
21 Optimization="0"
22 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\"
23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;LL_DEBUG"
24 MinimalRebuild="TRUE"
25 BasicRuntimeChecks="3"
26 RuntimeLibrary="1"
27 StructMemberAlignment="4"
28 ForceConformanceInForLoopScope="TRUE"
29 UsePrecompiledHeader="0"
30 WarningLevel="3"
31 WarnAsError="TRUE"
32 Detect64BitPortabilityProblems="FALSE"
33 DebugInformationFormat="4"/>
34 <Tool
35 Name="VCCustomBuildTool"/>
36 <Tool
37 Name="VCLibrarianTool"
38 OutputFile="$(OutDir)/llrender.lib"/>
39 <Tool
40 Name="VCMIDLTool"/>
41 <Tool
42 Name="VCPostBuildEventTool"/>
43 <Tool
44 Name="VCPreBuildEventTool"/>
45 <Tool
46 Name="VCPreLinkEventTool"/>
47 <Tool
48 Name="VCResourceCompilerTool"/>
49 <Tool
50 Name="VCWebServiceProxyGeneratorTool"/>
51 <Tool
52 Name="VCXMLDataGeneratorTool"/>
53 <Tool
54 Name="VCManagedWrapperGeneratorTool"/>
55 <Tool
56 Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
57 </Configuration>
58 <Configuration
59 Name="Release|Win32"
60 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
61 IntermediateDirectory="Release"
62 ConfigurationType="4"
63 CharacterSet="1">
64 <Tool
65 Name="VCCLCompilerTool"
66 AdditionalOptions="/Oy-"
67 GlobalOptimizations="TRUE"
68 InlineFunctionExpansion="2"
69 EnableIntrinsicFunctions="TRUE"
70 OptimizeForProcessor="3"
71 OptimizeForWindowsApplication="TRUE"
72 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\"
73 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE"
74 RuntimeLibrary="0"
75 StructMemberAlignment="0"
76 ForceConformanceInForLoopScope="TRUE"
77 UsePrecompiledHeader="0"
78 WarningLevel="3"
79 WarnAsError="TRUE"
80 Detect64BitPortabilityProblems="FALSE"
81 DebugInformationFormat="3"/>
82 <Tool
83 Name="VCCustomBuildTool"/>
84 <Tool
85 Name="VCLibrarianTool"
86 OutputFile="$(OutDir)/llrender.lib"/>
87 <Tool
88 Name="VCMIDLTool"/>
89 <Tool
90 Name="VCPostBuildEventTool"/>
91 <Tool
92 Name="VCPreBuildEventTool"/>
93 <Tool
94 Name="VCPreLinkEventTool"/>
95 <Tool
96 Name="VCResourceCompilerTool"/>
97 <Tool
98 Name="VCWebServiceProxyGeneratorTool"/>
99 <Tool
100 Name="VCXMLDataGeneratorTool"/>
101 <Tool
102 Name="VCManagedWrapperGeneratorTool"/>
103 <Tool
104 Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
105 </Configuration>
106 <Configuration
107 Name="ReleaseNoOpt|Win32"
108 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
109 IntermediateDirectory="$(ConfigurationName)"
110 ConfigurationType="4"
111 CharacterSet="1">
112 <Tool
113 Name="VCCLCompilerTool"
114 AdditionalOptions="/Oy-"
115 Optimization="0"
116 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\"
117 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE"
118 RuntimeLibrary="0"
119 StructMemberAlignment="0"
120 ForceConformanceInForLoopScope="TRUE"
121 UsePrecompiledHeader="0"
122 WarningLevel="3"
123 WarnAsError="TRUE"
124 Detect64BitPortabilityProblems="FALSE"
125 DebugInformationFormat="3"/>
126 <Tool
127 Name="VCCustomBuildTool"/>
128 <Tool
129 Name="VCLibrarianTool"
130 OutputFile="$(OutDir)/llrender.lib"/>
131 <Tool
132 Name="VCMIDLTool"/>
133 <Tool
134 Name="VCPostBuildEventTool"/>
135 <Tool
136 Name="VCPreBuildEventTool"/>
137 <Tool
138 Name="VCPreLinkEventTool"/>
139 <Tool
140 Name="VCResourceCompilerTool"/>
141 <Tool
142 Name="VCWebServiceProxyGeneratorTool"/>
143 <Tool
144 Name="VCXMLDataGeneratorTool"/>
145 <Tool
146 Name="VCManagedWrapperGeneratorTool"/>
147 <Tool
148 Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
149 </Configuration>
150 </Configurations>
151 <References>
152 </References>
153 <Files>
154 <Filter
155 Name="Source Files"
156 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
157 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
158 <File
159 RelativePath=".\llfont.cpp">
160 </File>
161 <File
162 RelativePath=".\llfontgl.cpp">
163 </File>
164 <File
165 RelativePath=".\llgldbg.cpp">
166 </File>
167 <File
168 RelativePath=".\llrender.cpp">
169 </File>
170 <File
171 RelativePath=".\llimagegl.cpp">
172 </File>
173 <File
174 RelativePath=".\llrendertarget.cpp">
175 </File>
176 <File
177 RelativePath=".\llvertexbuffer.cpp">
178 </File>
179 </Filter>
180 <Filter
181 Name="Header Files"
182 Filter="h;hpp;hxx;hm;inl;inc;xsd"
183 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
184 <File
185 RelativePath=".\glext.h">
186 </File>
187 <File
188 RelativePath=".\llagpmempool.h">
189 </File>
190 <File
191 RelativePath=".\llagpmempoolarb.h">
192 </File>
193 <File
194 RelativePath=".\llagpmempoolati.h">
195 </File>
196 <File
197 RelativePath=".\llagpmempoolnv.h">
198 </File>
199 <File
200 RelativePath=".\llfont.h">
201 </File>
202 <File
203 RelativePath=".\llfontgl.h">
204 </File>
205 <File
206 RelativePath=".\llgldbg.h">
207 </File>
208 <File
209 RelativePath=".\llrender.h">
210 </File>
211 <File
212 RelativePath=".\llimagegl.h">
213 </File>
214 <File
215 RelativePath=".\llrendertarget.h">
216 </File>
217 <File
218 RelativePath=".\llvertexbuffer.h">
219 </File>
220 <File
221 RelativePath=".\llvertexprogramgl.h">
222 </File>
223 </Filter>
224 <Filter
225 Name="Resource Files"
226 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
227 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
228 </Filter>
229 </Files>
230 <Globals>
231 </Globals>
232</VisualStudioProject>
diff --git a/linden/indra/llrender/llrender_vc8.vcproj b/linden/indra/llrender/llrender_vc8.vcproj
deleted file mode 100644
index 2147cec..0000000
--- a/linden/indra/llrender/llrender_vc8.vcproj
+++ /dev/null
@@ -1,329 +0,0 @@
1<?xml version="1.0" encoding="Windows-1252"?>
2<VisualStudioProject
3 ProjectType="Visual C++"
4 Version="8.00"
5 Name="llrender"
6 ProjectGUID="{2ADE3C14-94C4-40BF-B033-70F3C954EE90}"
7 RootNamespace="llrender"
8 Keyword="Win32Proj"
9 >
10 <Platforms>
11 <Platform
12 Name="Win32"
13 />
14 </Platforms>
15 <ToolFiles>
16 </ToolFiles>
17 <Configurations>
18 <Configuration
19 Name="Debug|Win32"
20 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
21 IntermediateDirectory="Debug"
22 ConfigurationType="4"
23 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
24 CharacterSet="1"
25 >
26 <Tool
27 Name="VCPreBuildEventTool"
28 />
29 <Tool
30 Name="VCCustomBuildTool"
31 />
32 <Tool
33 Name="VCXMLDataGeneratorTool"
34 />
35 <Tool
36 Name="VCWebServiceProxyGeneratorTool"
37 />
38 <Tool
39 Name="VCMIDLTool"
40 />
41 <Tool
42 Name="VCCLCompilerTool"
43 Optimization="0"
44 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\"
45 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG"
46 MinimalRebuild="true"
47 BasicRuntimeChecks="3"
48 RuntimeLibrary="1"
49 StructMemberAlignment="4"
50 TreatWChar_tAsBuiltInType="false"
51 ForceConformanceInForLoopScope="true"
52 UsePrecompiledHeader="0"
53 WarningLevel="3"
54 WarnAsError="true"
55 Detect64BitPortabilityProblems="false"
56 DebugInformationFormat="4"
57 />
58 <Tool
59 Name="VCManagedResourceCompilerTool"
60 />
61 <Tool
62 Name="VCResourceCompilerTool"
63 />
64 <Tool
65 Name="VCPreLinkEventTool"
66 />
67 <Tool
68 Name="VCLibrarianTool"
69 OutputFile="$(OutDir)/llrender.lib"
70 />
71 <Tool
72 Name="VCALinkTool"
73 />
74 <Tool
75 Name="VCXDCMakeTool"
76 />
77 <Tool
78 Name="VCBscMakeTool"
79 />
80 <Tool
81 Name="VCFxCopTool"
82 />
83 <Tool
84 Name="VCPostBuildEventTool"
85 />
86 </Configuration>
87 <Configuration
88 Name="Release|Win32"
89 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
90 IntermediateDirectory="Release"
91 ConfigurationType="4"
92 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
93 CharacterSet="1"
94 >
95 <Tool
96 Name="VCPreBuildEventTool"
97 />
98 <Tool
99 Name="VCCustomBuildTool"
100 />
101 <Tool
102 Name="VCXMLDataGeneratorTool"
103 />
104 <Tool
105 Name="VCWebServiceProxyGeneratorTool"
106 />
107 <Tool
108 Name="VCMIDLTool"
109 />
110 <Tool
111 Name="VCCLCompilerTool"
112 AdditionalOptions="/Oy-"
113 InlineFunctionExpansion="2"
114 EnableIntrinsicFunctions="true"
115 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\"
116 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE"
117 RuntimeLibrary="0"
118 StructMemberAlignment="0"
119 TreatWChar_tAsBuiltInType="false"
120 ForceConformanceInForLoopScope="true"
121 UsePrecompiledHeader="0"
122 WarningLevel="3"
123 WarnAsError="true"
124 Detect64BitPortabilityProblems="false"
125 DebugInformationFormat="3"
126 />
127 <Tool
128 Name="VCManagedResourceCompilerTool"
129 />
130 <Tool
131 Name="VCResourceCompilerTool"
132 />
133 <Tool
134 Name="VCPreLinkEventTool"
135 />
136 <Tool
137 Name="VCLibrarianTool"
138 OutputFile="$(OutDir)/llrender.lib"
139 />
140 <Tool
141 Name="VCALinkTool"
142 />
143 <Tool
144 Name="VCXDCMakeTool"
145 />
146 <Tool
147 Name="VCBscMakeTool"
148 />
149 <Tool
150 Name="VCFxCopTool"
151 />
152 <Tool
153 Name="VCPostBuildEventTool"
154 />
155 </Configuration>
156 <Configuration
157 Name="ReleaseNoOpt|Win32"
158 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
159 IntermediateDirectory="$(ConfigurationName)"
160 ConfigurationType="4"
161 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
162 CharacterSet="1"
163 >
164 <Tool
165 Name="VCPreBuildEventTool"
166 />
167 <Tool
168 Name="VCCustomBuildTool"
169 />
170 <Tool
171 Name="VCXMLDataGeneratorTool"
172 />
173 <Tool
174 Name="VCWebServiceProxyGeneratorTool"
175 />
176 <Tool
177 Name="VCMIDLTool"
178 />
179 <Tool
180 Name="VCCLCompilerTool"
181 AdditionalOptions="/Oy-"
182 Optimization="0"
183 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\"
184 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE"
185 RuntimeLibrary="0"
186 StructMemberAlignment="0"
187 TreatWChar_tAsBuiltInType="false"
188 ForceConformanceInForLoopScope="true"
189 UsePrecompiledHeader="0"
190 WarningLevel="3"
191 WarnAsError="true"
192 Detect64BitPortabilityProblems="false"
193 DebugInformationFormat="3"
194 />
195 <Tool
196 Name="VCManagedResourceCompilerTool"
197 />
198 <Tool
199 Name="VCResourceCompilerTool"
200 />
201 <Tool
202 Name="VCPreLinkEventTool"
203 />
204 <Tool
205 Name="VCLibrarianTool"
206 OutputFile="$(OutDir)/llrender.lib"
207 />
208 <Tool
209 Name="VCALinkTool"
210 />
211 <Tool
212 Name="VCXDCMakeTool"
213 />
214 <Tool
215 Name="VCBscMakeTool"
216 />
217 <Tool
218 Name="VCFxCopTool"
219 />
220 <Tool
221 Name="VCPostBuildEventTool"
222 />
223 </Configuration>
224 </Configurations>
225 <References>
226 </References>
227 <Files>
228 <Filter
229 Name="Source Files"
230 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
231 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
232 >
233 <File
234 RelativePath=".\llfont.cpp"
235 >
236 </File>
237 <File
238 RelativePath=".\llfontgl.cpp"
239 >
240 </File>
241 <File
242 RelativePath=".\llgldbg.cpp"
243 >
244 </File>
245 <File
246 RelativePath=".\llimagegl.cpp"
247 >
248 </File>
249 <File
250 RelativePath=".\llrender.cpp"
251 >
252 </File>
253 <File
254 RelativePath=".\llrendertarget.cpp"
255 >
256 </File>
257 <File
258 RelativePath=".\llvertexbuffer.cpp"
259 >
260 </File>
261 </Filter>
262 <Filter
263 Name="Header Files"
264 Filter="h;hpp;hxx;hm;inl;inc;xsd"
265 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
266 >
267 <File
268 RelativePath=".\glext.h"
269 >
270 </File>
271 <File
272 RelativePath=".\llagpmempool.h"
273 >
274 </File>
275 <File
276 RelativePath=".\llagpmempoolarb.h"
277 >
278 </File>
279 <File
280 RelativePath=".\llagpmempoolati.h"
281 >
282 </File>
283 <File
284 RelativePath=".\llagpmempoolnv.h"
285 >
286 </File>
287 <File
288 RelativePath=".\llfont.h"
289 >
290 </File>
291 <File
292 RelativePath=".\llfontgl.h"
293 >
294 </File>
295 <File
296 RelativePath=".\llgldbg.h"
297 >
298 </File>
299 <File
300 RelativePath=".\llimagegl.h"
301 >
302 </File>
303 <File
304 RelativePath=".\llrender.h"
305 >
306 </File>
307 <File
308 RelativePath=".\llrendertarget.h"
309 >
310 </File>
311 <File
312 RelativePath=".\llvertexbuffer.h"
313 >
314 </File>
315 <File
316 RelativePath=".\llvertexprogramgl.h"
317 >
318 </File>
319 </Filter>
320 <Filter
321 Name="Resource Files"
322 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
323 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
324 >
325 </Filter>
326 </Files>
327 <Globals>
328 </Globals>
329</VisualStudioProject>
diff --git a/linden/indra/llrender/llrender_vc9.vcproj b/linden/indra/llrender/llrender_vc9.vcproj
deleted file mode 100644
index 67385e6..0000000
--- a/linden/indra/llrender/llrender_vc9.vcproj
+++ /dev/null
@@ -1,330 +0,0 @@
1<?xml version="1.0" encoding="Windows-1252"?>
2<VisualStudioProject
3 ProjectType="Visual C++"
4 Version="9.00"
5 Name="llrender"
6 ProjectGUID="{2ADE3C14-94C4-40BF-B033-70F3C954EE90}"
7 RootNamespace="llrender"
8 Keyword="Win32Proj"
9 TargetFrameworkVersion="131072"
10 >
11 <Platforms>
12 <Platform
13 Name="Win32"
14 />
15 </Platforms>
16 <ToolFiles>
17 </ToolFiles>
18 <Configurations>
19 <Configuration
20 Name="Debug|Win32"
21 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
22 IntermediateDirectory="Debug"
23 ConfigurationType="4"
24 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
25 CharacterSet="1"
26 >
27 <Tool
28 Name="VCPreBuildEventTool"
29 />
30 <Tool
31 Name="VCCustomBuildTool"
32 />
33 <Tool
34 Name="VCXMLDataGeneratorTool"
35 />
36 <Tool
37 Name="VCWebServiceProxyGeneratorTool"
38 />
39 <Tool
40 Name="VCMIDLTool"
41 />
42 <Tool
43 Name="VCCLCompilerTool"
44 Optimization="0"
45 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\"
46 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG"
47 MinimalRebuild="true"
48 BasicRuntimeChecks="3"
49 RuntimeLibrary="1"
50 StructMemberAlignment="4"
51 TreatWChar_tAsBuiltInType="false"
52 ForceConformanceInForLoopScope="true"
53 UsePrecompiledHeader="0"
54 WarningLevel="3"
55 WarnAsError="true"
56 Detect64BitPortabilityProblems="false"
57 DebugInformationFormat="4"
58 />
59 <Tool
60 Name="VCManagedResourceCompilerTool"
61 />
62 <Tool
63 Name="VCResourceCompilerTool"
64 />
65 <Tool
66 Name="VCPreLinkEventTool"
67 />
68 <Tool
69 Name="VCLibrarianTool"
70 OutputFile="$(OutDir)/llrender.lib"
71 />
72 <Tool
73 Name="VCALinkTool"
74 />
75 <Tool
76 Name="VCXDCMakeTool"
77 />
78 <Tool
79 Name="VCBscMakeTool"
80 />
81 <Tool
82 Name="VCFxCopTool"
83 />
84 <Tool
85 Name="VCPostBuildEventTool"
86 />
87 </Configuration>
88 <Configuration
89 Name="Release|Win32"
90 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
91 IntermediateDirectory="Release"
92 ConfigurationType="4"
93 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
94 CharacterSet="1"
95 >
96 <Tool
97 Name="VCPreBuildEventTool"
98 />
99 <Tool
100 Name="VCCustomBuildTool"
101 />
102 <Tool
103 Name="VCXMLDataGeneratorTool"
104 />
105 <Tool
106 Name="VCWebServiceProxyGeneratorTool"
107 />
108 <Tool
109 Name="VCMIDLTool"
110 />
111 <Tool
112 Name="VCCLCompilerTool"
113 AdditionalOptions="/Oy-"
114 InlineFunctionExpansion="2"
115 EnableIntrinsicFunctions="true"
116 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\"
117 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE"
118 RuntimeLibrary="0"
119 StructMemberAlignment="0"
120 TreatWChar_tAsBuiltInType="false"
121 ForceConformanceInForLoopScope="true"
122 UsePrecompiledHeader="0"
123 WarningLevel="3"
124 WarnAsError="true"
125 Detect64BitPortabilityProblems="false"
126 DebugInformationFormat="3"
127 />
128 <Tool
129 Name="VCManagedResourceCompilerTool"
130 />
131 <Tool
132 Name="VCResourceCompilerTool"
133 />
134 <Tool
135 Name="VCPreLinkEventTool"
136 />
137 <Tool
138 Name="VCLibrarianTool"
139 OutputFile="$(OutDir)/llrender.lib"
140 />
141 <Tool
142 Name="VCALinkTool"
143 />
144 <Tool
145 Name="VCXDCMakeTool"
146 />
147 <Tool
148 Name="VCBscMakeTool"
149 />
150 <Tool
151 Name="VCFxCopTool"
152 />
153 <Tool
154 Name="VCPostBuildEventTool"
155 />
156 </Configuration>
157 <Configuration
158 Name="ReleaseNoOpt|Win32"
159 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
160 IntermediateDirectory="$(ConfigurationName)"
161 ConfigurationType="4"
162 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
163 CharacterSet="1"
164 >
165 <Tool
166 Name="VCPreBuildEventTool"
167 />
168 <Tool
169 Name="VCCustomBuildTool"
170 />
171 <Tool
172 Name="VCXMLDataGeneratorTool"
173 />
174 <Tool
175 Name="VCWebServiceProxyGeneratorTool"
176 />
177 <Tool
178 Name="VCMIDLTool"
179 />
180 <Tool
181 Name="VCCLCompilerTool"
182 AdditionalOptions="/Oy-"
183 Optimization="0"
184 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\"
185 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE"
186 RuntimeLibrary="0"
187 StructMemberAlignment="0"
188 TreatWChar_tAsBuiltInType="false"
189 ForceConformanceInForLoopScope="true"
190 UsePrecompiledHeader="0"
191 WarningLevel="3"
192 WarnAsError="true"
193 Detect64BitPortabilityProblems="false"
194 DebugInformationFormat="3"
195 />
196 <Tool
197 Name="VCManagedResourceCompilerTool"
198 />
199 <Tool
200 Name="VCResourceCompilerTool"
201 />
202 <Tool
203 Name="VCPreLinkEventTool"
204 />
205 <Tool
206 Name="VCLibrarianTool"
207 OutputFile="$(OutDir)/llrender.lib"
208 />
209 <Tool
210 Name="VCALinkTool"
211 />
212 <Tool
213 Name="VCXDCMakeTool"
214 />
215 <Tool
216 Name="VCBscMakeTool"
217 />
218 <Tool
219 Name="VCFxCopTool"
220 />
221 <Tool
222 Name="VCPostBuildEventTool"
223 />
224 </Configuration>
225 </Configurations>
226 <References>
227 </References>
228 <Files>
229 <Filter
230 Name="Source Files"
231 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
232 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
233 >
234 <File
235 RelativePath=".\llfont.cpp"
236 >
237 </File>
238 <File
239 RelativePath=".\llfontgl.cpp"
240 >
241 </File>
242 <File
243 RelativePath=".\llgldbg.cpp"
244 >
245 </File>
246 <File
247 RelativePath=".\llrender.cpp"
248 >
249 </File>
250 <File
251 RelativePath=".\llimagegl.cpp"
252 >
253 </File>
254 <File
255 RelativePath=".\llrendertarget.cpp"
256 >
257 </File>
258 <File
259 RelativePath=".\llvertexbuffer.cpp"
260 >
261 </File>
262 </Filter>
263 <Filter
264 Name="Header Files"
265 Filter="h;hpp;hxx;hm;inl;inc;xsd"
266 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
267 >
268 <File
269 RelativePath=".\glext.h"
270 >
271 </File>
272 <File
273 RelativePath=".\llagpmempool.h"
274 >
275 </File>
276 <File
277 RelativePath=".\llagpmempoolarb.h"
278 >
279 </File>
280 <File
281 RelativePath=".\llagpmempoolati.h"
282 >
283 </File>
284 <File
285 RelativePath=".\llagpmempoolnv.h"
286 >
287 </File>
288 <File
289 RelativePath=".\llfont.h"
290 >
291 </File>
292 <File
293 RelativePath=".\llfontgl.h"
294 >
295 </File>
296 <File
297 RelativePath=".\llgldbg.h"
298 >
299 </File>
300 <File
301 RelativePath=".\llrender.h"
302 >
303 </File>
304 <File
305 RelativePath=".\llimagegl.h"
306 >
307 </File>
308 <File
309 RelativePath=".\llrendertarget.h"
310 >
311 </File>
312 <File
313 RelativePath=".\llvertexbuffer.h"
314 >
315 </File>
316 <File
317 RelativePath=".\llvertexprogramgl.h"
318 >
319 </File>
320 </Filter>
321 <Filter
322 Name="Resource Files"
323 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
324 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
325 >
326 </Filter>
327 </Files>
328 <Globals>
329 </Globals>
330</VisualStudioProject>
diff --git a/linden/indra/newview/llrendersphere.cpp b/linden/indra/llrender/llrendersphere.cpp
index 6e5c850..0c3cd19 100644
--- a/linden/indra/newview/llrendersphere.cpp
+++ b/linden/indra/llrender/llrendersphere.cpp
@@ -2,16 +2,26 @@
2 * @file llrendersphere.cpp 2 * @file llrendersphere.cpp
3 * @brief implementation of the LLRenderSphere class. 3 * @brief implementation of the LLRenderSphere class.
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=internal$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2008, Linden Research, Inc.
8 * 8 *
9 * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of 9 * Second Life Viewer Source Code
10 * this source code is governed by the Linden Lab Source Code Disclosure 10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * Agreement ("Agreement") previously entered between you and Linden 11 * to you under the terms of the GNU General Public License, version 2.0
12 * Lab. By accessing, using, copying, modifying or distributing this 12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * software, you acknowledge that you have been informed of your 13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * obligations under the Agreement and agree to abide by those obligations. 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
15 * 25 *
16 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO 26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
17 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, 27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
@@ -23,7 +33,8 @@
23// a lit sphere at different LOD levels. You only need one instance of sphere 33// a lit sphere at different LOD levels. You only need one instance of sphere
24// per viewer - then call the appropriate list. 34// per viewer - then call the appropriate list.
25 35
26#include "llviewerprecompiledheaders.h" 36#include "linden_common.h"
37
27#include "llrendersphere.h" 38#include "llrendersphere.h"
28#include "llerror.h" 39#include "llerror.h"
29 40
diff --git a/linden/indra/newview/llrendersphere.h b/linden/indra/llrender/llrendersphere.h
index ace57e4..ace57e4 100644
--- a/linden/indra/newview/llrendersphere.h
+++ b/linden/indra/llrender/llrendersphere.h
diff --git a/linden/indra/llrender/llrendertarget.cpp b/linden/indra/llrender/llrendertarget.cpp
index 708c582..e18ec56 100644
--- a/linden/indra/llrender/llrendertarget.cpp
+++ b/linden/indra/llrender/llrendertarget.cpp
@@ -99,11 +99,16 @@ void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32
99 99
100 glGenFramebuffersEXT(1, (GLuint *) &mFBO); 100 glGenFramebuffersEXT(1, (GLuint *) &mFBO);
101 101
102 stop_glerror();
103
102 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO); 104 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO);
103 105
106 stop_glerror();
107
104 if (mDepth) 108 if (mDepth)
105 { 109 {
106 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, mUsage, mDepth, 0); 110 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, mUsage, mDepth, 0);
111 stop_glerror();
107 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, mUsage, mDepth, 0); 112 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, mUsage, mDepth, 0);
108 stop_glerror(); 113 stop_glerror();
109 } 114 }
diff --git a/linden/indra/llrender/llshadermgr.cpp b/linden/indra/llrender/llshadermgr.cpp
new file mode 100644
index 0000000..4416775
--- /dev/null
+++ b/linden/indra/llrender/llshadermgr.cpp
@@ -0,0 +1,513 @@
1/**
2 * @file llshadermgr.cpp
3 * @brief Shader manager implementation.
4 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$
6 *
7 * Copyright (c) 2005-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "linden_common.h"
33
34#include "llshadermgr.h"
35
36#include "llfile.h"
37#include "llrender.h"
38
39#if LL_DARWIN
40#include "OpenGL/OpenGL.h"
41#endif
42
43#ifdef LL_RELEASE_FOR_DOWNLOAD
44#define UNIFORM_ERRS LL_WARNS_ONCE("Shader")
45#else
46#define UNIFORM_ERRS LL_ERRS("Shader")
47#endif
48
49// Lots of STL stuff in here, using namespace std to keep things more readable
50using std::vector;
51using std::pair;
52using std::make_pair;
53using std::string;
54
55LLShaderMgr * LLShaderMgr::sInstance = NULL;
56
57LLShaderMgr::LLShaderMgr()
58{
59}
60
61
62LLShaderMgr::~LLShaderMgr()
63{
64}
65
66// static
67LLShaderMgr * LLShaderMgr::instance()
68{
69 if(NULL == sInstance)
70 {
71 LL_ERRS("Shaders") << "LLShaderMgr should already have been instantiated by the application!" << LL_ENDL;
72 }
73
74 return sInstance;
75}
76
77BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader)
78{
79 llassert_always(shader != NULL);
80 LLShaderFeatures *features = & shader->mFeatures;
81
82 //////////////////////////////////////
83 // Attach Vertex Shader Features First
84 //////////////////////////////////////
85
86 // NOTE order of shader object attaching is VERY IMPORTANT!!!
87 if (features->calculatesAtmospherics)
88 {
89 if (!shader->attachObject("windlight/atmosphericsVarsV.glsl"))
90 {
91 return FALSE;
92 }
93 }
94
95 if (features->calculatesLighting)
96 {
97 if (!shader->attachObject("windlight/atmosphericsHelpersV.glsl"))
98 {
99 return FALSE;
100 }
101
102 if (features->isSpecular)
103 {
104 if (!shader->attachObject("lighting/lightFuncSpecularV.glsl"))
105 {
106 return FALSE;
107 }
108
109 if (!shader->attachObject("lighting/sumLightsSpecularV.glsl"))
110 {
111 return FALSE;
112 }
113
114 if (!shader->attachObject("lighting/lightSpecularV.glsl"))
115 {
116 return FALSE;
117 }
118 }
119 else
120 {
121 if (!shader->attachObject("lighting/lightFuncV.glsl"))
122 {
123 return FALSE;
124 }
125
126 if (!shader->attachObject("lighting/sumLightsV.glsl"))
127 {
128 return FALSE;
129 }
130
131 if (!shader->attachObject("lighting/lightV.glsl"))
132 {
133 return FALSE;
134 }
135 }
136 }
137
138 // NOTE order of shader object attaching is VERY IMPORTANT!!!
139 if (features->calculatesAtmospherics)
140 {
141 if (!shader->attachObject("windlight/atmosphericsV.glsl"))
142 {
143 return FALSE;
144 }
145 }
146
147 if (features->hasSkinning)
148 {
149 if (!shader->attachObject("avatar/avatarSkinV.glsl"))
150 {
151 return FALSE;
152 }
153 }
154
155 ///////////////////////////////////////
156 // Attach Fragment Shader Features Next
157 ///////////////////////////////////////
158
159 if(features->calculatesAtmospherics)
160 {
161 if (!shader->attachObject("windlight/atmosphericsVarsF.glsl"))
162 {
163 return FALSE;
164 }
165 }
166
167 // NOTE order of shader object attaching is VERY IMPORTANT!!!
168 if (features->hasGamma)
169 {
170 if (!shader->attachObject("windlight/gammaF.glsl"))
171 {
172 return FALSE;
173 }
174 }
175
176 if (features->hasAtmospherics)
177 {
178 if (!shader->attachObject("windlight/atmosphericsF.glsl"))
179 {
180 return FALSE;
181 }
182 }
183
184 if (features->hasTransport)
185 {
186 if (!shader->attachObject("windlight/transportF.glsl"))
187 {
188 return FALSE;
189 }
190
191 // Test hasFullbright and hasShiny and attach fullbright and
192 // fullbright shiny atmos transport if we split them out.
193 }
194
195 // NOTE order of shader object attaching is VERY IMPORTANT!!!
196 if (features->hasWaterFog)
197 {
198 if (!shader->attachObject("environment/waterFogF.glsl"))
199 {
200 return FALSE;
201 }
202 }
203
204 if (features->hasLighting)
205 {
206
207 if (features->hasWaterFog)
208 {
209 if (!shader->attachObject("lighting/lightWaterF.glsl"))
210 {
211 return FALSE;
212 }
213 }
214
215 else
216 {
217 if (!shader->attachObject("lighting/lightF.glsl"))
218 {
219 return FALSE;
220 }
221 }
222 }
223
224 // NOTE order of shader object attaching is VERY IMPORTANT!!!
225 else if (features->isFullbright)
226 {
227
228 if (features->hasWaterFog)
229 {
230 if (!shader->attachObject("lighting/lightFullbrightWaterF.glsl"))
231 {
232 return FALSE;
233 }
234 }
235
236 else if (features->isShiny)
237 {
238 if (!shader->attachObject("lighting/lightFullbrightShinyF.glsl"))
239 {
240 return FALSE;
241 }
242 }
243
244 else
245 {
246 if (!shader->attachObject("lighting/lightFullbrightF.glsl"))
247 {
248 return FALSE;
249 }
250 }
251 }
252
253 // NOTE order of shader object attaching is VERY IMPORTANT!!!
254 else if (features->isShiny)
255 {
256
257 if (features->hasWaterFog)
258 {
259 if (!shader->attachObject("lighting/lightShinyWaterF.glsl"))
260 {
261 return FALSE;
262 }
263 }
264
265 else
266 {
267 if (!shader->attachObject("lighting/lightShinyF.glsl"))
268 {
269 return FALSE;
270 }
271 }
272 }
273 return TRUE;
274}
275
276//============================================================================
277// Load Shader
278
279static std::string get_object_log(GLhandleARB ret)
280{
281 std::string res;
282
283 //get log length
284 GLint length;
285 glGetObjectParameterivARB(ret, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
286 if (length > 0)
287 {
288 //the log could be any size, so allocate appropriately
289 GLcharARB* log = new GLcharARB[length];
290 glGetInfoLogARB(ret, length, &length, log);
291 res = std::string((char *)log);
292 delete[] log;
293 }
294 return res;
295}
296
297void LLShaderMgr::dumpObjectLog(GLhandleARB ret, BOOL warns)
298{
299 std::string log = get_object_log(ret);
300 if ( log.length() > 0 )
301 {
302 if (warns)
303 {
304 LL_WARNS("ShaderLoading") << log << LL_ENDL;
305 }
306 else
307 {
308 LL_DEBUGS("ShaderLoading") << log << LL_ENDL;
309 }
310}
311}
312
313GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type)
314{
315 GLenum error;
316 error = glGetError();
317 if (error != GL_NO_ERROR)
318 {
319 LL_WARNS("ShaderLoading") << "GL ERROR entering loadShaderFile(): " << error << LL_ENDL;
320 }
321
322 LL_DEBUGS("ShaderLoading") << "Loading shader file: " << filename << " class " << shader_level << LL_ENDL;
323
324 if (filename.empty())
325 {
326 return 0;
327 }
328
329
330 //read in from file
331 LLFILE* file = NULL;
332
333 S32 try_gpu_class = shader_level;
334 S32 gpu_class;
335
336 //find the most relevant file
337 for (gpu_class = try_gpu_class; gpu_class > 0; gpu_class--)
338 { //search from the current gpu class down to class 1 to find the most relevant shader
339 std::stringstream fname;
340 fname << getShaderDirPrefix();
341 fname << gpu_class << "/" << filename;
342
343 LL_DEBUGS("ShaderLoading") << "Looking in " << fname.str() << LL_ENDL;
344 file = LLFile::fopen(fname.str(), "r"); /* Flawfinder: ignore */
345 if (file)
346 {
347 LL_INFOS("ShaderLoading") << "Loading file: shaders/class" << gpu_class << "/" << filename << " (Want class " << gpu_class << ")" << LL_ENDL;
348 break; // done
349 }
350 }
351
352 if (file == NULL)
353 {
354 LL_WARNS("ShaderLoading") << "GLSL Shader file not found: " << filename << LL_ENDL;
355 return 0;
356 }
357
358 //we can't have any lines longer than 1024 characters
359 //or any shaders longer than 1024 lines... deal - DaveP
360 GLcharARB buff[1024];
361 GLcharARB* text[1024];
362 GLuint count = 0;
363
364
365 //copy file into memory
366 while(fgets((char *)buff, 1024, file) != NULL && count < (sizeof(buff)/sizeof(buff[0])))
367 {
368 text[count++] = (GLcharARB *)strdup((char *)buff);
369 }
370 fclose(file);
371
372 //create shader object
373 GLhandleARB ret = glCreateShaderObjectARB(type);
374 error = glGetError();
375 if (error != GL_NO_ERROR)
376 {
377 LL_WARNS("ShaderLoading") << "GL ERROR in glCreateShaderObjectARB: " << error << LL_ENDL;
378 }
379 else
380 {
381 //load source
382 glShaderSourceARB(ret, count, (const GLcharARB**) text, NULL);
383 error = glGetError();
384 if (error != GL_NO_ERROR)
385 {
386 LL_WARNS("ShaderLoading") << "GL ERROR in glShaderSourceARB: " << error << LL_ENDL;
387 }
388 else
389 {
390 //compile source
391 glCompileShaderARB(ret);
392 error = glGetError();
393 if (error != GL_NO_ERROR)
394 {
395 LL_WARNS("ShaderLoading") << "GL ERROR in glCompileShaderARB: " << error << LL_ENDL;
396 }
397 }
398 }
399 //free memory
400 for (GLuint i = 0; i < count; i++)
401 {
402 free(text[i]);
403 }
404 if (error == GL_NO_ERROR)
405 {
406 //check for errors
407 GLint success = GL_TRUE;
408 glGetObjectParameterivARB(ret, GL_OBJECT_COMPILE_STATUS_ARB, &success);
409 error = glGetError();
410 if (error != GL_NO_ERROR || success == GL_FALSE)
411 {
412 //an error occured, print log
413 LL_WARNS("ShaderLoading") << "GLSL Compilation Error: (" << error << ") in " << filename << LL_ENDL;
414 dumpObjectLog(ret);
415 ret = 0;
416 }
417 }
418 else
419 {
420 ret = 0;
421 }
422 stop_glerror();
423
424 //successfully loaded, save results
425 if (ret)
426 {
427 // Add shader file to map
428 mShaderObjects[filename] = ret;
429 shader_level = try_gpu_class;
430 }
431 else
432 {
433 if (shader_level > 1)
434 {
435 shader_level--;
436 return loadShaderFile(filename,shader_level,type);
437 }
438 LL_WARNS("ShaderLoading") << "Failed to load " << filename << LL_ENDL;
439 }
440 return ret;
441}
442
443BOOL LLShaderMgr::linkProgramObject(GLhandleARB obj, BOOL suppress_errors)
444{
445 //check for errors
446 glLinkProgramARB(obj);
447 GLint success = GL_TRUE;
448 glGetObjectParameterivARB(obj, GL_OBJECT_LINK_STATUS_ARB, &success);
449 if (!suppress_errors && success == GL_FALSE)
450 {
451 //an error occured, print log
452 LL_WARNS("ShaderLoading") << "GLSL Linker Error:" << LL_ENDL;
453 }
454
455// NOTE: Removing LL_DARWIN block as it doesn't seem to actually give the correct answer,
456// but want it for reference once I move it.
457#if 0
458 // Force an evaluation of the gl state so the driver can tell if the shader will run in hardware or software
459 // per Apple's suggestion
460 glBegin(gGL.mMode);
461 glEnd();
462
463 // Query whether the shader can or cannot run in hardware
464 // http://developer.apple.com/qa/qa2007/qa1502.html
465 long vertexGPUProcessing;
466 CGLContextObj ctx = CGLGetCurrentContext();
467 CGLGetParameter (ctx, kCGLCPGPUVertexProcessing, &vertexGPUProcessing);
468 long fragmentGPUProcessing;
469 CGLGetParameter (ctx, kCGLCPGPUFragmentProcessing, &fragmentGPUProcessing);
470 if (!fragmentGPUProcessing || !vertexGPUProcessing)
471 {
472 LL_WARNS("ShaderLoading") << "GLSL Linker: Running in Software:" << LL_ENDL;
473 success = GL_FALSE;
474 suppress_errors = FALSE;
475 }
476
477#else
478 std::string log = get_object_log(obj);
479 LLStringUtil::toLower(log);
480 if (log.find("software") != std::string::npos)
481 {
482 LL_WARNS("ShaderLoading") << "GLSL Linker: Running in Software:" << LL_ENDL;
483 success = GL_FALSE;
484 suppress_errors = FALSE;
485 }
486#endif
487 if (!suppress_errors)
488 {
489 dumpObjectLog(obj, !success);
490 }
491
492 return success;
493}
494
495BOOL LLShaderMgr::validateProgramObject(GLhandleARB obj)
496{
497 //check program validity against current GL
498 glValidateProgramARB(obj);
499 GLint success = GL_TRUE;
500 glGetObjectParameterivARB(obj, GL_OBJECT_VALIDATE_STATUS_ARB, &success);
501 if (success == GL_FALSE)
502 {
503 LL_WARNS("ShaderLoading") << "GLSL program not valid: " << LL_ENDL;
504 dumpObjectLog(obj);
505 }
506 else
507 {
508 dumpObjectLog(obj, FALSE);
509 }
510
511 return success;
512}
513
diff --git a/linden/indra/llrender/llshadermgr.h b/linden/indra/llrender/llshadermgr.h
new file mode 100644
index 0000000..8918416
--- /dev/null
+++ b/linden/indra/llrender/llshadermgr.h
@@ -0,0 +1,75 @@
1/**
2 * @file llshadermgr.h
3 * @brief Shader Manager
4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 *
7 * Copyright (c) 2001-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LL_SHADERMGR_H
33#define LL_SHADERMGR_H
34
35#include "llgl.h"
36#include "llglslshader.h"
37
38class LLShaderMgr
39{
40public:
41 LLShaderMgr();
42 virtual ~LLShaderMgr();
43
44 // singleton pattern implementation
45 static LLShaderMgr * instance();
46
47 BOOL attachShaderFeatures(LLGLSLShader * shader);
48 void dumpObjectLog(GLhandleARB ret, BOOL warns = TRUE);
49 BOOL linkProgramObject(GLhandleARB obj, BOOL suppress_errors = FALSE);
50 BOOL validateProgramObject(GLhandleARB obj);
51 GLhandleARB loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type);
52
53 // Implemented in the application to actually point to the shader directory.
54 virtual std::string getShaderDirPrefix(void) = 0; // Pure Virtual
55
56 // Implemented in the application to actually update out of date uniforms for a particular shader
57 virtual void updateShaderUniforms(LLGLSLShader * shader) = 0; // Pure Virtual
58
59public:
60 // Map of shader names to compiled
61 std::map<std::string, GLhandleARB> mShaderObjects;
62
63 //global (reserved slot) shader parameters
64 std::vector<std::string> mReservedAttribs;
65
66 std::vector<std::string> mReservedUniforms;
67
68protected:
69
70 // our parameter manager singleton instance
71 static LLShaderMgr * sInstance;
72
73}; //LLShaderMgr
74
75#endif
diff --git a/linden/indra/llrender/llvertexbuffer.cpp b/linden/indra/llrender/llvertexbuffer.cpp
index 9635ae3..547663b 100644
--- a/linden/indra/llrender/llvertexbuffer.cpp
+++ b/linden/indra/llrender/llvertexbuffer.cpp
@@ -190,10 +190,12 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi
190 if (mode > NUM_MODES) 190 if (mode > NUM_MODES)
191 { 191 {
192 llerrs << "Invalid draw mode: " << mode << llendl; 192 llerrs << "Invalid draw mode: " << mode << llendl;
193 return;
193 } 194 }
194 195
195 glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, 196 glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT,
196 ((U16*) getIndicesPointer()) + indices_offset); 197 ((U16*) getIndicesPointer()) + indices_offset);
198 stop_glerror();
197} 199}
198 200
199void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const 201void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const
@@ -217,6 +219,7 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const
217 if (mode > NUM_MODES) 219 if (mode > NUM_MODES)
218 { 220 {
219 llerrs << "Invalid draw mode: " << mode << llendl; 221 llerrs << "Invalid draw mode: " << mode << llendl;
222 return;
220 } 223 }
221 224
222 glDrawElements(sGLMode[mode], count, GL_UNSIGNED_SHORT, 225 glDrawElements(sGLMode[mode], count, GL_UNSIGNED_SHORT,
@@ -240,9 +243,11 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const
240 if (mode > NUM_MODES) 243 if (mode > NUM_MODES)
241 { 244 {
242 llerrs << "Invalid draw mode: " << mode << llendl; 245 llerrs << "Invalid draw mode: " << mode << llendl;
246 return;
243 } 247 }
244 248
245 glDrawArrays(sGLMode[mode], first, count); 249 glDrawArrays(sGLMode[mode], first, count);
250 stop_glerror();
246} 251}
247 252
248//static 253//static
diff --git a/linden/indra/llrender/llvertexbuffer.h b/linden/indra/llrender/llvertexbuffer.h
index 64a6f60..8edcf69 100644
--- a/linden/indra/llrender/llvertexbuffer.h
+++ b/linden/indra/llrender/llvertexbuffer.h
@@ -41,6 +41,7 @@
41#include "llmemory.h" 41#include "llmemory.h"
42#include <set> 42#include <set>
43#include <vector> 43#include <vector>
44#include <list>
44 45
45//============================================================================ 46//============================================================================
46// NOTES 47// NOTES