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

Add support for building for Windows ARM64 devices #3430

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion build_scripts/build_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,10 @@ def RunCMake(context, force, extraArgs = None):

# Note - don't want to add -A (architecture flag) if generator is, ie, Ninja
if IsVisualStudio2019OrGreater() and "Visual Studio" in generator:
generator = generator + " -A x64"
if "ARM" in os.environ.get('PROCESSOR_IDENTIFIER'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the platform module be used here?
https://docs.python.org/3/library/platform.html#module-platform

generator = generator + " -A arm64"
else:
generator = generator + " -A x64"

toolset = context.cmakeToolset
if toolset is not None:
Expand Down
6 changes: 4 additions & 2 deletions pxr/base/arch/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@
#if defined(i386) || defined(__i386__) || defined(__x86_64__) || \
defined(_M_IX86) || defined(_M_X64)
#define ARCH_CPU_INTEL
#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM)
#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || \
defined(_M_ARM64)
#define ARCH_CPU_ARM
#endif

//
// Bits
//

#if defined(__x86_64__) || defined(__aarch64__) || defined(_M_X64)
#if defined(__x86_64__) || defined(__aarch64__) || defined(_M_X64) || \
defined(_M_ARM64)
#define ARCH_BITS_64
#else
#error "Unsupported architecture. x86_64 or ARM64 required."
Expand Down
12 changes: 10 additions & 2 deletions pxr/base/arch/timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ ArchGetTickTime()
return __rdtsc();
#elif defined (ARCH_CPU_ARM)
uint64_t result;
#if defined(ARCH_COMPILER_MSVC)
// MSVC does not support inline assembly on ARM64 platforms
// 0x5F02 == ARM64_CNTVCT - manually calculated value avoids <windows.h>
result = _ReadStatusReg(0x5F02);
#else
__asm __volatile("mrs %0, CNTVCT_EL0" : "=&r" (result));
#endif
return result;
#else
#error Unknown architecture.
Expand All @@ -68,7 +74,8 @@ inline uint64_t
ArchGetStartTickTime()
{
uint64_t t;
#if defined (ARCH_OS_DARWIN)
#if defined (ARCH_OS_DARWIN) || \
(defined (ARCH_CPU_ARM) && defined (ARCH_COMPILER_MSVC))
return ArchGetTickTime();
#elif defined (ARCH_CPU_ARM)
std::atomic_signal_fence(std::memory_order_seq_cst);
Expand Down Expand Up @@ -109,7 +116,8 @@ inline uint64_t
ArchGetStopTickTime()
{
uint64_t t;
#if defined (ARCH_OS_DARWIN)
#if defined (ARCH_OS_DARWIN) || \
(defined (ARCH_CPU_ARM) && defined (ARCH_COMPILER_MSVC))
return ArchGetTickTime();
#elif defined (ARCH_CPU_ARM)
std::atomic_signal_fence(std::memory_order_seq_cst);
Expand Down