Nebula
Toggle main menu visibility
Loading...
Searching...
No Matches
round.h
Go to the documentation of this file.
1
#pragma once
2
//------------------------------------------------------------------------------
12
#include "
core/types.h
"
13
14
//------------------------------------------------------------------------------
15
namespace
Util
16
{
17
class
Round
18
{
19
public
:
21
static
uint
RoundUp2
(
uint
val);
23
static
uint
RoundUp4
(
uint
val);
25
static
uint
RoundUp8
(
uint
val);
27
static
uint
RoundUp16
(
uint
val);
29
static
uint
RoundUp32
(
uint
val);
31
static
uint
RoundUp
(
uint
val,
uint
boundary);
32
};
33
34
//------------------------------------------------------------------------------
37
__forceinline
uint
38
Round::RoundUp2
(
uint
val)
39
{
40
return
((
uint
)val + (2 - 1)) & ~(2 - 1);
41
}
42
43
//------------------------------------------------------------------------------
46
__forceinline
uint
47
Round::RoundUp4
(
uint
val)
48
{
49
return
((
uint
)val + (4 - 1)) & ~(4 - 1);
50
}
51
52
//------------------------------------------------------------------------------
55
__forceinline
uint
56
Round::RoundUp8
(
uint
val)
57
{
58
return
((
uint
)val + (8 - 1)) & ~(8 - 1);
59
}
60
61
//------------------------------------------------------------------------------
64
__forceinline
uint
65
Round::RoundUp16
(
uint
val)
66
{
67
return
((
uint
)val + (16 - 1)) & ~(16 - 1);
68
}
69
70
//------------------------------------------------------------------------------
73
__forceinline
uint
74
Round::RoundUp32
(
uint
val)
75
{
76
return
((
uint
)val + (32 - 1)) & ~(32 - 1);
77
}
78
79
//------------------------------------------------------------------------------
82
__forceinline
uint
83
Round::RoundUp
(
uint
val,
uint
boundary)
84
{
85
n_assert
(0 != boundary);
86
return
(((val - 1) / boundary) + 1) * boundary;
87
}
88
89
}
// namespace Util
90
//------------------------------------------------------------------------------
Util::Round
Definition
round.h:18
Util::Round::RoundUp8
static uint RoundUp8(uint val)
round up to nearest 8 bytes boundary
Definition
round.h:56
Util::Round::RoundUp16
static uint RoundUp16(uint val)
round up to nearest 16 bytes boundary
Definition
round.h:65
Util::Round::RoundUp
static uint RoundUp(uint val, uint boundary)
generic roundup
Definition
round.h:83
Util::Round::RoundUp32
static uint RoundUp32(uint val)
round up to nearest 32 bytes boundary
Definition
round.h:74
Util::Round::RoundUp4
static uint RoundUp4(uint val)
round up to nearest 4 bytes boundary
Definition
round.h:47
Util::Round::RoundUp2
static uint RoundUp2(uint val)
round up to nearest 2 bytes boundary
Definition
round.h:38
n_assert
#define n_assert(exp)
Definition
debug.h:50
Util
A quad tree designed to return regions of free 2D space.
Definition
String.cs:6
types.h
uint
unsigned int uint
Definition
types.h:33
code
foundation
util
round.h
Generated on
for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.