
Sample Applications 391
In the second (and optimal) attempt, we will use
minmax8, minmax12,and
minmax16 multiple times. Each time, though, we must copy two unprocessed
elements rather than one in order to set up for the next smaller subset. The
compute shader for the median filtering is shown in Listing 7.23.
#include ”MedianShared . h l s l i ”
Texture2D<float> input ;
RWTexture2D<float> output ;
[ numthreads (NUM
X THREADS , NUM Y THREADS , 1 ) ]
void CSMai n ( i nt2 dt : SV
DispatchThreadID)
{
float4 e [7]; // 28 sl o t s , we u s e t h e f i r s t 25
LoadNeighbors( input , dt , e );
minmax16(e ); // D i s c a rd min/max o f v0 . . v1 5 (2n +1=25, n+2<16). ...