From 8e358fb31f74313411876a5e1258ef5283738217 Mon Sep 17 00:00:00 2001 From: bloeys Date: Wed, 7 Dec 2022 01:45:28 +0400 Subject: [PATCH] Correct DefaultCpuDispatcherCreate --- main.go | 2 +- pgo/libs/libphysx-c.a | Bin 23772 -> 23772 bytes pgo/pgo.go | 19 +++++++++++++++++-- pgo/physx-c/CPxDefaultCpuDispatcher.h | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index c607895..3a261b1 100755 --- a/main.go +++ b/main.go @@ -36,7 +36,7 @@ func main() { sd := pgo.NewSceneDesc(ts) sd.SetGravity(pgo.NewVec3(0, -9.8, 0)) - sd.SetCpuDispatcher(pgo.DefaultCpuDispatcherCreate(2, 0).ToCpuDispatcher()) + sd.SetCpuDispatcher(pgo.DefaultCpuDispatcherCreate(2, nil).ToCpuDispatcher()) sd.SetOnContactCallback(contactHandler) scene := p.CreateScene(sd) diff --git a/pgo/libs/libphysx-c.a b/pgo/libs/libphysx-c.a index 15a092aead78d80d7af7914e58e1a8328a4136de..257a945c948451c739e7b70fbfd75c0bd7d290ad 100755 GIT binary patch delta 103 zcmcb!lkv_@#tn7)oJT&3edcClVBna%(NKEwBK--BhbEgEX-tkbFaoj;7)wuHY4D## y)4t{TpUh+o(W){z)`){~=jH>(GMWHF3@6wC diff --git a/pgo/pgo.go b/pgo/pgo.go index 53a4f94..0d01896 100755 --- a/pgo/pgo.go +++ b/pgo/pgo.go @@ -362,9 +362,24 @@ func (d *DefaultCpuDispatcher) ToCpuDispatcher() *CpuDispatcher { return &CpuDispatcher{cCpuDisp: (*C.struct_CPxCpuDispatcher)(d.cDefCpuDisp)} } -func DefaultCpuDispatcherCreate(numThreads, affinityMasks uint32) *DefaultCpuDispatcher { +// DefaultCpuDispatcherCreate sets the number of threads used by physX. +// If affinityMasksPerThread is nil/zero then default masks are used, otherwise the size of the array +// must match the number of threads +func DefaultCpuDispatcherCreate(numThreads uint32, affinityMasksPerThread []uint32) *DefaultCpuDispatcher { + + if len(affinityMasksPerThread) == 0 { + return &DefaultCpuDispatcher{ + cDefCpuDisp: C.CPxDefaultCpuDispatcherCreate(C.uint(numThreads), nil), + } + } + + arr := make([]C.uint, len(affinityMasksPerThread)) + for i := 0; i < len(arr); i++ { + arr[i] = C.uint(affinityMasksPerThread[i]) + } + return &DefaultCpuDispatcher{ - cDefCpuDisp: C.CPxDefaultCpuDispatcherCreate(C.uint(numThreads), C.uint(affinityMasks)), + cDefCpuDisp: C.CPxDefaultCpuDispatcherCreate(C.uint(numThreads), &arr[0]), } } diff --git a/pgo/physx-c/CPxDefaultCpuDispatcher.h b/pgo/physx-c/CPxDefaultCpuDispatcher.h index 4a161e1..be7f913 100755 --- a/pgo/physx-c/CPxDefaultCpuDispatcher.h +++ b/pgo/physx-c/CPxDefaultCpuDispatcher.h @@ -11,7 +11,7 @@ extern "C" { void* obj; }; - CPxAPI CSTRUCT CPxDefaultCpuDispatcher* CPxDefaultCpuDispatcherCreate(CPxU32 numThreads, CPxU32 affinityMasks); + CPxAPI CSTRUCT CPxDefaultCpuDispatcher* CPxDefaultCpuDispatcherCreate(CPxU32 numThreads, CPxU32* affinityMasks); CPxAPI CSTRUCT CPxCpuDispatcher* CPxDefaultCpuDispatcher_toCPxCpuDispatcher(CSTRUCT CPxDefaultCpuDispatcher* cdcd); CPxAPI void CPxDefaultCpuDispatcher_release(CSTRUCT CPxDefaultCpuDispatcher* cdcd);