private void UpdateBackBuffer()
        {
            IDirect3DSurface             surface = HolographicFrame.GetRenderingParameters(HolographicFrame.CurrentPrediction.CameraPoses[0]).Direct3D11BackBuffer;
            IDirect3DDxgiInterfaceAccess surfaceDxgiInterfaceAccess = surface as IDirect3DDxgiInterfaceAccess;
            IntPtr resource = surfaceDxgiInterfaceAccess.GetInterface(ID3D11Resource);

            if (backBuffer == null || backBuffer.NativeResource.NativePointer != resource)
            {
                // Clean up references to previous resources.
                backBuffer?.Dispose();
                LeftEyeBuffer?.Dispose();
                RightEyeBuffer?.Dispose();

                // This can change every frame as the system moves to the next buffer in the
                // swap chain. This mode of operation will occur when certain rendering modes
                // are activated.
                Texture2D d3DBackBuffer = new Texture2D(resource);

                backBuffer = new Texture(GraphicsDevice).InitializeFromImpl(d3DBackBuffer, false);

                LeftEyeBuffer = backBuffer.ToTextureView(new TextureViewDescription()
                {
                    ArraySlice = 0, Type = ViewType.Single
                });
                RightEyeBuffer = backBuffer.ToTextureView(new TextureViewDescription()
                {
                    ArraySlice = 1, Type = ViewType.Single
                });
            }

            Description.BackBufferFormat = backBuffer.Format;
            Description.BackBufferWidth  = backBuffer.Width;
            Description.BackBufferHeight = backBuffer.Height;
        }
Esempio n. 2
0
        internal static void Dispose()
        {
            _font                 = null;
            _fontSmall            = null;
            _uiTextureRegionAtlas = null;
            _uiStylesheet         = null;
            Stylesheet.Current    = null;

            _assetManager.ClearCache();

            _whiteRegion = null;
            if (_white != null)
            {
                _white.Dispose();
                _white = null;
            }

#if !XENKO
            if (_uiRasterizerState != null)
            {
                _uiRasterizerState.Dispose();
                _uiRasterizerState = null;
            }
#endif
        }
Esempio n. 3
0
        internal static void Dispose()
        {
            _font              = null;
            _fontSmall         = null;
            _uiSpritesheet     = null;
            _uiStylesheet      = null;
            Stylesheet.Current = null;

            _whiteRegion = null;
            if (_white != null)
            {
                _white.Dispose();
                _white = null;
            }

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

#if !XENKO
            if (_uiRasterizerState != null)
            {
                _uiRasterizerState.Dispose();
                _uiRasterizerState = null;
            }
#endif
        }
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public override void Dispose()
 {
     if (!texture.IsDisposed)
     {
         texture.Dispose();
     }
 }
        private bool NeedToRecreateTexture(Xenko.Graphics.Texture tex, Vector3 dim)
        {
            if (tex == null || !TextureDimensionsEqual(tex, dim))
            {
                if (tex != null)
                {
                    tex.Dispose();
                }

                return(true);
            }
            return(false);
        }
Esempio n. 6
0
        public static bool DisposeTextureBySpecs(Xenko.Graphics.Texture tex, Vector3 dim, Xenko.Graphics.PixelFormat pixelFormat, MultisampleCount samples)
        {
            if (tex == null || !TextureDimensionsEqual(tex, dim) || tex.Format != pixelFormat || tex.MultisampleCount != samples)
            {
                if (tex != null)
                {
                    tex.Dispose();
                }

                return(true);
            }
            return(false);
        }
    private bool NeedToRecreateTexture(Xenko.Graphics.Texture tex, Vector3 dim, Xenko.Graphics.PixelFormat pixelFormat, MultisampleCount samples)
    {
        if (tex == null || !TextureDimensionsEqual(tex, dim) || tex.Format != pixelFormat || tex.MultisampleCount != samples)
        {
            if (tex != null)
            {
                tex.Dispose();
            }

            return(true);
        }
        return(false);
    }