fixup!
This commit is contained in:
parent
c5f0d83ed4
commit
bb772870d5
2 changed files with 46 additions and 32 deletions
|
@ -33,4 +33,48 @@ void DumpTGA(std::string filename, short width, short height, u8* raw_data) {
|
|||
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
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<u16>(const u16* src, u16* dst, unsigned int width, unsigned int height);
|
||||
template void CopyTextureAndTile<u24_be>(const u24_be* src, u24_be* dst, unsigned int width, unsigned int height);
|
||||
template void CopyTextureAndTile<u32>(const u32* src, u32* dst, unsigned int width, unsigned int height);
|
||||
|
||||
template<typename T>
|
||||
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<u16>(const u16* src, u16* dst, unsigned int width, unsigned int height);
|
||||
template void CopyTextureAndUntile<u24_be>(const u24_be* src, u24_be* dst, unsigned int width, unsigned int height);
|
||||
template void CopyTextureAndUntile<u32>(const u32* src, u32* dst, unsigned int width, unsigned int height);
|
||||
} // namespace
|
||||
|
|
|
@ -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<typename T>
|
||||
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<typename T>
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue