- Created Layout for Textures
- Separated Build and Output directories
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
#define FENNEC_LANG_BITS_H
|
||||
|
||||
#include <fennec/lang/intrinsics.h>
|
||||
#include <fennec/memory/memory.h>
|
||||
#include <fennec/lang/detail/__bits.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -46,6 +46,20 @@ constexpr ToT bit_cast(const FromT& from)
|
||||
}
|
||||
}
|
||||
|
||||
constexpr void* bitmask(void* arr, const void* mask, size_t n)
|
||||
{
|
||||
if (arr == mask) return arr;
|
||||
uint8_t* d = static_cast<uint8_t*>(arr);
|
||||
const uint8_t* s = static_cast<const uint8_t*>(mask);
|
||||
|
||||
while (n >= 8) { detail::__bitmask_64(d, s); d += 8; s += 8; n -= 8; }
|
||||
while (n >= 4) { detail::__bitmask_32(d, s); d += 4; s += 4; n -= 4; }
|
||||
while (n >= 2) { detail::__bitmask_16(d, s); d += 2; s += 2; n -= 2; }
|
||||
while (n >= 1) { *d++ = *s++; --n; }
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_LANG_BITS_H
|
||||
|
||||
46
include/fennec/lang/detail/__bits.h
Normal file
46
include/fennec/lang/detail/__bits.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_LANG_DETAIL_BITS_H
|
||||
#define FENNEC_LANG_DETAIL_BITS_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// helper for copying 2 bytes at once
|
||||
constexpr size_t __bitmask_16(void* dst, const void* src)
|
||||
{ *static_cast<uint16_t*>(dst) = *static_cast<const uint16_t*>(src); return 2; }
|
||||
|
||||
// helper for copying 4 bytes at once
|
||||
constexpr size_t __bitmask_32(void* dst, const void* src)
|
||||
{ *static_cast<uint32_t*>(dst) = *static_cast<const uint32_t*>(src); return 4; }
|
||||
|
||||
// helper for copying 8 bytes at once
|
||||
constexpr size_t __bitmask_64(void* dst, const void* src)
|
||||
{ *static_cast<uint64_t*>(dst) = *static_cast<const uint64_t*>(src); return 8; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_LANG_DETAIL_BITS_H
|
||||
@@ -30,7 +30,7 @@
|
||||
#ifndef FENNEC_LANG_FLOAT_H
|
||||
#define FENNEC_LANG_FLOAT_H
|
||||
|
||||
#include <fennec/memory/bits.h>
|
||||
#include <fennec/lang/bits.h>
|
||||
|
||||
#define FLT_HAS_INFINITY 1
|
||||
#define FLT_HAS_QUIET_NAN 1
|
||||
|
||||
@@ -276,7 +276,6 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <fennec/math/vector.h>
|
||||
#include <../lang/bits.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
@@ -75,6 +75,14 @@ constexpr int memcmp(const void* lhs, const void* rhs, size_t n)
|
||||
return 0;
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Safe version of memcmp
|
||||
/// \copydoc fennec::memcmp
|
||||
/// \param n0 The size, in bytes, of lhs
|
||||
/// \param n1 The size, in bytes, of rhs
|
||||
constexpr int memcmp_s(const void* lhs, size_t n0, const void* rhs, size_t n1)
|
||||
{ return memcmp(lhs, rhs, n0 < n1 ? n0 : n1); }
|
||||
|
||||
///
|
||||
/// \brief Copies the first \f$n\f$ bytes of \f$src\f$ to \f$dst\f$.
|
||||
/// \param dst The destination object, interpreted as an array of bytes
|
||||
@@ -101,6 +109,14 @@ constexpr void* memcpy(void* dst, const void* src, size_t n)
|
||||
return dst;
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Safe version of memcpy
|
||||
/// \copydoc fennec::memcpy
|
||||
/// \param n0 The size, in bytes, of dst
|
||||
/// \param n1 The size, in bytes, of src
|
||||
constexpr void* memcpy_s(void* dst, size_t n0, const void* src, size_t n1)
|
||||
{ return memcpy(dst, src, n0 < n1 ? n0 : n1); }
|
||||
|
||||
///
|
||||
/// \brief Copies the first \f$n\f$ bytes of \f$src\f$ to \f$dst\f$, with overlap correction..
|
||||
/// \param dst The destination object, interpreted as an array of bytes
|
||||
@@ -131,6 +147,14 @@ constexpr void* memmove(void* dst, const void* src, size_t n)
|
||||
return dst;
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Safe version of memmove
|
||||
/// \copydoc fennec::memmove
|
||||
/// \param n0 The size, in bytes, of dst
|
||||
/// \param n1 The size, in bytes, of src
|
||||
constexpr void* memmove_s(void* dst, size_t n0, const void* src, size_t n1)
|
||||
{ return memmove(dst, src, n0 < n1 ? n0 : n1); }
|
||||
|
||||
///
|
||||
/// \brief Sets all bytes of \f$dst\f$ to \f$ch\f$, interpreted as an \f$uint8_t\f$
|
||||
/// \param dst The destination object, interpreted as an array of bytes
|
||||
|
||||
Reference in New Issue
Block a user