【目标】
双显卡测试
【思路】
1 在创建Device的时候加入测试代码
FD3D9DynamicRHI.UpdateD3DDeviceFromViewports
for( UINT Adapter=0;Adapter<Direct3D->GetAdapterCount();Adapter++){D3DADAPTER_IDENTIFIER9 Identifier;HRESULT Res=Direct3D->GetAdapterIdentifier(Adapter,0,&Identifier);if( appStrstr(*FString(Identifier.Description), TEXT("PerfHUD"))!= NULL ){AdapterNumber=Adapter;DeviceType= D3DDEVTYPE_REF;break;}printf("Device[%d]%s\n",Adapter,Identifier.Description);D3DCAPS9 DCaps;if(SUCCEEDED(Direct3D->GetDeviceCaps(AdapterIndex,D3DDEVTYPE_HAL,&DCaps))){printf("MaxPrimitiveCount=%d,MaxVertexIndex=%d\n",DCaps.MaxPrimitiveCount,DCaps.MaxVertexIndex);}}
2 在笔记本上测试,输出就一个显卡device
也就是驱动层已经自动分配了,
3 NVIDIA的说明 Optimus路由层会识别DX调用就会切独立GPU,然而并不是
http://www.docin.com/p-1654368378.html
4 官网开发向导
https://developer.nvidia.com/optimus
5 网上有个同样问题的帖子
http://stackoverflow.com/questions/10535950/forcing-nvidia-gpu-programmatically-in-optimus-laptops

解决方案

320
6 官方文档在附件
http://www.nvidia.com/object/LO_optimus_whitepapers.html





静态链接
7 实验
尝试在PIB.h
// Nvidia Global variableextern"C"{_declspec(dllexport)extern DWORD NvOptimusEnablement;}
PIB.cpp
// Nvidia Global variableextern"C"{_declspec(dllexport) DWORD NvOptimusEnablement=0x00000001;}

但是测试还是没有效果
8 实验
测试动态链接库
在WinMain中
HINSTANCE his =LoadLibraryA("nvapi.dll");....FreeLibrary(his);//释放dll



10 这个问题比较贴切
http://stackoverflow.com/questions/16354607/directx11-sdk-june2010-initialization-on-vc-2010
回答

11 这个说的是官方方法没效果的
http://stackoverflow.com/questions/17270429/forcing-hardware-accelerated-rendering
12
http://gamedev.stackexchange.com/questions/53999/select-display-adapter-in-d3d9/54004#54004

13
createdxgifactory1
enumadapters 1
https://msdn.microsoft.com/en-us/library/windows/desktop/bb174538(v=vs.85).aspx

上面是DX11的接口
14 在FD3D9DynamicRHI.UpdateD3DDeviceFromViewports中,添加测试代码
15 把显卡名字显示到标题栏中
16 实验:使用DX11
参数添加 -dx11
【步骤】
1
附件列表
浙公网安备 33010602011771号