public InitialEvaluator(int totalNumOpParts, OperatorPartContext context, ProgressVisualizer progressVisualizer, float progressStart, float progressScale) { _totalNumOpParts = totalNumOpParts; _context = context; _progressVisualizer = progressVisualizer; _progressStart = progressStart; _progressScale = progressScale; }
public InitialEvaluator(int totalNumOpParts, OperatorPartContext context, ProgressVisualizer progressVisualizer) { _totalNumOpParts = totalNumOpParts; _context = context; _progressVisualizer = progressVisualizer; }
public void Precalc() { Logger.Info("Precalculating ..."); var pv = new ProgressVisualizer(_form, D3DDevice.Device, D3DDevice.SwapChain); pv.Update(0.0f); MetaManager.InitializeCallback = progress => pv.Update(0.3f * progress); MetaManager.Instance.LoadMetaOperators(); _model = new Model(); //replace the measure operator by nop to remove render flush calls var script = @"using System; using System.Collections.Generic; namespace Framefield.Core.IDca9a3a0e_c1c7_42b6_a0e5_cdb4c61d0b18 { public class Class_Group : OperatorPart.Function { public override OperatorPartContext Eval(OperatorPartContext context, List<OperatorPart> inputs, int outputIdx) { foreach (var input in inputs[0].Connections) input.Eval(context); return context; } } }"; var measureMetaOp = _model.MetaOpManager.GetMetaOperator(Guid.Parse("86580803-34fe-40a8-8dbf-9197dedb889c")); if (measureMetaOp != null) { var measureMetaOpPart = measureMetaOp.OperatorParts[0].Item2; measureMetaOpPart.Version = Guid.NewGuid(); measureMetaOpPart.Script = script; measureMetaOpPart.Compile(); } //replace lightswidgets op by nop var lightWidgetsMetaOp = _model.MetaOpManager.GetMetaOperator(Guid.Parse("86b0f0e1-5c9f-430e-8086-abadbf26866c")); if (lightWidgetsMetaOp != null) { var lightWidgetsMetaOpPart = lightWidgetsMetaOp.OperatorParts[0].Item2; lightWidgetsMetaOpPart.Version = Guid.NewGuid(); lightWidgetsMetaOpPart.Script = script; lightWidgetsMetaOpPart.Compile(); } //update everything var context = new OperatorPartContext(_defaultContext, 0.0f); context.D3DDevice = D3DDevice.Device; context.Effect = _renderer.SceneDefaultEffect; context.InputLayout = _renderer.SceneDefaultInputLayout; context.RenderTargetView = _renderTargetView; context.DepthStencilView = _renderTargetDepthView; context.DepthStencilState = _renderer.DefaultDepthStencilState; context.BlendState = _renderer.DefaultBlendState; context.BlendFactor = _renderer.DefaultBlendFactor; context.RasterizerState = _renderer.DefaultRasterizerState; context.SamplerState = _renderer.DefaultSamplerState; context.Viewport = _viewport; context.Texture0 = _texture; var statisticsCollector = new StatisticsCollector(); _model.HomeOperator.Outputs[0].TraverseWithFunction(statisticsCollector, null); int totalNumOpParts = statisticsCollector.NumTotalOpParts; int totalNumEvaluations = statisticsCollector.NumTotalEvaluations; var initialEvaluator = new InitialEvaluator(totalNumOpParts, context, pv); _model.HomeOperator.Outputs[0].TraverseWithFunction(initialEvaluator, null); pv.Dispose(); _model.HomeOperator.Outputs[0].MarkInvalidatables(); OperatorPart.HasValidInvalidationMarksOnOperatorPartsForTraversing = true; Logger.Info("Statistics: number of operator parts: {0}, total evaluations: {1}, number of time accessors: {2}", totalNumOpParts, totalNumEvaluations, _timeAccessorOpPartFunctions.Count); // ResourceManager.DisposeAll(); }
public void Precalc() { Logger.Info("Precalculating ..."); var pv = new ProgressVisualizer(_form, D3DDevice.Device, D3DDevice.SwapChain); pv.Update(0.0f); MetaManager.InitializeCallback = progress => pv.Update(_operatorLoadEndProgress * progress); MetaManager.Instance.LoadMetaOperators(); _model = new Model(); //replace the measure operator by nop to remove render flush calls var script = @"using System; using System.Collections.Generic; namespace Framefield.Core.IDca9a3a0e_c1c7_42b6_a0e5_cdb4c61d0b18 { public class Class_Group : OperatorPart.Function { public override OperatorPartContext Eval(OperatorPartContext context, List<OperatorPart> inputs, int outputIdx) { foreach (var input in inputs[0].Connections) input.Eval(context); return context; } } }"; var measureMetaOp = _model.MetaOpManager.GetMetaOperator(Guid.Parse("86580803-34fe-40a8-8dbf-9197dedb889c")); if (measureMetaOp != null) { var measureMetaOpPart = measureMetaOp.OperatorParts[0].Item2; measureMetaOpPart.Version = Guid.NewGuid(); measureMetaOpPart.Script = script; measureMetaOpPart.Compile(); } //replace lightswidgets op by nop var lightWidgetsMetaOp = _model.MetaOpManager.GetMetaOperator(Guid.Parse("86b0f0e1-5c9f-430e-8086-abadbf26866c")); if (lightWidgetsMetaOp != null) { var lightWidgetsMetaOpPart = lightWidgetsMetaOp.OperatorParts[0].Item2; lightWidgetsMetaOpPart.Version = Guid.NewGuid(); lightWidgetsMetaOpPart.Script = script; lightWidgetsMetaOpPart.Compile(); } //update everything var context = GetNewContext(); var statisticsCollector = new StatisticsCollector(); _model.HomeOperator.Outputs[0].TraverseWithFunction(statisticsCollector, null); int totalNumOpParts = statisticsCollector.NumTotalOpParts; int totalNumEvaluations = statisticsCollector.NumTotalEvaluations; var initialEvaluator = new InitialEvaluator(totalNumOpParts, context, pv, _operatorLoadEndProgress, _preCacheStartProgress - _operatorLoadEndProgress); _model.HomeOperator.Outputs[0].TraverseWithFunction(initialEvaluator, null); var timeClipEvaluator = new TimeClipEvaluator(); _model.HomeOperator.Outputs[0].TraverseWithFunction(timeClipEvaluator, null); _model.HomeOperator.Outputs[0].MarkInvalidatables(); OperatorPart.HasValidInvalidationMarksOnOperatorPartsForTraversing = true; if (_settings.PreCacheEnabled) { // draw the first, last and center frame of each TimeClip // in reverse order to warm up caches var preCacheTimes = timeClipEvaluator.GetResult(); int i = 0; foreach (double t in preCacheTimes) { Logger.Debug("pre-rendering frame at t={0}", t); D3DDevice.BeginFrame(); DrawFrame((float)t); D3DDevice.EndFrame(); i++; pv.Update(_preCacheStartProgress + (1.0f - _preCacheStartProgress) * i / preCacheTimes.Count); } } pv.Dispose(); Logger.Info("Statistics: number of operator parts: {0}, total evaluations: {1}, number of time accessors: {2}", totalNumOpParts, totalNumEvaluations, _timeAccessorOpPartFunctions.Count); // ResourceManager.DisposeAll(); }