diff --git a/build_scripts/build_usd.py b/build_scripts/build_usd.py index 6d4e8feb05..0627c97c88 100644 --- a/build_scripts/build_usd.py +++ b/build_scripts/build_usd.py @@ -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'): + generator = generator + " -A arm64" + else: + generator = generator + " -A x64" toolset = context.cmakeToolset if toolset is not None: diff --git a/pxr/base/arch/defines.h b/pxr/base/arch/defines.h index 021dd28cf5..84fb13152d 100644 --- a/pxr/base/arch/defines.h +++ b/pxr/base/arch/defines.h @@ -35,7 +35,8 @@ #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 @@ -43,7 +44,8 @@ // 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." diff --git a/pxr/base/arch/timing.h b/pxr/base/arch/timing.h index d5e71f128c..baa69e448c 100644 --- a/pxr/base/arch/timing.h +++ b/pxr/base/arch/timing.h @@ -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 + result = _ReadStatusReg(0x5F02); + #else __asm __volatile("mrs %0, CNTVCT_EL0" : "=&r" (result)); + #endif return result; #else #error Unknown architecture. @@ -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); @@ -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);