From c605b24432359f4a7ea03a08f7470d355fc14c4d Mon Sep 17 00:00:00 2001 From: Julien Valentin Date: Tue, 2 Jan 2018 18:29:42 +0100 Subject: [PATCH] remove old BindImageTexture path --- include/osg/Texture | 34 --------------------- src/osg/Texture.cpp | 23 -------------- src/osg/TextureBuffer.cpp | 21 ------------- src/osgWrappers/serializers/osg/Texture.cpp | 28 ++++++++++++----- 4 files changed, 20 insertions(+), 86 deletions(-) diff --git a/include/osg/Texture b/include/osg/Texture index b34c5aff2..f1a7203a3 100644 --- a/include/osg/Texture +++ b/include/osg/Texture @@ -676,38 +676,6 @@ class OSG_EXPORT Texture : public osg::StateAttribute * min filter is used. */ void allocateMipmapLevels(); - /** Encapsulates texture image load/store attributes */ - struct ImageAttachment - { - GLuint unit; - GLint level; - GLboolean layered; - GLint layer; - GLenum access; - GLenum format; - - ImageAttachment() - : unit(0), level(0), layered(GL_FALSE), layer(0), access(0), format(0) {} - }; - - /** Type of access that will be performed on the texture image. */ - enum ImageAccess - { - NOT_USED = 0, - READ_ONLY = GL_READ_ONLY_ARB, - WRITE_ONLY = GL_WRITE_ONLY_ARB, - READ_WRITE = GL_READ_WRITE_ARB - }; - - /** Bind texture to an image unit (available only if GL version is 4.2 or greater) - * The format parameter for the image unit need not exactly match the texture internal format, - * but if it is set to 0, the texture internal format will be used. - * See http://www.opengl.org/registry/specs/ARB/shader_image_load_store.txt */ - void bindToImageUnit(unsigned int unit, GLenum access, GLenum format=0, int level=0, bool layered=false, int layer=0); - - ImageAttachment& getImageAttachment() { return _imageAttachment; } - const ImageAttachment& getImageAttachment() const { return _imageAttachment; } - /** Sets GL_TEXTURE_COMPARE_MODE_ARB to GL_COMPARE_R_TO_TEXTURE_ARB * See http://oss.sgi.com/projects/ogl-sample/registry/ARB/shadow.txt. */ void setShadowComparison(bool flag) { _use_shadow_comparison = flag; } @@ -890,8 +858,6 @@ class OSG_EXPORT Texture : public osg::StateAttribute ShadowTextureMode _shadow_texture_mode; float _shadow_ambient; - ImageAttachment _imageAttachment; - public: struct OSG_EXPORT TextureProfile diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index 752cb22d9..b665c7aa5 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -1382,16 +1382,6 @@ void Texture::setMaxAnisotropy(float anis) } } -void Texture::bindToImageUnit(unsigned int unit, GLenum access, GLenum format, int level, bool layered, int layer) -{ - _imageAttachment.unit = unit; - _imageAttachment.level = level; - _imageAttachment.layered = layered ? GL_TRUE : GL_FALSE; - _imageAttachment.layer = layer; - _imageAttachment.access = access; - _imageAttachment.format = format; - dirtyTextureParameters(); -} /** Force a recompile on next apply() of associated OpenGL texture objects.*/ void Texture::dirtyTextureObject() @@ -1995,19 +1985,6 @@ void Texture::applyTexParameters(GLenum target, State& state) const } } - // Apply image load/store attributes - if (extensions->isBindImageTextureSupported() && _imageAttachment.access!=0) - { - TextureObject* tobj = getTextureObject(contextID); - if (tobj) - { - extensions->glBindImageTexture( - _imageAttachment.unit, tobj->id(), _imageAttachment.level, - _imageAttachment.layered, _imageAttachment.layer, _imageAttachment.access, - _imageAttachment.format!=0 ? _imageAttachment.format : _internalFormat); - } - } - getTextureParameterDirty(state.getContextID()) = false; } diff --git a/src/osg/TextureBuffer.cpp b/src/osg/TextureBuffer.cpp index 349b6e0bf..5eb78e60b 100644 --- a/src/osg/TextureBuffer.cpp +++ b/src/osg/TextureBuffer.cpp @@ -160,7 +160,6 @@ void TextureBuffer::apply(State& state) const #endif if (textureObject) { - const GLExtensions* extensions = state.get(); if(_bufferData.valid() &&_modifiedCount[contextID]!=_bufferData->getModifiedCount() ) { _modifiedCount[contextID]=_bufferData->getModifiedCount() ; @@ -178,18 +177,6 @@ void TextureBuffer::apply(State& state) const } textureObject->bind(); - - if( getTextureParameterDirty(contextID) ) - { - if( extensions->isBindImageTextureSupported() && _imageAttachment.access!=0 ) - { - extensions->glBindImageTexture( - _imageAttachment.unit, textureObject->id(), _imageAttachment.level, - _imageAttachment.layered, _imageAttachment.layer, _imageAttachment.access, - _imageAttachment.format!=0 ? _imageAttachment.format : _internalFormat); - } - getTextureParameterDirty(state.getContextID()) = false; - } } else if (_bufferData.valid() &&_bufferData->getBufferObject() )//&& _bufferObject->getNumBufferData()>0 ) { @@ -205,13 +192,6 @@ void TextureBuffer::apply(State& state) const textureObject->_profile._internalFormat=_internalFormat; textureObject->bind(); - if ( extensions->isBindImageTextureSupported() && _imageAttachment.access!=0 ) - { - extensions->glBindImageTexture( - _imageAttachment.unit, textureObject->id(), _imageAttachment.level, - _imageAttachment.layered, _imageAttachment.layer, _imageAttachment.access, - _imageAttachment.format!=0 ? _imageAttachment.format : _internalFormat); - } getTextureParameterDirty(state.getContextID()) = false; computeInternalFormat(); @@ -239,4 +219,3 @@ void TextureBuffer::computeInternalFormat() const if (getImage() ) computeInternalFormatWithImage(*getImage()); else computeInternalFormatType(); } - diff --git a/src/osgWrappers/serializers/osg/Texture.cpp b/src/osgWrappers/serializers/osg/Texture.cpp index bb8f1a7bd..64bec3eeb 100644 --- a/src/osgWrappers/serializers/osg/Texture.cpp +++ b/src/osgWrappers/serializers/osg/Texture.cpp @@ -73,22 +73,31 @@ static bool writeInternalFormat( osgDB::OutputStream& os, const osg::Texture& te // _imageAttachment static bool checkImageAttachment( const osg::Texture& attr ) { - return attr.getImageAttachment().access!=0; + return false; } +struct DummyImageAttachment +{ +DummyImageAttachment(): unit(0), level(0), layered(GL_FALSE), layer(0), access(0), format(0){} + GLuint unit; + GLint level; + GLboolean layered; + GLint layer; + GLenum access; + GLenum format; +}; + static bool readImageAttachment( osgDB::InputStream& is, osg::Texture& attr ) { - osg::Texture::ImageAttachment attachment; + DummyImageAttachment attachment; is >> attachment.unit >> attachment.level >> attachment.layered >> attachment.layer >> attachment.access >> attachment.format; - attr.bindToImageUnit( attachment.unit, attachment.access, attachment.format, - attachment.level, attachment.layered!=GL_FALSE, attachment.layer ); return true; } static bool writeImageAttachment( osgDB::OutputStream& os, const osg::Texture& attr ) { - const osg::Texture::ImageAttachment& attachment = attr.getImageAttachment(); + DummyImageAttachment attachment; os << attachment.unit << attachment.level << attachment.layered << attachment.layer << attachment.access << attachment.format << std::endl; return true; @@ -248,9 +257,12 @@ REGISTER_OBJECT_WRAPPER( Texture, UPDATE_TO_VERSION_SCOPED( 95 ) ADD_USER_SERIALIZER( ImageAttachment ); // _imageAttachment } - - { - UPDATE_TO_VERSION_SCOPED( 98 ) + { + UPDATE_TO_VERSION_SCOPED( 153 ) + REMOVE_SERIALIZER( ImageAttachment ); + } + { + UPDATE_TO_VERSION_SCOPED( 98 ) ADD_USER_SERIALIZER( Swizzle ); // _swizzle } }