void OnResize() { Helpers.Dispose(ref depthBuffer); Helpers.Dispose(ref dsv); Helpers.Dispose(ref colorBuffer); Helpers.Dispose(ref rtv); var resolution = Surface.Resolution; TextBatcher.Resolution = resolution; UILineBatcher.Resolution = resolution; depthBuffer = new Texture2D(Surface.Device, new Texture2DDescription { Format = Format.R32_Typeless, ArraySize = 1, MipLevels = 1, Width = resolution.X, Height = resolution.Y, SampleDescription = new SampleDescription(1, 0), Usage = ResourceUsage.Default, BindFlags = BindFlags.DepthStencil, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None }); depthBuffer.DebugName = "Depth Buffer"; var depthStencilViewDescription = new DepthStencilViewDescription { Flags = DepthStencilViewFlags.None, Dimension = DepthStencilViewDimension.Texture2D, Format = Format.D32_Float, Texture2D = { MipSlice = 0 } }; dsv = new DepthStencilView(Surface.Device, depthBuffer, depthStencilViewDescription); dsv.DebugName = "Depth DSV"; //Using a 64 bit texture in the demos for lighting is pretty silly. But we gon do it. colorBuffer = new Texture2D(Surface.Device, new Texture2DDescription { Format = Format.R16G16B16A16_Float, ArraySize = 1, MipLevels = 1, Width = resolution.X, Height = resolution.Y, SampleDescription = new SampleDescription(1, 0), Usage = ResourceUsage.Default, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None }); colorBuffer.DebugName = "Color Buffer"; srv = new ShaderResourceView(Surface.Device, colorBuffer); srv.DebugName = "Color SRV"; rtv = new RenderTargetView(Surface.Device, colorBuffer); rtv.DebugName = "Color RTV"; }
public void Resize(Int2 resolution, bool fullScreen) { Helpers.Dispose(ref drawingSurfaceRTV); Helpers.Dispose(ref drawingSurfaceBuffer); swapChain.ResizeBuffers(2, resolution.X, resolution.Y, Format.Unknown, SwapChainFlags.None); swapChain.IsFullScreen = fullScreen; // Get the backbuffer from the swapchain. drawingSurfaceBuffer = Resource.FromSwapChain <Texture2D>(swapChain, 0); drawingSurfaceBuffer.DebugName = "Window Backbuffer"; drawingSurfaceRTV = new RenderTargetView(Device, drawingSurfaceBuffer) { DebugName = "Window Backbuffer RTV" }; Resolution = resolution; }