summaryrefslogtreecommitdiff
path: root/indra/llrender/llrendertarget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender/llrendertarget.cpp')
-rw-r--r--indra/llrender/llrendertarget.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index dcee340a71..0745397c3a 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -370,21 +370,39 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)
bool LLRenderTarget::allocateDepth()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY;
+ if (mResX == 0 || mResY == 0)
+ {
+ LL_WARNS() << "Unable to allocate depth buffer for render target " << mName
+ << ": size " << mResX << "x" << mResY << LL_ENDL;
+ return false;
+ }
+
LLImageGL::generateTextures(1, &mDepth);
gGL.getTexUnit(0)->bindManual(mUsage, mDepth);
U32 internal_type = LLTexUnit::getInternalType(mUsage);
- LLImageGL::setManualImage(internal_type, 0, GL_DEPTH_COMPONENT24, mResX, mResY, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL, false);
- gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
-
- sBytesAllocated += mResX*mResY*4;
-
- if (glGetError() != GL_NO_ERROR)
+ // Apple's GL rejects the sized GL_DEPTH_COMPONENT24 internal format
+ // with GL_UNSIGNED_INT. The unsized format is the one it allocates.
+#if LL_DARWIN
+ const U32 depth_internal = GL_DEPTH_COMPONENT;
+#else
+ const U32 depth_internal = GL_DEPTH_COMPONENT24;
+#endif
+ glGetError();
+ LLImageGL::setManualImage(internal_type, 0, depth_internal, mResX, mResY, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL, false);
+ GLenum err = glGetError();
+ if (err != GL_NO_ERROR)
{
- LL_WARNS() << "Unable to allocate depth buffer for render target " << mName << LL_ENDL;
+ LL_WARNS() << "Unable to allocate depth buffer for render target " << mName
+ << " (" << mResX << "x" << mResY << ") gl error " << err << LL_ENDL;
return false;
}
+ gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
+ glGetError();
+
+ sBytesAllocated += mResX*mResY*4;
+
return true;
}