예제 #1
0
        public RenderEngine(int width, int height)
        {
            _width  = width;
            _height = height;

            _gpuHandle = new GPUHandle();
            _gpuHandle.Init();

            _renderProgram = new GPUProgram(_gpuHandle, "renderer.cl");
            _renderProgram.BuildProgram();
            _renderProgram.CreateKernel("render");

            _renderProgram.SetKernelArg("render", 0, _width);
            _renderProgram.SetKernelArg("render", 1, _height);

            Bitmap bg = (Bitmap)Image.FromFile("background.jpg");

            _backgroundImage = new GPUImage(_gpuHandle);
            _backgroundImage.WriteImage(bg, MemFlags.ReadOnly);

            int totalPixels = _width * _height;
        }
예제 #2
0
        /// <summary>
        /// Creates an empty GPU Program
        /// </summary>
        /// <param name="handle">handle to GPU</param>
        public GPUProgram(GPUHandle handle)
        {
            _handle = handle;

            _kernels = new Dictionary <string, Kernel>();
        }
예제 #3
0
 /// <summary>
 /// Creates and builds a GPU Program from source code
 /// </summary>
 /// <param name="handle">handle to GPU</param>
 /// <param name="sourceCode">source code of program</param>
 public GPUProgram(GPUHandle handle, string[] sourceCode) : this(handle)
 {
     CreateProgram(sourceCode);
 }
예제 #4
0
 /// <summary>
 /// Creates and builds a GPU Program from external file
 /// </summary>
 /// <param name="handle">handle to GPU</param>
 /// <param name="path">Path to external program</param>
 public GPUProgram(GPUHandle handle, string path) : this(handle, LoadProgramFromFile(path))
 {
 }
예제 #5
0
 private GPUBuffer(GPUHandle handle)
 {
     _handle = handle;
 }
예제 #6
0
 /// <summary>
 /// Creates a new GPU Buffer or predefined size
 /// </summary>
 /// <param name="handle">What GPU Instance to create it on</param>
 /// <param name="flags">What Read/Write flags to use</param>
 /// <param name="size">Size of memory of the buffer</param>
 public GPUBuffer(GPUHandle handle, MemFlags flags, int size) : this(handle)
 {
     ErrorCode error;
     _buffer = Cl.CreateBuffer <T>(handle.Context, flags, size, out error);
     CLException.CheckException(error);
 }
예제 #7
0
 public GPUImage(GPUHandle handle)
 {
     _handle = handle;
 }