summaryrefslogtreecommitdiff
path: root/indra/llrender/llrendertarget.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender/llrendertarget.h')
-rw-r--r--indra/llrender/llrendertarget.h112
1 files changed, 78 insertions, 34 deletions
diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h
index df88640970..ae8613d9be 100644
--- a/indra/llrender/llrendertarget.h
+++ b/indra/llrender/llrendertarget.h
@@ -2,37 +2,36 @@
* @file llrendertarget.h
* @brief Off screen render target abstraction. Loose wrapper for GL_EXT_framebuffer_objects.
*
- * $LicenseInfo:firstyear=2001&license=viewergpl$
- *
- * Copyright (c) 2001-2007, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlife.com/developers/opensource/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at http://secondlife.com/developers/opensource/flossexception
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLRENDERTARGET_H
#define LL_LLRENDERTARGET_H
+// LLRenderTarget is unavailible on the mapserver since it uses FBOs.
+#if !LL_MESA_HEADLESS
+
#include "llgl.h"
+#include "llrender.h"
/*
SAMPLE USAGE:
@@ -53,11 +52,12 @@
...
//use target as a texture
- target.bindTexture();
+ gGL.getTexUnit(INDEX)->bind(&target);
... <issue drawing commands> ...
*/
+class LLMultisampleBuffer;
class LLRenderTarget
{
@@ -66,15 +66,25 @@ public:
static BOOL sUseFBO;
LLRenderTarget();
- ~LLRenderTarget();
+ virtual ~LLRenderTarget();
//allocate resources for rendering
//must be called before use
//multiple calls will release previously allocated resources
- void allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage = GL_TEXTURE_2D, BOOL use_fbo = FALSE);
+ void allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, BOOL stencil, LLTexUnit::eTextureType usage = LLTexUnit::TT_TEXTURE, BOOL use_fbo = FALSE);
+
+ //provide this render target with a multisample resource.
+ void setSampleBuffer(LLMultisampleBuffer* buffer);
+
+ //add color buffer attachment
+ //limit of 4 color attachments per render target
+ virtual void addColorAttachment(U32 color_fmt);
//allocate a depth texture
- void allocateDepth();
+ virtual void allocateDepth();
+
+ //share depth buffer with provided render target
+ virtual void shareDepthBuffer(LLRenderTarget& target);
//free any allocated resources
//safe to call redundantly
@@ -82,14 +92,14 @@ public:
//bind target for rendering
//applies appropriate viewport
- void bindTarget();
+ virtual void bindTarget();
//unbind target for rendering
static void unbindTarget();
//clear render targer, clears depth buffer if present,
//uses scissor rect if in copy-to-texture mode
- void clear();
+ void clear(U32 mask = 0xFFFFFFFF);
//get applied viewport
void getViewport(S32* viewport);
@@ -100,11 +110,14 @@ public:
//get Y resolution
U32 getHeight() const { return mResY; }
- //bind results of render for sampling
- void bindTexture();
+ LLTexUnit::eTextureType getUsage(void) const { return mUsage; }
+
+ U32 getTexture(U32 attachment = 0) const;
- //bind results of render for sampling depth buffer
- void bindDepth();
+ U32 getDepth(void) const { return mDepth; }
+ BOOL hasStencil() const { return mStencil; }
+
+ void bindTexture(U32 index, S32 channel);
//flush rendering operations
//must be called when rendering is complete
@@ -114,23 +127,54 @@ public:
// the current depth texture. A depth texture will be allocated if needed.
void flush(BOOL fetch_depth = FALSE);
+ void copyContents(LLRenderTarget& source, S32 srcX0, S32 srcY0, S32 srcX1, S32 srcY1,
+ S32 dstX0, S32 dstY0, S32 dstX1, S32 dstY1, U32 mask, U32 filter);
+
+ static void copyContentsToFramebuffer(LLRenderTarget& source, S32 srcX0, S32 srcY0, S32 srcX1, S32 srcY1,
+ S32 dstX0, S32 dstY0, S32 dstX1, S32 dstY1, U32 mask, U32 filter);
+
//Returns TRUE if target is ready to be rendered into.
//That is, if the target has been allocated with at least
//one renderable attachment (i.e. color buffer, depth buffer).
BOOL isComplete() const;
-private:
+ static LLRenderTarget* getCurrentBoundTarget() { return sBoundTarget; }
+
+protected:
+ friend class LLMultisampleBuffer;
U32 mResX;
U32 mResY;
- U32 mTex;
+ std::vector<U32> mTex;
U32 mFBO;
U32 mDepth;
- U32 mStencil;
+ BOOL mStencil;
BOOL mUseDepth;
BOOL mRenderDepth;
- U32 mUsage;
+ LLTexUnit::eTextureType mUsage;
+ U32 mSamples;
+ LLMultisampleBuffer* mSampleBuffer;
+
+ static LLRenderTarget* sBoundTarget;
};
+class LLMultisampleBuffer : public LLRenderTarget
+{
+public:
+ LLMultisampleBuffer();
+ virtual ~LLMultisampleBuffer();
+
+ void releaseSampleBuffer();
+
+ virtual void bindTarget();
+ void bindTarget(LLRenderTarget* ref);
+ virtual void allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, BOOL stencil, LLTexUnit::eTextureType usage, BOOL use_fbo);
+ void allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, BOOL stencil, LLTexUnit::eTextureType usage, BOOL use_fbo, U32 samples);
+ virtual void addColorAttachment(U32 color_fmt);
+ virtual void allocateDepth();
+};
+
+#endif //!LL_MESA_HEADLESS
+
#endif