gpt4 book ai didi

delphi - 强制配备 nVidia Optimus 的系统为我的应用程序使用真正的 GPU?

转载 作者:行者123 更新时间:2023-12-03 14:54:01 25 4
gpt4 key购买 nike

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

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

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 也不支持变量导出。我确实尝试了其中一些,但无法使其发挥作用。

在同一个 nvidia 文档中,我读到可以通过静态链接到少数列出的 dll 之一来强制使用正确的 GPU。但我不想链接到我不使用的 dll。 (为什么 opengl.dll 不是其中之一,我无法理解。)一个简单的导出变量看起来更干净。

最佳答案

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

这个说法是不正确的。下面是展示如何从 Delphi DLL 导出全局变量的最简单示例:

library GlobalVarExport;

uses
Windows;

var
NvOptimusEnablement: DWORD;

exports
NvOptimusEnablement;

begin
NvOptimusEnablement := 1;
end.

我认为你的问题是你这样写的:

library GlobalVarExport;

uses
Windows;

var
NvOptimusEnablement: DWORD=1;

exports
NvOptimusEnablement;

begin
end.

编译失败并出现以下错误:

E2276 Identifier 'NvOptimusEnablement' cannot be exported

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

关于delphi - 强制配备 nVidia Optimus 的系统为我的应用程序使用真正的 GPU?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15372931/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com