private static MyAdapterInfo[] GetAdaptersList(Direct3D d3d) { MyAdapterInfo[] result = new MyAdapterInfo[d3d.AdapterCount]; for (var i = 0; i < result.Length; i++) { result[i] = new MyAdapterInfo(); var details = d3d.GetAdapterIdentifier(i); var currentDisplayMode = d3d.GetAdapterDisplayMode(i); result[i].CurrentDisplayMode = new MyDisplayMode { Height = currentDisplayMode.Height, Width = currentDisplayMode.Width, RefreshRate = currentDisplayMode.RefreshRate, AspectRatio = currentDisplayMode.AspectRatio }; result[i].DeviceName = details.DeviceName; result[i].VendorId = details.VendorId; result[i].DeviceId = details.DeviceId; result[i].Description = details.Description; result[i].Name = details.Description + " (" + details.DeviceName.Replace("\\", "").Replace(".", "") + ")"; result[i].SupportedDisplayModes = new MyDisplayMode[0]; bool retry = false; try { result[i].SupportedDisplayModes = GetSupportedDisplayModes(d3d, i); } catch (SharpDXException dxgiException) { if (dxgiException.ResultCode != ResultCode.NotAvailable) { throw; } m_backbufferFormat = Format.A8B8G8R8; retry = true; } if (retry) { try { result[i].SupportedDisplayModes = GetSupportedDisplayModes(d3d, i); } catch (SharpDXException dxgiException) { if (dxgiException.ResultCode != ResultCode.NotAvailable) { throw; } } } } MyGraphicTest test = new MyGraphicTest(); test.TestDX(d3d, ref result); return(result); }
public DeviceContext(IntPtr handle, int backBufferWidth, int backBufferHeight, bool fullScreen, bool verticalSync) { PerformanceMonitor = new PerformanceMonitor(); _formHandle = handle; PresentationParameters = new PresentParameters() { BackBufferFormat = Format.X8R8G8B8, BackBufferCount = 1, BackBufferWidth = backBufferWidth, BackBufferHeight = backBufferHeight, MultiSampleType = MultisampleType.None, SwapEffect = SwapEffect.Discard, EnableAutoDepthStencil = true, AutoDepthStencilFormat = Format.D24S8, PresentFlags = PresentFlags.DiscardDepthStencil, PresentationInterval = PresentInterval.Immediate, Windowed = !fullScreen, DeviceWindowHandle = _formHandle }; try { Direct3D library = new Direct3D(); if (library.AdapterCount == 0) { throw new Exception("Unable to find an appropriate Direct3D adapter."); } AdapterDetails adapterDetails = library.GetAdapterIdentifier(0); AdapterInformation adapterInformation = library.Adapters[0]; _device = new Device(library, 0, DeviceType.Hardware, _formHandle, CreateFlags.HardwareVertexProcessing, PresentationParameters); _viewport = _device.Viewport; _capabilities = _device.Capabilities; Tracer.Info("Adapter: {0}", adapterDetails.DeviceName); Tracer.Info("Driver: {0}, v{1}", adapterDetails.Driver, adapterDetails.DriverVersion); Tracer.Info("Max Texture Size: {0}x{1}", _capabilities.MaxTextureWidth, _capabilities.MaxTextureHeight); Tracer.Info("Max Texture Repeat: {0}", _capabilities.MaxTextureRepeat); Tracer.Info("Max Texture Aspect Ratio: {0}", _capabilities.MaxTextureAspectRatio); Tracer.Info("Texture Size Options: {0}", _capabilities.TextureCaps); } catch (Exception e) { Tracer.Error(e); return; } _vertexDeclarationBuilder = new VertexDeclarationBuilder(this); }
internal override void MakeApiInfo() { AdapterDetails details = Direct3D.GetAdapterIdentifier(d3d, 0); string adapter = details.Description; uint memRaw = Device.GetAvailableTextureMemory(device); float texMem = Device.GetAvailableTextureMemory(device) / 1024f / 1024f; ApiInfo = new string[] { "-- Using Direct3D9 --", "Adapter: " + adapter, "Processing mode: " + createFlags, "Texture memory: " + texMem + " MB", "Max texture size: (" + MaxTexWidth + ", " + MaxTexHeight + ")", "Depth buffer format: " + depthFormat, "Back buffer format: " + viewFormat, }; }
internal override void MakeApiInfo() { AdapterDetails details = Direct3D.GetAdapterIdentifier(d3d, 0); string adapter = details.Description; totalMem = VideoMemoryMB; ApiInfo = new string[] { "-- Using Direct3D9 --", "Adapter: " + adapter, "Processing mode: " + createFlags, null, "Max texture size: (" + MaxTexWidth + ", " + MaxTexHeight + ")", "Depth buffer format: " + depthFormat, "Back buffer format: " + viewFormat, }; UpdateApiInfo(); }
public DeviceEnumeration(Direct3D d3d) { InitializeComponent(); _displayModes = new List<DisplayMode>(); _settingsScript = new Script("DisplaySettings.txt"); _adapter = d3d.GetAdapterIdentifier(0); var allowedFormats = new[] { Format.X1R5G5B5, Format.A1R5G5B5, Format.R5G6B5, Format.X8R8G8B8, Format.A8R8G8B8, Format.A2R10G10B10, }; for (var af = 0; af < allowedFormats.Length; af++) { var format = allowedFormats[af]; var modes = d3d.GetAdapterModeCount(0, format); for (var m = 0; m < modes; m++) { var mode = d3d.EnumerateAdapterModes(0, format, m); if (mode.Height < 600) continue; var displayMode = new DisplayMode { Mode = mode, Bpp = af < 3 ? "16 bpp" : "32 bpp" }; _displayModes.Add(displayMode); } } txtAdapterName.Text = _adapter.Description; txtDriverVersion.Text = _adapter.DriverVersion.ToString(); if (_settingsScript.VariableCount == 0) { _windowed = true; rbWindowed.Checked = true; } else { if (_settingsScript.GetBool("windowed")) { _windowed = true; rbWindowed.Checked = true; } else { rbFullscreen.Checked = true; _windowed = false; } } if (!_windowed) { // enable fullscreen options chkVSync.Enabled = true; cbColorFormat.Enabled = true; cbResolution.Enabled = true; cbRefresh.Enabled = true; chkVSync.Checked = _settingsScript.GetBool("vsync"); ResetColorFormats(); long selectedRes = _settingsScript.GetNumber("resolution"); ResetResolution(selectedRes); long refresh = _settingsScript.GetNumber("refresh"); ResetRefresh(refresh); } }
public DeviceEnumeration(Direct3D d3d) { InitializeComponent(); _displayModes = new List <DisplayMode>(); _settingsScript = new Script("DisplaySettings.txt"); _adapter = d3d.GetAdapterIdentifier(0); var allowedFormats = new[] { Format.X1R5G5B5, Format.A1R5G5B5, Format.R5G6B5, Format.X8R8G8B8, Format.A8R8G8B8, Format.A2R10G10B10, }; for (var af = 0; af < allowedFormats.Length; af++) { var format = allowedFormats[af]; var modes = d3d.GetAdapterModeCount(0, format); for (var m = 0; m < modes; m++) { var mode = d3d.EnumerateAdapterModes(0, format, m); if (mode.Height < 600) { continue; } var displayMode = new DisplayMode { Mode = mode, Bpp = af < 3 ? "16 bpp" : "32 bpp" }; _displayModes.Add(displayMode); } } txtAdapterName.Text = _adapter.Description; txtDriverVersion.Text = _adapter.DriverVersion.ToString(); if (_settingsScript.VariableCount == 0) { _windowed = true; rbWindowed.Checked = true; } else { if (_settingsScript.GetBool("windowed")) { _windowed = true; rbWindowed.Checked = true; } else { rbFullscreen.Checked = true; _windowed = false; } } if (!_windowed) { // enable fullscreen options chkVSync.Enabled = true; cbColorFormat.Enabled = true; cbResolution.Enabled = true; cbRefresh.Enabled = true; chkVSync.Checked = _settingsScript.GetBool("vsync"); ResetColorFormats(); long selectedRes = _settingsScript.GetNumber("resolution"); ResetResolution(selectedRes); long refresh = _settingsScript.GetNumber("refresh"); ResetRefresh(refresh); } }