Game Development Community

64bit Support

by James Urquhart · in Torque 2D Professional · 02/07/2013 (2:41 pm) · 12 replies

Hi all,

For anyone interested I have some fixes which allow Torque2D to be built for 64bit platforms, specifically 64bit OSX (and likely Linux too if you can get it to compile). 32bit Windows & OSX builds still work as normal. The fork is located here:

https://github.com/jamesu/Torque2D/tree/sixtyfoursupport

The biggest problem was that I had to modify the script compiler and interpreter so it reserved 2 spaces in the opcode list for StringTable entries. Thankfully from what I can tell everything still seems to be working. An alternate method would have been to just expand the codestream to use 64bit opcodes, but this would have essentially doubled the size of a typical compiled script for no good reason.

I also had to change the use of the va_list parameter in dVprintf and dVsprintf, since it seems the 64bit compiler in OSX doesn't like casting pointers to va_lists. In addition I introduced a ThreadIdent type for thread ids since on 64bit OSX systems "pthread_self" will return a 64bit pointer. Finally of course some of the hash functions had to be altered.

UPDATE: 64bit windows is now supported too, provided you add the x64 platform to the project file.

18-Mar-03: This has been turned into a pull request ( https://github.com/GarageGames/Torque2D/pull/46 )

Have fun!

#1
02/07/2013 (8:50 pm)
Very nice contribution James. Hopefully some others can jump in and help vet the Windows side of this. If it checks out, a pull request might be in order. Thanks for joining the collaboration =)
#2
02/07/2013 (8:53 pm)
@James is a genius!

Good work!
#3
02/08/2013 (2:52 am)
Nice work James!
#4
02/09/2013 (6:29 am)
I've updated the code to support compilation for 64bit windows using visual studio.

Firstly, if you are using Visual Studio Express and you need to compile 64bit code, these links might point you in the right direction:

http://stackoverflow.com/questions/1865069/how-to-compile-a-64-bit-application-using-visual-c-2010-express
http://social.msdn.microsoft.com/Forums/en-US/Vsexpressinstall/thread/9ec96544-0b7d-4b0b-8eca-dffb30a385be/

Since the VS solution hasn't been updated, you'll need to manually modify it as follows:

- Change the platform to "x64"
- Remove unicows.lib from the linker libs
- Exclude the following from the build:
  • math/mMath_ASM.asm
  • math/mMathAMD_ASM.asm
  • math/mMathSSE_ASM.asm
  • platform/platformCPUInfo.asm

The only serious problem is for some bizarre reason libpng causes a crash when loading PNGs. If you disable the PNG loader Torque2D otherwise appears to work fine.
#5
02/09/2013 (7:24 am)
I've managed to fix PNG loading. I have no idea why, but libpng on 64bit windows doesn't like loading PNGs using memory allocated by the frame allocator, so for now I've added a simple ifdef hack to use malloc/free on windows.
#6
02/09/2013 (12:48 pm)
This looks like its worth a try, when I have got threw the stacks of stuff I'm accumulating while I try get rid of pnemonia I'll have a play with this x64 build, thanks James :-)
#7
02/13/2013 (3:48 pm)
@James - Awesome!
#8
02/15/2013 (9:42 am)
keep up the good work James
#9
02/26/2013 (12:22 pm)
Dude you rock!
#10
03/17/2013 (5:02 pm)
After much delay, I turned this into a pull request with an added visual studio 2010 project ( https://github.com/GarageGames/Torque2D/pull/46 )
#11
05/02/2013 (8:40 am)
Thanks @James.

This contribution has been saved as a branch in the main repo. One can see it here:

github.com/GarageGames/Torque2D/tree/sixtyfoursupport

If everyone interested can do me a favor and experiment with this branch, then report back here, we'll know it's vetted well and can be merged into development then master! This includes Mac/PC and even this branch under iOS.

Thanks!



#12
05/07/2013 (9:18 pm)
Can I get a couple of people to test this branch out? Basically just use it as a base like you would "master" to see if it vets out well.