diff --git a/src/video_core/utils.cpp b/src/video_core/utils.cpp index 6e1ff5cf4..dfac1b620 100644 --- a/src/video_core/utils.cpp +++ b/src/video_core/utils.cpp @@ -33,4 +33,48 @@ void DumpTGA(std::string filename, short width, short height, u8* raw_data) { fclose(fout); } + +template +void CopyTextureAndTile(const T* src, T* dst, unsigned int width, unsigned int height) { + for (unsigned int y = 0; y + 8 <= height; y += 8) { + for (unsigned int x = 0; x + 8 <= width; x += 8) { + const T* line = &src[y * width + x]; + + for (unsigned int yy = 0; yy < 8; ++yy) { + for (unsigned int xx = 0; xx < 8; ++xx) { + dst[morton_lut[yy * 8 + xx]] = line[xx]; + } + line += width; + } + + dst += 8 * 8; + } + } +} + +template void CopyTextureAndTile(const u16* src, u16* dst, unsigned int width, unsigned int height); +template void CopyTextureAndTile(const u24_be* src, u24_be* dst, unsigned int width, unsigned int height); +template void CopyTextureAndTile(const u32* src, u32* dst, unsigned int width, unsigned int height); + +template +void CopyTextureAndUntile(const T* src, T* dst, unsigned int width, unsigned int height) { + for (unsigned int y = 0; y + 8 <= height; y += 8) { + for (unsigned int x = 0; x + 8 <= width; x += 8) { + T* line = &dst[y * width + x]; + + for (unsigned int yy = 0; yy < 8; ++yy) { + for (unsigned int xx = 0; xx < 8; ++xx) { + line[xx] = src[morton_lut[yy * 8 + xx]]; + } + line += width; + } + + src += 8 * 8; + } + } +} + +template void CopyTextureAndUntile(const u16* src, u16* dst, unsigned int width, unsigned int height); +template void CopyTextureAndUntile(const u24_be* src, u24_be* dst, unsigned int width, unsigned int height); +template void CopyTextureAndUntile(const u32* src, u32* dst, unsigned int width, unsigned int height); } // namespace diff --git a/src/video_core/utils.h b/src/video_core/utils.h index faa4087a4..812d3818f 100644 --- a/src/video_core/utils.h +++ b/src/video_core/utils.h @@ -68,22 +68,7 @@ static inline u32 MortonInterleave(u32 x, u32 y) { * @param height Height of the texture, should be a multiple of 8. */ template -static inline void CopyTextureAndTile(const T* src, T* dst, unsigned int width, unsigned int height) { - for (unsigned int y = 0; y + 8 <= height; y += 8) { - for (unsigned int x = 0; x + 8 <= width; x += 8) { - const T* line = &src[y * width + x]; - - for (unsigned int yy = 0; yy < 8; ++yy) { - for (unsigned int xx = 0; xx < 8; ++xx) { - dst[morton_lut[yy * 8 + xx]] = line[xx]; - } - line += width; - } - - dst += 8 * 8; - } - } -} +void CopyTextureAndTile(const T* src, T* dst, unsigned int width, unsigned int height); /** * Copies texture data while undoing the transformation applied by `CopyTextureAndTile`. @@ -96,22 +81,7 @@ static inline void CopyTextureAndTile(const T* src, T* dst, unsigned int width, * @param height Height of the texture, should be a multiple of 8. */ template -static inline void CopyTextureAndUntile(const T* src, T* dst, unsigned int width, unsigned int height) { - for (unsigned int y = 0; y + 8 <= height; y += 8) { - for (unsigned int x = 0; x + 8 <= width; x += 8) { - T* line = &dst[y * width + x]; - - for (unsigned int yy = 0; yy < 8; ++yy) { - for (unsigned int xx = 0; xx < 8; ++xx) { - line[xx] = src[morton_lut[yy * 8 + xx]]; - } - line += width; - } - - src += 8 * 8; - } - } -} +void CopyTextureAndUntile(const T* src, T* dst, unsigned int width, unsigned int height); /** * Calculates the offset of the position of the pixel in Morton order