mirror of
https://github.com/JulianGro/overte.git
synced 2025-05-08 06:09:33 +02:00
Debugging the size problem and fixing the compression size evaluation
This commit is contained in:
parent
321f74c305
commit
1f090d8148
13 changed files with 97 additions and 22 deletions
|
@ -115,19 +115,20 @@ GLTexture::~GLTexture() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLTexture::copyMipFaceFromTexture(uint16_t sourceMip, uint16_t targetMip, uint8_t face) const {
|
Size GLTexture::copyMipFaceFromTexture(uint16_t sourceMip, uint16_t targetMip, uint8_t face) const {
|
||||||
if (!_gpuObject.isStoredMipFaceAvailable(sourceMip)) {
|
if (!_gpuObject.isStoredMipFaceAvailable(sourceMip)) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
auto size = _gpuObject.evalMipDimensions(sourceMip);
|
auto dim = _gpuObject.evalMipDimensions(sourceMip);
|
||||||
auto mipData = _gpuObject.accessStoredMipFace(sourceMip, face);
|
auto mipData = _gpuObject.accessStoredMipFace(sourceMip, face);
|
||||||
auto mipSize = _gpuObject.getStoredMipFaceSize(sourceMip, face);
|
auto mipSize = _gpuObject.getStoredMipFaceSize(sourceMip, face);
|
||||||
if (mipData) {
|
if (mipData) {
|
||||||
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat(), _gpuObject.getStoredMipFormat());
|
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat(), _gpuObject.getStoredMipFormat());
|
||||||
copyMipFaceLinesFromTexture(targetMip, face, size, 0, texelFormat.internalFormat, texelFormat.format, texelFormat.type, mipSize, mipData->readData());
|
return copyMipFaceLinesFromTexture(targetMip, face, dim, 0, texelFormat.internalFormat, texelFormat.format, texelFormat.type, mipSize, mipData->readData());
|
||||||
} else {
|
} else {
|
||||||
qCDebug(gpugllogging) << "Missing mipData level=" << sourceMip << " face=" << (int)face << " for texture " << _gpuObject.source().c_str();
|
qCDebug(gpugllogging) << "Missing mipData level=" << sourceMip << " face=" << (int)face << " for texture " << _gpuObject.source().c_str();
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -174,8 +174,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual Size size() const = 0;
|
virtual Size size() const = 0;
|
||||||
virtual void generateMips() const = 0;
|
virtual void generateMips() const = 0;
|
||||||
virtual void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const = 0;
|
virtual Size copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const = 0;
|
||||||
virtual void copyMipFaceFromTexture(uint16_t sourceMip, uint16_t targetMip, uint8_t face) const final;
|
virtual Size copyMipFaceFromTexture(uint16_t sourceMip, uint16_t targetMip, uint8_t face) const final;
|
||||||
|
|
||||||
GLTexture(const std::weak_ptr<gl::GLBackend>& backend, const Texture& texture, GLuint id);
|
GLTexture(const std::weak_ptr<gl::GLBackend>& backend, const Texture& texture, GLuint id);
|
||||||
};
|
};
|
||||||
|
@ -188,7 +188,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
GLExternalTexture(const std::weak_ptr<gl::GLBackend>& backend, const Texture& texture, GLuint id);
|
GLExternalTexture(const std::weak_ptr<gl::GLBackend>& backend, const Texture& texture, GLuint id);
|
||||||
void generateMips() const override {}
|
void generateMips() const override {}
|
||||||
void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override {}
|
Size copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override { return 0;}
|
||||||
|
|
||||||
Size size() const override { return 0; }
|
Size size() const override { return 0; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
GL41Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
GL41Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||||
void generateMips() const override;
|
void generateMips() const override;
|
||||||
void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
Size copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
||||||
virtual void syncSampler() const;
|
virtual void syncSampler() const;
|
||||||
|
|
||||||
void withPreservedTexture(std::function<void()> f) const;
|
void withPreservedTexture(std::function<void()> f) const;
|
||||||
|
@ -110,7 +110,7 @@ public:
|
||||||
void promote() override;
|
void promote() override;
|
||||||
void demote() override;
|
void demote() override;
|
||||||
void populateTransferQueue() override;
|
void populateTransferQueue() override;
|
||||||
void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
Size copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
||||||
|
|
||||||
Size size() const override { return _size; }
|
Size size() const override { return _size; }
|
||||||
Size _size { 0 };
|
Size _size { 0 };
|
||||||
|
|
|
@ -103,7 +103,8 @@ void GL41Texture::generateMips() const {
|
||||||
(void)CHECK_GL_ERROR();
|
(void)CHECK_GL_ERROR();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL41Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
Size GL41Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
||||||
|
Size amountCopied = sourceSize;
|
||||||
if (GL_TEXTURE_2D == _target) {
|
if (GL_TEXTURE_2D == _target) {
|
||||||
switch (internalFormat) {
|
switch (internalFormat) {
|
||||||
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
||||||
|
@ -136,8 +137,10 @@ void GL41Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(false);
|
assert(false);
|
||||||
|
amountCopied = 0;
|
||||||
}
|
}
|
||||||
(void)CHECK_GL_ERROR();
|
(void)CHECK_GL_ERROR();
|
||||||
|
return amountCopied;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL41Texture::syncSampler() const {
|
void GL41Texture::syncSampler() const {
|
||||||
|
@ -274,18 +277,21 @@ GL41VariableAllocationTexture::GL41VariableAllocationTexture(const std::weak_ptr
|
||||||
allocateStorage(allocatedMip);
|
allocateStorage(allocatedMip);
|
||||||
_memoryPressureStateStale = true;
|
_memoryPressureStateStale = true;
|
||||||
size_t maxFace = GLTexture::getFaceCount(_target);
|
size_t maxFace = GLTexture::getFaceCount(_target);
|
||||||
|
Size amount = 0;
|
||||||
for (uint16_t sourceMip = _populatedMip; sourceMip < mipLevels; ++sourceMip) {
|
for (uint16_t sourceMip = _populatedMip; sourceMip < mipLevels; ++sourceMip) {
|
||||||
uint16_t targetMip = sourceMip - _allocatedMip;
|
uint16_t targetMip = sourceMip - _allocatedMip;
|
||||||
for (uint8_t face = 0; face < maxFace; ++face) {
|
for (uint8_t face = 0; face < maxFace; ++face) {
|
||||||
copyMipFaceFromTexture(sourceMip, targetMip, face);
|
amount += copyMipFaceFromTexture(sourceMip, targetMip, face);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Backend::textureResourcePopulatedGPUMemSize.update(0, amount);
|
||||||
syncSampler();
|
syncSampler();
|
||||||
}
|
}
|
||||||
|
|
||||||
GL41VariableAllocationTexture::~GL41VariableAllocationTexture() {
|
GL41VariableAllocationTexture::~GL41VariableAllocationTexture() {
|
||||||
Backend::textureResourceCount.decrement();
|
Backend::textureResourceCount.decrement();
|
||||||
Backend::textureResourceGPUMemSize.update(_size, 0);
|
Backend::textureResourceGPUMemSize.update(_size, 0);
|
||||||
|
Backend::textureResourcePopulatedGPUMemSize.update(_size, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL41VariableAllocationTexture::allocateStorage(uint16 allocatedMip) {
|
void GL41VariableAllocationTexture::allocateStorage(uint16 allocatedMip) {
|
||||||
|
@ -309,10 +315,12 @@ void GL41VariableAllocationTexture::allocateStorage(uint16 allocatedMip) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GL41VariableAllocationTexture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
Size GL41VariableAllocationTexture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
||||||
|
Size amountCopied = 0;
|
||||||
withPreservedTexture([&] {
|
withPreservedTexture([&] {
|
||||||
Parent::copyMipFaceLinesFromTexture(mip, face, size, yOffset, internalFormat, format, type, sourceSize, sourcePointer);
|
amountCopied = Parent::copyMipFaceLinesFromTexture(mip, face, size, yOffset, internalFormat, format, type, sourceSize, sourcePointer);
|
||||||
});
|
});
|
||||||
|
return amountCopied;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL41VariableAllocationTexture::syncSampler() const {
|
void GL41VariableAllocationTexture::syncSampler() const {
|
||||||
|
@ -477,6 +485,7 @@ void GL41VariableAllocationTexture::promote() {
|
||||||
glDeleteTextures(1, &oldId);
|
glDeleteTextures(1, &oldId);
|
||||||
// update the memory usage
|
// update the memory usage
|
||||||
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
||||||
|
// no change to Backend::textureResourcePopulatedGPUMemSize
|
||||||
populateTransferQueue();
|
populateTransferQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,6 +517,7 @@ void GL41VariableAllocationTexture::demote() {
|
||||||
glDeleteTextures(1, &oldId);
|
glDeleteTextures(1, &oldId);
|
||||||
// update the memory usage
|
// update the memory usage
|
||||||
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
||||||
|
Backend::textureResourcePopulatedGPUMemSize.update(oldSize, _size); // Demoting unpopulate the memory delta old - _size
|
||||||
populateTransferQueue();
|
populateTransferQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||||
void generateMips() const override;
|
void generateMips() const override;
|
||||||
void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
Size copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
||||||
virtual void syncSampler() const;
|
virtual void syncSampler() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -98,12 +98,17 @@ public:
|
||||||
friend class GL45Backend;
|
friend class GL45Backend;
|
||||||
using PromoteLambda = std::function<void()>;
|
using PromoteLambda = std::function<void()>;
|
||||||
|
|
||||||
|
// Overight copy to inject counter for populated amount
|
||||||
|
Size copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GL45VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
GL45VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||||
~GL45VariableAllocationTexture();
|
~GL45VariableAllocationTexture();
|
||||||
Size size() const override { return _size; }
|
Size size() const override { return _size; }
|
||||||
Size _size { 0 };
|
Size _size { 0 };
|
||||||
|
void incrementPopulatedSize(Size delta) const;
|
||||||
|
void decrementPopulatedSize(Size delta) const;
|
||||||
|
mutable Size _populatedSize { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
class GL45ResourceTexture : public GL45VariableAllocationTexture {
|
class GL45ResourceTexture : public GL45VariableAllocationTexture {
|
||||||
|
@ -118,7 +123,7 @@ public:
|
||||||
void populateTransferQueue() override;
|
void populateTransferQueue() override;
|
||||||
|
|
||||||
void allocateStorage(uint16 mip);
|
void allocateStorage(uint16 mip);
|
||||||
void copyMipsFromTexture();
|
Size copyMipsFromTexture();
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -133,7 +133,8 @@ void GL45Texture::generateMips() const {
|
||||||
(void)CHECK_GL_ERROR();
|
(void)CHECK_GL_ERROR();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL45Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
Size GL45Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
||||||
|
Size amountCopied = sourceSize;
|
||||||
if (GL_TEXTURE_2D == _target) {
|
if (GL_TEXTURE_2D == _target) {
|
||||||
switch (internalFormat) {
|
switch (internalFormat) {
|
||||||
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
||||||
|
@ -176,9 +177,12 @@ void GL45Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Q_ASSERT(false);
|
assert(false);
|
||||||
|
amountCopied = 0;
|
||||||
}
|
}
|
||||||
(void)CHECK_GL_ERROR();
|
(void)CHECK_GL_ERROR();
|
||||||
|
|
||||||
|
return amountCopied;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL45Texture::syncSampler() const {
|
void GL45Texture::syncSampler() const {
|
||||||
|
|
|
@ -37,6 +37,31 @@ GL45VariableAllocationTexture::GL45VariableAllocationTexture(const std::weak_ptr
|
||||||
GL45VariableAllocationTexture::~GL45VariableAllocationTexture() {
|
GL45VariableAllocationTexture::~GL45VariableAllocationTexture() {
|
||||||
Backend::textureResourceCount.decrement();
|
Backend::textureResourceCount.decrement();
|
||||||
Backend::textureResourceGPUMemSize.update(_size, 0);
|
Backend::textureResourceGPUMemSize.update(_size, 0);
|
||||||
|
Backend::textureResourcePopulatedGPUMemSize.update(_populatedSize, 0);
|
||||||
|
}
|
||||||
|
void GL45VariableAllocationTexture::incrementPopulatedSize(Size delta) const {
|
||||||
|
_populatedSize += delta;
|
||||||
|
if (_size < _populatedSize) {
|
||||||
|
|
||||||
|
Backend::textureResourcePopulatedGPUMemSize.update(0, delta);
|
||||||
|
} else {
|
||||||
|
Backend::textureResourcePopulatedGPUMemSize.update(0, delta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void GL45VariableAllocationTexture::decrementPopulatedSize(Size delta) const {
|
||||||
|
_populatedSize -= delta;
|
||||||
|
if (_size < _populatedSize) {
|
||||||
|
Backend::textureResourcePopulatedGPUMemSize.update(delta, 0);
|
||||||
|
} else {
|
||||||
|
Backend::textureResourcePopulatedGPUMemSize.update(delta, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Size GL45VariableAllocationTexture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
||||||
|
Size amountCopied = 0;
|
||||||
|
amountCopied = Parent::copyMipFaceLinesFromTexture(mip, face, size, yOffset, internalFormat, format, type, sourceSize, sourcePointer);
|
||||||
|
incrementPopulatedSize(amountCopied);
|
||||||
|
return amountCopied;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Managed size resource textures
|
// Managed size resource textures
|
||||||
|
@ -63,7 +88,6 @@ GL45ResourceTexture::GL45ResourceTexture(const std::weak_ptr<GLBackend>& backend
|
||||||
_memoryPressureStateStale = true;
|
_memoryPressureStateStale = true;
|
||||||
copyMipsFromTexture();
|
copyMipsFromTexture();
|
||||||
syncSampler();
|
syncSampler();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL45ResourceTexture::allocateStorage(uint16 allocatedMip) {
|
void GL45ResourceTexture::allocateStorage(uint16 allocatedMip) {
|
||||||
|
@ -75,22 +99,24 @@ void GL45ResourceTexture::allocateStorage(uint16 allocatedMip) {
|
||||||
glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y);
|
glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y);
|
||||||
auto mipLevels = _gpuObject.getNumMips();
|
auto mipLevels = _gpuObject.getNumMips();
|
||||||
_size = 0;
|
_size = 0;
|
||||||
|
bool wtf = false;
|
||||||
for (uint16_t mip = _allocatedMip; mip < mipLevels; ++mip) {
|
for (uint16_t mip = _allocatedMip; mip < mipLevels; ++mip) {
|
||||||
_size += _gpuObject.evalMipSize(mip);
|
_size += _gpuObject.evalMipSize(mip);
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend::textureResourceGPUMemSize.update(0, _size);
|
Backend::textureResourceGPUMemSize.update(0, _size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL45ResourceTexture::copyMipsFromTexture() {
|
Size GL45ResourceTexture::copyMipsFromTexture() {
|
||||||
auto mipLevels = _gpuObject.getNumMips();
|
auto mipLevels = _gpuObject.getNumMips();
|
||||||
size_t maxFace = GLTexture::getFaceCount(_target);
|
size_t maxFace = GLTexture::getFaceCount(_target);
|
||||||
|
Size amount = 0;
|
||||||
for (uint16_t sourceMip = _populatedMip; sourceMip < mipLevels; ++sourceMip) {
|
for (uint16_t sourceMip = _populatedMip; sourceMip < mipLevels; ++sourceMip) {
|
||||||
uint16_t targetMip = sourceMip - _allocatedMip;
|
uint16_t targetMip = sourceMip - _allocatedMip;
|
||||||
for (uint8_t face = 0; face < maxFace; ++face) {
|
for (uint8_t face = 0; face < maxFace; ++face) {
|
||||||
copyMipFaceFromTexture(sourceMip, targetMip, face);
|
amount += copyMipFaceFromTexture(sourceMip, targetMip, face);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL45ResourceTexture::syncSampler() const {
|
void GL45ResourceTexture::syncSampler() const {
|
||||||
|
@ -141,6 +167,7 @@ void GL45ResourceTexture::promote() {
|
||||||
glDeleteTextures(1, &oldId);
|
glDeleteTextures(1, &oldId);
|
||||||
// update the memory usage
|
// update the memory usage
|
||||||
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
||||||
|
// no change to Backend::textureResourcePopulatedGPUMemSize
|
||||||
syncSampler();
|
syncSampler();
|
||||||
populateTransferQueue();
|
populateTransferQueue();
|
||||||
}
|
}
|
||||||
|
@ -150,6 +177,7 @@ void GL45ResourceTexture::demote() {
|
||||||
Q_ASSERT(_allocatedMip < _maxAllocatedMip);
|
Q_ASSERT(_allocatedMip < _maxAllocatedMip);
|
||||||
auto oldId = _id;
|
auto oldId = _id;
|
||||||
auto oldSize = _size;
|
auto oldSize = _size;
|
||||||
|
auto oldPopulatedMip = _populatedMip;
|
||||||
|
|
||||||
// allocate new texture
|
// allocate new texture
|
||||||
const_cast<GLuint&>(_id) = allocate(_gpuObject);
|
const_cast<GLuint&>(_id) = allocate(_gpuObject);
|
||||||
|
@ -165,6 +193,16 @@ void GL45ResourceTexture::demote() {
|
||||||
glDeleteTextures(1, &oldId);
|
glDeleteTextures(1, &oldId);
|
||||||
// update the memory usage
|
// update the memory usage
|
||||||
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
||||||
|
// Demoting unpopulate the memory delta
|
||||||
|
if (oldPopulatedMip != _populatedMip) {
|
||||||
|
auto numPopulatedDemoted = _populatedMip - oldPopulatedMip;
|
||||||
|
Size amountUnpopulated = 0;
|
||||||
|
for (int i = 0; i < numPopulatedDemoted; i++) {
|
||||||
|
//amountUnpopulated += _gpuObject.getStoredMipSize(oldPopulatedMip + i);
|
||||||
|
amountUnpopulated += _gpuObject.evalMipSize(oldPopulatedMip + i);
|
||||||
|
}
|
||||||
|
decrementPopulatedSize(amountUnpopulated);
|
||||||
|
}
|
||||||
syncSampler();
|
syncSampler();
|
||||||
populateTransferQueue();
|
populateTransferQueue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,6 +256,8 @@ ContextMetricSize Backend::textureExternalGPUMemSize;
|
||||||
ContextMetricCount Backend::texturePendingGPUTransferCount;
|
ContextMetricCount Backend::texturePendingGPUTransferCount;
|
||||||
ContextMetricSize Backend::texturePendingGPUTransferMemSize;
|
ContextMetricSize Backend::texturePendingGPUTransferMemSize;
|
||||||
|
|
||||||
|
ContextMetricSize Backend::textureResourcePopulatedGPUMemSize;
|
||||||
|
|
||||||
Size Context::getFreeGPUMemSize() {
|
Size Context::getFreeGPUMemSize() {
|
||||||
return Backend::freeGPUMemSize.getValue();
|
return Backend::freeGPUMemSize.getValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,8 @@ static const int TYPE_SIZE[NUM_TYPES] = {
|
||||||
2,
|
2,
|
||||||
2,
|
2,
|
||||||
1,
|
1,
|
||||||
|
1,
|
||||||
|
|
||||||
1
|
1
|
||||||
};
|
};
|
||||||
// Array answering the question Does this type is integer or not
|
// Array answering the question Does this type is integer or not
|
||||||
|
|
|
@ -424,8 +424,12 @@ public:
|
||||||
uint16 evalMipHeight(uint16 level) const { return std::max(_height >> level, 1); }
|
uint16 evalMipHeight(uint16 level) const { return std::max(_height >> level, 1); }
|
||||||
uint16 evalMipDepth(uint16 level) const { return std::max(_depth >> level, 1); }
|
uint16 evalMipDepth(uint16 level) const { return std::max(_depth >> level, 1); }
|
||||||
|
|
||||||
// The size of a face is a multiple of the padded line = (width * texelFormat_size + alignment padding)
|
// The true size of a line or a sirface depends on the format and the padding
|
||||||
|
// is a multiple of the padded line = (width * texelFormat_size + alignment padding)
|
||||||
|
//
|
||||||
|
uint16 evaTiledWidth(uint16 width) const { return width >> 2 + width & 0x03; }
|
||||||
Size evalMipLineSize(uint16 level) const { return evalPaddedSize(evalMipWidth(level) * getTexelFormat().getSize()); }
|
Size evalMipLineSize(uint16 level) const { return evalPaddedSize(evalMipWidth(level) * getTexelFormat().getSize()); }
|
||||||
|
Size evalMipSurfaceSize(uint16 level) const { return evalPaddedSize(evalMipWidth(level) * getTexelFormat().getSize()); }
|
||||||
|
|
||||||
// Size for each face of a mip at a particular level
|
// Size for each face of a mip at a particular level
|
||||||
uint32 evalMipFaceNumTexels(uint16 level) const { return evalMipWidth(level) * evalMipHeight(level) * evalMipDepth(level); }
|
uint32 evalMipFaceNumTexels(uint16 level) const { return evalMipWidth(level) * evalMipHeight(level) * evalMipDepth(level); }
|
||||||
|
|
|
@ -46,6 +46,8 @@ void EngineStats::run(const RenderContextPointer& renderContext) {
|
||||||
config->texturePendingGPUTransferCount = gpu::Context::getTexturePendingGPUTransferCount();
|
config->texturePendingGPUTransferCount = gpu::Context::getTexturePendingGPUTransferCount();
|
||||||
config->texturePendingGPUTransferSize = gpu::Context::getTexturePendingGPUTransferMemSize();
|
config->texturePendingGPUTransferSize = gpu::Context::getTexturePendingGPUTransferMemSize();
|
||||||
|
|
||||||
|
config->textureResourcePopulatedGPUMemSize = gpu::Context::getTextureResourcePopulatedGPUMemSize();
|
||||||
|
|
||||||
renderContext->args->_context->getFrameStats(_gpuStats);
|
renderContext->args->_context->getFrameStats(_gpuStats);
|
||||||
|
|
||||||
config->frameAPIDrawcallCount = _gpuStats._DSNumAPIDrawcalls;
|
config->frameAPIDrawcallCount = _gpuStats._DSNumAPIDrawcalls;
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace render {
|
||||||
|
|
||||||
Q_PROPERTY(quint32 texturePendingGPUTransferCount MEMBER texturePendingGPUTransferCount NOTIFY dirty)
|
Q_PROPERTY(quint32 texturePendingGPUTransferCount MEMBER texturePendingGPUTransferCount NOTIFY dirty)
|
||||||
Q_PROPERTY(qint64 texturePendingGPUTransferSize MEMBER texturePendingGPUTransferSize NOTIFY dirty)
|
Q_PROPERTY(qint64 texturePendingGPUTransferSize MEMBER texturePendingGPUTransferSize NOTIFY dirty)
|
||||||
|
Q_PROPERTY(qint64 textureResourcePopulatedGPUMemSize MEMBER textureResourcePopulatedGPUMemSize NOTIFY dirty)
|
||||||
|
|
||||||
Q_PROPERTY(quint32 frameAPIDrawcallCount MEMBER frameAPIDrawcallCount NOTIFY dirty)
|
Q_PROPERTY(quint32 frameAPIDrawcallCount MEMBER frameAPIDrawcallCount NOTIFY dirty)
|
||||||
Q_PROPERTY(quint32 frameDrawcallCount MEMBER frameDrawcallCount NOTIFY dirty)
|
Q_PROPERTY(quint32 frameDrawcallCount MEMBER frameDrawcallCount NOTIFY dirty)
|
||||||
|
@ -84,6 +85,7 @@ namespace render {
|
||||||
qint64 textureResourceGPUMemSize { 0 };
|
qint64 textureResourceGPUMemSize { 0 };
|
||||||
qint64 textureExternalGPUMemSize { 0 };
|
qint64 textureExternalGPUMemSize { 0 };
|
||||||
qint64 texturePendingGPUTransferSize { 0 };
|
qint64 texturePendingGPUTransferSize { 0 };
|
||||||
|
qint64 textureResourcePopulatedGPUMemSize { 0 };
|
||||||
|
|
||||||
quint32 frameAPIDrawcallCount{ 0 };
|
quint32 frameAPIDrawcallCount{ 0 };
|
||||||
quint32 frameDrawcallCount{ 0 };
|
quint32 frameDrawcallCount{ 0 };
|
||||||
|
|
|
@ -102,6 +102,11 @@ Item {
|
||||||
prop: "textureFramebufferGPUMemSize",
|
prop: "textureFramebufferGPUMemSize",
|
||||||
label: "Framebuffer",
|
label: "Framebuffer",
|
||||||
color: "#EF93D1"
|
color: "#EF93D1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: "textureResourcePopulatedGPUMemSize",
|
||||||
|
label: "Populated",
|
||||||
|
color: "#C6A61F"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue