/// <summary> /// Initializes a new instance of the <see cref="FormatSupportInfo"/> class. /// </summary> /// <param name="format">The format being queried.</param> /// <param name="formatSupport">The format support.</param> /// <param name="computeSupport">The compute support.</param> /// <param name="multisampleMax">The multisample maximum.</param> public FormatSupportInfo(BufferFormat format, D3D11.FormatSupport formatSupport, D3D11.ComputeShaderFormatSupport computeSupport, GorgonMultisampleInfo multisampleMax) { Format = format; FormatSupport = (BufferFormatSupport)formatSupport; ComputeSupport = (ComputeShaderFormatSupport)computeSupport; MaxMultisampleCountQuality = multisampleMax; }
/// <summary> /// Checks for standard antialiasing support. /// </summary> private bool CheckIsStandardAntialiasingPossible() { // Very important to check possible antialiasing // More on the used technique // see http://msdn.microsoft.com/en-us/library/windows/apps/dn458384.aspx D3D11.FormatSupport formatSupport = m_handlerD3D11.Device1.CheckFormatSupport(GraphicsHelper.DEFAULT_TEXTURE_FORMAT); if ((formatSupport & D3D11.FormatSupport.MultisampleRenderTarget) != D3D11.FormatSupport.MultisampleRenderTarget) { return(false); } if ((formatSupport & D3D11.FormatSupport.MultisampleResolve) != D3D11.FormatSupport.MultisampleResolve) { return(false); } if (m_handlerD3D11.FeatureLevel == SharpDX.Direct3D.FeatureLevel.Level_9_1) { return(false); } try { D3D11.Texture2DDescription textureDescription = new D3D11.Texture2DDescription(); textureDescription.Width = 100; textureDescription.Height = 100; textureDescription.MipLevels = 1; textureDescription.ArraySize = 1; textureDescription.Format = GraphicsHelper.DEFAULT_TEXTURE_FORMAT; textureDescription.Usage = D3D11.ResourceUsage.Default; textureDescription.SampleDescription = new DXGI.SampleDescription(2, 0); textureDescription.BindFlags = D3D11.BindFlags.ShaderResource | D3D11.BindFlags.RenderTarget; textureDescription.CpuAccessFlags = D3D11.CpuAccessFlags.None; textureDescription.OptionFlags = D3D11.ResourceOptionFlags.None; D3D11.Texture2D testTexture = new D3D11.Texture2D(m_handlerD3D11.Device1, textureDescription); GraphicsHelper.SafeDispose(ref testTexture); } catch (Exception) { return(false); } // Check for quality levels int lowQualityLevels = m_handlerD3D11.Device1.CheckMultisampleQualityLevels(GraphicsHelper.DEFAULT_TEXTURE_FORMAT, 2); int mediumQualityLevels = m_handlerD3D11.Device1.CheckMultisampleQualityLevels(GraphicsHelper.DEFAULT_TEXTURE_FORMAT, 4); int hightQualityLevels = m_handlerD3D11.Device1.CheckMultisampleQualityLevels(GraphicsHelper.DEFAULT_TEXTURE_FORMAT, 8); // Generate sample descriptions for each possible quality level if (lowQualityLevels > 0) { m_antialiasingConfigLow = new DXGI.SampleDescription(2, lowQualityLevels - 1); } if (mediumQualityLevels > 0) { m_antialiasingConfigMedium = new DXGI.SampleDescription(4, mediumQualityLevels - 1); } if (hightQualityLevels > 0) { m_antialiasingConfigHigh = new DXGI.SampleDescription(8, hightQualityLevels - 1); } return(lowQualityLevels > 0); }