Compute Shader

The new Comput Shader is a transparent parallel processing model, and an evolution of HLSL, targeted for Post processing, the A-Buffer, ray-tracing, Physics and AI.
It enables much more general algorithms than ever before. You could write this before as well, but with the compute shader, it just gets alot simpler..
 
 
This is an example of a Compute Shader Allison Klein shared with us on her session on Direct3D and GPUs.
 
OutputBuffer<uint> Result;
ImageAverage()
{
  groupshared uint Total[32];
  groupshared uint Count[32];
 
  float3 vPixel = load( sampler, sv_ThreadID );
  float fLuminance = dot( vPixel, LUM_VECTOR );
  uint value = fLuminance*65536;
  uint idx = (sv_ThreadID.x + sv_ThreadID.y + sv_ThreadID.z) % 32;
 
  InterlockedAdd(Total[idx], value);
  InterlockedAdd(Count[idx], 1);
 
  SyncronizeThreadGroup();
 
  if (threadIDInGroup.x == 0)
  {
    for( uint i=0: i<32;i++)
    {
       TheTotal += Total[i];
       TheCount += Count[i];
     }
     float fAverage = TheTotal/TheCount;
     UnorderedStore( Result[GroupID], fAverage );
  }
This entry was posted in Technology. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.