Open zeromus opened 5 years ago
DRI_PRIME
and you set it to 0 for the first card, 1 for the second et cetera. Still can't remember the equivalent for AMD.I've seen it in MAME (dep. walker shows as exported, so yeah it's trivial to add).
extern "C"
{
__declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
it's trivial to add
It's not, C# does not have the ability to export static data fields. Even for more modern .NET, the UnmanagedCallersOnly
attribute only can export functions, not static data members (and I believe it is limited to NativeAOT?). The only workaround to provide the exports is to have a fully native application in the first place (i.e. NativeAOT) and statically link in some C library which provides the data exports. This isn't happening in BizHawk for a long time, so the only method for us is to just link against nvapi64.dll
and call NvAPI_Initialize
it seems (for AMD, seems like there isn't any solution ???)
The = 1 is probably implemented in the driver as checking for nonzero; therefore if you export any function at all, it will be nonzero and satisfy the driver. So you can export a dummy function and it won't really make a difference.
Also, in case there was still tension about using more modern .net in order to placate people like me who won't upgrade, which doesn't matter anymore because it's already happened and IDGAF anymore, you could probably make a CLI tool that would add a new dll export to an executable. This would have the advantage of solving the problem for everyone, so it would be worth some engineering, and maybe make a good assignment for a college student.
For "isn't happening for a long time" I'm more referring to the limitations imposed by NativeAOT if anything (or I guess more IL trimming since that's mandated for NativeAOT), which more make it so our use of reflection needs to be mostly ripped out and replaced with source generators or whatever (some uses could still be done by just adding some attributes, although some like BizInvoker aren't as simple), and we would need to ditch WinForms since that's not NativeAOT compatible (although we need to do so anyways to move everything to modern .NET, Linux included)
There's a concept of forcing optimus to enable. Using this should improve the experience for laptop users and quiet support requests. It seems a little complicated. Someone with such a laptop needs to investigate it. Using c# makes it more complex. Here are several possibilities: https://stackoverflow.com/questions/17270429/forcing-hardware-accelerated-rendering