internal CPUFractalEngine(CPUDeviceEntry devEntry) { int fractalSize, branchesSize, variWeightsSize; Fractal.GetNativeFractalSizes(out fractalSize, out branchesSize, out variWeightsSize); //these are allocated from unmanaged memory so we don't have to worry about pinning them all the time fractal = (NativeFractal *)Marshal.AllocHGlobal(fractalSize); branches = (NativeBranch *)Marshal.AllocHGlobal(branchesSize); variWeights = (float *)Marshal.AllocHGlobal(variWeightsSize); int iterCount = Util.Clamp(2 * devEntry.NumCores, 2, MaxUseableIterators); iterators = new Iterator[iterCount]; int dotBufferSize = Marshal.SizeOf(typeof(Dot)) * DotsPerCycle; dots = (Dot *)Marshal.AllocHGlobal(dotBufferSize); int dotIndiciesSize = Marshal.SizeOf(typeof(ushort)) * DotsPerCycle; dotIndicies = (ushort *)Marshal.AllocHGlobal(dotIndiciesSize); for (int i = 0; i < DotsPerCycle; i++) { dotIndicies[i] = (ushort)i; } for (int i = 0; i < IteratorCount; i++) { iterators[i] = new Iterator(i); iterators[i].SetFractal(this.fractal, branches, variWeights); iterators[i].SetOutput(dots); } globalStats = new NativeGlobalStatEntry(); tonemapVertShader = GLUtil.MakeShader("tonemap_vert_glsl", Kernels.KernelResources.tonemap_vert_glsl, ShaderType.VertexShader); tonemapFragShader = GLUtil.MakeShader("tonemap_frag_glsl", Kernels.KernelResources.tonemap_frag_glsl, ShaderType.FragmentShader); tonemapProgram = GLUtil.MakeProgram("tonemap_program", tonemapVertShader, tonemapFragShader); accumSamplerLocation = GL.GetUniformLocation(tonemapProgram, "accumSampler"); scaleConstantLocation = GL.GetUniformLocation(tonemapProgram, "scaleConstant"); brightnessLocation = GL.GetUniformLocation(tonemapProgram, "brightness"); invGammaLocation = GL.GetUniformLocation(tonemapProgram, "invGamma"); vibrancyLocation = GL.GetUniformLocation(tonemapProgram, "vibrancy"); upScaleFactorLocation = GL.GetUniformLocation(tonemapProgram, "upScaleFactor"); subStepXLocation = GL.GetUniformLocation(tonemapProgram, "subStepX"); subStepYLocation = GL.GetUniformLocation(tonemapProgram, "subStepY"); #if DEBUG FractalManager.Blip += delegate(object obj, EventArgs ea){ iterators[0].GetStuck(); }; #endif }
public void SetOutput(Dot *output) { lock (syncRoot){ set_iterator_output(iterHandle, DotsPerIterator, output + id * DotsPerIterator); } }
extern private static void set_iterator_output(IntPtr iter, int dot_count, Dot *output);