Пример #1
0
        private IEnumerator <object> PreloadShadersAsyncImpl(RenderCoordinator coordinator, DeviceManager dm, IndexBuffer tempIb, List <Material> materials, Action <float> onProgress, int speed)
        {
            var sw   = Stopwatch.StartNew();
            var wfns = new Task.WaitForNextStep();

            for (int i = 0; i < materials.Count; i++)
            {
                var m = materials[i];
                if (onProgress != null)
                {
                    onProgress(i / (float)materials.Count);
                }
                coordinator.BeforeIssue(() => m.Preload(coordinator, dm, tempIb));
                if ((i % speed) == 0)
                {
                    yield return(wfns);
                }
            }

            onProgress(1f);

            coordinator.DisposeResource(tempIb);

            var elapsed = sw.Elapsed.TotalMilliseconds;

            Debug.WriteLine($"Async shader preload took {elapsed:000.00}ms");
        }
Пример #2
0
        private void QueueGenerateMips()
        {
            lock (Lock) {
                _IsQueued = false;

                var workItem = new GenerateMipsWorkItem {
                    Atlas  = this,
                    Region = DirtyMipsRegion
                };
                DirtyMipsRegion = default;

                if ((workItem.Region.Width <= 0) || (workItem.Region.Height <= 0))
                {
                    return;
                }

                Coordinator.ThreadGroup.Enqueue(workItem);
                Coordinator.BeforeIssue(_BeforeIssue);
            }
        }