强制系统为我的应用程序使用真正的

强制系统为我的应用程序使用真正的

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

问题描述

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

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

全局变量 NvOptimusEnablement(驱动程序版本 302 中的新增功能)从 302 版驱动程序开始,应用程序开发人员可以在运行时指示 Optimus 驱动程序使用高性能渲染任何应用程序的图形——即使是那些应用程序没有现有的应用程序配置文件.他们可以通过导出一个名为 NvOptimusEnablement 的全局变量.擎天柱驱动程序寻找出口的存在和价值.只有 LSB的 DWORD 在这个时候很重要.0x00000001 的值表示应该使用高性能图形执行渲染.一个值 0x00000000 表示应忽略此方法.示例用法:

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

问题是我想用 Delphi 来做这件事.从我读过的内容来看,即使存在一些黑客攻击,Delphi 也不支持导出变量.我确实尝试了其中的一些,但无法使其发挥作用.

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

解决方案

这种说法是错误的.下面是一个最简单的例子,展示了如何从 Delphi DLL 中导出全局变量:

library GlobalVarExport;用途视窗;无功NvOptimusEnablement:DWORD;出口NvOptimusEnablement;开始NvOptimusEnablement := 1;结尾.

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

library GlobalVarExport;用途视窗;无功NvOptimusEnablement:DWORD=1;出口NvOptimusEnablement;开始结尾.

编译失败并出现此错误:

E2276 标识符NvOptimusEnablement"无法导出

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

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

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

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

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.

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.

解决方案

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.

And that fails to compile with this error:

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 04:19