Moved the assignment of the ModifiedCount to before GL texture calls.

This commit is contained in:
Robert Osfield 2017-10-19 17:48:53 +01:00
parent 3b790b5e15
commit 2e1a58b6aa
7 changed files with 29 additions and 28 deletions

View File

@ -172,10 +172,10 @@ void Texture1D::apply(State& state) const
}
else if (_image.valid() && getModifiedCount(contextID) != _image->getModifiedCount())
{
applyTexImage1D(GL_TEXTURE_1D,_image.get(),state, _textureWidth, _numMipmapLevels);
// update the modified count to show that it is up to date.
getModifiedCount(contextID) = _image->getModifiedCount();
applyTexImage1D(GL_TEXTURE_1D,_image.get(),state, _textureWidth, _numMipmapLevels);
}
}
@ -210,13 +210,13 @@ void Texture1D::apply(State& state) const
applyTexParameters(GL_TEXTURE_1D,state);
// update the modified count to show that it is upto date.
getModifiedCount(contextID) = _image->getModifiedCount();
applyTexImage1D(GL_TEXTURE_1D,_image.get(),state, _textureWidth, _numMipmapLevels);
textureObject->setAllocated(_numMipmapLevels,_internalFormat,_textureWidth,1,1,0);
// update the modified count to show that it is upto date.
getModifiedCount(contextID) = _image->getModifiedCount();
_textureObjectBuffer[contextID] = textureObject;
// unref image data?

View File

