mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 20:36:49 +02:00
Update gl41 an gl45 texture backends to take into account min avail mip
This commit is contained in:
parent
674e767513
commit
b9ec573c8b
5 changed files with 28 additions and 10 deletions
|
@ -100,7 +100,7 @@ public:
|
||||||
GL41VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
GL41VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||||
~GL41VariableAllocationTexture();
|
~GL41VariableAllocationTexture();
|
||||||
|
|
||||||
bool canPopulate() const override { return _populatedMip > _allocatedMip && _gpuObject.isStoredMipFaceAvailable(_populatedMip - 1, 0); }
|
bool canPopulate() const override { return _gpuObject.isStoredMipFaceAvailable(_populatedMip - 1, 0); }
|
||||||
void allocateStorage(uint16 allocatedMip);
|
void allocateStorage(uint16 allocatedMip);
|
||||||
void syncSampler() const override;
|
void syncSampler() const override;
|
||||||
void promote() override;
|
void promote() override;
|
||||||
|
|
|
@ -231,15 +231,20 @@ using GL41VariableAllocationTexture = GL41Backend::GL41VariableAllocationTexture
|
||||||
GL41VariableAllocationTexture::GL41VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL41Texture(backend, texture) {
|
GL41VariableAllocationTexture::GL41VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL41Texture(backend, texture) {
|
||||||
auto mipLevels = texture.getNumMips();
|
auto mipLevels = texture.getNumMips();
|
||||||
_allocatedMip = mipLevels;
|
_allocatedMip = mipLevels;
|
||||||
|
_maxAllocatedMip = _populatedMip = mipLevels;
|
||||||
|
uint16_t minAvailableMip = texture.minAvailableMipLevel();
|
||||||
uvec3 mipDimensions;
|
uvec3 mipDimensions;
|
||||||
for (uint16_t mip = 0; mip < mipLevels; ++mip) {
|
for (uint16_t mip = 0; mip < mipLevels; ++mip) {
|
||||||
if (glm::all(glm::lessThanEqual(texture.evalMipDimensions(mip), INITIAL_MIP_TRANSFER_DIMENSIONS))) {
|
if (glm::all(glm::lessThanEqual(texture.evalMipDimensions(mip), INITIAL_MIP_TRANSFER_DIMENSIONS))
|
||||||
|
&& mip >= minAvailableMip) {
|
||||||
_maxAllocatedMip = _populatedMip = mip;
|
_maxAllocatedMip = _populatedMip = mip;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t allocatedMip = _populatedMip - std::min<uint16_t>(_populatedMip, 2);
|
auto targetMip = _populatedMip - std::min<uint16_t>(_populatedMip, 2);
|
||||||
|
uint16_t allocatedMip = std::max<uint16_t>(minAvailableMip, targetMip);
|
||||||
|
|
||||||
allocateStorage(allocatedMip);
|
allocateStorage(allocatedMip);
|
||||||
_memoryPressureStateStale = true;
|
_memoryPressureStateStale = true;
|
||||||
size_t maxFace = GLTexture::getFaceCount(_target);
|
size_t maxFace = GLTexture::getFaceCount(_target);
|
||||||
|
@ -292,6 +297,14 @@ void GL41VariableAllocationTexture::syncSampler() const {
|
||||||
void GL41VariableAllocationTexture::promote() {
|
void GL41VariableAllocationTexture::promote() {
|
||||||
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
||||||
Q_ASSERT(_allocatedMip > 0);
|
Q_ASSERT(_allocatedMip > 0);
|
||||||
|
|
||||||
|
uint16_t targetAllocatedMip = _allocatedMip - std::min<uint16_t>(_allocatedMip, 2);
|
||||||
|
targetAllocatedMip = std::max<uint16_t>(_gpuObject.minAvailableMipLevel(), targetAllocatedMip);
|
||||||
|
|
||||||
|
if (targetAllocatedMip >= _allocatedMip || !_gpuObject.isStoredMipFaceAvailable(targetAllocatedMip, 0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
GLuint oldId = _id;
|
GLuint oldId = _id;
|
||||||
auto oldSize = _size;
|
auto oldSize = _size;
|
||||||
// create new texture
|
// create new texture
|
||||||
|
@ -299,7 +312,7 @@ void GL41VariableAllocationTexture::promote() {
|
||||||
uint16_t oldAllocatedMip = _allocatedMip;
|
uint16_t oldAllocatedMip = _allocatedMip;
|
||||||
|
|
||||||
// allocate storage for new level
|
// allocate storage for new level
|
||||||
allocateStorage(_allocatedMip - std::min<uint16_t>(_allocatedMip, 2));
|
allocateStorage(targetAllocatedMip);
|
||||||
|
|
||||||
withPreservedTexture([&] {
|
withPreservedTexture([&] {
|
||||||
GLuint fbo { 0 };
|
GLuint fbo { 0 };
|
||||||
|
|
|
@ -46,16 +46,20 @@ GL45ResourceTexture::GL45ResourceTexture(const std::weak_ptr<GLBackend>& backend
|
||||||
|
|
||||||
_maxAllocatedMip = _populatedMip = mipLevels;
|
_maxAllocatedMip = _populatedMip = mipLevels;
|
||||||
|
|
||||||
|
uint16_t minAvailableMip = texture.minAvailableMipLevel();
|
||||||
|
|
||||||
uvec3 mipDimensions;
|
uvec3 mipDimensions;
|
||||||
for (uint16_t mip = 0; mip < mipLevels; ++mip) {
|
for (uint16_t mip = 0; mip < mipLevels; ++mip) {
|
||||||
if (glm::all(glm::lessThanEqual(texture.evalMipDimensions(mip), INITIAL_MIP_TRANSFER_DIMENSIONS))
|
if (glm::all(glm::lessThanEqual(texture.evalMipDimensions(mip), INITIAL_MIP_TRANSFER_DIMENSIONS))
|
||||||
&& texture.isStoredMipFaceAvailable(mip)) {
|
&& mip >= minAvailableMip) {
|
||||||
_maxAllocatedMip = _populatedMip = mip;
|
_maxAllocatedMip = _populatedMip = mip;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t allocatedMip = _populatedMip - std::min<uint16_t>(_populatedMip, 2);
|
auto targetMip = _populatedMip - std::min<uint16_t>(_populatedMip, 2);
|
||||||
|
uint16_t allocatedMip = std::max<uint16_t>(minAvailableMip, targetMip);
|
||||||
|
|
||||||
allocateStorage(allocatedMip);
|
allocateStorage(allocatedMip);
|
||||||
_memoryPressureStateStale = true;
|
_memoryPressureStateStale = true;
|
||||||
copyMipsFromTexture();
|
copyMipsFromTexture();
|
||||||
|
@ -99,8 +103,11 @@ void GL45ResourceTexture::syncSampler() const {
|
||||||
void GL45ResourceTexture::promote() {
|
void GL45ResourceTexture::promote() {
|
||||||
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
||||||
Q_ASSERT(_allocatedMip > 0);
|
Q_ASSERT(_allocatedMip > 0);
|
||||||
|
|
||||||
uint16_t targetAllocatedMip = _allocatedMip - std::min<uint16_t>(_allocatedMip, 2);
|
uint16_t targetAllocatedMip = _allocatedMip - std::min<uint16_t>(_allocatedMip, 2);
|
||||||
if (!_gpuObject.isStoredMipFaceAvailable(targetAllocatedMip, 0)) {
|
targetAllocatedMip = std::max<uint16_t>(_gpuObject.minAvailableMipLevel(), targetAllocatedMip);
|
||||||
|
|
||||||
|
if (targetAllocatedMip >= _allocatedMip || !_gpuObject.isStoredMipFaceAvailable(targetAllocatedMip, 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GLuint oldId = _id;
|
GLuint oldId = _id;
|
||||||
|
|
|
@ -588,8 +588,7 @@ void NetworkTexture::maybeHandleFinishedInitialLoad() {
|
||||||
_ktxResourceState = FAILED_TO_LOAD;
|
_ktxResourceState = FAILED_TO_LOAD;
|
||||||
finishedLoading(false);
|
finishedLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_file = file;
|
_file = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,6 @@ class NetworkTexture : public Resource, public Texture {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NetworkTexture(const QUrl& url, image::TextureUsage::Type type, const QByteArray& content, int maxNumPixels);
|
NetworkTexture(const QUrl& url, image::TextureUsage::Type type, const QByteArray& content, int maxNumPixels);
|
||||||
~NetworkTexture() override;
|
|
||||||
|
|
||||||
QString getType() const override { return "NetworkTexture"; }
|
QString getType() const override { return "NetworkTexture"; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue