大家好我有一個非常奇怪的問題。 當我從程序的開頭遍歷我的代碼時,它很好,但是當我到達代碼中的部分以創建設備和交換鏈時,Visual Studio開始滯後於輸入並且變得不可用。我的鼠標也給出了真正延遲的響應。停止它的唯一方法是按Ctrl + Alt + Del並關閉Visual Studio。D3D11 CreateDeviceAndSwapChain使Visual Studio不可用
下面是直到問題的代碼。
HRESULT hr = S_OK;
RECT rc;
GetClientRect((*pWindowHandle), &rc);
UINT width = rc.right - rc.left;
UINT height = rc.bottom - rc.top;
UINT createDeviceFlags = 0;
#ifdef _DEBUG
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
D3D_DRIVER_TYPE driverTypes[] =
{
D3D_DRIVER_TYPE_HARDWARE,
D3D_DRIVER_TYPE_WARP,
D3D_DRIVER_TYPE_REFERENCE,
};
UINT numDriverTypes = ARRAYSIZE(driverTypes);
D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_0
};
UINT numFeatureLevels = ARRAYSIZE(featureLevels);
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 1;
sd.BufferDesc.Width = width;
sd.BufferDesc.Height = height;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = (*pWindowHandle);
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.Windowed = TRUE;
sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; // allow full-screen switching
for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++)
{
m_driverType = driverTypes[driverTypeIndex];
hr = D3D11CreateDeviceAndSwapChain(NULL, m_driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels,
D3D11_SDK_VERSION, &sd, &m_pSwapChain, &m_pd3dDevice, &m_featureLevel, &m_pImmediateContext);
if (SUCCEEDED(hr))
break;
}
我有一種感覺,可能都與視覺工作室,而不是該項目自D3D11樣本項目也做同樣的。他們運行良好,但一旦你試圖暫停或打破VS拋出搖擺。 我已經嘗試修復我的版本VS2013 Update2
有什麼可以幫助我嗎?從debug文件夾
輸出
Build started 02/11/2014 16:24:14.
1>Project "C:\Users\luckielordie\Source\Repos\3dtut2\Tutorial02_2010.vcxproj" on node 2 (Build target(s)).
1>ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe /c /I..\..\..\DXUT11\Core /I..\..\..\DXUT11\Optional /ZI /nologo /W4 /WX- /Od /Oi /Oy- /D WIN32 /D _DEBUG /D DEBUG /D PROFILE /D _WINDOWS /D D3DXFX_LARGEADDRESS_HANDLE /D _UNICODE /D UNICODE /Gm- /EHsc /RTC1 /MDd /GS /arch:SSE2 /fp:fast /Zc:wchar_t /Zc:forScope /openmp- /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TP /analyze- /errorReport:prompt D3D11.cpp
D3D11.cpp
Link:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\luckielordie\Source\Repos\3dtut2\Debug\D3DApplication.exe" /INCREMENTAL /NOLOGO d3d11.lib d3dcompiler.lib dxguid.lib winmm.lib comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /manifestinput:"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\Include\Manifest\dpiaware.manifest" /DEBUG /PDB:"C:\Users\luckielordie\Source\Repos\3dtut2\Debug\D3DApplication.pdb" /SUBSYSTEM:WINDOWS /LARGEADDRESSAWARE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\luckielordie\Source\Repos\3dtut2\Debug\D3DApplication.lib" /MACHINE:X86 /SAFESEH /SAFESEH:NO Debug\Tutorial02.res
Debug\D3D11.obj
Debug\D3D11ResourceBuilder.obj
Debug\Game.obj
Debug\GameObject.obj
Debug\main.obj
Debug\Model.obj
Debug\Shader.obj
Debug\Window.obj
Tutorial02_2010.vcxproj -> C:\Users\luckielordie\Source\Repos\3dtut2\Debug\D3DApplication.exe
1>Done Building Project "C:\Users\luckielordie\Source\Repos\3dtut2\Tutorial02_2010.vcxproj" (Build target(s)).
Build succeeded.
Time Elapsed 00:00:01.42
編輯: 在輸出我得到一個線
A thread <threadnumber> has exited with code 0(0x0)
在VS中讀取輸出。它可以幫助你很多 – Quest 2014-11-02 16:06:56
添加輸出到OP – 2014-11-02 16:28:12
我不是那個意思......你有D3D11_CREATE_DEVICE_DEBUG標誌設置,所以在運行時輸出窗口應該有一些有用的信息 – Quest 2014-11-02 16:32:13