remove old BindImageTexture path

This commit is contained in:
Julien Valentin
2018-01-02 18:29:42 +01:00
parent f9b1c614bc
commit c605b24432
4 changed files with 20 additions and 86 deletions

View File

@@ -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

View File

@@ -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;
}

View File

@@ -160,7 +160,6 @@ void TextureBuffer::apply(State& state) const
#endif
if (textureObject)
{
const GLExtensions* extensions = state.get<GLExtensions>();
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();
}

View File

@@ -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
}
}