summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2023-09-07 19:46:10 +0800
committerErik Kundiman <erik@megapahit.org>2023-09-07 19:46:10 +0800
commite600f6504cd7edd9d2883ea7dc17c2574b1ff468 (patch)
treeefc0aa6d3b75e2877a0a323c5c24b75ff8ac902c
parent0aa43b264a76bb46cec2381b66708052b6b0ced9 (diff)
Bring back GL funcs & macros that work on macOS
-rw-r--r--indra/llrender/llatmosphere.cpp16
-rw-r--r--indra/llrender/llgl.cpp7
-rw-r--r--indra/llrender/llglslshader.cpp9
-rw-r--r--indra/llrender/llrender.cpp6
-rw-r--r--indra/llrender/llvertexbuffer.cpp49
5 files changed, 67 insertions, 20 deletions
diff --git a/indra/llrender/llatmosphere.cpp b/indra/llrender/llatmosphere.cpp
index 8e37ca9b90..941ffe2711 100644
--- a/indra/llrender/llatmosphere.cpp
+++ b/indra/llrender/llatmosphere.cpp
@@ -241,7 +241,11 @@ LLGLTexture* LLAtmosphere::getTransmittance()
m_transmittance->generateGLTexture();
m_transmittance->setAddressMode(LLTexUnit::eTextureAddressMode::TAM_CLAMP);
m_transmittance->setFilteringOption(LLTexUnit::eTextureFilterOptions::TFO_BILINEAR);
+#if GL_ARB_texture_float
+ m_transmittance->setExplicitFormat(GL_RGB32F_ARB, GL_RGB, GL_FLOAT);
+#else
m_transmittance->setExplicitFormat(GL_RGB32F, GL_RGB, GL_FLOAT);
+#endif
m_transmittance->setTarget(GL_TEXTURE_2D, LLTexUnit::TT_TEXTURE);
}
return m_transmittance;
@@ -255,7 +259,11 @@ LLGLTexture* LLAtmosphere::getScattering()
m_scattering->generateGLTexture();
m_scattering->setAddressMode(LLTexUnit::eTextureAddressMode::TAM_CLAMP);
m_scattering->setFilteringOption(LLTexUnit::eTextureFilterOptions::TFO_BILINEAR);
+#if GL_ARB_texture_float
+ m_scattering->setExplicitFormat(GL_RGB16F_ARB, GL_RGB, GL_FLOAT);
+#else
m_scattering->setExplicitFormat(GL_RGB16F, GL_RGB, GL_FLOAT);
+#endif
m_scattering->setTarget(GL_TEXTURE_3D, LLTexUnit::TT_TEXTURE_3D);
}
return m_scattering;
@@ -269,7 +277,11 @@ LLGLTexture* LLAtmosphere::getMieScattering()
m_mie_scatter_texture->generateGLTexture();
m_mie_scatter_texture->setAddressMode(LLTexUnit::eTextureAddressMode::TAM_CLAMP);
m_mie_scatter_texture->setFilteringOption(LLTexUnit::eTextureFilterOptions::TFO_BILINEAR);
+#if GL_ARB_texture_float
+ m_mie_scatter_texture->setExplicitFormat(GL_RGB16F_ARB, GL_RGB, GL_FLOAT);
+#else
m_mie_scatter_texture->setExplicitFormat(GL_RGB16F, GL_RGB, GL_FLOAT);
+#endif
m_mie_scatter_texture->setTarget(GL_TEXTURE_3D, LLTexUnit::TT_TEXTURE_3D);
}
return m_mie_scatter_texture;
@@ -283,7 +295,11 @@ LLGLTexture* LLAtmosphere::getIlluminance()
m_illuminance->generateGLTexture();
m_illuminance->setAddressMode(LLTexUnit::eTextureAddressMode::TAM_CLAMP);
m_illuminance->setFilteringOption(LLTexUnit::eTextureFilterOptions::TFO_BILINEAR);
+#if GL_ARB_texture_float
+ m_illuminance->setExplicitFormat(GL_RGB32F_ARB, GL_RGB, GL_FLOAT);
+#else
m_illuminance->setExplicitFormat(GL_RGB32F, GL_RGB, GL_FLOAT);
+#endif
m_illuminance->setTarget(GL_TEXTURE_2D, LLTexUnit::TT_TEXTURE);
}
return m_illuminance;
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index f597b1a932..9c809d5bd0 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -777,10 +777,12 @@ bool LLGLManager::initGL()
if (mHasTextureMultisample)
{
+#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
}
stop_glerror();
@@ -1621,8 +1623,13 @@ void LLGLState::initClass()
// sStateMap[GL_TEXTURE_2D] = GL_TRUE;
//make sure multisample defaults to disabled
+#if GL_ARB_multisample
+ sStateMap[GL_MULTISAMPLE_ARB] = GL_FALSE;
+ glDisable(GL_MULTISAMPLE_ARB);
+#elif GL_EXT_multisample || GL_EXT_multisample_compatibility
sStateMap[GL_MULTISAMPLE_EXT] = GL_FALSE;
glDisable(GL_MULTISAMPLE_EXT);
+#endif
}
//static
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 58a9e28270..f587fb414c 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -797,16 +797,21 @@ GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
+#if GL_VERSION_2_0 || GL_VERSION_3_2
if (
#if GL_VERSION_2_0
- (type >= GL_SAMPLER_1D_ARB && type <= GL_SAMPLER_2D_RECT_SHADOW_ARB) ||
+ (type >= GL_SAMPLER_1D_ARB && type <= GL_SAMPLER_2D_RECT_SHADOW_ARB)
#endif
- type == GL_SAMPLER_2D_MULTISAMPLE)
+#if GL_VERSION_3_2
+ || type == GL_SAMPLER_2D_MULTISAMPLE
+#endif
+ )
{ //this here is a texture
glUniform1i(location, mActiveTextureChannels);
LL_DEBUGS("ShaderUniform") << "Assigned to texture channel " << mActiveTextureChannels << LL_ENDL;
return mActiveTextureChannels++;
}
+#endif // GL_VERSION_2_0 || GL_VERSION_3_2
return -1;
}
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 89de6b93ea..91ce983e5a 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -906,9 +906,13 @@ void LLRender::init(bool needs_vertex_buffer)
{ //bind a dummy vertex array object so we're core profile compliant
//#ifdef GL_ARB_vertex_array_object
U32 ret;
+#if GL_APPLE_vertex_array_object
+ glGenVertexArraysAPPLE(1, &ret);
+ glBindVertexArrayAPPLE(ret);
+#else
glGenVertexArrays(1, &ret);
glBindVertexArray(ret);
-//#endif
+#endif
}
if (needs_vertex_buffer)
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index f71403d2f4..0c8a8fed6a 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -404,8 +404,11 @@ U32 LLVertexBuffer::getVAOName()
else
{
//#ifdef GL_ARB_vertex_array_object
+#if GL_APPLE_vertex_array_object
+ glGenVertexArraysAPPLE(1, &ret);
+#else
glGenVertexArrays(1, &ret);
-//#endif
+#endif
}
return ret;
@@ -758,8 +761,11 @@ void LLVertexBuffer::unbind()
if (sGLRenderArray)
{
//#if GL_ARB_vertex_array_object
+#if GL_APPLE_vertex_array_object
+ glBindVertexArrayAPPLE(0);
+#else
glBindVertexArray(0);
-//#endif
+#endif
sGLRenderArray = 0;
sGLRenderIndices = 0;
sIBOActive = false;
@@ -1259,8 +1265,11 @@ void LLVertexBuffer::setupVertexArray()
LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX;
//#if GL_ARB_vertex_array_object
+#if GL_APPLE_vertex_array_object
+ glBindVertexArrayAPPLE(mGLArray);
+#else
glBindVertexArray(mGLArray);
-//#endif
+#endif
sGLRenderArray = mGLArray;
static const U32 attrib_size[] =
@@ -1534,12 +1543,10 @@ U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_ran
{
if (map_range)
{
-/*
-#ifndef LL_MESA_HEADLESS
+#if !LL_MESA_HEADLESS && GL_APPLE_flush_buffer_range && LL_DARWIN
glBufferParameteriAPPLE(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE);
glBufferParameteriAPPLE(GL_ARRAY_BUFFER_ARB, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE);
#endif
-*/
src = (U8*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
}
else
@@ -1709,12 +1716,10 @@ U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range)
{
if (map_range)
{
-/*
-#ifndef LL_MESA_HEADLESS
+#if !LL_MESA_HEADLESS && GL_APPLE_flush_buffer_range && LL_DARWIN
glBufferParameteriAPPLE(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE);
glBufferParameteriAPPLE(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE);
#endif
-*/
src = (U8*) glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
}
else
@@ -1840,13 +1845,17 @@ void LLVertexBuffer::unmapBuffer()
S32 length = sTypeSize[region.mType]*region.mCount;
if (gGLManager.mHasMapBufferRange)
{
-#if GL_ARB_map_buffer_range || GL_EXT_map_buffer_range
+#if GL_APPLE_flush_buffer_range && LL_DARWIN
+ glFlushMappedBufferRangeAPPLE(GL_ARRAY_BUFFER, offset, length);
+#elif GL_ARB_map_buffer_range || GL_EXT_map_buffer_range
glFlushMappedBufferRange(GL_ARRAY_BUFFER, offset, length);
#endif
}
else if (gGLManager.mHasFlushBufferRange)
{
-#ifndef LL_MESA_HEADLESS
+#if !LL_MESA_HEADLESS && GL_APPLE_flush_buffer_range && LL_DARWIN
+ glFlushMappedBufferRangeAPPLE(GL_ARRAY_BUFFER, offset, length);
+#else
glFlushMappedBufferRange(GL_ARRAY_BUFFER, offset, length);
#endif
}
@@ -1920,20 +1929,20 @@ void LLVertexBuffer::unmapBuffer()
S32 length = sizeof(U16)*region.mCount;
if (gGLManager.mHasMapBufferRange)
{
-#if GL_ARB_map_buffer_range || GL_EXT_map_buffer_range
+#if GL_APPLE_flush_buffer_range && LL_DARWIN
+ glFlushMappedBufferRangeAPPLE(GL_ELEMENT_ARRAY_BUFFER, offset, length);
+#elif GL_ARB_map_buffer_range || GL_EXT_map_buffer_range
glFlushMappedBufferRange(GL_ELEMENT_ARRAY_BUFFER, offset, length);
#endif
}
- /*
else if (gGLManager.mHasFlushBufferRange)
{
-#ifdef GL_APPLE_flush_buffer_range
+#if GL_APPLE_flush_buffer_range && LL_DARWIN
#ifndef LL_MESA_HEADLESS
glFlushMappedBufferRangeAPPLE(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length);
#endif
#endif
}
- */
stop_glerror();
}
@@ -2071,8 +2080,11 @@ bool LLVertexBuffer::bindGLArray()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX;
//#if GL_ARB_vertex_array_object
+#if GL_APPLE_vertex_array_object
+ glBindVertexArrayAPPLE(mGLArray);
+#else
glBindVertexArray(mGLArray);
-//#endif
+#endif
sGLRenderArray = mGLArray;
}
@@ -2301,8 +2313,11 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
if (sGLRenderArray)
{
//#if GL_ARB_vertex_array_object
+#if GL_APPLE_vertex_array_object
+ glBindVertexArrayAPPLE(0);
+#else
glBindVertexArray(0);
-//#endif
+#endif
sGLRenderArray = 0;
sGLRenderIndices = 0;
sIBOActive = false;