Udostępnij za pośrednictwem


direct3d_ref accelerator in C++ AMP

In addition to the hardware on your system, in Microsoft's implementation of C++ AMP, as I have described in my accelerator blog post there are three known accelerators: cpu, direct3d_warp, and direct3d_ref. This post expands a bit more on direct3d_ref.

Reference Rasterizer or REF or "direct3d_ref" or "Software Adapter"

The DirectX SDK has always offered a reference implementation of DirectX and it is called the "Reference Rasterizer" or just REF. It emulates a generic graphics card in software on the CPU (from a Direct3D rasterization perspective). It is a slow single-threaded emulator that is extremely accurate – after all, it is the reference implementation.

You are only able to get REF with the DirectX SDK. Recently is got rolled into the Windows SDK. With Visual Studio 11, you also get the Windows SDK, hence you also get REF.

In C++ AMP we refer to REF as "direct3d_ref". Using the code snippet from my accelerator blog post, this is what the output is for REF on my installation:

New accelerator: Software Adapter
device_path = direct3d\ref
version = 11.0
dedicated_memory = 0 KB
doubles = true
limited_doubles = true
has_display = true
is_emulated = true
is_debug = true

You can create one directly with a single line of code:

accelerator my_acc(accelerator::direct3d_ref);

Note that accelerator:: direct3d_ref is equal to “direct3d\ref”.

Not for performance, Not for production

Given the mechanism via which you get REF, it is unlikely to be on your customer's machine. But even if it was, this is not something you would want to execute on in a production environment, so always check in release configuration that you are not running on REF. The reason is that it is very slow (think 1000 times slower than typical hardware).

This (non-C++ AMP) gaming forum discussion provides even more info on this point (as if this simple point needed elaborating on): "My system slows down when I turn on Reference rasterizer".

Also from this DirectX FAQ

"Is there a software rasterizer included with Direct3D?"

"Not for performance applications. A reference rasterizer is supplied for driver validation but the implementation is designed for accuracy and not performance."

Helps with debugging your C++ AMP code

In Visual Studio 11 there is excellent GPU debugging support for C++ AMP, that we will cover in future posts. While there will be hardware debugging offered by our hardware partners via a plug-in DLL to Visual Studio, there is an in-the-box emulator for debugging. Yup, you guessed it, that's REF again! Our team modified REF and Visual Studio to enable debugging on REF - there are many benefits to that, which will be covered in future posts.

FYI, in Visual Studio 11, REF is referred to (in the project properties against "Debugging Accelerator Type") as "GPU - Software Emulator".

Helps with validating driver bugs

As you may have guessed, REF is great for validating that you have found a driver bug. If it works in REF, and not on your hardware, then you have probably found a bug in the driver for that hardware.

Again, from this other DirectX FAQ:

"I think I have found a driver bug, what do I do?"

"First, ensure you have checked the results with the Reference Rasterizer. Then check the results with the latest WHQL certified version of the IHVs driver."

We’ll be offering guidance on how to file IHV bugs in a future post, until then as always use our MSDN forum.