Grindstone Game Engine
v0.2.0
An open source game engine and toolkit.
Toggle main menu visibility
Loading...
Searching...
No Matches
Sampler.hpp
1
#pragma once
2
3
#include <stdint.h>
4
#include "Formats.hpp"
5
6
namespace
Grindstone::GraphicsAPI {
14
struct
SamplerOptions
{
15
TextureWrapMode wrapModeU = TextureWrapMode::Repeat;
16
TextureWrapMode wrapModeV = TextureWrapMode::Repeat;
17
TextureWrapMode wrapModeW = TextureWrapMode::Repeat;
18
TextureFilter mipFilter = TextureFilter::Nearest;
19
TextureFilter minFilter = TextureFilter::Linear;
20
TextureFilter magFilter = TextureFilter::Linear;
21
// Anistropy dictates how pixels are blended together as the angle to its normal
22
// increase. When anisotropy == 0, it will be disabled.
23
float
anistropy = 0.0f;
24
float
mipMin = -1000.f;
25
float
mipMax = 1000.0f;
26
float
mipBias = 0.0f;
27
28
bool
operator==(
const
SamplerOptions
& o)
const
{
29
return
30
wrapModeU == o.wrapModeU &&
31
wrapModeV == o.wrapModeV &&
32
wrapModeW == o.wrapModeW &&
33
mipFilter == o.mipFilter &&
34
minFilter == o.minFilter &&
35
magFilter == o.magFilter &&
36
anistropy == o.anistropy &&
37
mipMin == o.mipMin &&
38
mipMax == o.mipMax &&
39
mipBias == o.mipBias;
40
}
41
42
bool
operator!=(
const
SamplerOptions
& o)
const
{
43
return
!(*
this
== o);
44
}
45
};
46
49
class
Sampler
{
50
public
:
51
struct
CreateInfo
{
52
const
char
* debugName =
nullptr
;
53
SamplerOptions
options;
54
};
55
56
virtual
~Sampler
() {};
57
};
58
}
59
60
namespace
std {
61
template
<>
62
struct
hash<Grindstone::GraphicsAPI::SamplerOptions> {
63
std::size_t operator()(
const
Grindstone::GraphicsAPI::SamplerOptions
& options)
const
noexcept
{
64
65
size_t
filters =
static_cast<
size_t
>
(options.wrapModeU) |
66
static_cast<
size_t
>
(options.wrapModeV) << 8 |
67
static_cast<
size_t
>
(options.wrapModeW) << 16 |
68
static_cast<
size_t
>
(options.mipFilter) << 24 |
69
static_cast<
size_t
>
(options.minFilter) << 32 |
70
static_cast<
size_t
>
(options.magFilter) << 40;
71
72
size_t
result = std::hash<uint32_t>{}(
static_cast<
uint64_t
>
(options.mipMin) | (
static_cast<
uint64_t
>
(options.mipMax) << 32u));
73
result ^= std::hash<uint32_t>{}(
static_cast<
uint64_t
>
(options.anistropy) | (
static_cast<
uint64_t
>
(options.mipBias) << 32u));
74
result ^= std::hash<size_t>{}(filters);
75
76
return
result;
77
}
78
};
79
}
Grindstone::GraphicsAPI::Sampler
Definition
Sampler.hpp:49
Grindstone::GraphicsAPI::SamplerOptions
Definition
Sampler.hpp:14
Grindstone::GraphicsAPI::Sampler::CreateInfo
Definition
Sampler.hpp:51
sources
code
Common
Graphics
Sampler.hpp
Generated by
1.17.0