Axiom.RenderSystems.DirectX9.D3DRenderSystem.GetDepthStencilFormatFor C# (CSharp) Method

GetDepthStencilFormatFor() private method

private GetDepthStencilFormatFor ( System.Text.Format fmt ) : System.Text.Format
fmt System.Text.Format
return System.Text.Format
        public Format GetDepthStencilFormatFor( Format fmt )
        {
            Format dsfmt;
            // Check if result is cached
            if ( _depthStencilHash.TryGetValue( fmt, out dsfmt ) )
                return dsfmt;

            // If not, probe with CheckDepthStencilMatch
            dsfmt = Format.Unknown;

            // Get description of primary render target
            var activeDevice = _deviceManager.ActiveDevice;
            var surface = activeDevice.PrimaryWindow.RenderSurface;
            var srfDesc = surface.Description;

            // Probe all depth stencil formats
            // Break on first one that matches
            foreach ( var df in DepthStencilFormats )
            {
                // Verify that the depth format exists
                if ( !_pD3D.CheckDeviceFormat( _activeD3DDriver.AdapterNumber, DeviceType.Hardware, srfDesc.Format, Usage.DepthStencil, ResourceType.Surface, df ) )
                    continue;
                // Verify that the depth format is compatible
                if (!_pD3D.CheckDepthStencilMatch( _activeD3DDriver.AdapterNumber, DeviceType.Hardware, srfDesc.Format, fmt, df ) )
                    continue;
                
                dsfmt = df;
                break;
            }
            // Cache result
            _depthStencilHash[ fmt ] = dsfmt;
            return dsfmt;
        }
D3DRenderSystem