Example #1
0
 public void Dispose()
 {
     Shaders.Dispose();
     foreach (var sampler in samplerStates)
     {
         sampler.Value.Dispose();
     }
     samplerStates.Clear();
     foreach (var rp in deferredPipelines)
     {
         rp.Dispose();
     }
     deferredPipelines = null;
     ImmPipeline.Dispose();
     ImmPipeline = null;
     if (Device != null)
     {
         Device.Dispose();
     }
     Instance = null;
 }
Example #2
0
        public void ExecuteTasks()
        {
            RenderingInProgress = true;
            var         taskCount = taskQueue.Count;
            List <Task> tasks     = new List <Task>();

            for (int i = 0, count = 0; i < taskCount; i += count)
            {
                var j = 0;
                tasks.Clear();
                for (count = 0; j < NUM_THREADS && i + j < taskCount; j++)
                {
                    count++;
                    RenderTask task;
                    if (!taskQueue.TryDequeue(out task))
                    {
                        throw new SystemException("error dequeueing rendertask");
                    }
                    var payload = new TaskPayload {
                        pipelineNumber = j,
                        task           = task
                    };
                    var t = new Task(() => { RunTask(payload); });
                    t.Start();
                    tasks.Add(t);
                }
                Task.WaitAll(tasks.ToArray());
                for (var k = 0; k < j; k++)
                {
                    if (!tasks[k].IsFaulted)
                    {
                        deferredPipelines[k].FinishCommandList();
                        ImmPipeline.ExecuteCommandList(deferredPipelines[k].CommandList);
                        deferredPipelines[k].ReleaseCommandList();
                    }
                }
            }
            RenderingInProgress = false;
        }