【目标】

 

 

双显卡测试

【思路】

1 在创建Device的时候加入测试代码

FD3D9DynamicRHI.UpdateD3DDeviceFromViewports

 

  1. for( UINT Adapter=0;Adapter<Direct3D->GetAdapterCount();Adapter++)
  2. {
  3. D3DADAPTER_IDENTIFIER9 Identifier;
  4. HRESULT Res=Direct3D->GetAdapterIdentifier(Adapter,0,&Identifier);
  5. if( appStrstr(*FString(Identifier.Description), TEXT("PerfHUD"))!= NULL )
  6. {
  7. AdapterNumber=Adapter;
  8. DeviceType= D3DDEVTYPE_REF;
  9. break;
  10. }
  11. printf("Device[%d]%s\n",Adapter,Identifier.Description);
  12. D3DCAPS9 DCaps;
  13. if(SUCCEEDED(Direct3D->GetDeviceCaps(AdapterIndex,D3DDEVTYPE_HAL,&DCaps)))
  14. {
  15. printf("MaxPrimitiveCount=%d,MaxVertexIndex=%d\n",DCaps.MaxPrimitiveCount,DCaps.MaxVertexIndex);
  16. }
  17. }
 

 

 

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


 

http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf

 

静态链接

 

7 实验

尝试在PIB.h 

 

  1. // Nvidia Global variable
  2. extern"C"{
  3. _declspec(dllexport)extern DWORD NvOptimusEnablement;
  4. }
 

 

PIB.cpp 

 

  1. // Nvidia Global variable
  2. extern"C"{
  3. _declspec(dllexport) DWORD NvOptimusEnablement=0x00000001;
  4. }
 
用dependence看

 

 

但是测试还是没有效果

 

 

8 实验

测试动态链接库

在WinMain中

 

  1. HINSTANCE his =LoadLibraryA("nvapi.dll");
  2. ....
  3. FreeLibrary(his);//释放dll
依然木有效果
 
9
 
 
 
 

 

 

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

 


 

【步骤】

 



 



附件列表

 

posted on 2016-09-02 15:45  维尔福  阅读(671)  评论(0编辑  收藏  举报