private void InitializeDepthStencil(uint nWidth, uint nHeight) { // Create depth stencil texture Texture2DDescription descDepth = new Texture2DDescription() { Width = nWidth, Height = nHeight, MipLevels = 1, ArraySize = 1, Format = Format.D16UNorm, SampleDescription = new SampleDescription() { Count = 1, Quality = 0 }, BindingOptions = BindingOptions.DepthStencil, }; depthStencil = device.CreateTexture2D(descDepth); // Create the depth stencil view DepthStencilViewDescription depthStencilViewDesc = new DepthStencilViewDescription() { Format = descDepth.Format, ViewDimension = DepthStencilViewDimension. Texture2D }; depthStencilView = device.CreateDepthStencilView(depthStencil, depthStencilViewDesc); }