diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/surface.cpp | 14 | ||||
| -rw-r--r-- | src/video_core/surface.h | 2 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 4 |
3 files changed, 15 insertions, 5 deletions
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp index 5b3c7aa5a..9055b1b92 100644 --- a/src/video_core/surface.cpp +++ b/src/video_core/surface.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include "common/common_types.h" | 4 | #include "common/common_types.h" |
| 5 | #include "common/math_util.h" | 5 | #include "common/math_util.h" |
| 6 | #include "common/settings.h" | ||
| 6 | #include "video_core/surface.h" | 7 | #include "video_core/surface.h" |
| 7 | 8 | ||
| 8 | namespace VideoCore::Surface { | 9 | namespace VideoCore::Surface { |
| @@ -400,11 +401,20 @@ std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) { | |||
| 400 | return {DefaultBlockWidth(format), DefaultBlockHeight(format)}; | 401 | return {DefaultBlockWidth(format), DefaultBlockHeight(format)}; |
| 401 | } | 402 | } |
| 402 | 403 | ||
| 403 | u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format) { | 404 | u64 TranscodedAstcSize(u64 base_size, PixelFormat format) { |
| 404 | constexpr u64 RGBA8_PIXEL_SIZE = 4; | 405 | constexpr u64 RGBA8_PIXEL_SIZE = 4; |
| 405 | const u64 base_block_size = static_cast<u64>(DefaultBlockWidth(format)) * | 406 | const u64 base_block_size = static_cast<u64>(DefaultBlockWidth(format)) * |
| 406 | static_cast<u64>(DefaultBlockHeight(format)) * RGBA8_PIXEL_SIZE; | 407 | static_cast<u64>(DefaultBlockHeight(format)) * RGBA8_PIXEL_SIZE; |
| 407 | return (base_size * base_block_size) / BytesPerBlock(format); | 408 | const u64 uncompressed_size = (base_size * base_block_size) / BytesPerBlock(format); |
| 409 | |||
| 410 | switch (Settings::values.astc_recompression.GetValue()) { | ||
| 411 | case Settings::AstcRecompression::Bc1: | ||
| 412 | return uncompressed_size / 8; | ||
| 413 | case Settings::AstcRecompression::Bc3: | ||
| 414 | return uncompressed_size / 4; | ||
| 415 | default: | ||
| 416 | return uncompressed_size; | ||
| 417 | } | ||
| 408 | } | 418 | } |
| 409 | 419 | ||
| 410 | } // namespace VideoCore::Surface | 420 | } // namespace VideoCore::Surface |
diff --git a/src/video_core/surface.h b/src/video_core/surface.h index a5e8e2f62..ec9cd2fbf 100644 --- a/src/video_core/surface.h +++ b/src/video_core/surface.h | |||
| @@ -517,6 +517,6 @@ size_t PixelComponentSizeBitsInteger(PixelFormat format); | |||
| 517 | 517 | ||
| 518 | std::pair<u32, u32> GetASTCBlockSize(PixelFormat format); | 518 | std::pair<u32, u32> GetASTCBlockSize(PixelFormat format); |
| 519 | 519 | ||
| 520 | u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format); | 520 | u64 TranscodedAstcSize(u64 base_size, PixelFormat format); |
| 521 | 521 | ||
| 522 | } // namespace VideoCore::Surface | 522 | } // namespace VideoCore::Surface |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 3faff0c2f..5986a7680 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -1972,7 +1972,7 @@ void TextureCache<P>::RegisterImage(ImageId image_id) { | |||
| 1972 | if ((IsPixelFormatASTC(image.info.format) && | 1972 | if ((IsPixelFormatASTC(image.info.format) && |
| 1973 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || | 1973 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || |
| 1974 | True(image.flags & ImageFlagBits::Converted)) { | 1974 | True(image.flags & ImageFlagBits::Converted)) { |
| 1975 | tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format); | 1975 | tentative_size = TranscodedAstcSize(tentative_size, image.info.format); |
| 1976 | } | 1976 | } |
| 1977 | total_used_memory += Common::AlignUp(tentative_size, 1024); | 1977 | total_used_memory += Common::AlignUp(tentative_size, 1024); |
| 1978 | image.lru_index = lru_cache.Insert(image_id, frame_tick); | 1978 | image.lru_index = lru_cache.Insert(image_id, frame_tick); |
| @@ -2142,7 +2142,7 @@ void TextureCache<P>::DeleteImage(ImageId image_id, bool immediate_delete) { | |||
| 2142 | if ((IsPixelFormatASTC(image.info.format) && | 2142 | if ((IsPixelFormatASTC(image.info.format) && |
| 2143 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || | 2143 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || |
| 2144 | True(image.flags & ImageFlagBits::Converted)) { | 2144 | True(image.flags & ImageFlagBits::Converted)) { |
| 2145 | tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format); | 2145 | tentative_size = TranscodedAstcSize(tentative_size, image.info.format); |
| 2146 | } | 2146 | } |
| 2147 | total_used_memory -= Common::AlignUp(tentative_size, 1024); | 2147 | total_used_memory -= Common::AlignUp(tentative_size, 1024); |
| 2148 | const GPUVAddr gpu_addr = image.gpu_addr; | 2148 | const GPUVAddr gpu_addr = image.gpu_addr; |