FidelityFX Parallel Sort 1.3

FidelityFX Parallel Sort is a technique which uses a GPU-based radix sort algorithm to sort a provided buffer of keys, and an optional payload.

Shading language requirements

HLSL GLSL CS_6_0

The technique

FidelityFX Parallel Sort will sort the provided key buffer and optional payload buffer using an RDNA-optimized GPU radix sort algorithm, which is one of the fastest sorting algorithms available for large data sets.

The algorithm works by operating over blocks of sequential data for optimal reads. A thread group will sort 1 or more blocks of data depending on the dataset size, and execute over a configurable amount of threads per thread group (currently set to 128).

In order to fully sort a buffer of 32-bit keys, the algorithm is invoked over 8 iterations, where each iteration will go through a 4-bit increment of the following steps:

  • Count: Counts the number of values in the local sort set according to the number of bits processed.

  • ReduceCount: Further reduces the value counts to thread group size alignments for faster offset calculation across thread groups.

  • ScanPrefix: Reduced counts are summed to provide thread group offsets.

  • ScanPrefix + Add: Thread counts are summed and summed with thread group offsets to provide the final offset location.

  • Scatter: Copies the source value to its new location (sorted up to n-bits processed thus far)

FidelityFX Parallel Sort Technique

Example C++

Via static lib:

Copied!

FfxParallelSortDispatchDescription  dispatchDesc = {};
dispatchDesc.commandList     = ffxGetCommandList (pCmdList);
dispatchDesc.keyBuffer       = ffxGetResource (m_pKeysToSort->GetResource(), L"ParallelSort_KeyBuffer", FFX_RESOURCE_STATE_PIXEL_COMPUTE_READ );
dispatchDesc.payloadBuffer   = ffxGetResource (m_pPayloadToSort->GetResource(), L"ParallelSort_PayloadBuffer", FFX_RESOURCE_STATE_PIXEL_COMPUTE_READ );
dispatchDesc.numKeysToSort   = <Number of keys to sort>;

FfxErrorCode  errorCode = ffxParallelSortContextDispatch (&m_ParallelSortContext, &dispatchDesc);
FFX_ASSERT(errorCode == FFX_OK );

See also

Related pages

  • Visit the FidelityFX SDK product page for download links and more information.

Looking for more documentation on GPUOpen?

AMD GPUOpen software blogs

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

GPUOpen Manuals

Don’t miss our manual documentation! And if slide decks are what you’re after, you’ll find 100+ of our finest presentations here.

AMD GPUOpen Performance Guides

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

Getting started: AMD GPUOpen software

New or fairly new to AMD’s tools, libraries, and effects? This is the best place to get started on GPUOpen!

AMD GPUOpen Getting Started Development and Performance

Looking for tips on getting started with developing and/or optimizing your game, whether on AMD hardware or generally? We’ve got you covered!

AMD GPUOpen Technical blogs

Browse our technical blogs, and find valuable advice on developing with AMD hardware, ray tracing, Vulkan®, DirectX®, Unreal Engine, and lots more.

Find out more about our software!

AMD GPUOpen Effects - AMD FidelityFX technologies

Create wonder. No black boxes. Meet the AMD FidelityFX SDK!

AMD GPUOpen Samples

Browse all our useful samples. Perfect for when you’re needing to get started, want to integrate one of our libraries, and much more.

AMD GPUOpen developer SDKs

Discover what our SDK technologies can offer you. Query hardware or software, manage memory, create rendering applications or machine learning, and much more!

AMD GPUOpen Developer Tools

Analyze, Optimize, Profile, Benchmark. We provide you with the developer tools you need to make sure your game is the best it can be!