summaryrefslogtreecommitdiff
path: root/indra/llrender/llrendertarget.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2022-05-26 03:07:14 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2022-05-26 03:07:14 +0300
commit58a500bee8dc06acb35acb5c2e5c65d2df99a0d8 (patch)
tree9ce445b7171e208842baaa0da5a76a57516b33d5 /indra/llrender/llrendertarget.cpp
parent2242f089e4da03b361255a8a5175c788a99cbf8e (diff)
parentcdbd06e8ed6e3f4285a61f5c0b607a65dfdf8dfd (diff)
Merge branch 'master' into DRTVWR-561-maint-O
Diffstat (limited to 'indra/llrender/llrendertarget.cpp')
-rw-r--r--indra/llrender/llrendertarget.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index e3c0255290..0408010513 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -170,6 +170,53 @@ 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)
{
if (color_fmt == 0)
@@ -437,11 +484,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);
}