summaryrefslogtreecommitdiffstats
path: root/src/video_core/texture_cache/util.cpp
diff options
context:
space:
mode:
authorGPUCode <geoster3d@gmail.com>2023-06-06 22:10:06 +0200
committerbunnei <bunneidev@gmail.com>2023-06-28 03:00:09 +0200
commiteac46ad7ceca5e35b396a8b80bfc38dc6ef1a4fe (patch)
tree761e98947d8e26a6409e24befa99cd127f67458d /src/video_core/texture_cache/util.cpp
parentrenderer_vulkan: Add more feature checking (diff)
downloadyuzu-eac46ad7ceca5e35b396a8b80bfc38dc6ef1a4fe.tar
yuzu-eac46ad7ceca5e35b396a8b80bfc38dc6ef1a4fe.tar.gz
yuzu-eac46ad7ceca5e35b396a8b80bfc38dc6ef1a4fe.tar.bz2
yuzu-eac46ad7ceca5e35b396a8b80bfc38dc6ef1a4fe.tar.lz
yuzu-eac46ad7ceca5e35b396a8b80bfc38dc6ef1a4fe.tar.xz
yuzu-eac46ad7ceca5e35b396a8b80bfc38dc6ef1a4fe.tar.zst
yuzu-eac46ad7ceca5e35b396a8b80bfc38dc6ef1a4fe.zip
Diffstat (limited to 'src/video_core/texture_cache/util.cpp')
-rw-r--r--src/video_core/texture_cache/util.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp
index f781cb7a0..9a618a57a 100644
--- a/src/video_core/texture_cache/util.cpp
+++ b/src/video_core/texture_cache/util.cpp
@@ -24,7 +24,7 @@
#include "video_core/engines/maxwell_3d.h"
#include "video_core/memory_manager.h"
#include "video_core/surface.h"
-#include "video_core/texture_cache/decode_bc4.h"
+#include "video_core/texture_cache/decode_bc.h"
#include "video_core/texture_cache/format_lookup_table.h"
#include "video_core/texture_cache/formatter.h"
#include "video_core/texture_cache/samples_helper.h"
@@ -61,8 +61,6 @@ using VideoCore::Surface::PixelFormatFromDepthFormat;
using VideoCore::Surface::PixelFormatFromRenderTargetFormat;
using VideoCore::Surface::SurfaceType;
-constexpr u32 CONVERTED_BYTES_PER_BLOCK = BytesPerBlock(PixelFormat::A8B8G8R8_UNORM);
-
struct LevelInfo {
Extent3D size;
Extent3D block;
@@ -612,7 +610,8 @@ u32 CalculateConvertedSizeBytes(const ImageInfo& info) noexcept {
}
return output_size;
}
- return NumBlocksPerLayer(info, TILE_SIZE) * info.resources.layers * CONVERTED_BYTES_PER_BLOCK;
+ return NumBlocksPerLayer(info, TILE_SIZE) * info.resources.layers *
+ ConvertedBytesPerBlock(info.format);
}
u32 CalculateLayerStride(const ImageInfo& info) noexcept {
@@ -945,7 +944,8 @@ void ConvertImage(std::span<const u8> input, const ImageInfo& info, std::span<u8
tile_size.height, output.subspan(output_offset));
output_offset += copy.image_extent.width * copy.image_extent.height *
- copy.image_subresource.num_layers * CONVERTED_BYTES_PER_BLOCK;
+ copy.image_subresource.num_layers *
+ BytesPerBlock(PixelFormat::A8B8G8R8_UNORM);
} else if (astc) {
// BC1 uses 0.5 bytes per texel
// BC3 uses 1 byte per texel
@@ -956,7 +956,8 @@ void ConvertImage(std::span<const u8> input, const ImageInfo& info, std::span<u8
const u32 plane_dim = copy.image_extent.width * copy.image_extent.height;
const u32 level_size = plane_dim * copy.image_extent.depth *
- copy.image_subresource.num_layers * CONVERTED_BYTES_PER_BLOCK;
+ copy.image_subresource.num_layers *
+ BytesPerBlock(PixelFormat::A8B8G8R8_UNORM);
decode_scratch.resize_destructive(level_size);
Tegra::Texture::ASTC::Decompress(
@@ -976,10 +977,15 @@ void ConvertImage(std::span<const u8> input, const ImageInfo& info, std::span<u8
bpp_div;
output_offset += static_cast<u32>(copy.buffer_size);
} else {
- DecompressBC4(input_offset, copy.image_extent, output.subspan(output_offset));
-
+ const Extent3D image_extent{
+ .width = copy.image_extent.width,
+ .height = copy.image_extent.height * copy.image_subresource.num_layers,
+ .depth = copy.image_extent.depth,
+ };
+ DecompressBCn(input_offset, output.subspan(output_offset), image_extent, info.format);
output_offset += copy.image_extent.width * copy.image_extent.height *
- copy.image_subresource.num_layers * CONVERTED_BYTES_PER_BLOCK;
+ copy.image_subresource.num_layers *
+ ConvertedBytesPerBlock(info.format);
}
}
}