sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.69k stars 638 forks source link

SharpDX.DXGI fails on GetDisplayModeList for second monitor (E_FAIL/Unspecified error) #914

Closed Inari-Whitebear closed 7 years ago

Inari-Whitebear commented 7 years ago

I have two display. My main one on the right (1920x1080) and my second one on the left (). When calling GetDisplayModeList for the second, this code fails with

{HRESULT: [0x80004005], Module: [General], ApiCode: [E_FAIL/Unspecified error], Message: Unspecified error

   at SharpDX.Result.CheckError()
   at SharpDX.DXGI.Output.GetDisplayModeList(Format enumFormat, Int32 flags, Int32& numModesRef, ModeDescription[] descRef)
   at SharpDX.DXGI.Output.GetDisplayModeList(Format format, DisplayModeEnumerationFlags flags)
   at sharpdxgitest.Form1..ctor() in D:\Dev\sharpdxgitest\sharpdxgitest\Form1.cs:line 25
   at sharpdxgitest.Program.Main() in D:\Dev\sharpdxgitest\sharpdxgitest\Program.cs:line 19
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
Factory1 a = new Factory1();
for (int i = 0; i < a.Adapters.Length; ++i)
{
  for (int j = 0; j < a.Adapters[i].Outputs.Length; ++j)
  {
    var outputs = a.Adapters[i].Outputs[j];
    ModeDescription[] displayModeList = outputs.GetDisplayModeList(Format.R8G8B8A8_UNorm_SRgb, DisplayModeEnumerationFlags.Interlaced);
  }
}
xoofx commented 7 years ago

Unless proven otherwise, unlikely a SharpDX issue but a behavior of the underlying DXGI api. You can try to replicate this with a simple C++ program.

Inari-Whitebear commented 7 years ago

Ah, yeah, seems it's a dxgi fail :/ Wasn't aware that was the Window's APIs name so I thought it was a SharpDX thing still