From 20eb368e147e1c27f05d6923c51596f8dfe24e89 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Sat, 13 Feb 2021 16:49:24 -0500 Subject: renderer_vulkan: Accelerate ASTC decoding Co-Authored-By: Rodrigo Locatti --- src/video_core/textures/decoders.cpp | 23 ----------------------- src/video_core/textures/decoders.h | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 25 deletions(-) (limited to 'src/video_core/textures') diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index 62685a183..3a463d5db 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp @@ -17,26 +17,7 @@ #include "video_core/textures/texture.h" namespace Tegra::Texture { - namespace { -/** - * This table represents the internal swizzle of a gob, in format 16 bytes x 2 sector packing. - * Calculates the offset of an (x, y) position within a swizzled texture. - * Taken from the Tegra X1 Technical Reference Manual. pages 1187-1188 - */ -constexpr SwizzleTable MakeSwizzleTableConst() { - SwizzleTable table{}; - for (u32 y = 0; y < table.size(); ++y) { - for (u32 x = 0; x < table[0].size(); ++x) { - table[y][x] = ((x % 64) / 32) * 256 + ((y % 8) / 2) * 64 + ((x % 32) / 16) * 32 + - (y % 2) * 16 + (x % 16); - } - } - return table; -} - -constexpr SwizzleTable SWIZZLE_TABLE = MakeSwizzleTableConst(); - template void Swizzle(std::span output, std::span input, u32 bytes_per_pixel, u32 width, u32 height, u32 depth, u32 block_height, u32 block_depth, u32 stride_alignment) { @@ -91,10 +72,6 @@ void Swizzle(std::span output, std::span input, u32 bytes_per_pixe } } // Anonymous namespace -SwizzleTable MakeSwizzleTable() { - return SWIZZLE_TABLE; -} - void UnswizzleTexture(std::span output, std::span input, u32 bytes_per_pixel, u32 width, u32 height, u32 depth, u32 block_height, u32 block_depth, u32 stride_alignment) { diff --git a/src/video_core/textures/decoders.h b/src/video_core/textures/decoders.h index d7cdc81e8..4c14cefbf 100644 --- a/src/video_core/textures/decoders.h +++ b/src/video_core/textures/decoders.h @@ -23,8 +23,22 @@ constexpr u32 GOB_SIZE_SHIFT = GOB_SIZE_X_SHIFT + GOB_SIZE_Y_SHIFT + GOB_SIZE_Z_ using SwizzleTable = std::array, GOB_SIZE_Y>; -/// Returns a z-order swizzle table -SwizzleTable MakeSwizzleTable(); +/** + * This table represents the internal swizzle of a gob, in format 16 bytes x 2 sector packing. + * Calculates the offset of an (x, y) position within a swizzled texture. + * Taken from the Tegra X1 Technical Reference Manual. pages 1187-1188 + */ +constexpr SwizzleTable MakeSwizzleTable() { + SwizzleTable table{}; + for (u32 y = 0; y < table.size(); ++y) { + for (u32 x = 0; x < table[0].size(); ++x) { + table[y][x] = ((x % 64) / 32) * 256 + ((y % 8) / 2) * 64 + ((x % 32) / 16) * 32 + + (y % 2) * 16 + (x % 16); + } + } + return table; +} +constexpr SwizzleTable SWIZZLE_TABLE = MakeSwizzleTable(); /// Unswizzles a block linear texture into linear memory. void UnswizzleTexture(std::span output, std::span input, u32 bytes_per_pixel, -- cgit v1.2.3