Restructured the way that applyTexParameters() is applied to address issues with Intel drivers not handling mipmap generations unless the tex parameters are reapplied on new upload of data.
This commit is contained in:
parent
39881b5576
commit
7b6eedbdf4
@ -160,10 +160,10 @@ void Texture1D::apply(State& state) const
|
||||
{
|
||||
textureObject->bind();
|
||||
|
||||
if (getTextureParameterDirty(state.getContextID())) applyTexParameters(GL_TEXTURE_1D,state);
|
||||
|
||||
if (_subloadCallback.valid())
|
||||
{
|
||||
applyTexParameters(GL_TEXTURE_1D,state);
|
||||
|
||||
_subloadCallback->subload(*this,state);
|
||||
}
|
||||
else if (_image.valid() && getModifiedCount(contextID) != _image->getModifiedCount())
|
||||
@ -171,9 +171,14 @@ void Texture1D::apply(State& state) const
|
||||
// update the modified count to show that it is up to date.
|
||||
getModifiedCount(contextID) = _image->getModifiedCount();
|
||||
|
||||
applyTexParameters(GL_TEXTURE_1D,state);
|
||||
|
||||
applyTexImage1D(GL_TEXTURE_1D,_image.get(),state, _textureWidth, _numMipmapLevels);
|
||||
}
|
||||
|
||||
if (getTextureParameterDirty(state.getContextID()))
|
||||
applyTexParameters(GL_TEXTURE_1D,state);
|
||||
|
||||
}
|
||||
else if (_subloadCallback.valid())
|
||||
{
|
||||
|
@ -193,11 +193,10 @@ void Texture2D::apply(State& state) const
|
||||
{
|
||||
textureObject->bind();
|
||||
|
||||
if (getTextureParameterDirty(state.getContextID()))
|
||||
applyTexParameters(GL_TEXTURE_2D,state);
|
||||
|
||||
if (_subloadCallback.valid())
|
||||
{
|
||||
applyTexParameters(GL_TEXTURE_2D,state);
|
||||
|
||||
_subloadCallback->subload(*this,state);
|
||||
}
|
||||
else if (_image.valid() && getModifiedCount(contextID) != _image->getModifiedCount())
|
||||
@ -205,6 +204,8 @@ void Texture2D::apply(State& state) const
|
||||
// update the modified tag to show that it is up to date.
|
||||
getModifiedCount(contextID) = _image->getModifiedCount();
|
||||
|
||||
applyTexParameters(GL_TEXTURE_2D,state);
|
||||
|
||||
applyTexImage2D_subload(state,GL_TEXTURE_2D,_image.get(),
|
||||
_textureWidth, _textureHeight, _internalFormat, _numMipmapLevels);
|
||||
}
|
||||
@ -213,6 +214,9 @@ void Texture2D::apply(State& state) const
|
||||
_readPBuffer->bindPBufferToTexture(GL_FRONT);
|
||||
}
|
||||
|
||||
if (getTextureParameterDirty(state.getContextID()))
|
||||
applyTexParameters(GL_TEXTURE_2D,state);
|
||||
|
||||
}
|
||||
else if (_subloadCallback.valid())
|
||||
{
|
||||
|
@ -278,16 +278,16 @@ void Texture2DArray::apply(State& state) const
|
||||
// bind texture object
|
||||
textureObject->bind();
|
||||
|
||||
// if texture parameters changed, then reset them
|
||||
if (getTextureParameterDirty(state.getContextID())) applyTexParameters(GL_TEXTURE_2D_ARRAY_EXT,state);
|
||||
|
||||
// if subload is specified, then use it to subload the images to GPU memory
|
||||
if (_subloadCallback.valid())
|
||||
{
|
||||
applyTexParameters(GL_TEXTURE_2D_ARRAY_EXT,state);
|
||||
|
||||
_subloadCallback->subload(*this,state);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool applyParameters = true;
|
||||
GLsizei n = 0;
|
||||
for(Images::const_iterator itr = _images.begin();
|
||||
itr != _images.end();
|
||||
@ -299,6 +299,13 @@ void Texture2DArray::apply(State& state) const
|
||||
if (getModifiedCount(n,contextID) != image->getModifiedCount())
|
||||
{
|
||||
getModifiedCount(n,contextID) = image->getModifiedCount();
|
||||
|
||||
if (applyParameters)
|
||||
{
|
||||
applyTexParameters(GL_TEXTURE_2D_ARRAY_EXT,state);
|
||||
applyParameters = false;
|
||||
}
|
||||
|
||||
applyTexImage2DArray_subload(state, image, n, _textureWidth, _textureHeight, image->r(), _internalFormat, _numMipmapLevels);
|
||||
}
|
||||
n += image->r();
|
||||
@ -306,6 +313,9 @@ void Texture2DArray::apply(State& state) const
|
||||
}
|
||||
}
|
||||
|
||||
// if texture parameters changed, then reset them
|
||||
if (getTextureParameterDirty(state.getContextID()))
|
||||
applyTexParameters(GL_TEXTURE_2D_ARRAY_EXT,state);
|
||||
}
|
||||
|
||||
// there is no texture object, but exists a subload callback, so use it to upload images
|
||||
|
@ -241,10 +241,10 @@ void Texture3D::apply(State& state) const
|
||||
// we have a valid image
|
||||
textureObject->bind();
|
||||
|
||||
if (getTextureParameterDirty(state.getContextID())) applyTexParameters(GL_TEXTURE_3D,state);
|
||||
|
||||
if (_subloadCallback.valid())
|
||||
{
|
||||
applyTexParameters(GL_TEXTURE_3D,state);
|
||||
|
||||
_subloadCallback->subload(*this,state);
|
||||
}
|
||||
else if (_image.get() && getModifiedCount(contextID) != _image->getModifiedCount())
|
||||
@ -252,11 +252,16 @@ void Texture3D::apply(State& state) const
|
||||
// update the modified count to show that it is up to date.
|
||||
getModifiedCount(contextID) = _image->getModifiedCount();
|
||||
|
||||
applyTexParameters(GL_TEXTURE_3D,state);
|
||||
|
||||
computeRequiredTextureDimensions(state,*_image,_textureWidth, _textureHeight, _textureDepth,_numMipmapLevels);
|
||||
|
||||
applyTexImage3D(GL_TEXTURE_3D,_image.get(),state, _textureWidth, _textureHeight, _textureDepth,_numMipmapLevels);
|
||||
}
|
||||
|
||||
if (getTextureParameterDirty(state.getContextID()))
|
||||
applyTexParameters(GL_TEXTURE_3D,state);
|
||||
|
||||
}
|
||||
else if (_subloadCallback.valid())
|
||||
{
|
||||
|
@ -233,24 +233,32 @@ void TextureCubeMap::apply(State& state) const
|
||||
{
|
||||
textureObject->bind();
|
||||
|
||||
if (getTextureParameterDirty(state.getContextID())) applyTexParameters(GL_TEXTURE_CUBE_MAP,state);
|
||||
|
||||
if (_subloadCallback.valid())
|
||||
{
|
||||
applyTexParameters(GL_TEXTURE_CUBE_MAP,state);
|
||||
|
||||
_subloadCallback->subload(*this,state);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool applyParameters = true;
|
||||
for (int n=0; n<6; n++)
|
||||
{
|
||||
const osg::Image* image = _images[n].get();
|
||||
if (image && getModifiedCount((Face)n,contextID) != image->getModifiedCount())
|
||||
{
|
||||
getModifiedCount((Face)n,contextID) = image->getModifiedCount();
|
||||
if (applyParameters)
|
||||
{
|
||||
applyTexParameters(GL_TEXTURE_CUBE_MAP,state);
|
||||
applyParameters = false;
|
||||
}
|
||||
applyTexImage2D_subload( state, faceTarget[n], _images[n].get(), _textureWidth, _textureHeight, _internalFormat, _numMipmapLevels);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getTextureParameterDirty(state.getContextID()))
|
||||
applyTexParameters(GL_TEXTURE_CUBE_MAP,state);
|
||||
|
||||
}
|
||||
else if (_subloadCallback.valid())
|
||||
|
Loading…
Reference in New Issue
Block a user