private static void PrintSupportedQualityLevels(Device device, Format format) { for (var sampleCount = 1; sampleCount <= 32; sampleCount *= 2) { var qualityLevels = device.CheckMultisampleQualityLevels(format, sampleCount); Console.WriteLine(" Sample Count: {0}", sampleCount); if (qualityLevels != 0) Console.WriteLine(" Max Quality Level: {0}", qualityLevels); else { Console.WriteLine(" Not supported"); } if (qualityLevels == 0) break; } }
static void BuildMultisampleList(Format backBufferFormat, SettingsCombo10 combo) { Adapter adapter = null; if (combo.DriverType == DriverType.Hardware) { adapter = GraphicsDeviceManager.Factory.GetAdapter(combo.AdapterOrdinal); } SlimDX.Direct3D10.Device device; try { device = new SlimDX.Direct3D10.Device(adapter, combo.DriverType, DeviceCreationFlags.None); } catch (Direct3D10Exception) { // no good if (adapter != null) { adapter.Dispose(); } return; } for (int i = 1; i <= SlimDX.Direct3D10.Device.MultisampleCountMaximum; i++) { try { int quality = device.CheckMultisampleQualityLevels(backBufferFormat, i); combo.MultisampleCounts.Add(i); combo.MultisampleQualities.Add(quality); } catch (Direct3D10Exception) { // eat the exception } } device.Dispose(); if (adapter != null) { adapter.Dispose(); } }
private static void PrintSupportedQualityLevels(Device device, Format format) { for (var sampleCount = 1; sampleCount <= 32; sampleCount *= 2) { var qualityLevels = device.CheckMultisampleQualityLevels(format, sampleCount); Console.WriteLine(" Sample Count: {0}", sampleCount); if (qualityLevels != 0) { Console.WriteLine(" Max Quality Level: {0}", qualityLevels); } else { Console.WriteLine(" Not supported"); } if (qualityLevels == 0) { break; } } }
private void CreateSwapChain(IntPtr windowHandle, PresentationParameters presentParams) { DXGI.Format surfaceFormat = D3D10Helper.ToD3DSurfaceFormat(presentParams.BackBufferFormat); switch (presentParams.PresentInterval) { case PresentInterval.Immediate: _interval = 0; break; case PresentInterval.One: _interval = 1; break; case PresentInterval.Two: _interval = 2; break; } DXGI.SampleDescription sampleDesc = new DXGI.SampleDescription(1, 0); bool msEnabled = false; if (presentParams.MultiSampleCount > 1) { sampleDesc.Count = presentParams.MultiSampleCount; int q = _graphicsDevice.CheckMultisampleQualityLevels(surfaceFormat, presentParams.MultiSampleCount); if (presentParams.MultiSampleQuality < q) { sampleDesc.Quality = presentParams.MultiSampleQuality; } else { sampleDesc.Quality = q - 1; } msEnabled = true; } DXGI.SwapEffect swap; if (presentParams.RenderTargetUsage == RenderTargetUsage.PlatformDefault) { if (msEnabled) { swap = DXGI.SwapEffect.Discard; } else { swap = DXGI.SwapEffect.Sequential; } } else if (presentParams.RenderTargetUsage == RenderTargetUsage.DiscardContents) { swap = DXGI.SwapEffect.Discard; } else { swap = DXGI.SwapEffect.Sequential; } DXGI.ModeDescription modeDesc = new DXGI.ModeDescription(presentParams.BackBufferWidth, presentParams.BackBufferHeight, new SDX.Rational(60, 1), surfaceFormat); modeDesc.Scaling = DXGI.DisplayModeScaling.Stretched; _swapChain = new DXGI.SwapChain(_factory, _graphicsDevice, new DXGI.SwapChainDescription { BufferCount = 1, Flags = DXGI.SwapChainFlags.AllowModeSwitch, IsWindowed = true, ModeDescription = modeDesc, OutputHandle = windowHandle, SampleDescription = sampleDesc, SwapEffect = swap, Usage = DXGI.Usage.RenderTargetOutput }); //Add to tracker _renderer.Resources.AddTrackedObject(_swapChain.ComPointer, this); _factory.SetWindowAssociation(windowHandle, DXGI.WindowAssociationFlags.IgnoreAll | DXGI.WindowAssociationFlags.IgnoreAltEnter); }
/// <summary> /// Queries for the number of multisample quality levels are supported for the sample count. /// </summary> /// <param name="format">Specified format</param> /// <param name="multiSamplecount">Sample count</param> /// <returns>Number of supported quality levels </returns> public int QueryMultiSampleQualityLevels(SurfaceFormat format, int multiSamplecount) { return(_graphicsDevice.CheckMultisampleQualityLevels(D3D10Helper.ToD3DSurfaceFormat(format), multiSamplecount)); }