1

I'm creating a DirectX application with native C++ and using C++/CLI to facilitate IPC with a C# application.

However, when it comes to building the entire solution; I'm confused about how to make the system work for x86 and x64 CPU architectures, whilst still maintaining as high-performance as possible.

I'm wary of (and want to avoid) any sort of emulation (e.g. WoW32/64).

Of course, I can compile the C# projects using AnyCPU. But then what do I compile the C++ output as?

Do I just compile two separate builds; one for x86 and one for x64?

Thank you

Xenoprimate
  • 7,691
  • 15
  • 58
  • 95
  • WoW is not emulation. x86-64 is not emulation. Of course, there still might be a performance degradation or limitation running 32-bit code with 64-bit DirectX drivers. (IA-64 does emulate x86. Perhaps that's why it's not used anymore.) – Tom Blodget Aug 11 '13 at 19:25

1 Answers1

3

You should do 2 separate builds.

AnyCPU means that the managed code will execute as 32bit on a 32bit architecture, and 64bit on a 64 one (the JIT takes care of it). see here: What does the Visual Studio "Any CPU" target mean?

But since you have unmanaged code, you'll need to have 2 distincts dlls for the 32bit version and the 64 one of it. So unless you choose the unmanaged dll to load and the wrapper to use at runtime by detecting which architecture it is indeed (and I'm not sure you can actually), you'll need to make 2 separate builds.

Community
  • 1
  • 1
ppetrov
  • 3,077
  • 2
  • 15
  • 27
  • 1
    To clarify, (as stated in the accepted answer to the linked question) AnyCPU means the assembly can be loaded in a 32-bit or a 64-bit *process*. So on X64 Windows, it can execute as either 32-bit or 64-bit code. When creating a process from an AnyCPU assembly, X64 Windows naturally creates a 64-bit process. – Tom Blodget Aug 11 '13 at 19:18
  • +1 Yep just done this. Created two unmanaged C++/CLI DLLs and installed into the GAC. The C# project then loads the right one dynamically at runtime – Dr. Andrew Burnett-Thompson Sep 16 '13 at 20:32