Beispiel #1
0
        void PopulateCommandList(Pipeline.Pipeline pipeline, Pipeline.PipelineAssets pipelineAssets)
        {
            var viewport         = new SharpDX.ViewportF(0, 0, pipeline.Size.Width, pipeline.Size.Height);
            var scissorRectangle = new SharpDX.Rectangle(0, 0, pipeline.Size.Width, pipeline.Size.Height);

            pipeline.CommandAllocators[pipeline.FrameIndex].Reset();
            pipelineAssets.CommandList.Reset(pipeline.CommandAllocators[pipeline.FrameIndex], pipelineAssets.PipelineState);

            pipelineAssets.CommandList.SetGraphicsRootSignature(pipelineAssets.RootSignature);
            pipelineAssets.CommandList.SetDescriptorHeaps(1, new SharpDX.Direct3D12.DescriptorHeap[] { pipelineAssets.ConstantBufferViewHeap });
            pipelineAssets.CommandList.SetGraphicsRootDescriptorTable(0, pipelineAssets.ConstantBufferViewHeap.GPUDescriptorHandleForHeapStart);

            pipelineAssets.CommandList.SetViewport(viewport);
            pipelineAssets.CommandList.SetScissorRectangles(scissorRectangle);
            pipelineAssets.CommandList.ResourceBarrierTransition(pipeline.RenderTargets[pipeline.FrameIndex], SharpDX.Direct3D12.ResourceStates.Present, SharpDX.Direct3D12.ResourceStates.RenderTarget);

            var rtvHandle = pipeline.RenderTargetViewHeap.CPUDescriptorHandleForHeapStart + pipeline.FrameIndex * pipeline.RtvDescriptorSize;

            pipelineAssets.CommandList.SetRenderTargets(rtvHandle, null);
            pipelineAssets.CommandList.ClearRenderTargetView(rtvHandle, GraphicsSettings.ClearColor.Value, 0, null);
            pipelineAssets.CommandList.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;
            pipelineAssets.CommandList.SetVertexBuffer(0, pipelineAssets.VertexBufferView);
            pipelineAssets.CommandList.DrawInstanced(3, 1, 0, 0);

            pipelineAssets.CommandList.ResourceBarrierTransition(pipeline.RenderTargets[pipeline.FrameIndex], SharpDX.Direct3D12.ResourceStates.RenderTarget, SharpDX.Direct3D12.ResourceStates.Present);
            pipelineAssets.CommandList.Close();
        }
Beispiel #2
0
        /// <summary>
        /// Performs the processing procedure against an input
        /// </summary>
        /// <param name="pipeline">The processing pipeline</param>
        /// <param name="input">The input to be processed</param>
        /// <returns>The output from the pipeline, or null if the process
        /// is cancelled</returns>
        private Image _processInput(Pipeline.Pipeline pipeline, JobInput input)
        {
            Image theInput = input.Input;

            foreach (PipelineEntry entry in pipeline)
            {
                lock ( _cancelPadlock )
                {
                    if (_cancel)
                    {
                        return(null);
                    }
                }

                AlgorithmPlugin plugin = entry.Process;
                plugin.Input = theInput;
                plugin.Run(entry.ProcessInput);
                theInput = plugin.Output ?? plugin.Input;
            }

            InputProcessedArgs e = new InputProcessedArgs(input.Identifier, (Image)theInput.Clone());

            _ticket.OnInputProcessed(e);
            return(theInput);
        }
        public static void Test()
        {
            InputQueryRecordManager manager =
                new InputQueryRecordManager("result.xml", new TimeSpan(0, 1, 0));

            WriteInputQueryList(manager.QueryList);

            Pipeline.Pipeline pipeline = new Pipeline.Pipeline();
            pipeline.InputTextSubscriberManager.AddSubscriber(manager);

            pipeline.OnInputTextReady(new InputQuery("Wait"));
            pipeline.OnInputTextReady(new InputQuery("苹果"));
            pipeline.OnInputTextReady(new InputQuery("林添"));
            pipeline.OnInputTextReady(new InputQuery("SmartMe"));

            Thread.Sleep(1000);

            WriteInputQueryList(manager.QueryList);

            InputQueryRecordManager anotherManager = new InputQueryRecordManager
                                                         ("result.xml", TimeSpan.MaxValue);

            Thread.Sleep(1000);

            WriteInputQueryList(anotherManager.QueryList);
        }
        public static void Test()
        {
            InputQueryRecordManager manager =
                new InputQueryRecordManager("result.xml", new TimeSpan(0, 1, 0));

            WriteInputQueryList(manager.QueryList);

            Pipeline.Pipeline pipeline = new Pipeline.Pipeline();
            pipeline.InputTextSubscriberManager.AddSubscriber(manager);

            pipeline.OnInputTextReady(new InputQuery("Wait"));
            pipeline.OnInputTextReady(new InputQuery("苹果"));
            pipeline.OnInputTextReady(new InputQuery("林添"));
            pipeline.OnInputTextReady(new InputQuery("SmartMe"));

            Thread.Sleep(1000);

            WriteInputQueryList(manager.QueryList);

            InputQueryRecordManager anotherManager = new InputQueryRecordManager
                ("result.xml", TimeSpan.MaxValue);

            Thread.Sleep(1000);

            WriteInputQueryList(anotherManager.QueryList);
        }
Beispiel #5
0
        public void Update(Pipeline.Pipeline pipeline, Pipeline.PipelineAssets pipelineAssets, System.TimeSpan total, System.TimeSpan delta)
        {
            Camera.Update(total, delta);

            SharpDX.Matrix worldMatrix;
            SharpDX.Matrix viewProjectionMatrix;

            // worldMatrix = SharpDX.Matrix.RotationY((float)total.TotalSeconds);
            worldMatrix          = SharpDX.Matrix.Identity;
            viewProjectionMatrix = Camera.GetViewProjection(pipeline.Size);

            constantBufferData.viewProjectionMatrix = worldMatrix * viewProjectionMatrix;
            SharpDX.Utilities.Write(pipelineAssets.ConstantBufferPointer, ref constantBufferData);
        }
Beispiel #6
0
        /// <summary>
        /// Processes a single input from the job
        /// </summary>
        /// <param name="pipeline">The Pipeline to use in processing</param>
        /// <param name="input">The input to be processed</param>
        /// <returns>true if the process is completed successfully</returns>
        private bool _handleNextInput(Pipeline.Pipeline pipeline, JobInput input)
        {
            lock ( _cancelPadlock )
            {
                if (_cancel)
                {
                    _ticket.Result = JobResult.Cancelled;
                    _ticket.State  = JobState.Cancelled;
                    _currentArgs.Persister.Delete(_ticket.JobID);
                    return(false);
                }
            }

            return(_tryRunInput(pipeline, input));
        }
Beispiel #7
0
        /// <summary>
        /// Runs the job specified by the definition
        /// </summary>
        /// <param name="job">The definition of the job to run</param>
        private void _runJob(IJobDefinition job)
        {
            PipelineDefinition d = job.GetAlgorithms();

            Pipeline.Pipeline pipeline = _currentArgs.PipelineFactory.CreatePipeline(d);
            foreach (JobInput input in job.GetInputs())
            {
                if (_handleNextInput(pipeline, input) == false)
                {
                    return;
                }
            }

            var results = _currentArgs.Persister.Load(_ticket.JobID);

            _ticket.Result = new JobResult(results);
            _ticket.State  = JobState.Complete;
            _ticket.OnJobCompleted();
        }
Beispiel #8
0
 /// <summary>
 /// Attempts to run an input
 /// </summary>
 /// <param name="pipeline">The pipeline to use in processing</param>
 /// <param name="input">The input to process</param>
 /// <returns>true if the input is processed without error;
 /// false otherwise</returns>
 private bool _tryRunInput(Pipeline.Pipeline pipeline, JobInput input)
 {
     try
     {
         _ticket.OnBeganInput();
         Image theInput = _processInput(pipeline, input);
         _currentArgs.Persister.Persist(
             _ticket.JobID, theInput, input.Identifier);
         return(true);
     }
     catch (Exception e)
     {
         JobResult r = new JobResult(e);
         _ticket.Result = r;
         _ticket.State  = JobState.Error;
         _ticket.OnJobError(e);
         return(false);
     }
 }