@ -205,12 +205,11 @@ void Texture2D::apply(State& state) const
}
else if (_image.valid() && getModifiedCount(contextID) != _image->getModifiedCount())
{
applyTexImage2D_subload(state,GL_TEXTURE_2D,_image.get(),
_textureWidth, _textureHeight, _internalFormat, _numMipmapLevels);
// update the modified tag to show that it is up to date.
getModifiedCount(contextID) = _image->getModifiedCount();
applyTexImage2D_subload(state,GL_TEXTURE_2D,_image.get(),
_textureWidth, _textureHeight, _internalFormat, _numMipmapLevels);
}
else if (_readPBuffer.valid())
{
@ -226,6 +225,8 @@ void Texture2D::apply(State& state) const
applyTexParameters(GL_TEXTURE_2D,state);
if (_image.valid()) getModifiedCount(contextID) = _image->getModifiedCount();
_subloadCallback->load(*this,state);
textureObject->setAllocated(_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,1,_borderWidth);
@ -237,7 +238,6 @@ void Texture2D::apply(State& state) const
//glBindTexture( GL_TEXTURE_2D, handle );
// update the modified tag to show that it is up to date.
if (_image.valid()) getModifiedCount(contextID) = _image->getModifiedCount();
}
else if (_image.valid() && _image->data())
{
@ -257,6 +257,9 @@ void Texture2D::apply(State& state) const
applyTexParameters(GL_TEXTURE_2D,state);
// update the modified tag to show that it is up to date.
getModifiedCount(contextID) = image->getModifiedCount();
if (textureObject->isAllocated() && image->supportsTextureSubloading())
{
//OSG_NOTICE<<"Reusing texture object"<<std::endl;
@ -272,9 +275,6 @@ void Texture2D::apply(State& state) const
textureObject->setAllocated(true);
}
// update the modified tag to show that it is up to date.
getModifiedCount(contextID) = image->getModifiedCount();
// unref image data?
if (isSafeToUnrefImageData(state) && image->getDataVariance()==STATIC)
{

View File

@ -301,8 +301,8 @@ void Texture2DArray::apply(State& state) const
{
if (getModifiedCount(n,contextID) != image->getModifiedCount())
{
applyTexImage2DArray_subload(state, image, n, _textureWidth, _textureHeight, image->r(), _internalFormat, _numMipmapLevels);
getModifiedCount(n,contextID) = image->getModifiedCount();
applyTexImage2DArray_subload(state, image, n, _textureWidth, _textureHeight, image->r(), _internalFormat, _numMipmapLevels);
}
n += image->r();
}
@ -384,8 +384,8 @@ void Texture2DArray::apply(State& state) const
{
if (getModifiedCount(n,contextID) != image->getModifiedCount())
{
applyTexImage2DArray_subload(state, image, n, _textureWidth, _textureHeight, image->r(), _internalFormat, _numMipmapLevels);
getModifiedCount(n,contextID) = image->getModifiedCount();
applyTexImage2DArray_subload(state, image, n, _textureWidth, _textureHeight, image->r(), _internalFormat, _numMipmapLevels);
}
n += image->r();
}

View File

@ -253,12 +253,12 @@ void Texture3D::apply(State& state) const
}
else if (_image.get() && getModifiedCount(contextID) != _image->getModifiedCount())
{
computeRequiredTextureDimensions(state,*_image,_textureWidth, _textureHeight, _textureDepth,_numMipmapLevels);
applyTexImage3D(GL_TEXTURE_3D,_image.get(),state, _textureWidth, _textureHeight, _textureDepth,_numMipmapLevels);
// update the modified count to show that it is up to date.
getModifiedCount(contextID) = _image->getModifiedCount();
computeRequiredTextureDimensions(state,*_image,_textureWidth, _textureHeight, _textureDepth,_numMipmapLevels);
applyTexImage3D(GL_TEXTURE_3D,_image.get(),state, _textureWidth, _textureHeight, _textureDepth,_numMipmapLevels);
}
}
@ -295,6 +295,8 @@ void Texture3D::apply(State& state) const
textureObject->bind();
// update the modified count to show that it is up to date.
getModifiedCount(contextID) = _image->getModifiedCount();
applyTexParameters(GL_TEXTURE_3D,state);
@ -302,9 +304,6 @@ void Texture3D::apply(State& state) const
textureObject->setAllocated(_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,_textureDepth,0);
// update the modified count to show that it is up to date.
getModifiedCount(contextID) = _image->getModifiedCount();
// unref image data?
if (isSafeToUnrefImageData(state) && _image->getDataVariance()==STATIC)
{

View File

@ -112,11 +112,12 @@ void TextureBuffer::apply(State& state) const
{
if (_image.valid() && getModifiedCount(contextID) != _image->getModifiedCount())
{
_modifiedCount[contextID] = _image->getModifiedCount();
computeInternalFormat();
textureBufferObject->bindBuffer(GL_TEXTURE_BUFFER);
textureBufferObject->bufferSubData(_image.get() );
textureBufferObject->unbindBuffer(GL_TEXTURE_BUFFER);
_modifiedCount[contextID] = _image->getModifiedCount();
}
textureObject->bind();
@ -153,6 +154,9 @@ void TextureBuffer::apply(State& state) const
computeInternalFormat();
_textureWidth = _image->s();
_modifiedCount[contextID] = _image->getModifiedCount();
textureBufferObject->bindBuffer(GL_TEXTURE_BUFFER);
textureBufferObject->bufferData( _image.get() );
textureObject->setAllocated(true);
@ -161,7 +165,6 @@ void TextureBuffer::apply(State& state) const
textureObject->bind();
textureBufferObject->texBuffer(_internalFormat);
_modifiedCount[contextID] = _image->getModifiedCount();
}
else
{

View File

@ -250,8 +250,8 @@ void TextureCubeMap::apply(State& state) const
const osg::Image* image = _images[n].get();
if (image && getModifiedCount((Face)n,contextID) != image->getModifiedCount())
{
applyTexImage2D_subload( state, faceTarget[n], _images[n].get(), _textureWidth, _textureHeight, _internalFormat, _numMipmapLevels);
getModifiedCount((Face)n,contextID) = image->getModifiedCount();
applyTexImage2D_subload( state, faceTarget[n], _images[n].get(), _textureWidth, _textureHeight, _internalFormat, _numMipmapLevels);
}
}
}
@ -301,6 +301,7 @@ void TextureCubeMap::apply(State& state) const
const osg::Image* image = _images[n].get();
if (image)
{
getModifiedCount((Face)n,contextID) = image->getModifiedCount();
if (textureObject->isAllocated())
{
applyTexImage2D_subload( state, faceTarget[n], image, _textureWidth, _textureHeight, _internalFormat, _numMipmapLevels);
@ -309,7 +310,6 @@ void TextureCubeMap::apply(State& state) const
{
applyTexImage2D_load( state, faceTarget[n], image, _textureWidth, _textureHeight, _numMipmapLevels);
}
getModifiedCount((Face)n,contextID) = image->getModifiedCount();
}

View File

@ -209,10 +209,10 @@ void TextureRectangle::apply(State& state) const
}
else if (_image.valid() && getModifiedCount(contextID) != _image->getModifiedCount())
{
applyTexImage_subload(GL_TEXTURE_RECTANGLE, _image.get(), state, _textureWidth, _textureHeight, _internalFormat);
// update the modified count to show that it is up to date.
getModifiedCount(contextID) = _image->getModifiedCount();
applyTexImage_subload(GL_TEXTURE_RECTANGLE, _image.get(), state, _textureWidth, _textureHeight, _internalFormat);
}
}
else if (_subloadCallback.valid())
@ -392,7 +392,6 @@ void TextureRectangle::applyTexImage_subload(GLenum target, Image* image, State&
const unsigned int contextID = state.getContextID();
const GLExtensions* extensions = state.get<GLExtensions>();
// update the modified count to show that it is up to date.
getModifiedCount(contextID) = image->getModifiedCount();