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
#62
Yes, I've removed trianglefan, but still in my local harddisk. Unfortunately my new PC will be arrive next week (I've bought a new one) then I can push new updates to avoid trianglefan ;)
04/18/2014 (11:56 am)
Hi ZeroFault,Yes, I've removed trianglefan, but still in my local harddisk. Unfortunately my new PC will be arrive next week (I've bought a new one) then I can push new updates to avoid trianglefan ;)
#63
https://github.com/Lopuska/Torque3D/tree/trianglefanavoid
05/06/2014 (3:02 pm)
Ok, Here there are the new branch with only the changes for trianglefan drawcall avoidance.https://github.com/Lopuska/Torque3D/tree/trianglefanavoid
#64
I will add it to the Linux/OpenGL branch, when I have time.
05/06/2014 (3:05 pm)
@Anis, thx for your work :DI will add it to the Linux/OpenGL branch, when I have time.
#66
My main branch now will be:
https://github.com/Lopuska/Torque3D/tree/D3D9_D3D11_R%26D
05/06/2014 (4:03 pm)
Quick note: for reasons of convenience, I've made a personal branch; so I can easily make other experiments with more flexibility.My main branch now will be:
https://github.com/Lopuska/Torque3D/tree/D3D9_D3D11_R%26D
#67
Take into account that mobile devices must load precompiled shaders.
Therefore ShaderGen will be used for PCs only.
Bake hlsl into cso and call CreatePixelShader() and PSSetShader() after that.
05/09/2014 (4:59 am)
Good work!Take into account that mobile devices must load precompiled shaders.
Therefore ShaderGen will be used for PCs only.
Bake hlsl into cso and call CreatePixelShader() and PSSetShader() after that.
#68
05/10/2014 (12:49 pm)
Will it be possible to convert this to DirectX for mobile (Windows Phone)? Or has Anis ended the project?
#69
05/18/2014 (10:19 am)
It seems that there is an issue with GuiColorPicker. The big square color picker control is only showing some kind of red-ish color, no matter what color you select in the range control.
#70
Which branch have you used? This bug is already known by me and Luis.
It should be fixed really soon. It comes from the OpenGL code changes!
@raa:
Yes of course, with just some changes in effects part. (You cannot use shaders that are not compiled offline and you cannot use some win32/dx11 functions except for debugging purpose.
05/18/2014 (10:26 am)
@Richard:Which branch have you used? This bug is already known by me and Luis.
It should be fixed really soon. It comes from the OpenGL code changes!
@raa:
Yes of course, with just some changes in effects part. (You cannot use shaders that are not compiled offline and you cannot use some win32/dx11 functions except for debugging purpose.
#71
Of course this is a bit of a moot point for stock T3D which doesn't support non-square matrices. But it did trip me up a bit so I figured I'd note it here ;)
05/18/2014 (10:39 am)
Just a note @Anis, in :: _getShaderConstants the code you are using to determine the type of matrix constants relies on the register count to determine if its a 3x3 or 4x4 matrix. However for non-square matrices this won't work properly - instead Rows and Columns should be checked to emit the correct type.Of course this is a bit of a moot point for stock T3D which doesn't support non-square matrices. But it did trip me up a bit so I figured I'd note it here ;)
#72
05/18/2014 (10:42 am)
Thanks James! I've noted that. (:
#73
I've downloaded it 9th of May from your branch at github.com/Lopuska/Torque3D/tree/D3D9_D3D11_R%26D.
It seems that I have to be patient then. I just stumbled upon it.
Good luck with this and thanks for all the work you allready done.
05/18/2014 (11:07 am)
@Anis:I've downloaded it 9th of May from your branch at github.com/Lopuska/Torque3D/tree/D3D9_D3D11_R%26D.
Quote:It should be fixed really soon
It seems that I have to be patient then. I just stumbled upon it.
Good luck with this and thanks for all the work you allready done.
#74
05/18/2014 (11:11 am)
Quote:https://github.com/Lopuska/Torque3D/tree/trianglefanavoidI can confirm that the first commit seems to work there. At least with a nextgen derivation rolling in the latest beamng alterations. Haven't had time to go through the same steps to check against a 3.5.1 version. What's the likelihood of a clean version busting things? (or would you consider that premature?)
#75
05/18/2014 (3:16 pm)
Az, if you're already working against 3.5, 3.5.1 should be a breeze. There were only like 3 commits in 3.5.1 and they were minor gameplay-related changes.
#76
This end, looking at Nextgen plus maybe a months worth of additional tracking of the dx9 refactor and up to date opengl one before the two codebases diverged enough I couldn't keep up with both and had to make a call which to pay more attention to for the day to day codebase I'm working off of. Hence the qualified statement that it works this end, and the inquiry about whether it'd be desirable to roll in at least the conversions of trianglefan to trinanglelist if not necessarily the deprecation so that there are fewer points of divergeance, or whether that would be something to put off till later.
05/18/2014 (3:26 pm)
@Daniel: Not even close to 3.5.1 anymore when it comes to the GFX layer with the tracking of the beamng, and the partial dx9 refactor rolled together. This end, looking at Nextgen plus maybe a months worth of additional tracking of the dx9 refactor and up to date opengl one before the two codebases diverged enough I couldn't keep up with both and had to make a call which to pay more attention to for the day to day codebase I'm working off of. Hence the qualified statement that it works this end, and the inquiry about whether it'd be desirable to roll in at least the conversions of trianglefan to trinanglelist if not necessarily the deprecation so that there are fewer points of divergeance, or whether that would be something to put off till later.
#77
05/18/2014 (9:03 pm)
Oh right, sorry, I misunderstood what you were trying to do. I thought you wanted to merge 3.5.1 into the next-gen stuff.
#78
https://github.com/dragutux/Greed/tree/dev-temp
that branch is physx 3.3 from rextimmy + darkui + d3d-refactor (updated
to compile in vs2010 + lukaspj fixes for GFXTriangleFan -replacement by GFXTriangleList).
Note : the occurences of GFXTriangleList have to be proof checked for vertex
orientations.
Note 2 : this might get ugly in vs2013, not sure as it is now.
07/26/2014 (10:33 am)
works : https://github.com/dragutux/Greed/tree/dev-temp
that branch is physx 3.3 from rextimmy + darkui + d3d-refactor (updated
to compile in vs2010 + lukaspj fixes for GFXTriangleFan -replacement by GFXTriangleList).
Note : the occurences of GFXTriangleList have to be proof checked for vertex
orientations.
Note 2 : this might get ugly in vs2013, not sure as it is now.
#79
where can i get the dx11 shaders? In downloaded pack, tabletes, shaders dir is old dx9.
Any help about this effort?
Thanks for your time :)
09/23/2014 (11:43 am)
I have tried all that effort, but only problems I see. The Frames fell by 40%, D3D11 is disabled, only in the selection list appears of option window. Has anyone installed, has seen some effect optimization of this effort? where can i get the dx11 shaders? In downloaded pack, tabletes, shaders dir is old dx9.
Any help about this effort?
Thanks for your time :)
#80
01/13/2015 (5:03 am)
Did I Need To Download DirectX11 to Use It
ZeroFault
Default Studio Name
Have you already committed your code for the Triangle Fan removal or are you still waiting for Luis to push his updates?