ComputeShader again :)

I know, I know - a while ago I sended simular commit - and it was declained. But now I refresh it a bit and want try add it again. 


These files ComputeShader.cs and ComputeSurface2D.cs added only to WinDX and WinRT solutions. They will not touch opengl projects. No other files like Texture2D is touched. This is much cleaner version than old one.
I added some preparations for OpenGL to code. I assume, in future it will be helpful, if SDL or opengl4net will be implemented, instead Opentk.
Here is examples. 
-----------------------------------------WinDX demo project-----------------------------------------

    using System;
    using System.IO;
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;

    namespace ComputeShaderTestWinDX
    {
    public class Game1 : Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        ComputeShader cs;
        ComputeSurface2D csSurf;
        Texture2D output;

        public Game1()
            : base()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        public static byte[] GetFileContent(string filename)
        {
            if (!File.Exists(filename)) return null;

            string str = null;
            try
            {
                return File.ReadAllBytes(filename);
            }
            catch (Exception e)
            {
                throw e;
            }

            return null;
        }

        protected override void Initialize()
        {
            output = new Texture2D(GraphicsDevice, 1024, 1024, true, SurfaceFormat.Color);

            var arr = GetFileContent(@"Content\cs.cso");

            cs = new ComputeShader(GraphicsDevice, arr);
            csSurf = new ComputeSurface2D(GraphicsDevice, 1024, 1024);

            cs.SetOutputSurface(csSurf);
            cs.Compute(32, 32, 1);

            Color[] color = new Color[1024 * 1024];
            csSurf.GetData(color);
            output.SetData(color); 

            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
        }

        protected override void UnloadContent()
        {
            cs.Dispose();
            csSurf.Dispose();
            output.Dispose();
        }

        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();

            spriteBatch.Draw(output, Vector2.Zero, Color.White);

            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
    } 


--------------------------------WinRT demo project--------------------------------------------------

     using System;
     using System.Threading.Tasks;
     using Windows.ApplicationModel;
     using Windows.Storage;
     using Windows.Storage.Streams;
     using Microsoft.Xna.Framework;
     using Microsoft.Xna.Framework.Graphics;

      namespace ComputeShaderTestWinRT
      {
         public class Game1 : Game
         {
             GraphicsDeviceManager graphics;
             SpriteBatch spriteBatch;

        ComputeShader cs;
        ComputeSurface2D csSurf;
        Texture2D output;
        Task<IBuffer> bytecodebuffer; 

        public static async Task<IBuffer> GetFileContent(string filename)
        {
            var file = await Package.Current.InstalledLocation.GetFileAsync(filename);
            return await FileIO.ReadBufferAsync(file);
        }

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            output = new Texture2D(GraphicsDevice, 1024, 1024, true, SurfaceFormat.Color);
            bytecodebuffer = GetFileContent(@"Content\cs.cso");
            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
        }
 
        protected override void UnloadContent()
        {
            cs.Dispose();
            csSurf.Dispose();
            output.Dispose();
        }

        protected override void Update(GameTime gameTime)
        {
            if (cs == null && bytecodebuffer.IsCompleted)
            {
                var buffer = bytecodebuffer.Result;
                byte[] arr = new byte[buffer.Length];
                Windows.Storage.Streams.DataReader.FromBuffer(buffer).ReadBytes(arr);

                cs = new ComputeShader(GraphicsDevice, arr);
                csSurf = new ComputeSurface2D(GraphicsDevice, 1024, 1024);

                cs.SetOutputSurface(csSurf);
                cs.Compute(32, 32, 1);

                Color[] color = new Color[1024 * 1024];
                csSurf.GetData(color);
                output.SetData(color);
            }

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();

            spriteBatch.Draw(output, Vector2.Zero, Color.White);

            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
     }


Tested compiled shader file is here - https://github.com/Shqrdx/MGHelper/blob/master/Demo/Content/cs.cso
Push this file to Content folder for work.
Here is result of this computation - http://img716.imageshack.us/img716/2778/ivr9.png
Image processing test - http://t.co/Kg7q98uKV9
If somebody want test it yourself from this moment - try my library https://github.com/Shqrdx/MGHelper

This compute shader implementation is a basic and cool place for future experimenting - dont look angry on this. Discuss pls.