[英]DirectX : cannot create an directx11 device even though my system says it supports it
我打開 dxdiag 應用程序,選擇顯示選項卡以檢查支持的功能級別,這是結果
我今天內存不足,因為我的一個芯片被炸毀了,現在在 2GB 內存上運行
所以看起來我的設備支持 Directx 功能級別 11 很棒
跳轉到 Visual Studio 2019 我嘗試創建一個 D3D11 設備
D3D_FEATURE_LEVEL levels[] = { //Supported Levels We Want 11 or above
D3D_FEATURE_LEVEL_9_1,
D3D_FEATURE_LEVEL_9_2,
D3D_FEATURE_LEVEL_9_3,
D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_11_1
};
D3D_FEATURE_LEVEL supported = {};
HRESULT deviceCreate = D3D11CreateDevice(
nullptr //Use Default Adapter
,D3D_DRIVER_TYPE_HARDWARE,0 //Use Hardware ,no software module provided
,D3D11_CREATE_DEVICE_BGRA_SUPPORT | D3D11_CREATE_DEVICE_DEBUG //Flags for device creation
,levels,ARRAYSIZE(levels),D3D11_SDK_VERSION //Feature array,size of array,sdk to use
,&device,&supported,&context //Created Device,supported level,context
);
if (FAILED(deviceCreate))
{
MessageBox(NULL, L"Failed To Create D3D11 Device", L"Failed DirectX", MB_OK);
error = 1;
return;
}
switch (supported)
{
case D3D_FEATURE_LEVEL_9_1:MessageBox(NULL, L"9_1", L"9_1", MB_OK);
break;
case D3D_FEATURE_LEVEL_9_2:MessageBox(NULL, L"9_2", L"9_2", MB_OK);
break;
case D3D_FEATURE_LEVEL_9_3:MessageBox(NULL, L"9_3", L"9_3", MB_OK);
break;
case D3D_FEATURE_LEVEL_10_0:MessageBox(NULL, L"10_0", L"10_0", MB_OK);
break;
case D3D_FEATURE_LEVEL_10_1:MessageBox(NULL, L"10_1", L"10_1", MB_OK);
break;
case D3D_FEATURE_LEVEL_11_0:MessageBox(NULL, L"11_0", L"11_0", MB_OK);
break;
case D3D_FEATURE_LEVEL_11_1:MessageBox(NULL, L"11_1", L"11_1", MB_OK);
}
輸出:
我查看了我的制造商網站和 Windows 更新,但都說您已經安裝了最新的驅動程序。 任何幫助將不勝感激
正如評論中建議的那樣,刪除支持的最低功能級別即 9_1 是答案。
如果特征級別數組為空,則從文檔中獲取默認數組
D3D_FEATURE_LEVEL levels[] = {
D3D_FEATURE_LEVEL_9_1,
D3D_FEATURE_LEVEL_9_2,
D3D_FEATURE_LEVEL_9_3,
D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_11_1
};
當我超過陣列被用來和設備檢查其特征水平的支持但為了與第一支持的陣列中的特征量級別被返回[不適用於設備的最佳],這是相同的
因此,只需反轉數組並將 Feature level 11 放在數組中的第一個就是答案
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.