Esempio n. 1
0
        public Mandelbrot(Platform platform, int width, int height)
        {
            openCLPlatform    = platform;
            openCLDevices     = openCLPlatform.QueryDevices(DeviceType.ALL);
            openCLContext     = openCLPlatform.CreateDefaultContext();
            openCLCQ          = openCLContext.CreateCommandQueue(openCLDevices[0], CommandQueueProperties.PROFILING_ENABLE);
            mandelBrotProgram = openCLContext.CreateProgramWithSource(File.ReadAllText("Mandelbrot.cl"));
            try
            {
                mandelBrotProgram.Build();
            }
            catch (OpenCLException)
            {
                string buildLog = mandelBrotProgram.GetBuildLog(openCLDevices[0]);
                MessageBox.Show(buildLog, "Build error(64 bit debug sessions in vs2008 always fail like this - debug in 32 bit or use vs2010)");
                Application.Exit();
            }
            mandelbrotKernel = mandelBrotProgram.CreateKernel("Mandelbrot");

            Left         = -2.0f;
            Top          = 2.0f;
            Right        = 2.0f;
            Bottom       = -2.0f;
            BitmapWidth  = width;
            BitmapHeight = height;

            mandelbrotMemBuffer = openCLContext.CreateBuffer((MemFlags)((long)MemFlags.WRITE_ONLY), width * height * 4, IntPtr.Zero);
        }
Esempio n. 2
0
 public TemplateMatching()
 {
     Device       = new Device();
     Context      = Device.CreateContext();
     CommandQueue = Context.CreateCommandQueue();
     Program      = Context.CreateProgram(ShaderSource);
     PgKernel     = Program.CreateKernel("templateMatching");
 }
Esempio n. 3
0
        public Kernel CreateKernel(string source, string kernelName)
        {
            var program = new CLProgram(source, this);

            return(program.CreateKernel(kernelName));
        }