Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
73d58256
Commit
73d58256
authored
2 years ago
by
Rye Mutt
Browse files
Options
Downloads
Patches
Plain Diff
Introduce memory pooling into octree
parent
21ff0bb5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/llmath/lloctree.h
+77
-0
77 additions, 0 deletions
indra/llmath/lloctree.h
with
77 additions
and
0 deletions
indra/llmath/lloctree.h
+
77
−
0
View file @
73d58256
...
...
@@ -31,6 +31,8 @@
#include
"v3math.h"
#include
"llvector4a.h"
#include
<vector>
#include
"fix_macros.h"
#include
<boost/pool/pool.hpp>
#define OCT_ERRS LL_WARNS("OctreeErrors")
...
...
@@ -45,6 +47,10 @@ extern float gOctreeMinSize;
#define LL_OCTREE_MAX_CAPACITY 128
#endif*/
#if !LL_DEBUG
#define LL_OCTREE_POOLS 1
#endif
template
<
class
T
>
class
LLOctreeNode
;
template
<
class
T
>
...
...
@@ -93,6 +99,40 @@ class LLOctreeNode : public LLTreeNode<T>
typedef
LLOctreeNode
<
T
>
oct_node
;
typedef
LLOctreeListener
<
T
>
oct_listener
;
#if LL_OCTREE_POOLS
struct
octree_pool_alloc
{
typedef
std
::
size_t
size_type
;
typedef
std
::
ptrdiff_t
difference_type
;
static
char
*
malloc
(
const
size_type
bytes
)
{
return
(
char
*
)
ll_aligned_malloc_16
(
bytes
);
}
static
void
free
(
char
*
const
block
)
{
ll_aligned_free_16
(
block
);
}
};
static
boost
::
pool
<
octree_pool_alloc
>&
getPool
(
const
std
::
size_t
&
size
)
{
static
boost
::
pool
<
octree_pool_alloc
>
sPool
((
std
::
size_t
)
LL_NEXT_ALIGNED_ADDRESS
((
char
*
)
size
),
1200
);
llassert_always
((
std
::
size_t
)
LL_NEXT_ALIGNED_ADDRESS
((
char
*
)
size
)
==
sPool
.
get_requested_size
());
return
sPool
;
}
void
*
operator
new
(
size_t
size
)
{
return
getPool
(
size
).
malloc
();
}
void
*
operator
new
[](
size_t
size
)
{
return
getPool
(
size
).
malloc
();
}
void
operator
delete
(
void
*
ptr
)
{
getPool
(
sizeof
(
LLOctreeNode
<
T
>
)).
free
(
ptr
);
}
void
operator
delete
[](
void
*
ptr
)
{
getPool
(
sizeof
(
LLOctreeNode
<
T
>
)).
free
(
ptr
);
}
#else
void
*
operator
new
(
size_t
size
)
{
return
ll_aligned_malloc_16
(
size
);
...
...
@@ -102,6 +142,7 @@ class LLOctreeNode : public LLTreeNode<T>
{
ll_aligned_free_16
(
ptr
);
}
#endif
LLOctreeNode
(
const
LLVector4a
&
center
,
const
LLVector4a
&
size
,
...
...
@@ -676,6 +717,42 @@ class LLOctreeRoot : public LLOctreeNode<T>
:
BaseType
(
center
,
size
,
parent
)
{
}
#if LL_OCTREE_POOLS
void
*
operator
new
(
size_t
size
)
{
return
LLOctreeNode
<
T
>::
getPool
(
size
).
malloc
();
}
void
*
operator
new
[](
size_t
size
)
{
return
LLOctreeNode
<
T
>::
getPool
(
size
).
malloc
();
}
void
operator
delete
(
void
*
ptr
)
{
LLOctreeNode
<
T
>::
getPool
(
sizeof
(
LLOctreeNode
<
T
>
)).
free
(
ptr
);
}
void
operator
delete
[](
void
*
ptr
)
{
LLOctreeNode
<
T
>::
getPool
(
sizeof
(
LLOctreeNode
<
T
>
)).
free
(
ptr
);
}
#else
void
*
operator
new
(
size_t
size
)
{
return
ll_aligned_malloc_16
(
size
);
}
void
*
operator
new
[](
size_t
size
)
{
return
ll_aligned_malloc_16
(
size
);
}
void
operator
delete
(
void
*
ptr
)
{
ll_aligned_free_16
(
ptr
);
}
void
operator
delete
[](
void
*
ptr
)
{
ll_aligned_free_16
(
ptr
);
}
#endif
bool
balance
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment