Move Vectormath
main
C++20 game and graphics mathematics
Loading...
Searching...
No Matches
LayoutTraits.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstddef>
4
#include <span>
5
#include <type_traits>
6
7
#include <
mv/math/Vec3.hpp
>
8
#include <
mv/math/gpu/Vectors.hpp
>
9
10
namespace
mv::math
11
{
12
enum class
GpuLayout
13
{
14
Float3Packed12
,
15
Float3Array16
16
};
17
18
template
<
typename
T, GpuLayout Layout>
19
inline
constexpr
bool
IsGpuLayoutCompatible
=
false
;
20
21
template
<>
22
inline
constexpr
bool
23
IsGpuLayoutCompatible<PackedVec3f, GpuLayout::Float3Packed12>
=
true
;
24
25
template
<>
26
inline
constexpr
bool
27
IsGpuLayoutCompatible<gpu::Float3Slot16, GpuLayout::Float3Array16>
=
28
true
;
29
30
template
<>
31
inline
constexpr
bool
32
IsGpuLayoutCompatible<Vec3f, GpuLayout::Float3Array16>
=
true
;
33
34
template
<GpuLayout Layout,
typename
T>
35
requires
IsGpuLayoutCompatible<T, Layout>
36
[[
nodiscard
]] std::span<const std::byte>
AsGpuBytes
(
37
std::span<const T>
values
)
noexcept
38
{
39
return
std::as_bytes(
values
);
40
}
41
}
// namespace mv::math
42
43
static_assert
(
44
mv::math::IsGpuLayoutCompatible
<
mv::math::PackedVec3f
,
45
mv::math::GpuLayout::Float3Packed12
>);
46
static_assert
(
47
mv::math::IsGpuLayoutCompatible
<
mv::math::Vec3f
,
48
mv::math::GpuLayout::Float3Array16
>);
49
static_assert
(
50
mv::math::IsGpuLayoutCompatible
<
mv::math::gpu::Float3Slot16
,
51
mv::math::GpuLayout::Float3Array16
>);
Vec3.hpp
mv::math::Radians
Definition
Angles.hpp:12
Vectors.hpp
mv::math
Definition
Angles.hpp:8
mv::math::GpuLayout
GpuLayout
Definition
LayoutTraits.hpp:13
mv::math::GpuLayout::Float3Packed12
@ Float3Packed12
mv::math::GpuLayout::Float3Array16
@ Float3Array16
mv::math::Vec3f
Vec3< float > Vec3f
Definition
Vec3.hpp:344
mv::math::AsGpuBytes
std::span< const std::byte > AsGpuBytes(std::span< const T > values) noexcept
Definition
LayoutTraits.hpp:36
mv::math::IsGpuLayoutCompatible
constexpr bool IsGpuLayoutCompatible
Definition
LayoutTraits.hpp:19
mv::math::PackedVec3f
Definition
Vectors.hpp:22
mv::math::gpu::Float3Slot16
Definition
Vectors.hpp:15
packages
move
math
include
mv
math
gpu
LayoutTraits.hpp
Generated by
1.9.8