Nugget
Loading...
Searching...
No Matches
fragments.hh
Go to the documentation of this file.
1/*
2
3MIT License
4
5Copyright (c) 2022 PCSX-Redux authors
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26
27#pragma once
28
29#include <EASTL/array.h>
30#include <EASTL/utility.h>
31#include <stdint.h>
32
34
35namespace psyqo {
36
56namespace Fragments {
57
66template <Primitive Prim>
68 constexpr size_t maxSize() const { return 1; }
69 template <typename... Args>
70 SimpleFragment(Args &&...args) : primitive(eastl::forward<Args>(args)...) {
71 static_assert(sizeof(*this) == (sizeof(uint32_t) + sizeof(Prim)), "Spurious padding in simple fragment");
72 }
73 explicit SimpleFragment(const SimpleFragment &) = default;
74 typedef Prim FragmentBaseType;
75 constexpr size_t getActualFragmentSize() const { return sizeof(Prim) / sizeof(uint32_t); }
78};
79
91template <Primitive Prim, size_t N>
93 constexpr size_t maxSize() const { return N; }
95 static_assert(sizeof(*this) == (sizeof(unsigned) + sizeof(uint32_t) + sizeof(Prim) * N),
96 "Spurious padding in fixed fragment");
97 }
98 explicit FixedFragment(const FixedFragment &) = default;
99 typedef Prim FragmentBaseType;
100 size_t getActualFragmentSize() const { return (sizeof(Prim) * count) / sizeof(uint32_t); }
101 unsigned count = N;
103 eastl::array<Prim, N> primitives;
104};
105
120template <Primitive P, Primitive Prim, size_t N>
122 constexpr size_t maxSize() const { return N; }
124 static_assert(sizeof(*this) == (sizeof(unsigned) + sizeof(uint32_t) + sizeof(P) + sizeof(Prim) * N),
125 "Spurious padding in fixed fragment");
126 }
128 typedef Prim FragmentBaseType;
129 size_t getActualFragmentSize() const { return (sizeof(P) + sizeof(Prim) * count) / sizeof(uint32_t); }
130 unsigned count = N;
133 eastl::array<Prim, N> primitives;
134};
135
136} // namespace Fragments
137
138} // namespace psyqo
Definition cdrom-loader.hh:39
A maximum fixed sized fragment of similar primitives.
Definition fragments.hh:121
size_t getActualFragmentSize() const
Definition fragments.hh:129
FixedFragmentWithPrologue(const FixedFragmentWithPrologue &)=default
FixedFragmentWithPrologue()
Definition fragments.hh:123
uint32_t head
Definition fragments.hh:131
unsigned count
Definition fragments.hh:130
eastl::array< Prim, N > primitives
Definition fragments.hh:133
P prologue
Definition fragments.hh:132
Prim FragmentBaseType
Definition fragments.hh:128
constexpr size_t maxSize() const
Definition fragments.hh:122
A maximum fixed sized fragment of similar primitives.
Definition fragments.hh:92
FixedFragment()
Definition fragments.hh:94
FixedFragment(const FixedFragment &)=default
constexpr size_t maxSize() const
Definition fragments.hh:93
size_t getActualFragmentSize() const
Definition fragments.hh:100
eastl::array< Prim, N > primitives
Definition fragments.hh:103
Prim FragmentBaseType
Definition fragments.hh:99
unsigned count
Definition fragments.hh:101
uint32_t head
Definition fragments.hh:102
A fragment containing a single primitive.
Definition fragments.hh:67
Prim primitive
Definition fragments.hh:77
uint32_t head
Definition fragments.hh:76
constexpr size_t getActualFragmentSize() const
Definition fragments.hh:75
SimpleFragment(Args &&...args)
Definition fragments.hh:70
SimpleFragment(const SimpleFragment &)=default
constexpr size_t maxSize() const
Definition fragments.hh:68
Prim FragmentBaseType
Definition fragments.hh:74
void uint32_t(classId, spec)