mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
Check sparse texture support before enabling
This commit is contained in:
parent
a55669b83e
commit
151df32519
3 changed files with 13 additions and 9 deletions
|
@ -122,6 +122,7 @@ GLTexture::GLTexture(const std::weak_ptr<GLBackend>& backend, const Texture& tex
|
||||||
GLObject(backend, texture, id),
|
GLObject(backend, texture, id),
|
||||||
_storageStamp(texture.getStamp()),
|
_storageStamp(texture.getStamp()),
|
||||||
_target(getGLTextureType(texture)),
|
_target(getGLTextureType(texture)),
|
||||||
|
_internalFormat(gl::GLTexelFormat::evalGLTexelFormatInternal(texture.getTexelFormat())),
|
||||||
_maxMip(texture.maxMip()),
|
_maxMip(texture.maxMip()),
|
||||||
_minMip(texture.minMip()),
|
_minMip(texture.minMip()),
|
||||||
_virtualSize(texture.evalTotalSize()),
|
_virtualSize(texture.evalTotalSize()),
|
||||||
|
|
|
@ -113,6 +113,7 @@ public:
|
||||||
const GLuint& _texture { _id };
|
const GLuint& _texture { _id };
|
||||||
const Stamp _storageStamp;
|
const Stamp _storageStamp;
|
||||||
const GLenum _target;
|
const GLenum _target;
|
||||||
|
const GLenum _internalFormat;
|
||||||
const uint16 _maxMip;
|
const uint16 _maxMip;
|
||||||
uint16 _minMip;
|
uint16 _minMip;
|
||||||
const GLuint _virtualSize; // theoretical size as expected
|
const GLuint _virtualSize; // theoretical size as expected
|
||||||
|
|
|
@ -179,10 +179,13 @@ GLuint GL45Backend::getTextureID(const TexturePointer& texture, bool transfer) {
|
||||||
GL45Texture::GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, bool transferrable)
|
GL45Texture::GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, bool transferrable)
|
||||||
: GLTexture(backend, texture, allocate(texture), transferrable), _sparseInfo(*this), _transferState(*this) {
|
: GLTexture(backend, texture, allocate(texture), transferrable), _sparseInfo(*this), _transferState(*this) {
|
||||||
|
|
||||||
_sparse = enableSparseTextures && _transferrable && (_target != GL_TEXTURE_CUBE_MAP);
|
if (enableSparseTextures && _transferrable && (_target != GL_TEXTURE_CUBE_MAP)) {
|
||||||
|
GLint pageSizesCount = 0;
|
||||||
if (_sparse) {
|
glGetInternalformativ(_target, _internalFormat, GL_NUM_VIRTUAL_PAGE_SIZES_ARB, 1, &pageSizesCount);
|
||||||
glTextureParameteri(_id, GL_TEXTURE_SPARSE_ARB, GL_TRUE);
|
if (pageSizesCount > 0) {
|
||||||
|
_sparse = true;
|
||||||
|
glTextureParameteri(_id, GL_TEXTURE_SPARSE_ARB, GL_TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,15 +234,14 @@ void GL45Texture::generateMips() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL45Texture::allocateStorage() const {
|
void GL45Texture::allocateStorage() const {
|
||||||
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat());
|
|
||||||
glTextureParameteri(_id, GL_TEXTURE_BASE_LEVEL, 0);
|
|
||||||
glTextureParameteri(_id, GL_TEXTURE_MAX_LEVEL, _maxMip - _minMip);
|
|
||||||
if (_gpuObject.getTexelFormat().isCompressed()) {
|
if (_gpuObject.getTexelFormat().isCompressed()) {
|
||||||
qFatal("Compressed textures not yet supported");
|
qFatal("Compressed textures not yet supported");
|
||||||
}
|
}
|
||||||
|
glTextureParameteri(_id, GL_TEXTURE_BASE_LEVEL, 0);
|
||||||
|
glTextureParameteri(_id, GL_TEXTURE_MAX_LEVEL, _maxMip - _minMip);
|
||||||
// Get the dimensions, accounting for the downgrade level
|
// Get the dimensions, accounting for the downgrade level
|
||||||
Vec3u dimensions = _gpuObject.evalMipDimensions(_minMip);
|
Vec3u dimensions = _gpuObject.evalMipDimensions(_minMip);
|
||||||
glTextureStorage2D(_id, usedMipLevels(), texelFormat.internalFormat, dimensions.x, dimensions.y);
|
glTextureStorage2D(_id, usedMipLevels(), _internalFormat, dimensions.x, dimensions.y);
|
||||||
(void)CHECK_GL_ERROR();
|
(void)CHECK_GL_ERROR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +370,7 @@ void GL45Texture::stripToMip(uint16_t newMinMip) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newMinMip >= _sparseInfo._maxSparseLevel) {
|
if (newMinMip > _sparseInfo._maxSparseLevel) {
|
||||||
qWarning() << "Cannot increase the min mip into the mip tail";
|
qWarning() << "Cannot increase the min mip into the mip tail";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue