Пример #1
0
        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;
        }
Пример #2
0
        public static Texture ToTextureView(this Texture texture, ViewType type, int arraySlice, int mipLevel)
        {
            var viewDescription = texture.ViewDescription;

            viewDescription.Type       = type;
            viewDescription.ArraySlice = arraySlice;
            viewDescription.MipLevel   = mipLevel;
            return(texture.ToTextureView(viewDescription));
        }
Пример #3
0
        /// <summary>
        /// Gets a view on this depth stencil texture as a readonly depth stencil texture.
        /// </summary>
        /// <returns>A new texture object that is bouded to the requested view.</returns>
        public static Texture ToDepthStencilReadOnlyTexture(this Texture texture)
        {
            if (!texture.IsDepthStencil)
            {
                throw new NotSupportedException("This texture is not a valid depth stencil texture");
            }

            var viewDescription = texture.ViewDescription;

            viewDescription.Flags = TextureFlags.DepthStencilReadOnly;
            return(texture.ToTextureView(viewDescription));
        }