Torque 3D DirectX11 Port - DirectX 9 refactor
by Lopuska · in Torque 3D Professional · 03/11/2014 (6:23 pm) · 81 replies
Hi everybody!
I'm Lopuska, I'm from Italy.
I'm taking some of my time to try a conversion of Torque3D from DirectX9 to DirectX11.
This is my current status, there's still a lot of work to do...
I don't have many times in this period, if anyone would like to help me for this big task it would be great!
Before that, I've done a lot of code refactoring on D3D9 layer, also to make porting to D3D11 easier.
Here there are change list about DirectX9 refactoring:
- Better *.cpp organization / code cleaning
- Removed D3DX calls dependencies. (deprecated by Microsoft)
- Removed D3D9 XBOX360 old reference.
- Shader/Constant buffer refactor with a custom parser.
- gfxD3D9Shader total refactor.
- Mipmap autogen fixes
- Minor fixes under cubemap
- Speed improved on texture loading
- Removed 24bit format (deprecated since DX10) (i convert it to 32bit)
There is a better explanation about it on code as comment.
- Some performance improvement (especially under a lot of dynamic_cast used in wrong context)
- Removed fixed pipeline (deprecated by Microsoft since DX10)
- Many other minor bug fixed.
With this patch, you don't need DirectX SDK installed anymore. It's deprecated as well. You just need Visual Studio with its windows SDK.
Everything is inside d3d9.h/d3dcompiler.h -> d3d9.lib/d3dcompiler.lib
So, to try this patch, remove from linker input d3dx9.lib and dxerr.lib and DX_SDK includes to avoid conflicts and errors during compile/link.
(You can also remove d3d9.lib input linker because since this is Microsoft specific code, I've included it from #pragma directive inside *.cpp)
To remove fixed pipeline, I've used the same method used by Luis Anton Rebollo.
So if the community want to merge this part of code with Luis' work, it will be very easy because from high-level GFX layer you just need to make the same calls that Luis already do for OpenGL.
With the actual DirectX9 implementation, the situation should be:
//from precipitation.cpp
if(RenderDevice == OpenGL) //ugly!
GFX->setupGenericShaders(GFXDevice::GSTexture);
else if(RenderDevice == Direct3D9)
GFX->disableShaders();
With this Patch we have just:
GFX->setupGenericShaders(GFXDevice::GSTexture); //Now also DirectX use shaders without FFP
The main branch is:
https://github.com/Lopuska/Torque3D/tree/D3D9_D3D11_R%26D
For DirectX11 situation, I'll start a new thread.
byee!
Lopuska
I'm Lopuska, I'm from Italy.
I'm taking some of my time to try a conversion of Torque3D from DirectX9 to DirectX11.
This is my current status, there's still a lot of work to do...
I don't have many times in this period, if anyone would like to help me for this big task it would be great!
Before that, I've done a lot of code refactoring on D3D9 layer, also to make porting to D3D11 easier.
Here there are change list about DirectX9 refactoring:
- Better *.cpp organization / code cleaning
- Removed D3DX calls dependencies. (deprecated by Microsoft)
- Removed D3D9 XBOX360 old reference.
- Shader/Constant buffer refactor with a custom parser.
- gfxD3D9Shader total refactor.
- Mipmap autogen fixes
- Minor fixes under cubemap
- Speed improved on texture loading
- Removed 24bit format (deprecated since DX10) (i convert it to 32bit)
There is a better explanation about it on code as comment.
- Some performance improvement (especially under a lot of dynamic_cast used in wrong context)
- Removed fixed pipeline (deprecated by Microsoft since DX10)
- Many other minor bug fixed.
With this patch, you don't need DirectX SDK installed anymore. It's deprecated as well. You just need Visual Studio with its windows SDK.
Everything is inside d3d9.h/d3dcompiler.h -> d3d9.lib/d3dcompiler.lib
So, to try this patch, remove from linker input d3dx9.lib and dxerr.lib and DX_SDK includes to avoid conflicts and errors during compile/link.
(You can also remove d3d9.lib input linker because since this is Microsoft specific code, I've included it from #pragma directive inside *.cpp)
To remove fixed pipeline, I've used the same method used by Luis Anton Rebollo.
So if the community want to merge this part of code with Luis' work, it will be very easy because from high-level GFX layer you just need to make the same calls that Luis already do for OpenGL.
With the actual DirectX9 implementation, the situation should be:
//from precipitation.cpp
if(RenderDevice == OpenGL) //ugly!
GFX->setupGenericShaders(GFXDevice::GSTexture);
else if(RenderDevice == Direct3D9)
GFX->disableShaders();
With this Patch we have just:
GFX->setupGenericShaders(GFXDevice::GSTexture); //Now also DirectX use shaders without FFP
The main branch is:
https://github.com/Lopuska/Torque3D/tree/D3D9_D3D11_R%26D
For DirectX11 situation, I'll start a new thread.
byee!
Lopuska
#2
Jeff
03/11/2014 (7:04 pm)
This is awesome news, mind making a github branch so that way commits can be just posted there instead of using dropbox, as it also has an issue tracker as well? :)Jeff
#3
I'm on board to assist in whatever ways I can. I'll get the patch into a branch on github asap.
03/11/2014 (7:22 pm)
Oh wow, this is amazing. I just started working on a DX11 port this morning. I haven't even begun to come close to what you've accomplished already. I'm on board to assist in whatever ways I can. I'll get the patch into a branch on github asap.
#4
I didn't have much time to debug it, maybe I missed something. I'll take another look at it tomorrow.
03/11/2014 (11:28 pm)
I just got a chance to try it. I followed your instructions but I get following error:Quote:
gfxd3d9shader.cpp(779): error C3861: 'D3DCompileFromFile': identifier not found
I didn't have much time to debug it, maybe I missed something. I'll take another look at it tomorrow.
#5
@Andrew:
D3DCompileFromFile it's a D3D call defined in d3dcompiler.h
I'm sure that it's a conflict between DirectX SDK and Windows SDK.
Try to do this:
Go to your DirectX SDK root folder:
For me it's: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)
Just rename the folder adding in front of it a underscore:
C:\Program Files (x86)\_Microsoft DirectX SDK (June 2010)
Try to compile (:
This is just to understand if without DirectX SDK installed it works.
So, doing that you force Visual Studio to use Windows SDK.
NOTE:
Doing that, you'll have other errors during compile of XAUDIO2 backend implementation inside Torque3D.
This is because now, you are using XAUDIO 2.8 (instead of 2.7 of DirectX SDK). (there is some little difference between the two version)
Meanwhile, just remove "sfx/xaudio" from Visual Studio filter solution and use dsound or openal backends.
I've already finished to port Torque3D to the new XAUDIO 2.8. This evening, I'll publish also this patch. :)
03/12/2014 (2:52 am)
Thanks all for your kind words (:@Andrew:
D3DCompileFromFile it's a D3D call defined in d3dcompiler.h
I'm sure that it's a conflict between DirectX SDK and Windows SDK.
Try to do this:
Go to your DirectX SDK root folder:
For me it's: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)
Just rename the folder adding in front of it a underscore:
C:\Program Files (x86)\_Microsoft DirectX SDK (June 2010)
Try to compile (:
This is just to understand if without DirectX SDK installed it works.
So, doing that you force Visual Studio to use Windows SDK.
NOTE:
Doing that, you'll have other errors during compile of XAUDIO2 backend implementation inside Torque3D.
This is because now, you are using XAUDIO 2.8 (instead of 2.7 of DirectX SDK). (there is some little difference between the two version)
Meanwhile, just remove "sfx/xaudio" from Visual Studio filter solution and use dsound or openal backends.
I've already finished to port Torque3D to the new XAUDIO 2.8. This evening, I'll publish also this patch. :)
#6
Keep up the good work :-)
Definitely someone get a git patch going on-line.
03/12/2014 (3:29 am)
@AnisKeep up the good work :-)
Definitely someone get a git patch going on-line.
#8
As of Windows 8 the directx sdk is included in the windows sdk, however what about windows 7? When I was working on dx11 yesterday I was using the same directx sdk folder (june 2010), only I changed the libs it was looking for and everything seemed to work fine, leading me to believe the files it needs are within the june 2010 sdk. With that said, I checked the header and there's no definition for that function so obviously I'm using some sort of out of date version.
03/12/2014 (10:47 am)
If I rename the folder for the DX SDK then it can't find d3dcompiler.h. I checked the windows 7 sdk folder and d3dcompiler.h is not in there.As of Windows 8 the directx sdk is included in the windows sdk, however what about windows 7? When I was working on dx11 yesterday I was using the same directx sdk folder (june 2010), only I changed the libs it was looking for and everything seemed to work fine, leading me to believe the files it needs are within the june 2010 sdk. With that said, I checked the header and there's no definition for that function so obviously I'm using some sort of out of date version.
#9
DX SDK(June 2010)does indeed include d3dcompiler.h. It doesn't,however, include D3DCompileFromFile function. You'll need a newer SDK from the windows SDK for windows 8.
Edit: Also, if you have visual studio 2012 or 2013(not sure about the express editions) it should have installed the windows 8 sdk with it.
03/12/2014 (2:04 pm)
@Andrew DX SDK(June 2010)does indeed include d3dcompiler.h. It doesn't,however, include D3DCompileFromFile function. You'll need a newer SDK from the windows SDK for windows 8.
Edit: Also, if you have visual studio 2012 or 2013(not sure about the express editions) it should have installed the windows 8 sdk with it.
#10
What about visual C++, or even visual studio express 2013 for windows desktop?
I really would like to give things a try but don't have the money (right now) to upgrade to a visual studio 2012 license.
03/12/2014 (2:31 pm)
ah, so you must have visual studio 2012 or up to compile?What about visual C++, or even visual studio express 2013 for windows desktop?
I really would like to give things a try but don't have the money (right now) to upgrade to a visual studio 2012 license.
#11
No, you should be able to use visual studio 2010 as well. You just have to download the windows 8 sdk separately and add the necessary includes and libraries to your project configuration.
03/12/2014 (2:51 pm)
@KoryNo, you should be able to use visual studio 2010 as well. You just have to download the windows 8 sdk separately and add the necessary includes and libraries to your project configuration.
#12
03/12/2014 (3:00 pm)
@ZeroFault thanks for the info in case I decide to give this a try sometime soon.
#13
03/12/2014 (4:52 pm)
VS2013 express should work fine as well.
#14
03/12/2014 (5:19 pm)
With all these changes will you still be able to use an OpenGL version along side it? I understood the abstraction layer in the engine was designed to allow other outputs such as OpenGL if they were written. Since someone is working on that I was hoping they will play nice together.
#15
At this point I figured I'd try upgrading to VS2013. I upgraded the project, merged signmotion's vs2013 fixes, compiled, got the same linker error. Removed all Windows 8 SDK references from before since it's supposed to be built in, same linker error. Added libcpmtd as an ignored lib, and that just led to the following missing libs: comsuppw, OLDNAMES, LIBCMTD.
And now it's 2 am and I'm going to bed haha. That's enough for one night.
03/12/2014 (10:03 pm)
No luck getting it to compile as of yet. I removed all old lib references you mentioned, removed all DXSDK includes/library. I installed Windows 8 SDK and replaced it with proper paths I found in a Windows 8 SDK + VS2010 tutorial. That's when I got the linker error missing libcpmtd.lib. At this point I figured I'd try upgrading to VS2013. I upgraded the project, merged signmotion's vs2013 fixes, compiled, got the same linker error. Removed all Windows 8 SDK references from before since it's supposed to be built in, same linker error. Added libcpmtd as an ignored lib, and that just led to the following missing libs: comsuppw, OLDNAMES, LIBCMTD.
And now it's 2 am and I'm going to bed haha. That's enough for one night.
#16
I've downloaded and install it over night and now should be ready to go but I figured I'd stop here before messing with anything..
but seeing Andrew last post, maybe I should hold on a little bit until it's reported that someone has gotten it set up right to compile. That way I could have someone coach me in the right area :)
03/13/2014 (5:26 am)
What about the VS2013 for desktop? I'm assuming it the same thing as VS 2013 express but geared towards desktop apps rather than anything else..I've downloaded and install it over night and now should be ready to go but I figured I'd stop here before messing with anything..
but seeing Andrew last post, maybe I should hold on a little bit until it's reported that someone has gotten it set up right to compile. That way I could have someone coach me in the right area :)
#17
03/13/2014 (6:43 am)
Yes, yes, VS2013 "for desktop". Whatever they're calling their free offering for Windows Desktop Development this year. Yes, it should work - you have to download and install the Windows 8 SDK separately.
#18
The only issue i experience is that brush circle in world editor is not rendered. Can anyone else confirm this or its just me?
03/13/2014 (11:12 am)
Thanks!The only issue i experience is that brush circle in world editor is not rendered. Can anyone else confirm this or its just me?
#19
Mine is rendered, but not in the right place. Its rendering in a place other than where my mouse is pointing.
03/13/2014 (12:03 pm)
@thanasimosMine is rendered, but not in the right place. Its rendering in a place other than where my mouse is pointing.
#20
03/13/2014 (12:08 pm)
What version of visual studio and/or windows are you guys using? Also, what steps did you have to take to prepare the project to work?
Jimmy R Armes
And I'm glad someone is interested in cleaning up direct X pipeline somewhat.