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

This commit is contained in:
Robert Osfield 2017-10-19 20:57:25 +01:00
parent 8965c9369e
commit 24c2a0ca60
7 changed files with 28 additions and 27 deletions

View File

@ -168,10 +168,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);
}
}
@ -206,13 +206,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 up to date.
getModifiedCount(contextID) = _image->getModifiedCount();
_textureObjectBuffer[contextID] = textureObject;
// unref image data?

View File

@ -202,12 +202,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())
{
@ -224,6 +223,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);
@ -235,7 +236,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())
{
@ -255,6 +255,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;
@ -270,9 +273,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

@ -297,8 +297,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();
}
@ -380,8 +380,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

@ -249,12 +249,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);
}
}
@ -291,6 +291,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);
@ -298,9 +300,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

@ -163,6 +163,8 @@ void TextureBuffer::apply(State& state) const
const GLExtensions* extensions = state.get<GLExtensions>();
if(_bufferData.valid() &&_modifiedCount[contextID]!=_bufferData->getModifiedCount() )
{
_modifiedCount[contextID]=_bufferData->getModifiedCount() ;
GLBufferObject* glBufferObject = _bufferData->getBufferObject()->getOrCreateGLBufferObject(contextID);
if (glBufferObject)
{
@ -174,7 +176,6 @@ void TextureBuffer::apply(State& state) const
}
_modifiedCount[contextID]=_bufferData->getModifiedCount() ;
}
textureObject->bind();
@ -198,6 +199,8 @@ void TextureBuffer::apply(State& state) const
{
const GLExtensions* extensions = state.get<GLExtensions>();
_modifiedCount[contextID] = _bufferData->getModifiedCount();
textureObject = generateAndAssignTextureObject(contextID, GL_TEXTURE_BUFFER);
textureObject->_profile._internalFormat=_internalFormat;
textureObject->bind();
@ -221,7 +224,6 @@ void TextureBuffer::apply(State& state) const
textureObject->bind();
extensions->glTexBuffer(GL_TEXTURE_BUFFER, _internalFormat, glBufferObject->getGLObjectID());
_modifiedCount[contextID] = _bufferData->getModifiedCount();
}
}

View File

@ -246,8 +246,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);
}
}
}
@ -297,6 +297,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);
@ -305,7 +306,6 @@ void TextureCubeMap::apply(State& state) const
{
applyTexImage2D_load( state, faceTarget[n], image, _textureWidth, _textureHeight, _numMipmapLevels);
}
getModifiedCount((Face)n,contextID) = image->getModifiedCount();
}

View File

@ -204,10 +204,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())