From Art Tevs,

"A new texture class Texture2DArray derived from
Texture extends the osg to support the new
EXT_texture_array extensions. Texture arrays provides
a feature for people interesting in GPGPU programming.


Faetures and changes:

- Full support for layered 2D textures.

- New uniform types were added (sampler2DArray)

- FrameBufferObject implementation were changed to
support attaching of 2D array textures to the
framebuffer

- StateSet was slightly changed to support texture
arrays. NOTE: array textures can not be used in fixed
function pipeline. Thus using the layered texture as a
statemode for a Drawable produce invalid enumerant
OpenGL errors.

- Image class was extended to support handling of
array textures

Tests:
I have used this class as a new feature of my
application. It works for me without problems (Note:
Texture arrays were introduced only for shading
languages and not for fixed function pipelines!!!).
RTT with Texture2DArray works, as I have tested them
as texture targets for a camera with 6 layers/faces
(i.e. replacement for cube maps). I am using the array
textures in shader programming. Array textures can be
attached to the FBO and used as input and as output."
This commit is contained in:
Robert Osfield
2007-09-07 11:21:02 +00:00
parent ed6322630f
commit c7a72c8435
11 changed files with 915 additions and 7 deletions

View File

@@ -19,6 +19,7 @@
#include <osg/Texture1D>
#include <osg/Texture2D>
#include <osg/Texture3D>
#include <osg/Texture2DArray>
#include <osg/TextureCubeMap>
#include <osg/TextureRectangle>
#include <osg/Notify>
@@ -56,6 +57,7 @@ FBOExtensions::FBOExtensions(unsigned int contextID)
LOAD_FBO_EXT(glFramebufferTexture1DEXT);
LOAD_FBO_EXT(glFramebufferTexture2DEXT);
LOAD_FBO_EXT(glFramebufferTexture3DEXT);
LOAD_FBO_EXT(glFramebufferTextureLayerEXT);
LOAD_FBO_EXT(glFramebufferRenderbufferEXT);
LOAD_FBO_EXT(glGenerateMipmapEXT);
@@ -205,7 +207,8 @@ struct FrameBufferAttachment::Pimpl
TEXTURE2D,
TEXTURE3D,
TEXTURECUBE,
TEXTURERECT
TEXTURERECT,
TEXTURE2DARRAY
};
TargetType targetType;
@@ -269,6 +272,13 @@ FrameBufferAttachment::FrameBufferAttachment(Texture3D* target, int level, int z
_ximpl->zoffset = zoffset;
}
FrameBufferAttachment::FrameBufferAttachment(Texture2DArray* target, int layer, int level)
{
_ximpl = new Pimpl(Pimpl::TEXTURE2DARRAY, level);
_ximpl->textureTarget = target;
_ximpl->zoffset = layer;
}
FrameBufferAttachment::FrameBufferAttachment(TextureCubeMap* target, int face, int level)
{
_ximpl = new Pimpl(Pimpl::TEXTURECUBE, level);
@@ -312,6 +322,15 @@ FrameBufferAttachment::FrameBufferAttachment(Camera::Attachment& attachment)
_ximpl->zoffset = attachment._face;
return;
}
osg::Texture2DArray* texture2DArray = dynamic_cast<osg::Texture2DArray*>(texture);
if (texture2DArray)
{
_ximpl = new Pimpl(Pimpl::TEXTURE2DARRAY, attachment._level);
_ximpl->textureTarget = texture2DArray;
_ximpl->zoffset = attachment._face;
return;
}
osg::TextureCubeMap* textureCubeMap = dynamic_cast<osg::TextureCubeMap*>(texture);
if (textureCubeMap)
@@ -429,6 +448,9 @@ void FrameBufferAttachment::attach(State &state, GLenum attachment_point, const
case Pimpl::TEXTURE3D:
ext->glFramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, attachment_point, GL_TEXTURE_3D, tobj->_id, _ximpl->level, _ximpl->zoffset);
break;
case Pimpl::TEXTURE2DARRAY:
ext->glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, attachment_point, tobj->_id, _ximpl->level, _ximpl->zoffset);
break;
case Pimpl::TEXTURERECT:
ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment_point, GL_TEXTURE_RECTANGLE, tobj->_id, 0);
break;
@@ -588,6 +610,7 @@ void FrameBufferObject::apply(State &state) const
}
ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboID);
if (dirtyAttachmentList)