///の内部の関数D3D12CreateDevice(); ですが自分の提示画像の内臓グラフィックスでは調べたところDirectX11までしか対応してないようなのでWARP software deviceなるものを使ってDirectX12に無理やりバージョンアップ?させたいのですがどうすればいいのでしょうか?参考サイトのマイクロソフト公式リファレンスのソースを見て自分で調べましたがどうなっているかわかりません。
参考サイト: https://www.intel.co.jp/content/www/jp/ja/support/articles/000005524/graphics-drivers.html
参考サイト2: https://docs.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-d3d12createdevice#examples
参考サイト3: https://docs.microsoft.com/en-us/windows/win32/direct3darticles/directx-warp#how-to-use-warp
#pragma comment(lib,"d3d12.lib") #pragma comment(lib,"dxgi.lib") #include <Windows.h> #include <Winerror.h> #include <d3d12.h> #include <dxgi1_4.h> #include <dxgi.h> #include <dxgi1_5.h> #include <dxgi1_6.h> #include <combaseapi.h> #include <d3dcommon.h> #ifdef _DEBUG #include <iostream> #endif #include <vector> using namespace std; void DebugOutputFormatString(const char* format) //void DebugOutputFormatString(const char* format,...) { #ifdef _DEBUG va_list valist; va_start(valist, format); vprintf(format, valist); va_end(valist); #endif } LRESULT WindowProcedure(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam) { if(msg == WM_DESTROY) { PostQuitMessage(0); return 0; } return DefWindowProc(hwnd,msg,wparam,lparam); } /*feature level 配列*/ D3D_FEATURE_LEVEL levels[] = {//10 D3D_FEATURE_LEVEL_1_0_CORE, 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_12_0, D3D_FEATURE_LEVEL_12_1 // D3D_FEATURE_LEVEL_12_1, }; ID3D12Device* _dev = nullptr; IDXGIFactory6* _dxgiFactory = nullptr; IDXGISwapChain4* _swapchain = nullptr; #ifdef _DEBUG int main() { #else int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int) { #endif //ID3D12Device::CheckFeatureSupport(); // CheckFeatureSupport(D3D_FEATURE_LEVEL_12_0,IID_PPV_ARGS(&_dev)); /*フューチャーレベルを設定*/ D3D_FEATURE_LEVEL featureLevel; int t = 0; //for(auto lv : levels) for(auto lv : levels) { //HRESULT h = D3D12CreateDevice(nullptr, lv, IID_PPV_ARGS(&_dev)); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// HRESULT h = D3D12CreateDevice(nullptr, lv, IID_PPV_ARGS(&_dev)); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ( h == S_OK) { featureLevel = lv; cout<<"成功です"<<std::endl; break; }else { // printf("%ld\n",h); printf(" %d %lx\n",t,h); t++; } } if(_dev == nullptr ) { printf("null"); //exit(1); //return -1; } /*アダプタを設定*/ auto result = CreateDXGIFactory1(IID_PPV_ARGS(&_dxgiFactory)); if(result != S_OK) { //return -1; } std::vector<IDXGIAdapter*> adapters; IDXGIAdapter* tmpAdapter = nullptr; for(int i = 0; _dxgiFactory->EnumAdapters(i,&tmpAdapter) != DXGI_ERROR_NOT_FOUND; i++) { adapters.push_back(tmpAdapter); } for(auto adpt : adapters) { DXGI_ADAPTER_DESC adesc = { }; adpt->GetDesc(&adesc); std::wstring strDesc = adesc.Description; if(strDesc.find(L"INTEL") != std::string::npos) { printf("aaaa"); tmpAdapter = adpt; break; } } WNDCLASSEX w = {}; w.cbSize = sizeof(WNDCLASSEX); w.lpfnWndProc = (WNDPROC)WindowProcedure; w.hInstance = GetModuleHandle(nullptr); RegisterClassEx(&w); // RECT wrc = { 0,0,window_width,window_height }; RECT wrc = { 0,0,100,100 };//ウインドウサイズ AdjustWindowRect(&wrc, WS_OVERLAPPEDWINDOW, false);//ウインドウサイズの補正 HWND hwnd = CreateWindow(w.lpszClassName, TEXT("DX12テスト"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, wrc.right - wrc.left, wrc.bottom - wrc.top, nullptr, nullptr, w.hInstance, nullptr); ShowWindow(hwnd, SW_SHOW); /*コマンドキュー*/ ID3D12CommandQueue* _cmdQueue = nullptr; D3D12_COMMAND_QUEUE_DESC cmdQueueDesc = { }; cmdQueueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; cmdQueueDesc.NodeMask = 0; cmdQueueDesc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_NORMAL; cmdQueueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; result = _dev->CreateCommandQueue(&cmdQueueDesc, IID_PPV_ARGS(&_cmdQueue)); DXGI_SWAP_CHAIN_DESC1 swapchainDesc = { }; swapchainDesc.Width = (UINT)100; swapchainDesc.Height = (UINT)100; swapchainDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; swapchainDesc.Stereo = false; swapchainDesc.SampleDesc.Count = 1; swapchainDesc.SampleDesc.Quality = 0; swapchainDesc.BufferUsage = DXGI_USAGE_BACK_BUFFER; swapchainDesc.BufferCount = 2; swapchainDesc.Scaling = DXGI_SCALING_STRETCH; swapchainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; swapchainDesc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED; swapchainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; result = _dxgiFactory->CreateSwapChainForHwnd(_cmdQueue, hwnd, &swapchainDesc, nullptr, nullptr, (IDXGISwapChain1**)&_swapchain); if(result == S_OK) { } printf("S_OK\n"); MSG msg = { }; while (true) { if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (msg.message == WM_QUIT) { break; } } UnregisterClass(w.lpszClassName, w.hInstance); //DebugOutputFormatString("show window test."); getchar(); return 0; }
あなたの回答
tips
プレビュー