Minor fixes

This commit is contained in:
Jérôme Leclercq 2022-02-23 23:48:20 +01:00
parent 74dcb602b8
commit fe16584c8c
7 changed files with 15 additions and 21 deletions

View File

@ -29,7 +29,7 @@ namespace Nz
static bool Initialize(); static bool Initialize();
static void Uninitialize(); static void Uninitialize();
static std::shared_ptr<MaterialSettings> s_basicMaterialSettings; static std::shared_ptr<MaterialSettings> s_depthMaterialSettings;
}; };
} }

View File

@ -9,7 +9,7 @@ namespace Nz
{ {
inline const std::shared_ptr<MaterialSettings>& DepthMaterial::GetSettings() inline const std::shared_ptr<MaterialSettings>& DepthMaterial::GetSettings()
{ {
return s_basicMaterialSettings; return s_depthMaterialSettings;
} }
} }

View File

@ -30,7 +30,6 @@
namespace Nz namespace Nz
{ {
class PointLight;
class RenderFrame; class RenderFrame;
class RenderTarget; class RenderTarget;

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/ForwardFramePipeline.hpp> #include <Nazara/Graphics/ForwardFramePipeline.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Graphics/Debug.hpp> #include <Nazara/Graphics/Debug.hpp>
namespace Nz namespace Nz

View File

@ -39,8 +39,8 @@ namespace Nz
unsigned int GetNumberLength(float number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS); unsigned int GetNumberLength(float number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS);
unsigned int GetNumberLength(double number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS); unsigned int GetNumberLength(double number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS);
unsigned int GetNumberLength(long double number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS); unsigned int GetNumberLength(long double number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS);
template<typename T> /*constexpr*/ unsigned int IntegralLog2(T number); template<typename T> constexpr unsigned int IntegralLog2(T number);
template<typename T> /*constexpr*/ unsigned int IntegralLog2Pot(T pot); template<typename T> constexpr unsigned int IntegralLog2Pot(T pot);
template<typename T> constexpr T IntegralPow(T base, unsigned int exponent); template<typename T> constexpr T IntegralPow(T base, unsigned int exponent);
template<typename T, typename T2> constexpr T Lerp(const T& from, const T& to, const T2& interpolation); template<typename T, typename T2> constexpr T Lerp(const T& from, const T& to, const T2& interpolation);
template<typename T> constexpr T MultiplyAdd(T x, T y, T z); template<typename T> constexpr T MultiplyAdd(T x, T y, T z);

View File

@ -18,13 +18,13 @@ namespace Nz
namespace namespace
{ {
// https://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn // https://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn
static const unsigned int MultiplyDeBruijnBitPosition[32] = static constexpr unsigned int MultiplyDeBruijnBitPosition[32] =
{ {
0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
}; };
static const unsigned int MultiplyDeBruijnBitPosition2[32] = static constexpr unsigned int MultiplyDeBruijnBitPosition2[32] =
{ {
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
@ -32,7 +32,7 @@ namespace Nz
} }
template<typename T> template<typename T>
typename std::enable_if<sizeof(T) <= sizeof(UInt32), unsigned int>::type IntegralLog2(T number) constexpr std::enable_if_t<sizeof(T) <= sizeof(UInt32), unsigned int> IntegralLog2(T number)
{ {
// https://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn // https://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn
number |= number >> 1; // first round down to one less than a power of 2 number |= number >> 1; // first round down to one less than a power of 2
@ -45,8 +45,7 @@ namespace Nz
} }
template<typename T> template<typename T>
// The parentheses are needed for GCC constexpr std::enable_if_t<(sizeof(T) > sizeof(UInt32)), unsigned int> IntegralLog2(T number)
typename std::enable_if<(sizeof(T) > sizeof(UInt32)), unsigned int>::type IntegralLog2(T number)
{ {
static_assert(sizeof(T) % sizeof(UInt32) == 0, "Assertion failed"); static_assert(sizeof(T) % sizeof(UInt32) == 0, "Assertion failed");
@ -69,15 +68,14 @@ namespace Nz
} }
template<typename T> template<typename T>
typename std::enable_if<sizeof(T) <= sizeof(UInt32), unsigned int>::type IntegralLog2Pot(T number) constexpr std::enable_if_t<sizeof(T) <= sizeof(UInt32), unsigned int> IntegralLog2Pot(T number)
{ {
// https://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn // https://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn
return MultiplyDeBruijnBitPosition2[static_cast<UInt32>(number * 0x077CB531U) >> 27]; return MultiplyDeBruijnBitPosition2[static_cast<UInt32>(number * 0x077CB531U) >> 27];
} }
template<typename T> template<typename T>
// The parentheses are needed for GCC constexpr std::enable_if_t<(sizeof(T) > sizeof(UInt32)), unsigned int> IntegralLog2Pot(T number)
typename std::enable_if<(sizeof(T) > sizeof(UInt32)), unsigned int>::type IntegralLog2Pot(T number)
{ {
static_assert(sizeof(T) % sizeof(UInt32) == 0, "Assertion failed"); static_assert(sizeof(T) % sizeof(UInt32) == 0, "Assertion failed");
@ -391,8 +389,7 @@ namespace Nz
* \remark If number is 0, 0 is returned * \remark If number is 0, 0 is returned
*/ */
template<typename T> template<typename T>
//TODO: Mark as constexpr when supported by all major compilers constexpr unsigned int IntegralLog2(T number)
/*constexpr*/ inline unsigned int IntegralLog2(T number)
{ {
// Proxy needed to avoid an overload problem // Proxy needed to avoid an overload problem
return Detail::IntegralLog2<T>(number); return Detail::IntegralLog2<T>(number);
@ -409,8 +406,7 @@ namespace Nz
* \remark If number is 0, 0 is returned * \remark If number is 0, 0 is returned
*/ */
template<typename T> template<typename T>
//TODO: Mark as constexpr when supported by all major compilers constexpr unsigned int IntegralLog2Pot(T pot)
/*constexpr*/ inline unsigned int IntegralLog2Pot(T pot)
{ {
return Detail::IntegralLog2Pot<T>(pot); return Detail::IntegralLog2Pot<T>(pot);
} }

View File

@ -37,15 +37,15 @@ namespace Nz
options.basicOptionIndexes = &s_basicOptionIndexes; options.basicOptionIndexes = &s_basicOptionIndexes;
options.basicTextureIndexes = &s_basicTextureIndexes; options.basicTextureIndexes = &s_basicTextureIndexes;
s_basicMaterialSettings = std::make_shared<MaterialSettings>(Build(options)); s_depthMaterialSettings = std::make_shared<MaterialSettings>(Build(options));
return true; return true;
} }
void DepthMaterial::Uninitialize() void DepthMaterial::Uninitialize()
{ {
s_basicMaterialSettings.reset(); s_depthMaterialSettings.reset();
} }
std::shared_ptr<MaterialSettings> DepthMaterial::s_basicMaterialSettings; std::shared_ptr<MaterialSettings> DepthMaterial::s_depthMaterialSettings;
} }