Moved the _textureObjectBuffer assignment to after the imagery has been download to avoid crashes under multi-threaded compile of texture objects (was causing a crash with 3D Textures, but is something that would happen with other Texture types as well.)

This commit is contained in:
Robert Osfield
2008-07-16 13:23:58 +00:00
parent ccf22f6a15
commit 850034ab75
6 changed files with 17 additions and 6 deletions

View File

@@ -150,7 +150,7 @@ void Texture1D::apply(State& state) const
{
// we don't have a applyTexImage1D_subload yet so can't reuse.. so just generate a new texture object.
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(contextID,GL_TEXTURE_1D);
textureObject = generateTextureObject(contextID,GL_TEXTURE_1D);
textureObject->bind();
@@ -163,6 +163,8 @@ void Texture1D::apply(State& state) const
// update the modified count to show that it is upto date.
getModifiedCount(contextID) = _image->getModifiedCount();
_textureObjectBuffer[contextID] = textureObject;
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && _image->getDataVariance()==STATIC)
{
Texture1D* non_const_this = const_cast<Texture1D*>(this);

View File

@@ -184,7 +184,7 @@ void Texture2D::apply(State& state) const
computeRequiredTextureDimensions(state,*image,_textureWidth, _textureHeight, _numMipmapLevels);
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(
textureObject = generateTextureObject(
contextID,GL_TEXTURE_2D,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,1,0);
textureObject->bind();
@@ -210,6 +210,7 @@ void Texture2D::apply(State& state) const
// update the modified tag to show that it is upto date.
getModifiedCount(contextID) = image->getModifiedCount();
_textureObjectBuffer[contextID] = textureObject;
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && image->getDataVariance()==STATIC)
{

View File

@@ -242,7 +242,7 @@ void Texture2DArray::apply(State& state) const
computeRequiredTextureDimensions(state,*_images[0],_textureWidth, _textureHeight, _numMipmapLevels);
// create texture object
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(
textureObject = generateTextureObject(
contextID,GL_TEXTURE_2D_ARRAY_EXT,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,_textureDepth,0);
// bind texture
@@ -271,6 +271,8 @@ void Texture2DArray::apply(State& state) const
}
textureObject->setAllocated(_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,_textureDepth,0);
_textureObjectBuffer[contextID] = textureObject;
// no idea what this for ;-)
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded())
{

View File

@@ -231,7 +231,7 @@ void Texture3D::apply(State& state) const
// compute the dimensions of the texture.
computeRequiredTextureDimensions(state,*_image,_textureWidth, _textureHeight, _textureDepth,_numMipmapLevels);
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(contextID,GL_TEXTURE_3D);
textureObject = generateTextureObject(contextID,GL_TEXTURE_3D);
textureObject->bind();
@@ -245,6 +245,8 @@ void Texture3D::apply(State& state) const
// update the modified count to show that it is upto date.
getModifiedCount(contextID) = _image->getModifiedCount();
_textureObjectBuffer[contextID] = textureObject;
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && _image->getDataVariance()==STATIC)
{
Texture3D* non_const_this = const_cast<Texture3D*>(this);

View File

@@ -227,7 +227,7 @@ void TextureCubeMap::apply(State& state) const
_textureWidth = _textureHeight = minimum( _textureWidth , _textureHeight );
}
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(
textureObject = generateTextureObject(
contextID,GL_TEXTURE_CUBE_MAP,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,1,0);
textureObject->bind();
@@ -253,6 +253,8 @@ void TextureCubeMap::apply(State& state) const
}
_textureObjectBuffer[contextID] = textureObject;
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded())
{
TextureCubeMap* non_const_this = const_cast<TextureCubeMap*>(this);

View File

@@ -197,7 +197,7 @@ void TextureRectangle::apply(State& state) const
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex);
// we don't have a applyTexImage1D_subload yet so can't reuse.. so just generate a new texture object.
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(contextID,GL_TEXTURE_RECTANGLE);
textureObject = generateTextureObject(contextID,GL_TEXTURE_RECTANGLE);
textureObject->bind();
@@ -206,6 +206,8 @@ void TextureRectangle::apply(State& state) const
applyTexImage_load(GL_TEXTURE_RECTANGLE, _image.get(), state, _textureWidth, _textureHeight);
textureObject->setAllocated(1,_internalFormat,_textureWidth,_textureHeight,1,0);
_textureObjectBuffer[contextID] = textureObject;
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && _image->getDataVariance()==STATIC)
{