initial commit, 4.5 stable
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
This commit is contained in:
57
thirdparty/libktx/lib/swap.c
vendored
Normal file
57
thirdparty/libktx/lib/swap.c
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/* -*- tab-width: 4; -*- */
|
||||
/* vi: set sw=2 ts=4 expandtab: */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* Copyright 2010-2020 The Khronos Group Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <KHR/khrplatform.h>
|
||||
#include "ktx.h"
|
||||
|
||||
/*
|
||||
* SwapEndian16: Swaps endianness in an array of 16-bit values
|
||||
*/
|
||||
void
|
||||
_ktxSwapEndian16(khronos_uint16_t* pData16, ktx_size_t count)
|
||||
{
|
||||
for (ktx_size_t i = 0; i < count; ++i)
|
||||
{
|
||||
khronos_uint16_t x = *pData16;
|
||||
*pData16++ = (x << 8) | (x >> 8);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* SwapEndian32: Swaps endianness in an array of 32-bit values
|
||||
*/
|
||||
void
|
||||
_ktxSwapEndian32(khronos_uint32_t* pData32, ktx_size_t count)
|
||||
{
|
||||
for (ktx_size_t i = 0; i < count; ++i)
|
||||
{
|
||||
khronos_uint32_t x = *pData32;
|
||||
*pData32++ = (x << 24) | ((x & 0xFF00) << 8) | ((x & 0xFF0000) >> 8) | (x >> 24);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* SwapEndian364: Swaps endianness in an array of 32-bit values
|
||||
*/
|
||||
void
|
||||
_ktxSwapEndian64(khronos_uint64_t* pData64, ktx_size_t count)
|
||||
{
|
||||
for (ktx_size_t i = 0; i < count; ++i)
|
||||
{
|
||||
khronos_uint64_t x = *pData64;
|
||||
*pData64++ = (x << 56) | ((x & 0xFF00) << 40) | ((x & 0xFF0000) << 24)
|
||||
| ((x & 0xFF000000) << 8 ) | ((x & 0xFF00000000) >> 8)
|
||||
| ((x & 0xFF0000000000) >> 24)
|
||||
| ((x & 0xFF000000000000) << 40) | (x >> 56);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user