Beispiel #9
0
        public void Render(Pipeline.Pipeline pipeline, Pipeline.PipelineAssets pipelineAssets)
        {
            PopulateCommandList(pipeline, pipelineAssets);
            pipeline.CommandQueue.ExecuteCommandList(pipelineAssets.CommandList);

            var brush = new SharpDX.Direct2D1.SolidColorBrush(pipeline.D2DRenderTargets[0], SharpDX.Color4.White);

            pipeline.D3D11On12Device.AcquireWrappedResources(new SharpDX.Direct3D11.Resource[] { pipeline.WrappedBackBuffers[pipeline.FrameIndex] }, 1);
            pipeline.D2DRenderTargets[pipeline.FrameIndex].BeginDraw();
            pipeline.D2DRenderTargets[pipeline.FrameIndex].FillRectangle(new SharpDX.Mathematics.Interop.RawRectangleF(5f, 5f, 100f, 100f), brush);
            // textBrush.Color = Color4.Lerp(colors[t], colors[t + 1], f);
            // pipeline.D2DRenderTargets[pipeline.FrameIndex].DrawText("Hello Text", textFormat, new SharpDX.Mathematics.Interop.RawRectangleF((float)Math.Sin(Environment.TickCount / 1000.0F) * 200 + 400, 10, 2000, 500), textBrush);
            pipeline.D2DRenderTargets[pipeline.FrameIndex].EndDraw();
            pipeline.D3D11On12Device.ReleaseWrappedResources(new SharpDX.Direct3D11.Resource[] { pipeline.WrappedBackBuffers[pipeline.FrameIndex] }, 1);
            pipeline.D3D11Device.ImmediateContext.Flush();
            brush.Dispose();

            pipeline.SwapChain3.Present(1, 0);
            pipeline.MoveToNextFrame();
        }
Beispiel #10
0
        private static string RunPipeline(bool sendEmails, bool buildsSuccessfully, TestStatus testStatus)
        {
            var log = new StringBuilder();

            var config = Substitute.For <Config>();

            config
            .SendEmailSummary()
            .Returns(sendEmails);

            var emailer = Substitute.For <Emailer>();

            emailer
            .When(_ => _.Send(Arg.Any <string>()))
            .Do(call => log.AppendLine(
                    $"Sending mail with message <{string.Join(",", call.Args().Select(_ => _.ToString()))}>"));

            var logger = Substitute.For <Logger>();

            logger
            .When(_ => _.Info(Arg.Any <string>()))
            .Do(call => log.AppendLine($"Logging INFO: <{string.Join(",", call.Args().Select(_ => _.ToString()))}>"));
            logger
            .When(_ => _.Error(Arg.Any <string>()))
            .Do(call => log.AppendLine($"Logging ERROR: <{string.Join(",", call.Args().Select(_ => _.ToString()))}>"));

            var pipeline = new Pipeline.Pipeline(config, emailer, logger);

            var project = new Project.ProjectBuilder()
                          .SetDeploysSuccessfully(buildsSuccessfully)
                          .SetTestStatus(testStatus)
                          .Build();

            pipeline.Run(project);

            return(log.ToString());
        }
        public static void Test()
        {
            QueryResultRecordManager manager = new QueryResultRecordManager("data", new TimeSpan(0, 1, 0));

            Pipeline.Pipeline pipeline = new Pipeline.Pipeline();
            pipeline.QueryResultSubscriberManager.AddSubscriber(manager);

            QueryResult result = new QueryResult(new InputQuery("Bill Gates"));
            SearchEngineResult resultItem = new SearchEngineResult();
            resultItem.SearchEngineType = SearchEngineType.Google;
            resultItem.SearchUrl = "http://www.google.com/query.jsp";
            SearchEngineResult.ResultItem item = new SearchEngineResult.ResultItem();
            item.Title = "ddd";
            item.Url = "http://www.gfw.com/";
            item.SimilarUrl = "http://www.g.com/ddd";
            item.CacheUrl = "http://www.g.com/cache";
            item.Description = "Who cares?";
            resultItem.Results.Add(item);

            SuggestionResult resultItem1 = new SuggestionResult();
            resultItem1.SuggestionType = SuggestionType.Google;
            resultItem1.SearchUrl = "json";
            SuggestionResult.ResultItem item1 = new SuggestionResult.ResultItem();
            item1.Index = "1";
            item1.Number = "2";
            item1.Suggestion = "haha";
            resultItem1.Results.Add( item1 );

            result.SearchEngineResultItems.Add(resultItem);
            result.SuggestionResultItems.Add(resultItem1);

            pipeline.OnQueryResultReady(result);

            Thread.Sleep(1000);

            List<QueryResult> resultList = manager.GetResultList(DateTime.Today, DateTime.Today);
            foreach (QueryResult queryResult in resultList)
            {
                Console.WriteLine(queryResult);
            }
            Console.WriteLine("----------------------------------------------");

            manager.RemoveAllResultList();

            resultList = manager.GetResultList(DateTime.Today, DateTime.Today);
            foreach (QueryResult queryResult in resultList)
            {
                Console.WriteLine(queryResult);
            }

            Console.WriteLine("----------------------------------------------");

            result = new QueryResult(new InputQuery("Bill Gates"));
            resultItem = new SearchEngineResult();
            resultItem.SearchEngineType = SearchEngineType.Google;
            resultItem.SearchUrl = "http://www.google.com/query.jsp";
            item = new SearchEngineResult.ResultItem();
            item.Title = "ddd";
            item.Url = "http://www.gfw.com/";
            item.SimilarUrl = "http://www.g.com/ddd";
            item.CacheUrl = "http://www.g.com/cache";
            item.Description = "Who cares?";
            resultItem.Results.Add(item);

            result.Items.Add(resultItem);

            pipeline.OnQueryResultReady(result);

            Thread.Sleep(1000);

            manager.RemoveResultListFromDate(DateTime.Today);
            resultList = manager.GetResultList(DateTime.Today - new TimeSpan(1, 0, 0, 0), DateTime.Today);
            foreach (QueryResult queryResult in resultList)
            {
                Console.WriteLine(queryResult);
            }

            Console.WriteLine("----------------------------------------------");

            manager.RemoveResultListFromDate(DateTime.Today + new TimeSpan(1, 0, 0, 0));
            resultList = manager.GetResultList(DateTime.Today - new TimeSpan(1, 0, 0, 0), DateTime.Today);
            foreach (QueryResult queryResult in resultList)
            {
                Console.WriteLine(queryResult);
            }

            Console.WriteLine("----------------------------------------------");
        }
