From Ulrich Hertlein, "not sure how severe this is but I believe there's a bug in
Texture.cpp:applyTexImage2D_subload:
<code>
unsigned char* data = = (unsigned char*)image->data();
if (needImageRescale) {
// allocates rescale buffer
data = new unsigned char[newTotalSize];
// calls gluScaleImage into the data buffer
}
const unsigned char* dataPtr = image->data();
// subloads 'dataPtr'
// deletes 'data'
</code>
In effect, the scaled data would never be used.
I've also replaced bits of duplicate code in Texture1D/2D/2DArray/3D/Cubemap/Rectangle
that checks if the texture image can/should be unref'd with common functionality in
Texture.cpp.
"
This commit is contained in:
@@ -805,10 +805,13 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
|
||||
virtual void computeInternalFormat() const = 0;
|
||||
|
||||
/** Computes the internal format from Image parameters. */
|
||||
void computeInternalFormatWithImage(const osg::Image& image) const;
|
||||
|
||||
/** Computes the texture dimension for the given Image. */
|
||||
void computeRequiredTextureDimensions(State& state, const osg::Image& image,GLsizei& width, GLsizei& height,GLsizei& numMipmapLevels) const;
|
||||
|
||||
/** Computes the internal format type. */
|
||||
void computeInternalFormatType() const;
|
||||
|
||||
/** Helper method. Sets texture parameters. */
|
||||
@@ -818,6 +821,11 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
* glGenerateMipmapEXT() or GL_GENERATE_MIPMAP_SGIS are supported. */
|
||||
bool isHardwareMipmapGenerationEnabled(const State& state) const;
|
||||
|
||||
/** Returns true if the associated Image should be released and it's safe to do so. */
|
||||
bool isSafeToUnrefImageData(const State& state) const {
|
||||
return (_unrefImageDataAfterApply && state.getMaxTexturePoolSize()==0 && areAllTextureObjectsLoaded());
|
||||
}
|
||||
|
||||
/** Helper methods to be called before and after calling
|
||||
* gl[Compressed][Copy]Tex[Sub]Image2D to handle generating mipmaps. */
|
||||
GenerateMipmapMode mipmapBeforeTexImage(const State& state, bool hardwareMipmapOn) const;
|
||||
|
||||
Reference in New Issue
Block a user