thogarth - merged multiview branch to add multisampling support to texture2d arrays

This commit is contained in:
John W. Terrell 2020-01-10 03:07:59 +00:00 committed by Robert Osfield
parent 7d34a54a3b
commit 3ecd94babc
9 changed files with 468 additions and 40 deletions

View File

@ -265,6 +265,7 @@ class Texture2D;
class Texture2DMultisample;
class Texture3D;
class Texture2DArray;
class Texture2DMultisampleArray;
class TextureCubeMap;
class TextureRectangle;
@ -280,6 +281,7 @@ class OSG_EXPORT FrameBufferAttachment
explicit FrameBufferAttachment(Texture2DMultisample* target, unsigned int level = 0);
explicit FrameBufferAttachment(Texture3D* target, unsigned int zoffset, unsigned int level = 0);
explicit FrameBufferAttachment(Texture2DArray* target, unsigned int layer, unsigned int level = 0);
explicit FrameBufferAttachment(Texture2DMultisampleArray* target, unsigned int layer, unsigned int level = 0);
explicit FrameBufferAttachment(TextureCubeMap* target, unsigned int face, unsigned int level = 0);
explicit FrameBufferAttachment(TextureRectangle* target);
explicit FrameBufferAttachment(Camera::Attachment& attachment);
@ -304,6 +306,8 @@ class OSG_EXPORT FrameBufferAttachment
unsigned int getTexture3DZOffset() const;
unsigned int getTextureArrayLayer() const;
bool isArray() const;
void resizeGLObjectBuffers(unsigned int maxSize);
void releaseGLObjects(osg::State* = 0) const;
@ -341,6 +345,7 @@ class OSG_EXPORT FrameBufferObject: public StateAttribute
inline const MultipleRenderingTargets& getMultipleRenderingTargets() const { return _drawBuffers; }
bool isMultisample() const;
bool isArray() const;
int compare(const StateAttribute &sa) const;

View File

@ -240,6 +240,10 @@
#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
#endif
#ifndef GL_TEXTURE_2D_MULTISAMPLE_ARRAY
#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102
#endif
// Integer texture extension as in http://www.opengl.org/registry/specs/EXT/texture_integer.txt
#ifndef GL_EXT_texture_integer
#define GL_RGBA32UI_EXT 0x8D70

View File

