internal static void UnloadData()
        {
            MyRenderTexturePool.ReleaseResources();
            AssertStructuresEmpty();

            m_prunningStructure.Clear();
            m_cullingStructure.Clear();
            m_manualCullingStructure.Clear();
            m_shadowPrunningStructure.Clear();
            m_farObjectsPrunningStructure.Clear();
            m_atmospherePurunnigStructure.Clear();
            m_nearObjects.Clear();

            Clear();

            //Remove all empty cull objects (they could be already added empty)
            foreach (var ro in m_renderObjects)
            {
                MyCullableRenderObject cullObject = ro.Value as MyCullableRenderObject;
                if (cullObject != null && cullObject.EntitiesContained == 0)
                {
                    m_renderObjectsToDraw.Add(cullObject);
                }
            }
            foreach (var cullObject in m_renderObjectsToDraw)
            {
                m_renderObjects.Remove(cullObject.ID);
                cullObject.UnloadContent();
            }
            m_renderObjectsToDraw.Clear();

            System.Diagnostics.Debug.Assert(m_renderObjects.Count == 0);
        }
        internal static void LoadContent(MyRenderQualityEnum quality)
        {
            MyRender.Log.WriteLine("MyRender.LoadContent(...) - START");

            GraphicsDevice = Device;
            MyRenderConstants.SwitchRenderQuality(quality);
            MyRenderTexturePool.RenderQualityChanged(quality);
            //Log.WriteLine("Viewport: " + GraphicsDevice.Viewport.ToString());

            LoadContent();

            MyRender.Log.WriteLine("MyRender.LoadContent(...) - END");
        }
        internal static void UnloadContent(bool removeObjects = true)
        {
            MyRender.Log.WriteLine("MyRender.UnloadContent - START");
            MyRender.Log.IncreaseIndent();

            UnloadContent_Video();

            foreach (var ro in m_renderObjects)
            {
                ro.Value.UnloadContent();
            }

            foreach (var renderComponent in m_renderComponents.Reverse())
            {
                renderComponent.Value.UnloadContent();
            }

            for (int i = 0; i < m_renderTargets.GetLength(0); i++)
            {
                DisposeRenderTarget((MyRenderTargets)i);
            }

            DisposeSpotShadowRT();

            if (m_randomTexture != null)
            {
                m_randomTexture.Dispose();
                m_randomTexture = null;
            }

            UnloadEffects();

            Clear();

            if (m_fullscreenQuad != null)
            {
                m_fullscreenQuad.Dispose();
                m_fullscreenQuad = null;
            }

            MyTextureManager.UnloadTexture(BlankTexture);
            MyRenderTexturePool.ReleaseResources();

            if (m_spriteBatch != null)
            {
                m_spriteBatch.Dispose();
                m_spriteBatch = null;
            }

            if (DefaultSurface != null)
            {
                DefaultSurface.Dispose();
                DefaultSurface = null;
            }
            if (DefaultDepth != null)
            {
                DefaultDepth.Dispose();
                DefaultDepth = null;
            }

            try
            {
                if (GraphicsDevice != null)
                {
                    GraphicsDevice.SetStreamSource(0, null, 0, 0);
                    GraphicsDevice.Indices      = null;
                    GraphicsDevice.PixelShader  = null;
                    GraphicsDevice.VertexShader = null;
                    for (int i = 0; i < 16; i++)
                    {
                        GraphicsDevice.SetTexture(i, null);
                    }

                    GraphicsDevice.EvictManagedResources();
                }
                GraphicsDevice = null;
            }
            catch (Exception e)
            {
                //Because of crash on Win8
                Log.WriteLine(e);
            }

            MyRender.Log.DecreaseIndent();
            MyRender.Log.WriteLine("MyRender.UnloadContent - END");
        }