Managed wrapper for Direct3D10 - Device creationBy Ralf "Demirug" Kornmann, May 8 2006 |
D3D10 wrapper project status
The current version of the wrapper and ported tutorials from the D3D10 preview can be downloaded from the link at the bottom of this page. Please note that the wrapper is a work in progress and as such may be updated occasionally, most likely as new sections get added to this article series. The wrapper currently encompasses the basic functionality of the D3D10 API needed to implement C# versions of the SDK preview tutorials 1, 2 and 4.
The first one specifies the physical adapter that should host our new device. But as most of us won't have a Direct3D 10 compatible GPU, we don't need to specify it yet. At a later point we will look more closely at the process how to find a Direct3D adapter and use it for the device creation, but for the moment we'll pass in null here to indicate we won't use a hardware adapter.
The next parameter defines the driver type that should use for the new device. We know this as the device type from Direct3D 9 and there are still the same 4 types available. If we had a Direct3D 10 GPU in our system we could create a Hardware device. Another option is a pluggable software device. But as we don't have this too we are forced to use the reference driver. It can work in two different mode of operation. Both behave like a Direct3D 10 GPU but only one of them generates an image. Until we can get our hands to real hardware we are forced to use this last one if we want see anything.
The last parameter controls some behaviors of the new created device. It allows us to decide if we need some base services or not. Instead of a Direct3D 9 device a Direct3D 10 device is thread safe by default, to cater for the multicore processors that are slowly becoming mainstream, especially for game rig. But if we don't need this protection, you can disable it for efficiency.
The next difference to Direct3D 9 is the debug runtime. Instead of switching between the release and the debug version with the control panel, we can now activate it during device creation. But it will still cause a substantial performances hit and if we try to create a debug enabled device on a system without the SDK installed, it will fail.
The last option we can activate during device creation is called state mirror. By default we have only limited access to the internal data of different Direct3D 10 objects after they are created. The device independent description is thrown out by default to reduce memory usage, like with the D3D9 pure hardware device. By using the state mirror, we can force Direct3D 10 to save this information for later requests. Memory may be cheap today, but it is still not recommended to waste it on a state mirror if you don't need it.
So with this information, we are now ready to create our device with the simple call below.
device = new D3D10.Device(null, D3D10.DriverType.Reference, D3D10.CreateDeviceFlags.None);
This call gives us a multithread protected device without additional debug and state mirror information. It uses the CPU based reference driver and it is not bound to a specific graphic adapter. It seems we are ready to start now but there is something else we have to do.
In Direct3D 9 we needed an additional parameter called present parameters to create a device. This structure was used to create the primary swap chain for the device. However, Direct3D 10 devices don't have a default primary swap chain anymore. It was removed to give us the possibility to use the calculation power of modern GPUs for jobs that don't need to output a visual result on a swap chain. This is useful, but on the other hand it forces us to create our own swap chain when we need one.
In the next section, we'll take a closer look at how to create such a D3D10 swap chain by using the DXGI API.
Back to MDX10 introduction | Continue reading about MDX10 swap chains
Files for this article
Filename | Size |
? MDX10 wrapper & tutorials.zip | 135.7 KB |
Further reading
-
? -
? -
? -
DirectX Developer Center
?