Graphics: Improve TextureSampler handling
This commit is contained in:
@@ -22,6 +22,9 @@ namespace Nz
|
||||
SamplerWrap wrapModeU = SamplerWrap_Clamp;
|
||||
SamplerWrap wrapModeV = SamplerWrap_Clamp;
|
||||
SamplerWrap wrapModeW = SamplerWrap_Clamp;
|
||||
|
||||
inline bool operator==(const TextureSamplerInfo& samplerInfo) const;
|
||||
inline bool operator!=(const TextureSamplerInfo& samplerInfo) const;
|
||||
};
|
||||
|
||||
class NAZARA_RENDERER_API TextureSampler
|
||||
@@ -37,6 +40,9 @@ namespace Nz
|
||||
};
|
||||
}
|
||||
|
||||
template<>
|
||||
struct std::hash<Nz::TextureSamplerInfo>;
|
||||
|
||||
#include <Nazara/Renderer/TextureSampler.inl>
|
||||
|
||||
#endif // NAZARA_TEXTURE_HPP
|
||||
|
||||
@@ -3,10 +3,60 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
#include <Nazara/Core/Algorithm.hpp>
|
||||
#include <Nazara/Math/Algorithm.hpp>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline bool TextureSamplerInfo::operator==(const TextureSamplerInfo& samplerInfo) const
|
||||
{
|
||||
if (!NumberEquals(anisotropyLevel, samplerInfo.anisotropyLevel, 0.99f))
|
||||
return false;
|
||||
|
||||
if (magFilter != samplerInfo.magFilter)
|
||||
return false;
|
||||
|
||||
if (minFilter != samplerInfo.minFilter)
|
||||
return false;
|
||||
|
||||
if (mipmapMode != samplerInfo.mipmapMode)
|
||||
return false;
|
||||
|
||||
if (wrapModeU != samplerInfo.wrapModeU)
|
||||
return false;
|
||||
|
||||
if (wrapModeV != samplerInfo.wrapModeV)
|
||||
return false;
|
||||
|
||||
if (wrapModeW != samplerInfo.wrapModeW)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool TextureSamplerInfo::operator!=(const TextureSamplerInfo& samplerInfo) const
|
||||
{
|
||||
return !operator==(samplerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
struct std::hash<Nz::TextureSamplerInfo>
|
||||
{
|
||||
std::size_t operator()(const Nz::TextureSamplerInfo& sampler) const
|
||||
{
|
||||
std::size_t seed = 0;
|
||||
Nz::HashCombine(seed, sampler.anisotropyLevel);
|
||||
Nz::HashCombine(seed, sampler.magFilter);
|
||||
Nz::HashCombine(seed, sampler.minFilter);
|
||||
Nz::HashCombine(seed, sampler.mipmapMode);
|
||||
Nz::HashCombine(seed, sampler.wrapModeU);
|
||||
Nz::HashCombine(seed, sampler.wrapModeV);
|
||||
Nz::HashCombine(seed, sampler.wrapModeW);
|
||||
|
||||
return seed;
|
||||
}
|
||||
};
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
|
||||
Reference in New Issue
Block a user