Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistent islands #36

Merged
merged 55 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
c00f10c
global parallel toggle
erincatto Apr 9, 2023
7968f3a
union find island builder
erincatto Apr 12, 2023
673fefe
wip
erincatto Apr 14, 2023
f091554
compiles
erincatto Apr 16, 2023
26c0d70
initial test and fixes
erincatto Apr 17, 2023
77cad12
fixes
erincatto Apr 28, 2023
0c20ff0
wip
erincatto Apr 28, 2023
6de6b8e
wip
erincatto Apr 28, 2023
fd72bee
parallel UF working
erincatto Apr 29, 2023
d64f60e
thread-safe presolve callback
erincatto Apr 29, 2023
ae5d93c
wip
erincatto Apr 30, 2023
c2a9d8e
joints working with UF
erincatto Apr 30, 2023
26cf329
fix mutex stall
erincatto Apr 30, 2023
fba1755
CI fix
erincatto Apr 30, 2023
a0e88d1
CI fix
erincatto Apr 30, 2023
6dc7e88
CI fix
erincatto Apr 30, 2023
a51514f
CI fix
erincatto Apr 30, 2023
4463ce1
CI fix
erincatto Apr 30, 2023
0316885
CI fix
erincatto Apr 30, 2023
9c150ec
clean up
erincatto Apr 30, 2023
3afee33
wip
erincatto May 20, 2023
b98fbe8
wip
erincatto May 21, 2023
91a01f3
iterative waking
erincatto May 21, 2023
7a585dc
fix overflow
erincatto May 21, 2023
620ac1f
contact sorting
erincatto May 22, 2023
7798a8d
will std sort help? not much
erincatto May 27, 2023
94e8a82
wip
erincatto May 28, 2023
23c6812
wip
erincatto May 30, 2023
a7740a5
wip
erincatto Jun 9, 2023
ed0e999
wip
erincatto Jun 11, 2023
ced152e
wip
erincatto Jun 12, 2023
df60dca
wip
erincatto Jun 13, 2023
4e8c129
wip
erincatto Jun 15, 2023
26298c7
wip
erincatto Jun 17, 2023
562481a
wip
erincatto Jun 18, 2023
6f5e22d
wip
erincatto Jun 19, 2023
8609af1
wip
erincatto Jun 21, 2023
0e6ff6f
wip
erincatto Jun 23, 2023
803ae74
wip
erincatto Jun 24, 2023
c4e2da1
wip
erincatto Jun 26, 2023
a610f71
wip
erincatto Jun 29, 2023
10bb4b6
wip
erincatto Jun 29, 2023
1e31212
wip
erincatto Jul 2, 2023
6feccf5
wip
erincatto Jul 3, 2023
900859d
wip
erincatto Jul 4, 2023
8a9655a
hook up splitter
erincatto Jul 4, 2023
e142b95
fixes
erincatto Jul 4, 2023
e9e9dbe
fixes
erincatto Jul 5, 2023
a355b4d
bug fixes
erincatto Jul 5, 2023
17ee201
joints in persistent island
erincatto Jul 5, 2023
3b589a5
renamed island struct
erincatto Jul 6, 2023
1e05831
ensure island pool has sufficient capacity for splitter
erincatto Jul 6, 2023
d7c4677
CI fix
erincatto Jul 6, 2023
f6fb853
CI fix
erincatto Jul 6, 2023
5f31422
github MSVC actions has atomics?
erincatto Jul 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip
  • Loading branch information
erincatto committed May 21, 2023
commit b98fbe868524829fb12a7dd23b1ec1378344ec9c
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ set_target_properties(box2d PROPERTIES
)

if (MSVC)
target_compile_options(box2d PRIVATE /W4 /WX /experimental:c11atomics)
# target_compile_options(box2d PRIVATE /W4 /WX)
# target_compile_options(box2d PRIVATE /W4 /WX /experimental:c11atomics)
target_compile_options(box2d PRIVATE /W4 /WX)
else()
target_compile_options(box2d PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
Expand Down
44 changes: 42 additions & 2 deletions src/atomic.inl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,47 @@

#if defined(_MSC_VER) && !defined(__clang__)

//#define WIN32_LEAN_AND_MEAN
//#include <windows.h>
#if 1
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

// Returns the initial value
static inline long atomic_fetch_add_long(volatile long* obj, long val)
{
return InterlockedExchangeAdd(obj, val);
}

// Returns the initial value
static inline long atomic_fetch_sub_long(volatile long* obj, long val)
{
return InterlockedExchangeAdd(obj, -val);
}

// Returns the initial value
static inline long atomic_store_long(volatile long* obj, long val)
{
return InterlockedExchange(obj, val);
}

static inline long atomic_load_long(const volatile long* obj)
{
return *obj;
}

static inline bool atomic_compare_exchange_weak_long(volatile long* obj, long* expected, int32_t desired)
{
long current = InterlockedCompareExchange(obj, desired, *expected);
if (current == *expected)
{
return true;
}

*expected = current;
return false;
}

#else

#include <intrin.h>

// Returns the initial value
Expand Down Expand Up @@ -52,6 +91,7 @@ static inline bool atomic_compare_exchange_weak_long(volatile long* obj, long* e
*expected = current;
return false;
}
#endif

#else

Expand Down
20 changes: 14 additions & 6 deletions src/island_builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,13 @@ void b2FinishIslands(b2IslandBuilder* builder, const int32_t* awakeBodies, int32

void b2ResetIslands(b2IslandBuilder* builder, b2StackAllocator *allocator)
{
b2FreeStackItem(allocator, builder->sortedIslands);
builder->sortedIslands = NULL;
// Some of this stuff is NULL if the time step is zero.

if (builder->sortedIslands != NULL)
{
b2FreeStackItem(allocator, builder->sortedIslands);
builder->sortedIslands = NULL;
}

if (builder->contactIslands != NULL)
{
Expand All @@ -348,10 +353,13 @@ void b2ResetIslands(b2IslandBuilder* builder, b2StackAllocator *allocator)
builder->jointIslands = NULL;
}

b2FreeStackItem(allocator, builder->bodyIslandEnds);
builder->bodyIslandEnds = NULL;
b2FreeStackItem(allocator, builder->bodyIslands);
builder->bodyIslands = NULL;
if (builder->bodyIslands != NULL)
{
b2FreeStackItem(allocator, builder->bodyIslandEnds);
builder->bodyIslandEnds = NULL;
b2FreeStackItem(allocator, builder->bodyIslands);
builder->bodyIslands = NULL;
}

b2FreeStackItem(allocator, builder->contactLinks);
builder->contactLinks = NULL;
Expand Down
Loading