强制系统与nVidia Optimus使用真正的GPU为我的应用程序? [英] Force system with nVidia Optimus to use the real GPU for my application?

查看:941
本文介绍了强制系统与nVidia Optimus使用真正的GPU为我的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的应用程序始终使用nVidia Optimus笔记本电脑上的真正gpu来运行。

I want my application to always run using the real gpu on nVidia Optimus laptops.

从在Optimus系统上启用高性能图形渲染( http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf ):

From "Enabling High Performance Graphics Rendering on Optimus Systems", (http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf):


全局变量NvOptimusEnablement(驱动程序版本302中的新增)
从Release 302驱动程序开始,应用程序开发人员可以
在运行时指导Optimus驱动程序使用高性能
Graphics来呈现任何应用程序 - 即使那些
的应用程序没有现有的应用程序配置文件。他们可以通过
导出一个名为NvOptimusEnablement的全局变量来执行此操作。 Optimus
驱动程序查找导出的存在和值。目前只有DWORD的LSB
很重要。值0x00000001表示使用高性能图形执行渲染的
。 A
值为0x00000000表示此方法应该被忽略。
示例用法:

Global Variable NvOptimusEnablement (new in Driver Release 302) Starting with the Release 302 drivers, application developers can direct the Optimus driver at runtime to use the High Performance Graphics to render any application–even those applications for which there is no existing application profile. They can do this by exporting a global variable named NvOptimusEnablement. The Optimus driver looks for the existence and value of the export. Only the LSB of the DWORD matters at this time. A value of 0x00000001 indicates that rendering should be performed using High Performance Graphics. A value of 0x00000000 indicates that this method should be ignored. Example Usage:



extern "C" {   _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; }

问题是我想用Delphi做这个。从我读过的Delphi不支持导出变量,即使有一些黑客存在。我确实尝试了其中的一些,但无法使其正常工作。

The problem is that I want to do this using Delphi. From what I've read Delphi does not support export of variables even though some hacks exists. I did try a few of them but couldn't make it work.

在同一个nvidia文档中,我看到强制合适的GPU可以通过静态链接到一个的少数列出的dll。但我不想链接到我没有使用的dll。 (为什么opengl.dll不是其中之一是超出我的。)一个简单的导出变量看起来更清洁。

In the same nvidia document I read that forcing the proper GPU can be accomplished via linking statically to one of a handful listed dlls. But I don't want to link to dlls I'm not using. (Why the opengl.dll is not one of them is beyond me.) A simple exported variable seems much cleaner.

推荐答案


从我读过的Delphi不支持导出变量。

From what I've read Delphi does not support export of variables.

该语句不正确。以下是最简单的示例,显示如何从Delphi DLL导出全局变量:

That statement is incorrect. Here's the simplest example that shows how to export a global variable from a Delphi DLL:

library GlobalVarExport;

uses
  Windows;

var
  NvOptimusEnablement: DWORD;

exports
  NvOptimusEnablement;

begin
  NvOptimusEnablement := 1;
end.

我想你的问题是你这样写:

I think your problem is that you wrote it like this:

library GlobalVarExport;

uses
  Windows;

var
  NvOptimusEnablement: DWORD=1;

exports
  NvOptimusEnablement;

begin
end.

这个错误无法编译:


E2276 Identifier 'NvOptimusEnablement' cannot be exported

我不明白为什么编译器不喜欢第二个版本。这可能是一个错误。但是第一个版本的解决方法就好了。

I don't understand why the compiler doesn't like the second version. It's probably a bug. But the workaround in the first version is just fine.

这篇关于强制系统与nVidia Optimus使用真正的GPU为我的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