Parallel Programming in Native Code

Parallel programming using C++ AMP, PPL and Agents libraries.

direct3d namespace and HLSL intrinsics in C++ AMP

direct3d namespace and HLSL intrinsics in C++ AMP

  • Comments 3

As you know by now, as a rule most functionality in C++ AMP is in the concurrency namespace. The exception to that is the C++ AMP math library which introduces two sub namespaces (precise_math and fast_math), and the textures and short vector types which introduce one sub namespace (graphics).

The other sub namespace is direct3d.

direct3d namespace

You’ve already seen in the concurrency::direct3d namespace four DirectX Interop APIs. In concurrency::graphics::direct3d there are two more for interop with textures, plus some aliased functions for short vector types.

In the concurrency::direct3d namespace there are also 20 functions that you can find in <amp.h>. These intrinsics are offered when you do HLSL programming and, we decided to offer them through C++ AMP too. You can only call them from restrict(amp) functions. The list below is for your reference and it includes links to the HLSL documentation (I also encourage you to open the header file and look at our xml comments in there for each function).

  1. int abs(int _X)
  2. float clamp(float _X, float _Min, float _Max)
  3. int clamp(int _X, int _Min, int _Max)
  4. unsigned int countbits(unsigned int _X)
  5. int firstbithigh(int _X)
  6. int firstbitlow(int _X)
  7. int imax(int _X, int _Y)
  8. int imin(int _X, int _Y)
  9. float mad(float _X, float _Y, float _Z)
  10. double mad(double _X, double _Y, double _Z)
  11. int mad(int _X, int _Y, int _Z)
  12. unsigned int mad(unsigned int _X, unsigned int _Y, unsigned int _Z)
  13. float noise(float _X)
  14. float radians(float _X)
  15. float rcp(float _X)
  16. unsigned int reversebits(unsigned int _X)
  17. float saturate(float _X)
  18. int sign(int _X)
  19. float smoothstep(float _Min, float _Max, float _X)
  20. float step(float _Y, float _X)

And that is all you will find in the direct3d namespace.

HLSL intrinsics

Beyond the aforementioned 20 functions, you may be wondering about other HLSL intrinsics and access to them through C++ AMP. Well, if we haven’t wrapped them for you, then you cannot use them. However we have done exactly that for many of them in our fast_math namespace, debug functions, memory fences & barriers, and our atomic operations. If there are other intrinsics that we left out, please ask us about them (e.g. in our MSDN Forum) so we can potentially suggest a workaround or so we can consider them for a future release…

Blog - Comment List MSDN TechNet
  • Loading...
Leave a Comment
  • Please add 7 and 7 and type the answer here:
  • Post