Beispiel #12
0
        public static void Test()
        {
            QueryResultRecordManager manager = new QueryResultRecordManager("data", new TimeSpan(0, 1, 0));

            Pipeline.Pipeline pipeline = new Pipeline.Pipeline();
            pipeline.QueryResultSubscriberManager.AddSubscriber(manager);

            QueryResult        result     = new QueryResult(new InputQuery("Bill Gates"));
            SearchEngineResult resultItem = new SearchEngineResult();

            resultItem.SearchEngineType = SearchEngineType.Google;
            resultItem.SearchUrl        = "http://www.google.com/query.jsp";
            SearchEngineResult.ResultItem item = new SearchEngineResult.ResultItem();
            item.Title       = "ddd";
            item.Url         = "http://www.gfw.com/";
            item.SimilarUrl  = "http://www.g.com/ddd";
            item.CacheUrl    = "http://www.g.com/cache";
            item.Description = "Who cares?";
            resultItem.Results.Add(item);

            SuggestionResult resultItem1 = new SuggestionResult();

            resultItem1.SuggestionType = SuggestionType.Google;
            resultItem1.SearchUrl      = "json";
            SuggestionResult.ResultItem item1 = new SuggestionResult.ResultItem();
            item1.Index      = "1";
            item1.Number     = "2";
            item1.Suggestion = "haha";
            resultItem1.Results.Add(item1);

            result.SearchEngineResultItems.Add(resultItem);
            result.SuggestionResultItems.Add(resultItem1);

            pipeline.OnQueryResultReady(result);

            Thread.Sleep(1000);

            List <QueryResult> resultList = manager.GetResultList(DateTime.Today, DateTime.Today);

            foreach (QueryResult queryResult in resultList)
            {
                Console.WriteLine(queryResult);
            }
            Console.WriteLine("----------------------------------------------");

            manager.RemoveAllResultList();

            resultList = manager.GetResultList(DateTime.Today, DateTime.Today);
            foreach (QueryResult queryResult in resultList)
            {
                Console.WriteLine(queryResult);
            }

            Console.WriteLine("----------------------------------------------");

            result     = new QueryResult(new InputQuery("Bill Gates"));
            resultItem = new SearchEngineResult();
            resultItem.SearchEngineType = SearchEngineType.Google;
            resultItem.SearchUrl        = "http://www.google.com/query.jsp";
            item             = new SearchEngineResult.ResultItem();
            item.Title       = "ddd";
            item.Url         = "http://www.gfw.com/";
            item.SimilarUrl  = "http://www.g.com/ddd";
            item.CacheUrl    = "http://www.g.com/cache";
            item.Description = "Who cares?";
            resultItem.Results.Add(item);

            result.Items.Add(resultItem);

            pipeline.OnQueryResultReady(result);

            Thread.Sleep(1000);

            manager.RemoveResultListFromDate(DateTime.Today);
            resultList = manager.GetResultList(DateTime.Today - new TimeSpan(1, 0, 0, 0), DateTime.Today);
            foreach (QueryResult queryResult in resultList)
            {
                Console.WriteLine(queryResult);
            }

            Console.WriteLine("----------------------------------------------");

            manager.RemoveResultListFromDate(DateTime.Today + new TimeSpan(1, 0, 0, 0));
            resultList = manager.GetResultList(DateTime.Today - new TimeSpan(1, 0, 0, 0), DateTime.Today);
            foreach (QueryResult queryResult in resultList)
            {
                Console.WriteLine(queryResult);
            }

            Console.WriteLine("----------------------------------------------");
        }
