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.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index e3c0255290..0a4cc1bcf5 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -119,6 +119,7 @@ void LLRenderTarget::resize(U32 resx, U32 resy)
bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo, S32 samples)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY;
resx = llmin(resx, (U32) gGLManager.mGLMaxTextureSize);
resy = llmin(resy, (U32) gGLManager.mGLMaxTextureSize);
@@ -170,8 +171,56 @@ bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, boo
return addColorAttachment(color_fmt);
}
+void LLRenderTarget::setColorAttachment(LLImageGL* img, LLGLuint use_name)
+{
+ LL_PROFILE_ZONE_SCOPED;
+ llassert(img != nullptr); // img must not be null
+ llassert(sUseFBO); // FBO support must be enabled
+ llassert(mDepth == 0); // depth buffers not supported with this mode
+ llassert(mTex.empty()); // mTex must be empty with this mode (binding target should be done via LLImageGL)
+
+ if (mFBO == 0)
+ {
+ glGenFramebuffers(1, (GLuint*)&mFBO);
+ }
+
+ mResX = img->getWidth();
+ mResY = img->getHeight();
+ mUsage = img->getTarget();
+
+ if (use_name == 0)
+ {
+ use_name = img->getTexName();
+ }
+
+ mTex.push_back(use_name);
+
+ glBindFramebuffer(GL_FRAMEBUFFER, mFBO);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ LLTexUnit::getInternalType(mUsage), use_name, 0);
+ stop_glerror();
+
+ check_framebuffer_status();
+
+ glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO);
+}
+
+void LLRenderTarget::releaseColorAttachment()
+{
+ LL_PROFILE_ZONE_SCOPED;
+ llassert(mTex.size() == 1); //cannot use releaseColorAttachment with LLRenderTarget managed color targets
+ llassert(mFBO != 0); // mFBO must be valid
+
+ glBindFramebuffer(GL_FRAMEBUFFER, mFBO);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, LLTexUnit::getInternalType(mUsage), 0, 0);
+ glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO);
+
+ mTex.clear();
+}
+
bool LLRenderTarget::addColorAttachment(U32 color_fmt)
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY;
if (color_fmt == 0)
{
return true;
@@ -268,6 +317,7 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)
bool LLRenderTarget::allocateDepth()
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY;
if (mStencil)
{
//use render buffers where stencil buffers are in play
@@ -348,6 +398,7 @@ void LLRenderTarget::shareDepthBuffer(LLRenderTarget& target)
void LLRenderTarget::release()
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY;
if (mDepth)
{
if (mStencil)
@@ -437,11 +488,13 @@ void LLRenderTarget::bindTarget()
GL_COLOR_ATTACHMENT1,
GL_COLOR_ATTACHMENT2,
GL_COLOR_ATTACHMENT3};
+ LL_PROFILER_GPU_ZONEC( "gl.DrawBuffersARB", 0x4000FF )
glDrawBuffersARB(mTex.size(), drawbuffers);
}
if (mTex.empty())
{ //no color buffer to draw to
+ LL_PROFILER_GPU_ZONEC( "gl.DrawBuffer", 0x0000FF )
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);
}