Texture-compression fixes

Rename a highly confusing method, and disable the older texture-
compression code since it interacts badly with the new texture-cache.
This commit is contained in:
James Turner 2020-04-07 12:12:52 +01:00
parent c83dc79357
commit 8dbabc8b43
5 changed files with 22 additions and 9 deletions

View File

@ -292,9 +292,9 @@ bool setAttrs(const TexTuple& attrs, Texture* tex,
int s = image->s();
int t = image->t();
if (s <= t && 32 <= s) {
SGSceneFeatures::instance()->setTextureCompression(tex);
SGSceneFeatures::instance()->applyTextureCompression(tex);
} else if (t < s && 32 <= t) {
SGSceneFeatures::instance()->setTextureCompression(tex);
SGSceneFeatures::instance()->applyTextureCompression(tex);
}
tex->setMaxAnisotropy(SGSceneFeatures::instance()->getTextureFilter());
} else {

View File

@ -117,7 +117,9 @@ protected:
}
};
// disabling old-syle texture compression in favour of the
// texture-cache
#if 0
class SGTexCompressionVisitor : public SGTextureStateAttributeVisitor {
public:
virtual void apply(int, StateSet::RefAttributePair& refAttr)
@ -142,12 +144,13 @@ public:
int t = image->t();
if (s <= t && 32 <= s) {
SGSceneFeatures::instance()->setTextureCompression(texture);
SGSceneFeatures::instance()->applyTextureCompression(texture);
} else if (t < s && 32 <= t) {
SGSceneFeatures::instance()->setTextureCompression(texture);
SGSceneFeatures::instance()->applyTextureCompression(texture);
}
}
};
#endif
class SGTexDataVarianceVisitor : public SGTextureStateAttributeVisitor {
public:
@ -645,8 +648,12 @@ osg::Node* OptimizeModelPolicy::optimize(osg::Node* node,
SGTexDataVarianceVisitor dataVarianceVisitor;
node->accept(dataVarianceVisitor);
// disabling old-syle texture compression in favour of the
// texture-cache
#if 0
SGTexCompressionVisitor texComp;
node->accept(texComp);
#endif
return node;
}

View File

@ -75,9 +75,9 @@ SGLoadTexture2D(bool staticTexture, const std::string& path,
int t = image->t();
if (s <= t && 32 <= s) {
SGSceneFeatures::instance()->setTextureCompression(texture.get());
SGSceneFeatures::instance()->applyTextureCompression(texture.get());
} else if (t < s && 32 <= t) {
SGSceneFeatures::instance()->setTextureCompression(texture.get());
SGSceneFeatures::instance()->applyTextureCompression(texture.get());
}
}

View File

@ -67,8 +67,13 @@ SGSceneFeatures::instance()
}
void
SGSceneFeatures::setTextureCompression(osg::Texture* texture) const
SGSceneFeatures::applyTextureCompression(osg::Texture* texture) const
{
// disable older texture-compression, since it interacts confusingly
// with the the runtime texture-cache. We always want to use
// 'USE_IMAGE_DATA_FORMAT' when the texture-cache is active, since we
// decided whether to compress (or not) prior to this point.
#if 0
switch (_textureCompression) {
case UseARBCompression:
texture->setInternalFormatMode(osg::Texture::USE_ARB_COMPRESSION);
@ -86,6 +91,7 @@ SGSceneFeatures::setTextureCompression(osg::Texture* texture) const
texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
break;
}
#endif
}
bool

View File

@ -58,7 +58,7 @@ public:
TextureCompression getTextureCompression() const { return _textureCompression; }
// modify the texture compression on the texture parameter
void setTextureCompression(osg::Texture* texture) const;
void applyTextureCompression(osg::Texture* texture) const;
void setEnablePointSpriteLights(bool enable)
{