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

Fix ambigous PxComputeHash on webassembly #38

Open
wants to merge 1 commit into
base: release/104.0
Choose a base branch
from

Conversation

karjonas
Copy link

Compiling with webassembly I get the following error:

In file included from /home/qt/work/qt/qtquick3dphysics/src/3rdparty/PhysX/source/physxextensions/src/ExtMetaData.cpp:41:
In file included from /home/qt/work/qt/qtquick3dphysics/src/3rdparty/PhysX/source/physxextensions/src/serialization/SnSerializationRegistry.h:36:
In file included from /home/qt/work/qt/qtquick3dphysics/src/3rdparty/PhysX/include/foundation/PxHashMap.h:32:
In file included from /home/qt/work/qt/qtquick3dphysics/src/3rdparty/PhysX/include/foundation/PxHashInternals.h:36:
/home/qt/work/qt/qtquick3dphysics/src/3rdparty/PhysX/include/foundation/PxHash.h:127:10: error: call to 'PxComputeHash' is ambiguous

2077: /home/qt/work/qt/qtquick3dphysics/src/3rdparty/PhysX/include/foundation/PxHash.h:57:26: note: candidate function
PX_FORCE_INLINE uint32_t PxComputeHash(const uint32_t key)
                         ^
/home/qt/work/qt/qtquick3dphysics/src/3rdparty/PhysX/include/foundation/PxHash.h:69:26: note: candidate function
PX_FORCE_INLINE uint32_t PxComputeHash(const int32_t key)
                         ^
/home/qt/work/qt/qtquick3dphysics/src/3rdparty/PhysX/include/foundation/PxHash.h:76:26: note: candidate function
PX_FORCE_INLINE uint32_t PxComputeHash(const uint64_t key)
                         ^

I think this relates to the fact that webassembly integers are neither signed nor unsigned, see https://webassembly.github.io/spec/core/syntax/types.html

Anyhow, the fix is to simply use a template which look at the size of the type being hashed. This should work for both numbers and pointers. Note that this requires c++17.

@CLAassistant
Copy link

CLAassistant commented Nov 22, 2022

CLA assistant check
All committers have signed the CLA.

@karjonas
Copy link
Author

I updated this to a c++11 solution now since that is what is used for PhysX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants