2k1Toaster's picture

Any way to specify software render vs. hardware render like in DirectX?

Hello,

I have an application that works great. The problem is it relies on hardware rendering so if I run it via RemoteDesktop it won't work nor will it work on old hardware without OpenGL support.

The previous version of the app used DirectX and it was as simple as adding a try/catch around binding the graphics to hardware. If that failed, then it wasn't supported and it automatically did software rendering (no GPU, all CPU). Ate up the CPU like crazy, but it worked which is the important part.

Is there such a way in OpenGL? I see "GraphicsMode" but there is only "Default" in it...


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ERP's picture

I don't believe there is a way to force it.
OpenGL is supposed to fallback to software for unsupported functionality, so as long as there is an appropriate driver older hardware should work all be it painfully slowly.
Back in the bad old days it's what made OpenGL a pain in the ass to use for games, there was no way to tell what was hardware accelerated and what wasn't except to benchmark the features in the driver.

Of course that doesn't help with the remote desktop case.

elaverick's picture

You could potentially drop in the MesaGL libraries into the executable directory and allow it to do the software rendering for the application. The only way I can think of doing it automatically would be to have a bootstrapping program rename the DLL to the correct name if a RDP connection is detected.

2k1Toaster's picture

So how do the "MesaGL" libraries work?

If they are there, then it does software rendering? If not present then it does hardware?

If you try to run a "gamewindow" application on nonsupported hardware (like remote desktop) is there a way to catch it when it barfs, or is it an application exception immediately?

elaverick's picture

It's just a windows trick. The MesaGL libraries are a software implementation of OpenGL. Windows apps search for DLLs in their own working path or executable directory before looking for them in System32, this means if you place a DLL in the executable directory it will use that one in preference to the one in System32 for that one application.

I have to confess that I don't know if this will work with OpenTK, it depends on a few factors. For example if OpenTK hard links against the OpenGL32.dll in the System32 folder then it's going to ignore this standard search order. Secondly I don't know if .NET follows this behaviour, it's possible that since .NET applications are all run in a VM it may treat the root path of the VM as the start of the DLL search path rather than the program directory, although this would be pretty short sighted if it did.

If you want to test if it's feasible then drop the MesaGL OpenGL32.dll into the folder with your runtime and see if the framerate falls to lower levels (as MesaGL is a software renderer the performance is noticeably slower).

On a side note I see that MesaGL now supports OpenGLES which might be a nice way of testing GLES apps on a PC natively without complex emulators.

avc81's picture

i've tried mesa software rendering with opentk and it works..... except for color picking. if u want i managed to compile mesa 7.8.2 for windows

thorrablot's picture

Here's what the OpenGL org docs suggest. I believe you can get to the glGetString through the "accessing internal information" info at the bottom of this page

5.040 How do I know my program is using hardware acceleration on a Wintel card?

OpenGL doesn't provide a direct query to determine hardware acceleration usage. However, this can usually be inferred by using indirect methods.
If you are using the Win32 interface (as opposed to GLUT), call DescribePixelFormat() and check the returned dwFlags bitfield. If PFD_GENERIC_ACCELERATED is clear and PFD_GENERIC_FORMAT is set, then the pixel format is only supported by the generic implementation. Hardware acceleration is not possible for this format. For hardware acceleration, you need to choose a different format.
If glGetString(GL_VENDOR) returns something other than "Microsoft Corporation", it means you're using the board's ICD. If it returns "Microsoft Corporation", this implies you chose a pixel format that your device can't accelerate. However, glGetString(GL_VENDOR) also returns this if your device has an MCD instead of an ICD, which means you might still be hardware accelerated in this case.
Another way to check for hardware acceleration is to temporarily remove or rename the ICD, so it can't be loaded. If performance drops, it means you were hardware accelerated before. Don't forget to restore the ICD to its original location or name. (To find your ICD file name, run the regedit utility and search for a key named "OpenGLdrivers".)
You can also gather performance data by rendering into the back buffer and comparing the results against known performance statistics for your device. This method is particularly useful for devices that revert to software rendering for some state combinations or OpenGL features. See the section on performance for more information.

2k1Toaster's picture

Thanks everyone for the help. I am looking more into the mesa option as a backup. If I run into any problems I will let you know.