From Marcin Hajder, "This submission contains Texture2DMultisample osg implementation.

Texture2DMultismaple as name suggests provides means to directly access subsamples of rendered FBO target. (GLSL 1.5 texelFetch call).

Recently I was working on deferred renderer with OSG, during that I noticed there is no support for multisampled textures (GL_ARB_texture_multisample extension). After consultations with Paul Martz and Wojtek Lewandowski I added Texture2DMultisample class and made few necessary changes around osg::FrameBufferObject, osg::Texture and osgUtil::RenderStage classes."

and from follow email:

"Fixed. According to ARB_texture_multisample extension specification multisample textures  don't need TexParameters since they can only be fetched with  texelFetch."
This commit is contained in:
Robert Osfield
2010-04-22 17:02:22 +00:00
parent 3f7454fd8c
commit 5d0b84edd0
8 changed files with 291 additions and 4 deletions

View File

@@ -18,6 +18,7 @@
#include <osg/GLExtensions>
#include <osg/Texture1D>
#include <osg/Texture2D>
#include <osg/Texture2DMultisample>
#include <osg/Texture3D>
#include <osg/Texture2DArray>
#include <osg/TextureCubeMap>
@@ -287,7 +288,8 @@ struct FrameBufferAttachment::Pimpl
TEXTURE3D,
TEXTURECUBE,
TEXTURERECT,
TEXTURE2DARRAY
TEXTURE2DARRAY,
TEXTURE2DMULTISAMPLE
};
TargetType targetType;
@@ -344,6 +346,12 @@ FrameBufferAttachment::FrameBufferAttachment(Texture2D* target, int level)
_ximpl->textureTarget = target;
}
FrameBufferAttachment::FrameBufferAttachment(Texture2DMultisample* target, int level)
{
_ximpl = new Pimpl(Pimpl::TEXTURE2DMULTISAMPLE, level);
_ximpl->textureTarget = target;
}
FrameBufferAttachment::FrameBufferAttachment(Texture3D* target, int zoffset, int level)
{
_ximpl = new Pimpl(Pimpl::TEXTURE3D, level);
@@ -393,6 +401,14 @@ FrameBufferAttachment::FrameBufferAttachment(Camera::Attachment& attachment)
return;
}
osg::Texture2DMultisample* texture2DMS = dynamic_cast<osg::Texture2DMultisample*>(texture);
if (texture2DMS)
{
_ximpl = new Pimpl(Pimpl::TEXTURE2DMULTISAMPLE, attachment._level);
_ximpl->textureTarget = texture2DMS;
return;
}
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);
if (texture3D)
{
@@ -534,6 +550,9 @@ void FrameBufferAttachment::attach(State &state, GLenum target, GLenum attachmen
case Pimpl::TEXTURE2D:
ext->glFramebufferTexture2D(target, attachment_point, GL_TEXTURE_2D, tobj->id(), _ximpl->level);
break;
case Pimpl::TEXTURE2DMULTISAMPLE:
ext->glFramebufferTexture2D(target, attachment_point, GL_TEXTURE_2D_MULTISAMPLE, tobj->id(), _ximpl->level);
break;
case Pimpl::TEXTURE3D:
ext->glFramebufferTexture3D(target, attachment_point, GL_TEXTURE_3D, tobj->id(), _ximpl->level, _ximpl->zoffset);
break;