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

问题描述

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

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

从在Optimus系统上启用高性能图形渲染():

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; }

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

10-20 10:42