Beispiel #1
0
        public void UpdateResources(DeviceContext deviceContext)
        {
            for (int i = m_waitingAssets.Count - 1; i >= 0; --i)
            {
                CAsset asset = m_waitingAssets[i];
                if (asset.IsLoaded)
                {
                    CResource resource = m_registeredResources[asset.Guid];
                    System.Diagnostics.Debug.Assert(resource != null);
                    Task.Run(() => CreateResource(resource, asset));

                    ContainerUtilities.RemoveSwapAt(m_waitingAssets, i);
                    break;
                }
            }

            lock (m_resourceMutex)
            {
                for (int i = 0; i < m_waitingResources.Count; ++i)
                {
                    m_waitingResources[i].InitWithContext(m_graphicsDevice, deviceContext);
                }
                m_waitingResources.Clear();
            }
        }
Beispiel #2
0
        private void CreateResource(CResource target, CAsset source)
        {
            System.Diagnostics.Debug.Assert(source.IsLoaded);
            target.InitFromAsset(m_graphicsDevice, source);

            if (target.NeedsContext())
            {
                lock (m_resourceMutex)
                {
                    m_waitingResources.Add(target);
                }
            }
            else
            {
                target.FinishLoading();
            }
        }