summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/CMakeLists.txt1
-rw-r--r--indra/llrender/llcubemap.cpp2
-rw-r--r--indra/llrender/llcubemaparray.cpp2
-rw-r--r--indra/llrender/llfontfreetype.cpp10
-rw-r--r--indra/llrender/llfontfreetypesvg.cpp12
-rw-r--r--indra/llrender/llfontfreetypesvg.h6
-rw-r--r--indra/llrender/llgl.cpp46
-rw-r--r--indra/llrender/llglheaders.h44
-rw-r--r--indra/llrender/llglslshader.cpp44
-rw-r--r--indra/llrender/llglstates.h2
-rw-r--r--indra/llrender/llimagegl.cpp121
-rw-r--r--indra/llrender/llpostprocess.cpp12
-rw-r--r--indra/llrender/llrender.cpp22
-rw-r--r--indra/llrender/llrender.h7
-rw-r--r--indra/llrender/llrender2dutils.cpp2
-rw-r--r--indra/llrender/llrendertarget.cpp10
-rw-r--r--indra/llrender/llvertexbuffer.cpp27
17 files changed, 329 insertions, 41 deletions
diff --git a/indra/llrender/CMakeLists.txt b/indra/llrender/CMakeLists.txt
index ccff7c7a8c..d48b508ddc 100644
--- a/indra/llrender/CMakeLists.txt
+++ b/indra/llrender/CMakeLists.txt
@@ -108,3 +108,4 @@ target_link_libraries(llrender
OpenGL::GLU
)
+include(LibraryInstall)
diff --git a/indra/llrender/llcubemap.cpp b/indra/llrender/llcubemap.cpp
index 26e4aaad52..53691bafe2 100644
--- a/indra/llrender/llcubemap.cpp
+++ b/indra/llrender/llcubemap.cpp
@@ -214,7 +214,9 @@ void LLCubeMap::initEnvironmentMap(const std::vector<LLPointer<LLImageRaw> >& ra
enableTexture(0);
bind();
mImages[0]->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC);
+#if GL_VERSION_3_2
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
+#endif
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
gGL.getTexUnit(0)->disable();
disable();
diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp
index 4f5e13765a..4e7fa7316e 100644
--- a/indra/llrender/llcubemaparray.cpp
+++ b/indra/llrender/llcubemaparray.cpp
@@ -132,8 +132,10 @@ void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, bool us
U32 mip_resolution = resolution;
while (mip_resolution >= 1)
{
+#if GL_VERSION_4_0
glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mip, format, mip_resolution, mip_resolution, count * 6, 0,
GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
+#endif
if (!use_mips)
{
diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp
index 6128e03fa7..fa76669258 100644
--- a/indra/llrender/llfontfreetype.cpp
+++ b/indra/llrender/llfontfreetype.cpp
@@ -52,7 +52,9 @@
#include "llfontbitmapcache.h"
#include "llgl.h"
-#define ENABLE_OT_SVG_SUPPORT
+#if !defined(LL_NO_OTSVG)
+ #define ENABLE_OT_SVG_SUPPORT
+#endif
FT_Render_Mode gFontRenderMode = FT_RENDER_MODE_NORMAL;
@@ -87,7 +89,7 @@ LLFontManager::LLFontManager()
FT_Done_FreeType(gFTLibrary);
}
-#ifdef ENABLE_OT_SVG_SUPPORT
+#if defined(ENABLE_OT_SVG_SUPPORT)
SVG_RendererHooks hooks = {
LLFontFreeTypeSvgRenderer::OnInit,
LLFontFreeTypeSvgRenderer::OnFree,
@@ -483,8 +485,8 @@ LLFontGlyphInfo* LLFontFreetype::addGlyph(llwchar wch, EFontGlyphType glyph_type
continue;
}
glyph_index = FT_Get_Char_Index(pair.first->mFTFace, wch);
- if (glyph_index)
- {
+ if (glyph_index)
+ {
return addGlyphFromFont(pair.first, wch, glyph_index,
glyph_type);
}
diff --git a/indra/llrender/llfontfreetypesvg.cpp b/indra/llrender/llfontfreetypesvg.cpp
index 71f751329e..04825ae8a3 100644
--- a/indra/llrender/llfontfreetypesvg.cpp
+++ b/indra/llrender/llfontfreetypesvg.cpp
@@ -34,9 +34,17 @@
#endif
#define NANOSVG_IMPLEMENTATION
+#if __FreeBSD__
+#include <nanosvg.h>
+#else
#include <nanosvg/nanosvg.h>
+#endif
#define NANOSVGRAST_IMPLEMENTATION
+#if __FreeBSD__
+#include <nanosvgrast.h>
+#else
#include <nanosvg/nanosvgrast.h>
+#endif
#if LL_WINDOWS
#pragma warning (pop)
@@ -80,6 +88,7 @@ void LLFontFreeTypeSvgRenderer::OnDataFinalizer(void* objectp)
//static
FT_Error LLFontFreeTypeSvgRenderer::OnPresetGlypthSlot(FT_GlyphSlot glyph_slot, FT_Bool cache, FT_Pointer*)
{
+#ifndef LL_NO_OTSVG
FT_SVG_Document document = static_cast<FT_SVG_Document>(glyph_slot->other);
llassert(!glyph_slot->generic.data || !cache || glyph_slot->glyph_index == ((LLSvgRenderData*)glyph_slot->generic.data)->GlyphIndex);
@@ -166,6 +175,9 @@ FT_Error LLFontFreeTypeSvgRenderer::OnPresetGlypthSlot(FT_GlyphSlot glyph_slot,
}
return FT_Err_Ok;
+#else
+ return FT_Err_Unimplemented_Feature;
+#endif
}
// static
diff --git a/indra/llrender/llfontfreetypesvg.h b/indra/llrender/llfontfreetypesvg.h
index 4170cab273..94b83d5fff 100644
--- a/indra/llrender/llfontfreetypesvg.h
+++ b/indra/llrender/llfontfreetypesvg.h
@@ -29,7 +29,11 @@
#include <ft2build.h>
#include FT_TYPES_H
#include FT_MODULE_H
-#include FT_OTSVG_H
+#ifdef FT_OTSVG_H
+ #include FT_OTSVG_H
+#else
+ #define LL_NO_OTSVG
+#endif
// See https://freetype.org/freetype2/docs/reference/ft2-svg_fonts.html
class LLFontFreeTypeSvgRenderer
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index c5c9d50dee..6988e55034 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -76,7 +76,7 @@ static const std::string HEADLESS_VERSION_STRING("1.0");
llofstream gFailLog;
-#if GL_ARB_debug_output
+#if GL_ARB_debug_output || GL_KHR_debug
#ifndef APIENTRY
#define APIENTRY
@@ -99,9 +99,9 @@ void APIENTRY gl_debug_callback(GLenum source,
}*/
if (gGLManager.mIsDisabled &&
- severity == GL_DEBUG_SEVERITY_HIGH_ARB &&
- source == GL_DEBUG_SOURCE_API_ARB &&
- type == GL_DEBUG_TYPE_ERROR_ARB &&
+ severity == GL_DEBUG_SEVERITY_HIGH &&
+ source == GL_DEBUG_SOURCE_API &&
+ type == GL_DEBUG_TYPE_ERROR &&
id == GL_INVALID_VALUE)
{
// Suppress messages about deleting already deleted objects called from LLViewerWindow::stopGL()
@@ -161,7 +161,11 @@ void APIENTRY gl_debug_callback(GLenum source,
if (ubo != 0)
{
glGetBufferParameteriv(GL_UNIFORM_BUFFER, GL_BUFFER_SIZE, &ubo_size);
+#if GL_EXT_buffer_storage
+ glGetBufferParameteriv(GL_UNIFORM_BUFFER, GL_BUFFER_IMMUTABLE_STORAGE_EXT, &ubo_immutable);
+#else
glGetBufferParameteriv(GL_UNIFORM_BUFFER, GL_BUFFER_IMMUTABLE_STORAGE, &ubo_immutable);
+#endif
}
// No needs to halt when is called from LLViewerWindow::stopGL()
@@ -215,8 +219,6 @@ LLMatrix4 gGLObliqueProjectionInverse;
std::list<LLGLUpdate*> LLGLUpdate::sGLQ;
-#if (LL_WINDOWS || LL_LINUX) && !LL_MESA_HEADLESS
-
#if LL_WINDOWS
// WGL_ARB_create_context
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = nullptr;
@@ -236,7 +238,7 @@ PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC wglBlitContextFramebufferAMD = n
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = nullptr;
PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT = nullptr;
-#endif
+/*
// GL_VERSION_1_2
//PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements = nullptr;
@@ -982,6 +984,7 @@ PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC glMultiDrawArraysIndirectCount = nullpt
PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC glMultiDrawElementsIndirectCount = nullptr;
PFNGLPOLYGONOFFSETCLAMPPROC glPolygonOffsetClamp = nullptr;
+*/
#endif
LLGLManager gGLManager;
@@ -1136,6 +1139,7 @@ bool LLGLManager::initGL()
#endif
}
+#if GL_VERSION_1_3
if (mGLVersion >= 2.1f && LLImageGL::sCompressTextures)
{ //use texture compression
glHint(GL_TEXTURE_COMPRESSION_HINT, GL_NICEST);
@@ -1144,6 +1148,7 @@ bool LLGLManager::initGL()
{ //GL version is < 3.0, always disable texture compression
LLImageGL::sCompressTextures = false;
}
+#endif
// Trailing space necessary to keep "nVidia Corpor_ati_on" cards
// from being recognized as ATI.
@@ -1160,7 +1165,7 @@ bool LLGLManager::initGL()
mIsNVIDIA = true;
}
else if (mGLVendor.find("INTEL") != std::string::npos
-#if LL_LINUX
+#if LL_LINUX || __FreeBSD__
// The Mesa-based drivers put this in the Renderer string,
// not the Vendor string.
|| mGLRenderer.find("INTEL") != std::string::npos
@@ -1254,10 +1259,12 @@ bool LLGLManager::initGL()
}
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &mNumTextureImageUnits);
+#if GL_VERSION_3_2
glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &mMaxColorTextureSamples);
glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &mMaxDepthTextureSamples);
glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &mMaxIntegerSamples);
glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &mMaxSampleMaskWords);
+#endif
glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples);
glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &mMaxUniformBlockSize);
@@ -1267,7 +1274,7 @@ bool LLGLManager::initGL()
if (mGLVersion >= 4.59f)
{
- glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &mMaxAnisotropy);
+ glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &mMaxAnisotropy);
}
initGLStates();
@@ -1407,6 +1414,9 @@ void LLGLManager::shutdownGL()
void LLGLManager::initExtensions()
{
+#if LL_LINUX
+ glh_init_extensions("");
+#endif
#if LL_DARWIN
GLint num_extensions = 0;
std::string all_extensions{""};
@@ -1437,10 +1447,10 @@ void LLGLManager::initExtensions()
mInited = true;
-#if (LL_WINDOWS || LL_LINUX) && !LL_MESA_HEADLESS
+/*
+#if LL_WINDOWS
LL_DEBUGS("RenderInit") << "GL Probe: Getting symbols" << LL_ENDL;
-#if LL_WINDOWS
// WGL_AMD_gpu_association
wglGetGPUIDsAMD = (PFNWGLGETGPUIDSAMDPROC)GLH_EXT_GET_PROC_ADDRESS("wglGetGPUIDsAMD");
wglGetGPUInfoAMD = (PFNWGLGETGPUINFOAMDPROC)GLH_EXT_GET_PROC_ADDRESS("wglGetGPUInfoAMD");
@@ -1458,8 +1468,6 @@ void LLGLManager::initExtensions()
// WGL_ARB_create_context
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)GLH_EXT_GET_PROC_ADDRESS("wglCreateContextAttribsARB");
-#endif
-
// Load entire OpenGL API through GetProcAddress, leaving sections beyond mGLVersion unloaded
@@ -2277,6 +2285,7 @@ void LLGLManager::initExtensions()
glPolygonOffsetClamp = (PFNGLPOLYGONOFFSETCLAMPPROC)GLH_EXT_GET_PROC_ADDRESS("glPolygonOffsetClamp");
#endif
+*/
}
void rotate_quat(LLQuaternion& rotation)
@@ -2303,12 +2312,14 @@ void log_glerror()
error = glGetError();
while (LL_UNLIKELY(error))
{
+#if GLU_VERSION_1_1
GLubyte const * gl_error_msg = gluErrorString(error);
if (NULL != gl_error_msg)
{
LL_WARNS() << "GL Error: " << error << " GL Error String: " << gl_error_msg << LL_ENDL ;
}
else
+#endif // GLU_VERSION_1_1
{
// gluErrorString returns NULL for some extensions' error codes.
// you'll probably have to grep for the number in glext.h.
@@ -2327,6 +2338,7 @@ void do_assert_glerror()
if (LL_UNLIKELY(error))
{
quit = true;
+#if GLU_VERSION_1_1
GLubyte const * gl_error_msg = gluErrorString(error);
if (NULL != gl_error_msg)
{
@@ -2339,6 +2351,7 @@ void do_assert_glerror()
}
}
else
+#endif // GLU_VERSION_1_1
{
// gluErrorString returns NULL for some extensions' error codes.
// you'll probably have to grep for the number in glext.h.
@@ -2413,8 +2426,10 @@ void LLGLState::initClass()
// sStateMap[GL_TEXTURE_2D] = GL_TRUE;
//make sure multisample defaults to disabled
+#if GL_EXT_multisample || GL_EXT_multisampled_compatibility
sStateMap[GL_MULTISAMPLE] = GL_FALSE;
glDisable(GL_MULTISAMPLE);
+#endif
}
//static
@@ -2429,6 +2444,7 @@ void LLGLState::restoreGL()
void LLGLState::resetTextureStates()
{
gGL.flush();
+#if GL_VERSION_1_3
GLint maxTextureUnits;
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &maxTextureUnits);
@@ -2438,6 +2454,7 @@ void LLGLState::resetTextureStates()
glClientActiveTexture(GL_TEXTURE0+j);
j == 0 ? gGL.getTexUnit(j)->enable(LLTexUnit::TT_TEXTURE) : gGL.getTexUnit(j)->disable();
}
+#endif
}
void LLGLState::dumpStates()
@@ -2587,6 +2604,7 @@ void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor
{
return;
}
+ LL_INFOS() << "GL: " << version << LL_ENDL;
version_string->assign(version);
@@ -2962,5 +2980,3 @@ extern "C"
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
#endif
-
-
diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h
index 3d4dc5e698..a2685376cd 100644
--- a/indra/llrender/llglheaders.h
+++ b/indra/llrender/llglheaders.h
@@ -27,7 +27,7 @@
#ifndef LL_LLGLHEADERS_H
#define LL_LLGLHEADERS_H
-#if LL_MESA
+#if LL_MESA || LL_LINUX || __FreeBSD__
//----------------------------------------------------------------------------
// MESA headers
// quotes so we get libraries/.../GL/ version
@@ -41,6 +41,22 @@
# include "GL/glh_extensions.h"
# undef __APPLE__
+#elif LL_LINUX
+#define GL_GLEXT_PROTOTYPES
+#define GLX_GLEXT_PROTOTYPES
+
+#include "GL/gl.h"
+#include "GL/glext.h"
+#include "GL/glu.h"
+
+// The __APPLE__ kludge is to make glh_extensions.h not symbol-clash horribly
+# define __APPLE__
+# include "GL/glh_extensions.h"
+# undef __APPLE__
+
+# include "GL/glx.h"
+# include "GL/glxext.h"
+
#elif LL_WINDOWS
//----------------------------------------------------------------------------
// LL_WINDOWS
@@ -823,10 +839,14 @@ extern PFNGLPOLYGONOFFSETCLAMPPROC glPolygonOffsetClamp;
#define GL_EXT_separate_specular_color 1
#define GL_GLEXT_PROTOTYPES
-#include "GL/glext.h"
+#include <OpenGL/glext.h>
+
+#define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
+#include <OpenGL/gl3.h>
#include "GL/glh_extensions.h"
+#if 0
// These symbols don't exist on 10.3.9, so they have to be declared weak. Redeclaring them here fixes the problem.
// Note that they also must not be called on 10.3.9. This should be taken care of by a runtime check for the existence of the GL extension.
#include <AvailabilityMacros.h>
@@ -1028,6 +1048,26 @@ extern void glGetBufferPointervARB (GLenum, GLenum, GLvoid* *);
#endif
#include <OpenGL/gl.h>
+#endif // 0
+
+#elif LL_LINUX
+
+#define GL_GLEXT_PROTOTYPES
+#define GLX_GLEXT_PROTOTYPES
+
+#include "GL/gl.h"
+#include "GL/glu.h"
+#include "GL/glext.h"
+#include "GL/glx.h"
+
+// The __APPLE__ kludge is to make glh_extensions.h not symbol-clash horribly
+# define __APPLE__
+# include "GL/glh_extensions.h"
+# undef __APPLE__
+
+// #include <X11/Xlib.h>
+// #include <X11/Xutil.h>
+#include "GL/glh_extensions.h"
#endif // LL_MESA / LL_WINDOWS / LL_DARWIN
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 45bb24a5b7..f6539b8d03 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -255,12 +255,18 @@ void LLGLSLShader::placeProfileQuery(bool for_runtime)
glGenQueries(1, &mPrimitivesQuery);
}
- glBeginQuery(GL_TIME_ELAPSED, mTimerQuery);
+#if GL_EXT_timer_query || GL_EXT_disjoint_timer_query
+ glBeginQuery(GL_TIME_ELAPSED_EXT, mTimerQuery);
+#endif
if (!for_runtime)
{
+#if GL_VERSION_1_5
glBeginQuery(GL_SAMPLES_PASSED, mSamplesQuery);
+#endif
+#if GL_VERSION_3_0
glBeginQuery(GL_PRIMITIVES_GENERATED, mPrimitivesQuery);
+#endif
}
}
}
@@ -271,19 +277,30 @@ bool LLGLSLShader::readProfileQuery(bool for_runtime, bool force_read)
{
if (!mProfilePending)
{
- glEndQuery(GL_TIME_ELAPSED);
+#if GL_EXT_timer_query || GL_EXT_disjoint_timer_query
+ glEndQuery(GL_TIME_ELAPSED_EXT);
+#endif
if (!for_runtime)
{
+#if GL_VERSION_1_5
glEndQuery(GL_SAMPLES_PASSED);
+#endif
+#if GL_VERSION_3_0
glEndQuery(GL_PRIMITIVES_GENERATED);
+#endif
}
mProfilePending = for_runtime;
}
if (mProfilePending && for_runtime && !force_read)
{
+#if GL_ARB_timer_query
GLuint64 result = 0;
glGetQueryObjectui64v(mTimerQuery, GL_QUERY_RESULT_AVAILABLE, &result);
+#else
+ GLuint result = 0;
+ glGetQueryObjectuiv(mTimerQuery, GL_QUERY_RESULT_AVAILABLE, &result);
+#endif
if (result != GL_TRUE)
{
@@ -291,22 +308,34 @@ bool LLGLSLShader::readProfileQuery(bool for_runtime, bool force_read)
}
}
+#if GL_ARB_timer_query
GLuint64 time_elapsed = 0;
glGetQueryObjectui64v(mTimerQuery, GL_QUERY_RESULT, &time_elapsed);
+#else
+ GLuint time_elapsed = 0;
+ glGetQueryObjectuiv(mTimerQuery, GL_QUERY_RESULT, &time_elapsed);
+#endif
mTimeElapsed += time_elapsed;
mProfilePending = false;
if (!for_runtime)
{
+#if GL_ARB_timer_query
GLuint64 samples_passed = 0;
glGetQueryObjectui64v(mSamplesQuery, GL_QUERY_RESULT, &samples_passed);
GLuint64 primitives_generated = 0;
glGetQueryObjectui64v(mPrimitivesQuery, GL_QUERY_RESULT, &primitives_generated);
+#else
+ GLuint primitives_generated = 0;
+ glGetQueryObjectuiv(mPrimitivesQuery, GL_QUERY_RESULT, &primitives_generated);
+#endif
sTotalTimeElapsed += time_elapsed;
+#if GL_VERSION_1_5
sTotalSamplesDrawn += samples_passed;
mSamplesDrawn += samples_passed;
+#endif
U32 tri_count = (U32)primitives_generated / 3;
@@ -721,10 +750,14 @@ void LLGLSLShader::mapUniform(GLint index)
case GL_FLOAT_VEC2: size *= 2; break;
case GL_FLOAT_VEC3: size *= 3; break;
case GL_FLOAT_VEC4: size *= 4; break;
+#if GL_VERSION_1_1
case GL_DOUBLE: size *= 2; break;
+#if GL_VERSION_4_0
case GL_DOUBLE_VEC2: size *= 2; break;
case GL_DOUBLE_VEC3: size *= 6; break;
case GL_DOUBLE_VEC4: size *= 8; break;
+#endif // GL_VERSION_4_0
+#endif // GL_VERSION_1_1
case GL_INT_VEC2: size *= 2; break;
case GL_INT_VEC3: size *= 3; break;
case GL_INT_VEC4: size *= 4; break;
@@ -743,6 +776,7 @@ void LLGLSLShader::mapUniform(GLint index)
case GL_FLOAT_MAT3x4: size *= 12; break;
case GL_FLOAT_MAT4x2: size *= 8; break;
case GL_FLOAT_MAT4x3: size *= 12; break;
+#if GL_VERSION_4_0
case GL_DOUBLE_MAT2: size *= 8; break;
case GL_DOUBLE_MAT3: size *= 18; break;
case GL_DOUBLE_MAT4: size *= 32; break;
@@ -752,6 +786,7 @@ void LLGLSLShader::mapUniform(GLint index)
case GL_DOUBLE_MAT3x4: size *= 24; break;
case GL_DOUBLE_MAT4x2: size *= 16; break;
case GL_DOUBLE_MAT4x3: size *= 24; break;
+#endif // GL_VERSION_4_0
}
mTotalUniformSize += size;
}
@@ -815,7 +850,10 @@ GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type, GLint
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
- if ((type >= GL_SAMPLER_1D && type <= GL_SAMPLER_2D_RECT_SHADOW) ||
+ if (
+#if GL_VERSION_2_0
+ (type >= GL_SAMPLER_1D && type <= GL_SAMPLER_2D_RECT_SHADOW) ||
+#endif
type == GL_SAMPLER_2D_MULTISAMPLE ||
type == GL_SAMPLER_CUBE_MAP_ARRAY)
{ //this here is a texture
diff --git a/indra/llrender/llglstates.h b/indra/llrender/llglstates.h
index 9bb980d7ad..68d4df8e90 100644
--- a/indra/llrender/llglstates.h
+++ b/indra/llrender/llglstates.h
@@ -166,6 +166,7 @@ public:
//----------------------------------------------------------------------------
+#if GL_VERSION_1_1
class LLGLSSpecular
{
public:
@@ -190,6 +191,7 @@ public:
}
}
};
+#endif
//----------------------------------------------------------------------------
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 9df0fef5d1..08c05a0771 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -301,28 +301,46 @@ S32 LLImageGL::dataFormatBits(S32 dataformat)
{
switch (dataformat)
{
+#if GL_VERSION_3_0
case GL_COMPRESSED_RED: return 8;
+#endif
case GL_COMPRESSED_RG: return 16;
+#if GL_VERSION_1_3
case GL_COMPRESSED_RGB: return 24;
+#endif
+#if GL_VERSION_2_1
case GL_COMPRESSED_SRGB: return 32;
+#endif
+#if GL_VERSION_1_3
case GL_COMPRESSED_RGBA: return 32;
+#endif
+#if GL_VERSION_2_1
case GL_COMPRESSED_SRGB_ALPHA: return 32;
+#endif
+#if GL_VERSION_1_3
case GL_COMPRESSED_LUMINANCE: return 8;
case GL_COMPRESSED_LUMINANCE_ALPHA: return 16;
case GL_COMPRESSED_ALPHA: return 8;
+#endif
+#if GL_EXT_texture_compression_s3tc || GL_EXT_texture_compression_dxt1
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return 4;
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return 4;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: return 8;
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return 8;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return 8;
+#endif
+#if GL_EXT_texture_sRGB || GL_EXT_texture_compression_s3tc_srgb
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return 4;
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return 8;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: return 8;
+#endif
case GL_LUMINANCE: return 8;
case GL_LUMINANCE8: return 8;
case GL_ALPHA: return 8;
case GL_ALPHA8: return 8;
case GL_RED: return 8;
case GL_R8: return 8;
+#if GL_VERSION_1_1
case GL_COLOR_INDEX: return 8;
+#endif
case GL_LUMINANCE_ALPHA: return 16;
case GL_LUMINANCE8_ALPHA8: return 16;
case GL_RG: return 16;
@@ -332,8 +350,10 @@ S32 LLImageGL::dataFormatBits(S32 dataformat)
case GL_RGB8: return 24;
case GL_RGBA: return 32;
case GL_RGBA8: return 32;
+#if GL_VERSION_2_1
case GL_SRGB_ALPHA: return 32;
case GL_BGRA: return 32; // Used for QuickTime media textures on the Mac
+#endif
case GL_DEPTH_COMPONENT: return 24;
case GL_DEPTH_COMPONENT24: return 24;
case GL_R16F: return 16;
@@ -355,6 +375,8 @@ S64 LLImageGL::dataFormatBytes(S32 dataformat, S32 width, S32 height)
{
switch (dataformat)
{
+#if GL_EXT_texture_compression_s3tc || GL_EXT_texture_compression_dxt1 \
+ || GL_EXT_texture_sRGB || GL_EXT_texture_compression_s3tc_srgb
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
@@ -364,6 +386,7 @@ S64 LLImageGL::dataFormatBytes(S32 dataformat, S32 width, S32 height)
if (width < 4) width = 4;
if (height < 4) height = 4;
break;
+#endif
default:
break;
}
@@ -377,23 +400,31 @@ S32 LLImageGL::dataFormatComponents(S32 dataformat)
{
switch (dataformat)
{
+#if GL_EXT_texture_compression_s3tc || GL_EXT_texture_compression_dxt1
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return 3;
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return 3;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: return 4;
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return 4;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return 4;
+#endif
+#if GL_EXT_texture_sRGB || GL_EXT_texture_compression_s3tc_srgb
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return 3;
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return 4;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: return 4;
+#endif
case GL_LUMINANCE: return 1;
case GL_ALPHA: return 1;
case GL_RED: return 1;
+#if GL_VERSION_1_1
case GL_COLOR_INDEX: return 1;
+#endif
case GL_LUMINANCE_ALPHA: return 2;
case GL_RG: return 2;
case GL_RGB: return 3;
case GL_SRGB: return 3;
case GL_RGBA: return 4;
+#if GL_VERSION_2_1
case GL_SRGB_ALPHA: return 4;
case GL_BGRA: return 4; // Used for QuickTime media textures on the Mac
+#endif
default:
LL_ERRS() << "LLImageGL::Unknown format: " << std::hex << dataformat << std::dec << LL_ENDL;
return 0;
@@ -793,11 +824,13 @@ bool LLImageGL::setImage(const U8* data_in, bool data_hasmips /* = false */, S32
}
else
{
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
stop_glerror();
}
+#endif
LLImageGL::setManualImage(mTarget, gl_level, mFormatInternal, w, h, mFormatPrimary, GL_UNSIGNED_BYTE, (GLvoid*)data_in, mAllowCompression);
if (gl_level == 0)
@@ -806,11 +839,13 @@ bool LLImageGL::setImage(const U8* data_in, bool data_hasmips /* = false */, S32
}
updatePickMask(w, h, data_in);
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
stop_glerror();
}
+#endif
stop_glerror();
}
@@ -823,11 +858,13 @@ bool LLImageGL::setImage(const U8* data_in, bool data_hasmips /* = false */, S32
{
stop_glerror();
{
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
stop_glerror();
}
+#endif
S32 w = getWidth(mCurrentDiscardLevel);
S32 h = getHeight(mCurrentDiscardLevel);
@@ -837,10 +874,12 @@ bool LLImageGL::setImage(const U8* data_in, bool data_hasmips /* = false */, S32
//use legacy mipmap generation mode (note: making this condional can cause rendering issues)
// -- but making it not conditional triggers deprecation warnings when core profile is enabled
// (some rendering issues while core profile is enabled are acceptable at this point in time)
+#if GL_VERSION_1_4
if (!LLRender::sGLCoreProfile)
{
glTexParameteri(mTarget, GL_GENERATE_MIPMAP, GL_TRUE);
}
+#endif
LLImageGL::setManualImage(mTarget, 0, mFormatInternal,
w, h,
@@ -851,11 +890,13 @@ bool LLImageGL::setImage(const U8* data_in, bool data_hasmips /* = false */, S32
updatePickMask(w, h, data_in);
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
stop_glerror();
}
+#endif
if (LLRender::sGLCoreProfile)
{
@@ -940,11 +981,13 @@ bool LLImageGL::setImage(const U8* data_in, bool data_hasmips /* = false */, S32
llassert(w > 0 && h > 0 && cur_mip_data);
(void)cur_mip_data;
{
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
stop_glerror();
}
+#endif
LLImageGL::setManualImage(mTarget, m, mFormatInternal, w, h, mFormatPrimary, mFormatType, cur_mip_data, mAllowCompression);
if (m == 0)
@@ -957,11 +1000,13 @@ bool LLImageGL::setImage(const U8* data_in, bool data_hasmips /* = false */, S32
updatePickMask(w, h, cur_mip_data);
}
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
stop_glerror();
}
+#endif
}
if (prev_mip_data && prev_mip_data != data_in)
{
@@ -996,11 +1041,13 @@ bool LLImageGL::setImage(const U8* data_in, bool data_hasmips /* = false */, S32
}
else
{
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
stop_glerror();
}
+#endif
LLImageGL::setManualImage(mTarget, 0, mFormatInternal, w, h,
mFormatPrimary, mFormatType, (GLvoid *)data_in, mAllowCompression);
@@ -1010,11 +1057,13 @@ bool LLImageGL::setImage(const U8* data_in, bool data_hasmips /* = false */, S32
stop_glerror();
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
stop_glerror();
}
+#endif
}
}
@@ -1030,7 +1079,9 @@ U32 type_width_from_pixtype(U32 pixtype)
{
case GL_UNSIGNED_BYTE:
case GL_BYTE:
+#if GL_VERSION_1_2
case GL_UNSIGNED_INT_8_8_8_8_REV:
+#endif
type_width = 1;
break;
case GL_UNSIGNED_SHORT:
@@ -1177,11 +1228,13 @@ bool LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3
glPixelStorei(GL_UNPACK_ROW_LENGTH, data_width);
stop_glerror();
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
stop_glerror();
}
+#endif
const U8* sub_datap = datap + (y_pos * data_width + x_pos) * getComponents();
// Update the GL texture
@@ -1205,11 +1258,13 @@ bool LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3
gGL.getTexUnit(0)->disable();
stop_glerror();
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
stop_glerror();
}
+#endif
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
stop_glerror();
@@ -1416,31 +1471,51 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt
break;
case GL_RGB:
case GL_RGB8:
+#if GL_VERSION_1_3
intformat = GL_COMPRESSED_RGB;
+#endif
break;
case GL_SRGB:
case GL_SRGB8:
+#if GL_VERSION_2_1
intformat = GL_COMPRESSED_SRGB;
+#endif
break;
case GL_RGBA:
case GL_RGBA8:
+#if GL_VERSION_1_3
intformat = GL_COMPRESSED_RGBA;
+#endif
break;
- case GL_SRGB_ALPHA:
case GL_SRGB8_ALPHA8:
+#if GL_VERSION_2_1
+ case GL_SRGB_ALPHA:
intformat = GL_COMPRESSED_SRGB_ALPHA;
+#endif
break;
case GL_LUMINANCE:
+#if GL_VERSION_1_1
case GL_LUMINANCE8:
+#endif
+#if GL_VERSION_1_3
intformat = GL_COMPRESSED_LUMINANCE;
+#endif
break;
case GL_LUMINANCE_ALPHA:
+#if GL_VERSION_1_1
case GL_LUMINANCE8_ALPHA8:
+#endif
+#if GL_VERSION_1_3
intformat = GL_COMPRESSED_LUMINANCE_ALPHA;
+#endif
break;
case GL_ALPHA:
+#if GL_VERSION_1_1
case GL_ALPHA8:
+#endif
+#if GL_VERSION_1_3
intformat = GL_COMPRESSED_ALPHA;
+#endif
break;
default:
LL_WARNS() << "Could not compress format: " << std::hex << intformat << std::dec << LL_ENDL;
@@ -1574,13 +1649,21 @@ bool LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S
{
case 1:
// Use luminance alpha (for fonts)
+#if GL_VERSION_1_1
mFormatInternal = GL_LUMINANCE8;
+#else
+ mFormatInternal = GL_LUMINANCE;
+#endif
mFormatPrimary = GL_LUMINANCE;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 2:
// Use luminance alpha (for fonts)
+#if GL_VERSION_1_1
mFormatInternal = GL_LUMINANCE8_ALPHA8;
+#else
+ mFormatInternal = GL_LUMINANCE_ALPHA;
+#endif
mFormatPrimary = GL_LUMINANCE_ALPHA;
mFormatType = GL_UNSIGNED_BYTE;
break;
@@ -1862,6 +1945,7 @@ bool LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
LLImageDataLock lock(imageraw);
+#if GL_VERSION_1_3
if (is_compressed)
{
LLGLint glbytes;
@@ -1888,6 +1972,7 @@ bool LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
glGetTexImage(GL_TEXTURE_2D, gl_discard, mFormatPrimary, mFormatType, (GLvoid*)(imageraw->getData()));
//stop_glerror();
}
+#endif // GL_VERSION_1_3
//-----------------------------------------------------------------------------------------------
if((error = glGetError()) != GL_NO_ERROR)
@@ -1976,11 +2061,13 @@ bool LLImageGL::getIsResident(bool test_now)
{
if (test_now)
{
+#if GL_VERSION_1_1
if (mTexName != 0)
{
glAreTexturesResident(1, (GLuint*)&mTexName, &mIsResident);
}
else
+#endif
{
mIsResident = false;
}
@@ -2110,12 +2197,16 @@ void LLImageGL::calcAlphaChannelOffsetAndStride()
mIsMask = false;
return; //no alpha channel.
case GL_RGBA:
+#if GL_VERSION_2_1
case GL_SRGB_ALPHA:
+#endif
mAlphaStride = 4;
break;
+#if GL_EXT_bgra
case GL_BGRA_EXT:
mAlphaStride = 4;
break;
+#endif
default:
break;
}
@@ -2125,6 +2216,7 @@ void LLImageGL::calcAlphaChannelOffsetAndStride()
{
mAlphaOffset = mAlphaStride - 1 ;
}
+#if GL_VERSION_1_2
else if(is_little_endian())
{
if (mFormatType == GL_UNSIGNED_INT_8_8_8_8)
@@ -2147,10 +2239,15 @@ void LLImageGL::calcAlphaChannelOffsetAndStride()
mAlphaOffset = 0 ;
}
}
+#endif // GL_VERSION_1_2
if( mAlphaStride < 1 || //unsupported format
- mAlphaOffset < 0 || //unsupported type
- (mFormatPrimary == GL_BGRA_EXT && mFormatType != GL_UNSIGNED_BYTE)) //unknown situation
+ mAlphaOffset < 0 //unsupported type
+#if GL_EXT_bgra
+ ||
+ (mFormatPrimary == GL_BGRA_EXT && mFormatType != GL_UNSIGNED_BYTE) //unknown situation
+#endif
+ )
{
LL_WARNS() << "Cannot analyze alpha for image with format type " << std::hex << mFormatType << std::dec << LL_ENDL;
@@ -2298,6 +2395,8 @@ bool LLImageGL::isCompressed()
bool is_compressed = false;
switch (mFormatPrimary)
{
+#if GL_EXT_texture_compression_s3tc || GL_EXT_texture_compression_dxt1 \
+ || GL_EXT_texture_sRGB || GL_EXT_texture_compression_s3tc_srgb
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
@@ -2306,6 +2405,7 @@ bool LLImageGL::isCompressed()
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
is_compressed = true;
break;
+#endif
default:
break;
}
@@ -2322,7 +2422,10 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in)
if (mFormatType != GL_UNSIGNED_BYTE ||
((mFormatPrimary != GL_RGBA)
- && (mFormatPrimary != GL_SRGB_ALPHA)))
+#if GL_VERSION_2_1
+ && (mFormatPrimary != GL_SRGB_ALPHA)
+#endif
+ ))
{
//cannot generate a pick mask for this texture
freePickMask();
@@ -2500,7 +2603,9 @@ bool LLImageGL::scaleDown(S32 desired_discard)
sScratchPBOSize = (U32)size;
}
+#if GL_VERSION_1_3
glGetTexImage(mTarget, mip, mFormatPrimary, mFormatType, nullptr);
+#endif
free_tex_image(mTexName);
diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp
index eef7193c92..2e70c6953d 100644
--- a/indra/llrender/llpostprocess.cpp
+++ b/indra/llrender/llpostprocess.cpp
@@ -296,8 +296,10 @@ void LLPostProcess::getShaderUniforms(glslUniforms & uniforms, GLuint & prog)
void LLPostProcess::doEffects(void)
{
/// Save GL State
+#if GL_VERSION_1_1
glPushAttrib(GL_ALL_ATTRIB_BITS);
glPushClientAttrib(GL_ALL_ATTRIB_BITS);
+#endif
/// Copy the screen buffer to the render texture
{
@@ -322,15 +324,19 @@ void LLPostProcess::doEffects(void)
viewPerspective();
/// Reset GL State
+#if GL_VERSION_1_1
glPopClientAttrib();
glPopAttrib();
+#endif
checkError();
}
void LLPostProcess::copyFrameBuffer(U32 & texture, unsigned int width, unsigned int height)
{
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture);
+#if GL_VERSION_3_1
glCopyTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, 0, 0, width, height, 0);
+#endif
}
void LLPostProcess::drawOrthoQuad(unsigned int width, unsigned int height, QuadType type)
@@ -371,8 +377,10 @@ void LLPostProcess::createTexture(LLPointer<LLImageGL>& texture, unsigned int wi
if(texture->createGLTexture())
{
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture->getTexName());
+#if GL_VERSION_3_1
glTexImage2D(GL_TEXTURE_RECTANGLE, 0, 4, width, height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, &data[0]);
+#endif
gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
}
@@ -406,18 +414,22 @@ bool LLPostProcess::checkError(void)
while (glErr != GL_NO_ERROR)
{
// shaderErrorLog << (const char *) gluErrorString(glErr) << std::endl;
+#if GLU_VERSION_1_1
char const * err_str_raw = (const char *) gluErrorString(glErr);
if(err_str_raw == NULL)
{
+#endif
std::ostringstream err_builder;
err_builder << "unknown error number " << glErr;
mShaderErrorString = err_builder.str();
+#if GLU_VERSION_1_1
}
else
{
mShaderErrorString = err_str_raw;
}
+#endif
retCode = true;
glErr = glGetError();
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index eb2cd560a6..d333a3fd54 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -83,10 +83,16 @@ static thread_local std::list<LLVertexBufferData> *sBufferDataList = nullptr;
static const GLenum sGLTextureType[] =
{
GL_TEXTURE_2D,
+#if GL_VERSION_3_1
GL_TEXTURE_RECTANGLE,
+#endif
GL_TEXTURE_CUBE_MAP,
+#if GL_VERSION_4_0
GL_TEXTURE_CUBE_MAP_ARRAY,
+#endif
+#if GL_VERSION_3_2
GL_TEXTURE_2D_MULTISAMPLE,
+#endif
GL_TEXTURE_3D
};
@@ -514,17 +520,18 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio
{
if (LLImageGL::sGlobalUseAnisotropic && option == TFO_ANISOTROPIC)
{
- glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY, gGLManager.mMaxAnisotropy);
+ glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY_EXT, gGLManager.mMaxAnisotropy);
}
else
{
- glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY, 1.f);
+ glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f);
}
}
}
GLint LLTexUnit::getTextureSource(eTextureBlendSrc src)
{
+#if GL_VERSION_1_3
switch(src)
{
// All four cases should return the same value.
@@ -539,8 +546,10 @@ GLint LLTexUnit::getTextureSource(eTextureBlendSrc src)
case TBS_TEX_ALPHA:
case TBS_ONE_MINUS_TEX_COLOR:
case TBS_ONE_MINUS_TEX_ALPHA:
+#endif
return GL_TEXTURE;
+#if GL_VERSION_1_3
// All four cases should return the same value.
case TBS_VERT_COLOR:
case TBS_VERT_ALPHA:
@@ -559,6 +568,7 @@ GLint LLTexUnit::getTextureSource(eTextureBlendSrc src)
LL_WARNS() << "Unknown eTextureBlendSrc: " << src << ". Using Vertex Color instead." << LL_ENDL;
return GL_PRIMARY_COLOR;
}
+#endif
}
GLint LLTexUnit::getTextureSourceType(eTextureBlendSrc src, bool isAlpha)
@@ -605,7 +615,9 @@ void LLTexUnit::setColorScale(S32 scale)
{
mCurrColorScale = scale;
gGL.flush();
+#if GL_VERSION_1_1
glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE, scale );
+#endif
}
}
@@ -615,7 +627,9 @@ void LLTexUnit::setAlphaScale(S32 scale)
{
mCurrAlphaScale = scale;
gGL.flush();
+#if GL_VERSION_1_1
glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, scale );
+#endif
}
}
@@ -867,7 +881,9 @@ bool LLRender::init(bool needs_vertex_buffer)
glCullFace(GL_BACK);
// necessary for reflection maps
+#if GL_VERSION_3_2
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
+#endif
#if LL_WINDOWS
if (glGenVertexArrays == nullptr)
@@ -2016,9 +2032,11 @@ void LLRender::debugTexUnits(void)
case LLTexUnit::TT_TEXTURE:
LL_CONT << "Texture 2D";
break;
+#if GL_VERSION_3_1
case LLTexUnit::TT_RECT_TEXTURE:
LL_CONT << "Texture Rectangle";
break;
+#endif
case LLTexUnit::TT_CUBE_MAP:
LL_CONT << "Cube Map";
break;
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index fc7c5ccc18..7162ce51a4 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -34,6 +34,7 @@
//#include "linden_common.h"
+#include <array>
#include "v2math.h"
#include "v3math.h"
#include "v4coloru.h"
@@ -68,10 +69,16 @@ public:
typedef enum
{
TT_TEXTURE = 0, // Standard 2D Texture
+#if GL_VERSION_3_1
TT_RECT_TEXTURE, // Non power of 2 texture
+#endif
TT_CUBE_MAP, // 6-sided cube map texture
+#if GL_VERSION_4_0
TT_CUBE_MAP_ARRAY, // Array of cube maps
+#endif
+#if GL_VERSION_3_2
TT_MULTISAMPLE_TEXTURE, // see GL_ARB_texture_multisample
+#endif
TT_TEXTURE_3D, // standard 3D Texture
TT_NONE, // No texture type is currently enabled
} eTextureType;
diff --git a/indra/llrender/llrender2dutils.cpp b/indra/llrender/llrender2dutils.cpp
index 5b08c29d64..9144ce6d62 100644
--- a/indra/llrender/llrender2dutils.cpp
+++ b/indra/llrender/llrender2dutils.cpp
@@ -1802,10 +1802,12 @@ void LLRender2D::setLineWidth(F32 width)
// If outside the allowed range, glLineWidth fails with "invalid value".
// On Darwin, the range is [1, 1].
static GLfloat range[2]{0.0};
+#if GL_VERSION_1_2
if (range[1] == 0)
{
glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, range);
}
+#endif
width *= lerp(LLRender::sUIGLScaleFactor.mV[VX], LLRender::sUIGLScaleFactor.mV[VY], 0.5f);
glLineWidth(llclamp(width, range[0], range[1]));
}
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index 38bc5ff331..0e4aa2ee7a 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -255,12 +255,14 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)
stop_glerror();
}
+#if GL_VERSION_3_1
if (mUsage != LLTexUnit::TT_RECT_TEXTURE)
{
gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_MIRROR);
stop_glerror();
}
else
+#endif
{
// ATI doesn't support mirrored repeat for rectangular textures.
gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
@@ -429,7 +431,8 @@ void LLRenderTarget::bindTarget()
if (mTex.empty())
{ //no color buffer to draw to
- glDrawBuffer(GL_NONE);
+ GLenum buffers[] = {GL_NONE};
+ glDrawBuffers(0, buffers);
glReadBuffer(GL_NONE);
}
else
@@ -499,7 +502,9 @@ void LLRenderTarget::bindTexture(U32 index, S32 channel, LLTexUnit::eTextureFilt
{
case GL_SRGB:
case GL_SRGB8:
+#if GL_VERSION_2_1
case GL_SRGB_ALPHA:
+#endif
case GL_SRGB8_ALPHA8:
isSRGB = true;
break;
@@ -542,7 +547,8 @@ void LLRenderTarget::flush()
sCurResX = gGLViewport[2];
sCurResY = gGLViewport[3];
glReadBuffer(GL_BACK);
- glDrawBuffer(GL_BACK);
+ GLenum drawbuffers[] = {GL_BACK};
+ glDrawBuffers(1, drawbuffers);
}
}
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index b2aa0eb675..cc0329c6f8 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -948,7 +948,8 @@ void LLVertexBuffer::initClass(LLWindow* window)
LL_INFOS() << "VBO Pooling Disabled" << LL_ENDL;
sVBOPool = new LLAppleVBOPool();
- if (gGLManager.mIsApple)
+ //if (gGLManager.mIsApple)
+ if(0)
{
LL_INFOS() << "VBO Pooling Disabled" << LL_ENDL;
sVBOPool = new LLAppleVBOPool();
@@ -1291,7 +1292,8 @@ U8* LLVertexBuffer::mapVertexBuffer(LLVertexBuffer::AttributeType type, U32 inde
count = mNumVerts - index;
}
- if (!gGLManager.mIsApple)
+ //if (!gGLManager.mIsApple)
+ if (1)
{
U32 start = mOffsets[type] + sTypeSize[type] * index;
U32 end = start + sTypeSize[type] * count-1;
@@ -1328,7 +1330,8 @@ U8* LLVertexBuffer::mapIndexBuffer(U32 index, S32 count)
count = mNumIndices-index;
}
- if (!gGLManager.mIsApple)
+ //if (!gGLManager.mIsApple)
+ if(1)
{
U32 start = sizeof(U16) * index;
U32 end = start + sizeof(U16) * count-1;
@@ -1365,6 +1368,20 @@ void LLVertexBuffer::flush_vbo(GLenum target, U32 start, U32 end, void* data, U8
{
if (gGLManager.mIsApple)
{
+ U32 MapBits = GL_MAP_WRITE_BIT;
+ U32 buffer_size = end-start+1;
+
+ U8 * mptr = NULL;
+ mptr = (U8*) glMapBufferRange( target, start, end-start+1, MapBits);
+
+ if (mptr)
+ {
+ std::memcpy(mptr, (U8*) data, buffer_size);
+ if(!glUnmapBuffer(target)) LL_WARNS() << "glUnmapBuffer() failed" << LL_ENDL;
+ }
+ else LL_WARNS() << "glMapBufferRange() returned NULL" << LL_ENDL;
+
+ /*
// on OS X, flush_vbo doesn't actually write to the GL buffer, so be sure to call
// _mapBuffer to tag the buffer for flushing to GL
_mapBuffer();
@@ -1372,6 +1389,7 @@ void LLVertexBuffer::flush_vbo(GLenum target, U32 start, U32 end, void* data, U8
STOP_GLERROR;
// copy into mapped buffer
memcpy(dst+start, data, end-start+1);
+ */
}
else
{
@@ -1429,7 +1447,8 @@ void LLVertexBuffer::_unmapBuffer()
}
};
- if (gGLManager.mIsApple)
+ //if (gGLManager.mIsApple)
+ if (0)
{
STOP_GLERROR;
if (mMappedData)