From b9303e5494942ca2f60bf08f3ea248e3c9591cfa Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Wed, 7 Sep 2022 21:17:01 +0200 Subject: [PATCH] Mipmapping is now taken into consideration when calculating the VRAM usage. --- es-core/src/resources/TextureData.cpp | 14 ++++++++++---- es-core/src/resources/TextureData.h | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/es-core/src/resources/TextureData.cpp b/es-core/src/resources/TextureData.cpp index ce784acd6..fc7da571c 100644 --- a/es-core/src/resources/TextureData.cpp +++ b/es-core/src/resources/TextureData.cpp @@ -38,8 +38,8 @@ TextureData::TextureData(bool tile) , mScalableNonAspect {false} , mHasRGBAData {false} , mPendingRasterization {false} - , mLinearMagnify {false} , mMipmapping {false} + , mLinearMagnify {false} { } @@ -314,8 +314,14 @@ void TextureData::setSourceSize(float width, float height) size_t TextureData::getVRAMUsage() { - if (mHasRGBAData || mTextureID != 0) - return mWidth * mHeight * 4; - else + if (mHasRGBAData || mTextureID != 0) { + // The estimated increase in VRAM usage with mipmapping enabled is 33% + if (mMipmapping) + return {static_cast(static_cast(mWidth * mHeight * 4) * 1.33f)}; + else + return mWidth * mHeight * 4; + } + else { return 0; + } } diff --git a/es-core/src/resources/TextureData.h b/es-core/src/resources/TextureData.h index dd5d85be5..57f435d29 100644 --- a/es-core/src/resources/TextureData.h +++ b/es-core/src/resources/TextureData.h @@ -99,8 +99,8 @@ private: std::atomic mScalableNonAspect; std::atomic mHasRGBAData; std::atomic mPendingRasterization; + std::atomic mMipmapping; bool mLinearMagnify; - bool mMipmapping; bool mReloadable; };