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; }
/// <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>(); }
/// <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); }
/// <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)) { }
private GPUBuffer(GPUHandle handle) { _handle = handle; }
/// <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); }
public GPUImage(GPUHandle handle) { _handle = handle; }