Home Articles Tutorials Resources About
Simple GPGPU framework   Last update: 2010-02-25 23:51:19 by Rim van Wersch

[Recent changes and release notes] [About the framework] [Downloads]



Recent changes and release notes

The GPGPU framework has recently undergone some changes and moved up from version 0.2 to version 0.3.
Below you'll find an overview of the most prominent new features.
  • Generic GPUProcessor and GPUBuffer implementation
    The 0.2 version only supported data to be passed back and forth as Vector4s, since this seemed the most typical and flexible approach. The downsides however are that this isn't quite optimal when dealing with other data formats, floating point texture operations remain slow on some cards and support for them also seems spotty on integrated cards.

    To fix this the framework was recoded to support a generic type parameter for the data elements. The constraint here is that the framework has to come up with a suitable GPU surface format for the data, so only the following type parameters are supported:

    • Color (maps to SurfaceFormat.Color)
    • Vector4 (maps to SurfaceFormat.Vector4)
    • Vector2 (maps to SurfaceFormat.Vector2)
    • float (maps to SurfaceFormat.Single)
    • byte (maps to SurfaceFormat.Alpha8)
    • PackedVector.HalfSingle (maps to SurfaceFormat.HalfSingle)
    • PackedVector.HalfVector2 (maps to SurfaceFormat.HalfVector2 )
    • PackedVector.HalfVector4 (maps to SurfaceFormat.HalfVector4 )

    You can add a custom mapping to GPUProcessor.MapTypeToSurfaceFormat() as appropriate though.

  • GPUBufferUsage for specialized use cases
    Version 0.2 was based on the idea that the data would be needed on the CPU after each Compute(). As a result the framework always copied data back and forth between all GPU resources and buffers when calling CommitInputs() and ResolveOutputs().

    With the new GPUBuffer.Usage property, you can specify if you want this behaviour or if the GPUProcessor should skip the Commit or Resolve for a particular buffer. A special case is the GPUBufferUsage.PassThrough option, which allows you to reuse a render target directly as the input for subsequent Compute() calls. This allows for multiple consequetive GPU computations without stalling to read data back to the CPU.
Unfortunately the generics code obviously introduces some breaking changes in the API, but you can still use the old framework (version 0.2) if you don't need the new features. Alternatively you can pass Vector4 as the type parameter when using the generics code. The only functionality that was dropped are the subcomponent getters (GPUBuffer.GetX etc), but this should not be too big a loss.


About the framework

This is a simple framework to perform general purpose calculations on the GPU. It's a very simple setup, but it seems reasonably efficient and not too complex to use. This should probably be considered another beta release, but I think it's reasonably feature complete and might be useful for someone out there. Besides, I still could use some feedback on performance and usability!

If you care to give it a shot, please let me know (or comment here if you don't want to mail) how it performs for you or if there are any features missing. The release includes a basic particle demo inside an XNA game and a barebones WinForms application that can be used as a crude starting point to use the framework outside of the XNA gaming context. Both these source projects contain version 0.2 of the GPGPU framework. The latest addition, an adaptation of the GameOfLife sample to the GPGPU framework contains version 0.3 of the framework.

The classes are pretty well documented, but I still hope I get around to writing a more detailed guide sometime, if it's useful for anyone that is. The demo apps should be enough to get you going, but if not please just go ahead and hit the feedback link.

I'm told a library is only as good as its demos, so I thought I'd throw in a little GPGPU black hole simulation I was tinkering on. It's obviously no physically correct simulation, I used some shady things in the shaders that may not work out for everyone and it's educational value is burried under trickery, but it's pretty




Files for this resource

Filename Size
  [0.3b] GPGPU Framework & GameOfLife Demo for XNA 3.zip 26.1 KB
  [0.2b] Black Hole Demo for XNA 3.zip 45.0 KB
  [0.2b] GPGPU XNA Particle Demo for XNA 3.zip 38.7 KB
  [0.2b] GPGPU WinForms PI Calculator for XNA 3.zip 22.7 KB
  [0.2b] GPGPU Effect File Template for XNA 3.zip 678.0 B
 
XNA info is sponsored by vector4. All content is copyright © 2005-2010 by its respective authors | About XNA info | Terms of Use | RSS feed