Home » Samples »

Barycentrics DirectX® Shader Extension Samples

The Barycentrics11/12 samples show how to enable new intrinsic instructions in your DirectX® 11/12 HLSL code. In particular, it shows how to read the barycentric coordinates from the hardware rasterizer. 

The barycentric coordinates are used to interpolate vertex attributes in your triangles. The interpolation type can be linear or perspective corrected. The barycentric coordinates can be computed for the pixel’s center, the sample position, or the centroid.

As suggested by Michal Drobot in his Low Level Optimizations for GCN presentation, this opens the door to new interpolation and attribute packing methods. 

Many algorithms that were only possible in the geometry shader can now be implemented in the pixel shader. For example:

  • Parallax curvature estimation.
  • (Closest) distance to edge (for AA).
  • (Closest) distance to vertex.
  • Spline-interpolated normals/curvature.

The intrinsic instructions are enabled through the AMD GPU Services (AGS) library: 

AMD GPU Services (AGS) Library

The AMD GPU Services (AGS) library provides software developers with the ability to query AMD GPU software and hardware state information that is not normally available through standard operating systems or graphics APIs.

System requirements

  • AMD Radeon™ GPU (HD 7000 series or newer).
  • 64-bit Windows® 10.
  • Visual Studio® 2019.
  • Graphics driver with shader extension support.
    • For example, AMD Radeon Software Crimson Edition 16.9.1 or later.
  • The Windows 10 SDK must be installed.

Technical blogs

More DirectX®12 tutorials/samples

DirectX 12

Developing DirectX® applications

Developing with DirectX? This page shares our DirectX blog posts, presentations, samples, and more. Let us help you create and optimize your DirectX applications!

You may also be interested in...

If slide decks are what you’re after, you’ll find 100+ of our finest presentations here. Plus there’s a handy list of our product manuals!

Developer guides

Browse our developer guides, and find valuable advice on developing with AMD hardware, ray tracing, Vulkan, DirectX, UE4, and lots more.

Words not enough? How about pictures? How about moving pictures? We have some amazing videos to share with you!

The home of great performance and optimization advice for AMD RDNA™ 2 GPUs, AMD Ryzen™ CPUs, and so much more.

Product Blogs

Our handy product blogs will help you make good use of our tools, SDKs, and effects, as well as sharing the latest features with new releases.


Discover our published publications.