如何在版本之间迁移? [英] How can I migrate between versions?
问题描述
从DirectX 10到11有什么变化?我已经在DirectX 10中编写了一些代码,我想将其更改为DirectX11.这仅仅是为了提高质量,我可以通过更改标头和dll文件或更改函数和编码方式来做到这一点吗?
What are changes from directx 10 to 11? Ive written some code in directx 10 and I want to change it to directx 11. Is this just about quality and I can do it just by changing headrs and dll files or functions and way of coding have been changed? ing.
推荐答案
首先,我要说的是,只要将D3D10DoSomething()
函数更改为D3D11DoSomething()
,一切都不会改变.他们会做同样的事情.无被动增益.您必须明确地使用新功能才能使您的应用程序更好. D3D10不具备的那些功能:例如硬件镶嵌,计算着色器,
First, I need to say, that nothing will change if you just change your D3D10DoSomething()
functions to D3D11DoSomething()
. They will do same things. No passive gain. You must use new features explicitly to make your app better. Those features that D3D10 don't have: such as hardware tessellation, compute shader, many many other stuff. To code.
因此,主要问题是您真的需要此功能"吗?或者,也许是以后需要这些功能"吗? 当您看到古老的D3D10代码时,您的编码伙伴会笑吗?
So, the main question is "do you really need this features"? Or, maybe, "will you need these features later"? Does your coding mates laughing when see your ancient D3D10 code?
如果回答是:
DirectX 10到11的移植非常简单.与DirectX 9到10的移植相比,这只是个玩笑.
DirectX 10 to 11 porting is very simple. It is just a joke compared to DirectX 9 to 10 porting.
在将D3D10移植到D3D11时,要做的事情很简短且不详尽:
Here is short and non-exhaustive list of things to do when porting D3D10 to D3D11:
- 备份您的来源
- 获取文本查找替换工具(例如在Visual Studio或grep中),找到"D3D10"并替换为"D3D11"
- 将
#include <d3d10*>
替换为#include <d3d11*>
在链接器选项中 - 将
d3d10*.lib
替换为d3d11*.lib
- backup your sources
- get text find-replace tool (such as in Visual studio, or grep), find "D3D10" and replace to "D3D11"
- replace
#include <d3d10*>
to#include <d3d11*>
- replace
d3d10*.lib
tod3d11*.lib
in linker options
创建设备和上下文:
- 在D3D11设备界面中,设备界面分为设备和上下文,因此上下文负责状态更改功能(大多数方法是
Set*()
/Get*()
). - 在其中使用
D3D10CreateDevice*
功能之一创建设备的位置(现在它们已成为ID3D11DeviceContext
参数,并添加与此处) - 将
device->ChangeState()
呼叫更改为deviceContext->ChangeState()
- In D3D11 device interface splitted to device and context, so device now responsible for creation functionality (most methods are
Create*()
) and context responsible for state changing functionality (most methods areSet*()
/Get*()
). - Where you create device with one of the
D3D10CreateDevice*
functions (now they've becomeD3D11CreateDevice*
), add additionalID3D11DeviceContext
parameter and also add parameters related toD3D_FEATURE_LEVEL
. (more about feature levels here) - Change
device->ChangeState()
calls todeviceContext->ChangeState()
其他内容:
- Some of functions accepts additional argument(s). Most times you just can pass
0
for the time until you don't need this functionality. If you get compiler errors related with number of arguments or "unable to convert parameter.." just find this function in DirectX 11 reference and see if you must add additional zero argument =)
着色器:
- 顶点,几何和像素着色器基本不变,因此您可以安全地使用旧的着色器.
- 如果使用Effect10框架,事情可能会更复杂,但是移植仍将花费一个小时左右的时间.在您访问 Microsoft网站或Google时,请参考有问题.
- Vertex, Geometry, Pixel shaders mostly unchanged, so you can safely use old ones.
- If you using Effect10 framework, things can be more complicated, but still porting will take one hour of time or so. Refer to Microsoft site or Google when you have questions.
And here are additional tips from Microsoft : link, link.
好吧,大都完成了!欢迎来到D3D11世界=)
Well, mostly done! Welcome to D3D11 world =)
这篇关于如何在版本之间迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!