Beispiel #13
0
        static void Main()
        {
            System.Windows.Forms.Application.SetHighDpiMode(System.Windows.Forms.HighDpiMode.SystemAware);
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

            var form           = new Form(800, 600);
            var pipeline       = new Pipeline.Pipeline(2, form.GraphicsPanel.ClientSize, form.GraphicsPanel.Handle);
            var pipelineAssets = new Pipeline.PipelineAssets(pipeline);
            var fpsCounter     = new FpsCounter();
            var engine         = new Engine.Engine();
            var bridge         = new UI.Bridge(engine, fpsCounter);

            form.GraphicsPanel.KeyDown += (object sender, System.Windows.Forms.KeyEventArgs e) =>
            {
                switch (e.KeyData)
                {
                case System.Windows.Forms.Keys.W:
                    engine.Camera.IsMovingForward = true;
                    break;

                case System.Windows.Forms.Keys.A:
                    engine.Camera.IsMovingLeft = true;
                    break;

                case System.Windows.Forms.Keys.S:
                    engine.Camera.IsMovingBackward = true;
                    break;

                case System.Windows.Forms.Keys.D:
                    engine.Camera.IsMovingRight = true;
                    break;
                }
            };

            form.GraphicsPanel.KeyUp += (object sender, System.Windows.Forms.KeyEventArgs e) =>
            {
                switch (e.KeyData)
                {
                case System.Windows.Forms.Keys.W:
                    engine.Camera.IsMovingForward = false;
                    break;

                case System.Windows.Forms.Keys.A:
                    engine.Camera.IsMovingLeft = false;
                    break;

                case System.Windows.Forms.Keys.S:
                    engine.Camera.IsMovingBackward = false;
                    break;

                case System.Windows.Forms.Keys.D:
                    engine.Camera.IsMovingRight = false;
                    break;
                }
            };

            form.GraphicsPanel.MouseMove += (object sender, System.Windows.Forms.MouseEventArgs e) =>
            {
            };

            form.WebView.CoreWebView2InitializationCompleted += (object sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e) =>
            {
                bridge.SetCoreWebView2(form.WebView.CoreWebView2);
            };

            form.GraphicsPanel.SizeChanged += (object sender, System.EventArgs e) =>
            {
                pipeline.WaitForGpu();
                pipeline.Resize(form.GraphicsPanel.ClientSize);
            };

            form.Show();
            fpsCounter.Initialize();
            var start = System.Diagnostics.Stopwatch.GetTimestamp();
            var last  = start;

            while (form.Created)
            {
                fpsCounter.OnFrame();

                var now   = System.Diagnostics.Stopwatch.GetTimestamp();
                var total = System.TimeSpan.FromTicks(now - start);
                var delta = System.TimeSpan.FromTicks(now - last);
                last = now;

                engine.Update(pipeline, pipelineAssets, total, delta);
                engine.Render(pipeline, pipelineAssets);
                pipeline.MoveToNextFrame();

                System.Windows.Forms.Application.DoEvents();
            }
        }