@ -0,0 +1,95 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* 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
* OpenSceneGraph Public License for more details.
*
*/
#ifndef OSG_TEXTURE2DMSARRAY
#define OSG_TEXTURE2DMSARRAY 1
#include <osg/Texture>
namespace osg {
class OSG_EXPORT Texture2DMultisampleArray : public Texture
{
public :
Texture2DMultisampleArray();
Texture2DMultisampleArray(GLsizei numSamples, GLboolean fixedsamplelocations);
Texture2DMultisampleArray(int width, int height, int depth, GLenum internalFormat, GLsizei numSamples, GLboolean fixedsamplelocations);
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
Texture2DMultisampleArray(const Texture2DMultisampleArray& text,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_StateAttribute(osg, Texture2DMultisampleArray,TEXTURE);
/** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
virtual int compare(const StateAttribute& rhs) const;
virtual GLenum getTextureTarget() const
{
return GL_TEXTURE_2D_MULTISAMPLE_ARRAY;
}
/** Texture2DMultisampleArray is related to non fixed pipeline usage only so isn't appropriate to enable/disable.*/
virtual bool getModeUsage(StateAttribute::ModeUsage&) const { return false; }
/** Sets the texture width and height. **/
inline void setTextureSize(int width, int height, int depth) const
{
_textureWidth = width;
_textureHeight = height;
_textureDepth = depth;
}
inline void setNumSamples( int samples ) { _numSamples = samples; }
GLsizei getNumSamples() const { return _numSamples; }
// unnecessary for Texture2DMultisampleArray
virtual void setImage(unsigned int /*face*/, Image* /*image*/) {}
virtual Image* getImage(unsigned int /*face*/) { return NULL; }
virtual const Image* getImage(unsigned int /*face*/) const { return NULL; }
virtual unsigned int getNumImages() const {return 0; }
virtual void allocateMipmap(State& /*state*/) const {}
void setTextureWidth(int width) { _textureWidth=width; }
void setTextureHeight(int height) { _textureHeight=height; }
void setTextureDepth(int depth) { _textureDepth=depth; }
virtual int getTextureWidth() const { return _textureWidth; }
virtual int getTextureHeight() const { return _textureHeight; }
virtual int getTextureDepth() const { return _textureDepth; }
/** Bind the texture object. If the texture object hasn't already been
* compiled, create the texture mipmap levels. */
virtual void apply(State& state) const;
protected :
virtual ~Texture2DMultisampleArray();
virtual void computeInternalFormat() const;
/** Subloaded images can have different texture and image sizes. */
mutable GLsizei _textureWidth, _textureHeight, _textureDepth;
mutable GLsizei _numSamples;
mutable GLboolean _fixedsamplelocations;
};
}
#endif

View File

@ -313,6 +313,13 @@ protected:
osg::ref_ptr<osg::FrameBufferObject> _fbo;
osg::ref_ptr<osg::FrameBufferObject> _resolveFbo;
// VRV_PATCH BEGIN
// for resolving individual layers of a multisampled texture 2d array
std::vector<osg::ref_ptr<osg::FrameBufferObject>> _arrayLayerFbos;
std::vector<osg::ref_ptr<osg::FrameBufferObject>> _resolveArrayLayerFbos;
// VRV_PATCH END
osg::ref_ptr<osg::GraphicsContext> _graphicsContext;
bool _disableFboAfterRender;

View File

@ -182,6 +182,7 @@ SET(TARGET_H
${HEADER_PATH}/Texture2D
${HEADER_PATH}/Texture2DMultisample
${HEADER_PATH}/Texture2DArray
${HEADER_PATH}/Texture2DMultisampleArray
${HEADER_PATH}/Texture3D
${HEADER_PATH}/TextureBuffer
${HEADER_PATH}/TextureCubeMap
@ -385,6 +386,7 @@ SET(TARGET_SRC
TexMat.cpp
Texture1D.cpp
Texture2DArray.cpp
Texture2DMultisampleArray.cpp
Texture2D.cpp
Texture2DMultisample.cpp
Texture3D.cpp

View File

@ -21,6 +21,7 @@
#include <osg/Texture2DMultisample>
#include <osg/Texture3D>
#include <osg/Texture2DArray>
#include <osg/Texture2DMultisampleArray>
#include <osg/TextureCubeMap>
#include <osg/TextureRectangle>
#include <osg/Notify>
@ -209,7 +210,8 @@ struct FrameBufferAttachment::Pimpl
TEXTURECUBE,
TEXTURERECT,
TEXTURE2DARRAY,
TEXTURE2DMULTISAMPLE
TEXTURE2DMULTISAMPLE,
TEXTURE2DMULTISAMPLEARRAY
};
TargetType targetType;
@ -286,6 +288,13 @@ FrameBufferAttachment::FrameBufferAttachment(Texture2DArray* target, unsigned in
_ximpl->zoffset = layer;
}
FrameBufferAttachment::FrameBufferAttachment(Texture2DMultisampleArray* target, unsigned int layer, unsigned int level)
{
_ximpl = new Pimpl(Pimpl::TEXTURE2DMULTISAMPLEARRAY, level);
_ximpl->textureTarget = target;
_ximpl->zoffset = layer;
}
FrameBufferAttachment::FrameBufferAttachment(TextureCubeMap* target, unsigned int face, unsigned int level)
{
_ximpl = new Pimpl(Pimpl::TEXTURECUBE, level);
@ -347,6 +356,15 @@ FrameBufferAttachment::FrameBufferAttachment(Camera::Attachment& attachment)
return;
}
osg::Texture2DMultisampleArray* texture2DMSArray = dynamic_cast<osg::Texture2DMultisampleArray*>(texture);
if (texture2DMSArray)
{
_ximpl = new Pimpl(Pimpl::TEXTURE2DMULTISAMPLEARRAY, attachment._level);
_ximpl->textureTarget = texture2DMSArray;
_ximpl->zoffset = attachment._face;
return;
}
osg::TextureCubeMap* textureCubeMap = dynamic_cast<osg::TextureCubeMap*>(texture);
if (textureCubeMap)
{
@ -410,6 +428,14 @@ bool FrameBufferAttachment::isMultisample() const
{
return _ximpl->renderbufferTarget->getSamples() > 0;
}
else if(_ximpl->textureTarget.valid())
{
osg::Texture2DMultisampleArray* tex2DMSArray = dynamic_cast<osg::Texture2DMultisampleArray*>(_ximpl->textureTarget.get());
if (tex2DMSArray != NULL)
{
return tex2DMSArray->getNumSamples() > 0;
}
}
return false;
}
@ -502,6 +528,24 @@ void FrameBufferAttachment::attach(State &state, GLenum target, GLenum attachmen
else
ext->glFramebufferTextureLayer(target, attachment_point, tobj->id(), _ximpl->level, _ximpl->zoffset);
break;
case Pimpl::TEXTURE2DMULTISAMPLEARRAY:
if (_ximpl->zoffset == Camera::FACE_CONTROLLED_BY_GEOMETRY_SHADER)
{
if (ext->glFramebufferTexture)
{
ext->glFramebufferTexture(target, attachment_point, tobj->id(), _ximpl->level);
}
}
else if (_ximpl->zoffset == Camera::FACE_CONTROLLED_BY_MULTIVIEW_SHADER)
{
if (ext->glFramebufferTextureMultiviewOVR)
{
ext->glFramebufferTextureMultiviewOVR(target, attachment_point, tobj->id(), _ximpl->level, 0, 2);
}
}
else
ext->glFramebufferTextureLayer(target, attachment_point, tobj->id(), _ximpl->level, _ximpl->zoffset);
break;
case Pimpl::TEXTURERECT:
ext->glFramebufferTexture2D(target, attachment_point, GL_TEXTURE_RECTANGLE, tobj->id(), 0);
break;
@ -572,6 +616,11 @@ unsigned int FrameBufferAttachment::getTextureArrayLayer() const
return _ximpl->zoffset;
}
bool FrameBufferAttachment::isArray() const
{
return _ximpl->targetType == Pimpl::TEXTURE2DARRAY || _ximpl->targetType == Pimpl::TEXTURE2DMULTISAMPLEARRAY;
}
void FrameBufferAttachment::resizeGLObjectBuffers(unsigned int maxSize)
{
if (_ximpl->renderbufferTarget.valid()) _ximpl->renderbufferTarget->resizeGLObjectBuffers(maxSize);
@ -807,6 +856,18 @@ bool FrameBufferObject::isMultisample() const
return false;
}
bool FrameBufferObject::isArray() const
{
if (_attachments.size())
{
// If the FBO is correctly set up then all attachments will be either
// arrays or standard types
return _attachments.begin()->second.isArray();
}
return false;
}
int FrameBufferObject::compare(const StateAttribute &sa) const
{
COMPARE_StateAttribute_Types(FrameBufferObject, sa);

View File

@ -142,6 +142,7 @@ class TextureGLModeSet
_textureModeSet.insert(GL_TEXTURE_RECTANGLE_NV);
_textureModeSet.insert(GL_TEXTURE_2D_ARRAY);
_textureModeSet.insert(GL_TEXTURE_2D_MULTISAMPLE);
_textureModeSet.insert(GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
_textureModeSet.insert(GL_TEXTURE_GEN_Q);
_textureModeSet.insert(GL_TEXTURE_GEN_R);

View File

@ -0,0 +1,156 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* 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
* OpenSceneGraph Public License for more details.
*
*/
#include <osg/GLExtensions>
#include <osg/Texture2DMultisampleArray>
#include <osg/State>
#include <osg/Notify>
using namespace osg;
Texture2DMultisampleArray::Texture2DMultisampleArray():
_textureWidth(0),
_textureHeight(0),
_textureDepth(0),
_numSamples(1),
_fixedsamplelocations(GL_FALSE)
{
}
Texture2DMultisampleArray::Texture2DMultisampleArray(GLsizei numSamples, GLboolean fixedsamplelocations):
_textureWidth(0),
_textureHeight(0),
_textureDepth(0),
_numSamples(numSamples),
_fixedsamplelocations(fixedsamplelocations)
{
}
Texture2DMultisampleArray::Texture2DMultisampleArray(int width, int height, int depth, GLenum internalFormat, GLsizei numSamples, GLboolean fixedsamplelocations) :
_textureWidth(width),
_textureHeight(height),
_textureDepth(depth),
_numSamples(numSamples),
_fixedsamplelocations(fixedsamplelocations)
{
setInternalFormat(internalFormat);
}
Texture2DMultisampleArray::Texture2DMultisampleArray(const Texture2DMultisampleArray& text,const CopyOp& copyop):
Texture(text,copyop),
_textureWidth(text._textureWidth),
_textureHeight(text._textureHeight),
_textureDepth(text._textureDepth),
_numSamples(text._numSamples),
_fixedsamplelocations(text._fixedsamplelocations)
{
}
Texture2DMultisampleArray::~Texture2DMultisampleArray()
{
}
int Texture2DMultisampleArray::compare(const StateAttribute& sa) const
{
// check the types are equal and then create the rhs variable
// used by the COMPARE_StateAttribute_Parameter macros below.
COMPARE_StateAttribute_Types(Texture2DMultisampleArray,sa)
int result = compareTexture(rhs);
if (result!=0) return result;
// compare each parameter in turn against the rhs.
if (_textureWidth != 0 && rhs._textureWidth != 0)
{
COMPARE_StateAttribute_Parameter(_textureWidth)
}
if (_textureHeight != 0 && rhs._textureHeight != 0)
{
COMPARE_StateAttribute_Parameter(_textureHeight)
}
if (_textureDepth != 0 && rhs._textureDepth != 0)
{
COMPARE_StateAttribute_Parameter(_textureDepth)
}
if (_numSamples != 0 && rhs._numSamples != 0)
{
COMPARE_StateAttribute_Parameter(_numSamples)
}
if (_fixedsamplelocations != 0 && rhs._fixedsamplelocations != 0)
{
COMPARE_StateAttribute_Parameter(_fixedsamplelocations)
}
return 0; // passed all the above comparison macros, must be equal.
}
void Texture2DMultisampleArray::apply(State& state) const
{
// current OpenGL context.
const unsigned int contextID = state.getContextID();
const GLExtensions* extensions = state.get<GLExtensions>();
if (!extensions->isTextureMultisampledSupported)
{
OSG_INFO<<"Texture2DMultisampleArray not supported."<<std::endl;
return;
}
#if 0
Texture::TextureObjectManager* tom = Texture::getTextureObjectManager(contextID).get();
ElapsedTime elapsedTime(&(tom->getApplyTime()));
tom->getNumberApplied()++;
#endif
// get the texture object for the current contextID.
TextureObject* textureObject = getTextureObject(contextID);
if (textureObject)
{
textureObject->bind();
}
else if ( (_textureWidth!=0) && (_textureHeight!=0) && (_textureDepth != 0) && (_numSamples!=0) )
{
textureObject = generateAndAssignTextureObject(
contextID,
getTextureTarget(),
1,
_internalFormat,
_textureWidth,
_textureHeight,
_textureDepth,
_borderWidth);
textureObject->bind();
extensions->glTexImage3DMultisample( getTextureTarget(),
_numSamples,
_internalFormat,
_textureWidth,
_textureHeight,
_textureDepth,
_fixedsamplelocations );
}
else
{
glBindTexture( getTextureTarget(), 0 );
}
}
void Texture2DMultisampleArray::computeInternalFormat() const
{
computeInternalFormatType();
}

View File

@ -17,6 +17,8 @@
#include <osg/Texture2D>
#include <osg/Texture2DMultisample>
#include <osg/Texture3D>
#include <osg/Texture2DArray>
#include <osg/Texture2DMultisampleArray>
#include <osg/TextureRectangle>
#include <osg/TextureCubeMap>
#include <osg/ContextData>
@ -243,11 +245,14 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
osg::Camera::BufferAttachmentMap& bufferAttachments = _camera->getBufferAttachmentMap();
_bufferAttachmentMap.clear();
_resolveArrayLayerFbos.clear();
_arrayLayerFbos.clear();
// compute the required dimensions
int width = static_cast<int>(_viewport->x() + _viewport->width());
int height = static_cast<int>(_viewport->y() + _viewport->height());
int depth = 1;
bool isArray = false;
for(osg::Camera::BufferAttachmentMap::iterator itr = bufferAttachments.begin();
itr != bufferAttachments.end();
++itr)
@ -296,6 +301,7 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
osg::Texture3D* texture3D = 0;
osg::TextureCubeMap* textureCubeMap = 0;
osg::TextureRectangle* textureRectangle = 0;
osg::Texture2DArray* texture2DArray = 0;
if (0 != (texture1D=dynamic_cast<osg::Texture1D*>(texture)))
{
if (texture1D->getTextureWidth()==0)
@ -339,7 +345,13 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
textureRectangle->setTextureSize(width,height);
}
}
else if (0 != (texture2DArray = dynamic_cast<osg::Texture2DArray*>(texture)))
{
isArray = true;
//width = texture2DArray->getTextureWidth();
//height = texture2DArray->getTextureHeight();
depth = texture2DArray->getTextureDepth();
}
}
}
@ -437,10 +449,62 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
break;
}
}
fbo_multisample->setAttachment(buffer,
osg::FrameBufferAttachment(new osg::RenderBuffer(
width, height, internalFormat,
samples, colorSamples)));
// VRV_PATCH BEGIN
if(!isArray)
{
fbo_multisample->setAttachment(buffer,
osg::FrameBufferAttachment(new osg::RenderBuffer(
width, height, internalFormat,
samples, colorSamples)));
}
else
{
if(ext->isTextureMultisampledSupported)
{
osg::Texture2DMultisampleArray* multiSampleTexArray = new osg::Texture2DMultisampleArray(width, height, depth, internalFormat, samples, GL_FALSE);
fbo_multisample->setAttachment(buffer, osg::FrameBufferAttachment(multiSampleTexArray, attachment._face, 0));
osg::Texture2DArray* attachmentAsTex2dArray = dynamic_cast<osg::Texture2DArray*>(attachment._texture.get());
// make a read and draw fbos for each layer so we can resolve later
for(unsigned int i=0; i<depth; i++)
{
osg::ref_ptr<osg::FrameBufferObject> layerfbo;
osg::ref_ptr<osg::FrameBufferObject> resolvelayerfbo;
if(static_cast<int>(_arrayLayerFbos.size()) <= i)
{
layerfbo = new osg::FrameBufferObject;
layerfbo->setName(_camera->getName() + "_layer_");
_arrayLayerFbos.push_back(layerfbo);
}
else
{
layerfbo = _arrayLayerFbos[i];
}
if (static_cast<int>(_resolveArrayLayerFbos.size()) <= i)
{
resolvelayerfbo = new osg::FrameBufferObject;
resolvelayerfbo->setName(_camera->getName() + "_resolvelayer_");
_resolveArrayLayerFbos.push_back(resolvelayerfbo);
}
else
{
resolvelayerfbo = _resolveArrayLayerFbos[i];
}
resolvelayerfbo->setAttachment(buffer, osg::FrameBufferAttachment(attachmentAsTex2dArray, i, 0));
layerfbo->setAttachment(buffer, osg::FrameBufferAttachment(multiSampleTexArray, i, 0));
}
}
else
{
fbo_multisample = NULL;
}
}
// VRV_PATCH END
}
if (buffer==osg::Camera::DEPTH_BUFFER) depthAttached = true;
@ -542,7 +606,11 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
}
else
{
setDrawBuffer(GL_NONE, false );
//OSG_WARN << "Camera '" << _camera->getName() << "' fbo details" << std::endl;
//dumpFboInfo(fbo);
setDrawBuffer(GL_NONE, false);
setReadBuffer(GL_NONE, false );
_fbo = fbo;
@ -558,6 +626,8 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
"multisample FBO setup failed, FBO status = 0x"
<< std::hex << status << std::dec << std::endl;
//dumpFboInfo(fbo_multisample);
fbo->apply(state);
fbo_multisample = 0;
_resolveFbo = 0;
@ -951,6 +1021,8 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
if (fbo_supported && _resolveFbo.valid() && ext->glBlitFramebuffer)
{
bool isArray = _resolveFbo->getAttachmentMap().begin()->second.isArray(); // VRV_PATCH
GLbitfield blitMask = 0;
bool needToBlitColorBuffers = false;
@ -979,52 +1051,77 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
}
}
// Bind the resolve framebuffer to blit into.
_fbo->apply(state, FrameBufferObject::READ_FRAMEBUFFER);
_resolveFbo->apply(state, FrameBufferObject::DRAW_FRAMEBUFFER);
if (blitMask)
if (!isArray) // VRV_PATCH
{
// Blit to the resolve framebuffer.
// Note that (with nvidia 175.16 windows drivers at least) if the read
// framebuffer is multisampled then the dimension arguments are ignored
// and the whole framebuffer is always copied.
ext->glBlitFramebuffer(
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->x() + _viewport->width()), static_cast<GLint>(_viewport->y() + _viewport->height()),
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->x() + _viewport->width()), static_cast<GLint>(_viewport->y() + _viewport->height()),
blitMask, GL_NEAREST);
}
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE)
if (needToBlitColorBuffers)
{
for (FrameBufferObject::AttachmentMap::const_iterator
it = _resolveFbo->getAttachmentMap().begin(),
end =_resolveFbo->getAttachmentMap().end(); it != end; ++it)
// Bind the resolve framebuffer to blit into.
_fbo->apply(state, FrameBufferObject::READ_FRAMEBUFFER);
_resolveFbo->apply(state, FrameBufferObject::DRAW_FRAMEBUFFER);
if (blitMask)
{
osg::Camera::BufferComponent attachment = it->first;
if (attachment >=osg::Camera::COLOR_BUFFER0)
// Blit to the resolve framebuffer.
// Note that (with nvidia 175.16 windows drivers at least) if the read
// framebuffer is multisampled then the dimension arguments are ignored
// and the whole framebuffer is always copied.
ext->glBlitFramebuffer(
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->x() + _viewport->width()), static_cast<GLint>(_viewport->y() + _viewport->height()),
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->x() + _viewport->width()), static_cast<GLint>(_viewport->y() + _viewport->height()),
blitMask, GL_NEAREST);
}
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
if (needToBlitColorBuffers)
{
for (FrameBufferObject::AttachmentMap::const_iterator
it = _resolveFbo->getAttachmentMap().begin(),
end =_resolveFbo->getAttachmentMap().end(); it != end; ++it)
{
state.glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + (attachment - osg::Camera::COLOR_BUFFER0));
state.glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT + (attachment - osg::Camera::COLOR_BUFFER0));
osg::Camera::BufferComponent attachment = it->first;
if (attachment >= osg::Camera::COLOR_BUFFER0)
{
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + (attachment - osg::Camera::COLOR_BUFFER0));
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT + (attachment - osg::Camera::COLOR_BUFFER0));
ext->glBlitFramebuffer(
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->x() + _viewport->width()), static_cast<GLint>(_viewport->y() + _viewport->height()),
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->x() + _viewport->width()), static_cast<GLint>(_viewport->y() + _viewport->height()),
GL_COLOR_BUFFER_BIT, GL_NEAREST);
}
}
// reset the read and draw buffers? will comment out for now with the assumption that
// the buffers will be set explicitly when needed elsewhere.
// glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
// glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
}
#endif
}
else
{
// VRV_PATCH BEGIN
if (blitMask)
{
for(unsigned int i = 0; i < _resolveArrayLayerFbos.size(); i++)
{
//_arrayLayerFbos[i]->dirtyAll();
_arrayLayerFbos[i]->apply(state, FrameBufferObject::READ_FRAMEBUFFER);
_resolveArrayLayerFbos[i]->apply(state, FrameBufferObject::DRAW_FRAMEBUFFER);
ext->glBlitFramebuffer(
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->x() + _viewport->width()), static_cast<GLint>(_viewport->y() + _viewport->height()),
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->x() + _viewport->width()), static_cast<GLint>(_viewport->y() + _viewport->height()),
GL_COLOR_BUFFER_BIT, GL_NEAREST);
blitMask, GL_NEAREST);
}
}
// reset the read and draw buffers? will comment out for now with the assumption that
// the buffers will be set explicitly when needed elsewhere.
// glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
// glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
// VRV_PATCH END
}
#endif
apply_read_fbo = true;
read_fbo = _resolveFbo.get();