glGetString?

I have a need to query the graphics card to find the card name. One option is to use glGetString to get the vendor, renderer (which is usually the chip set), OpenGL version and extensions. Unfortunately, the GL class in Unity does not offer GetString, so it would have to be done in a plugin. Of course, if I use plugins, I could use system-specific methods to query hardware.

Here are my two questions relating to this:

Can Unity give me any card info besides Shader.isSupported?
Do plugins work for web players (assuming I have plugins for both platforms)?

Thanks for any advice or insights!

glGetString: no, it’s not exposed at the moment, nor is any more info regarding the hardware. We’ll add that in the future. Besides, I’m interested: what do you need the exact hardware info for?

Plugins are disabled in the webplayer for security reasons. Plugins are totally uncontrolled native code, and one could easily imagine a plugin doing something really bad to the user’s machine. We can’t allow that in the web player.

As a developer I only care about what shaders a card can run, the number of texture units it has, and a couple of other things. However, when we deal with customers, we have historically needed to communicate using the name of the graphics card (with our old game engine). We will soon be launching a limited beta version of our product using Unity, and we wish to automatically collect some performance data. We don’t want to require our beta-testers to have to look anything up on their system (though it seems we will have to anyway).

I should mention that our customer base (for Big Brainz, Inc.) is not a gaming community, nor do they have gaming machines. It is comprised of parents looking for educational software for their children. They are a largely non-technical demographic, and any correspondence with them that concerns the graphics card capabilities will have to be in terms of the card name, at most. (Mac users may not have to worry so much about this due to the tight hardware integration).

Anyway, thanks for the reply and info. I suspected as much for web player plugins, but I wanted to be sure.

You may want to look into running the command system_profiler from a Unity script or plugin if that doesn’t work. I guess that only covers your Mac users, though. Maybe there’s something similar you could do for Windows.

Untested:

System.Diagnostics.Process.Start("system_profiler","> /tmp/profile.txt");

Then you could use regular .NET file IO to read it in and do whatever with it.

-Jon

On windows your best bet is launching dxdiag - this will get all relevant machine information and DirectX driver info. But most often both DX and GL drivers are inside the same driver, so for example if there’s nvidia driver nv4_disp.dll with a version of 6.14.10.9147, then it’s the driver that is used by OpenGL as well. Dxdiag also supports command line mode, with something like:

dxdiag /t outfile.txt

which would silently print all info to the given text file (there’s also an option to output in xml format).

That said, when you’ll be launching your beta program? Maybe Unity will have the functionality for this built in by then :roll:

Thanks aarku and Aras for those great suggestions. dxdiag will be sufficient for Windows machines.

Unfortunately I could not get Process.Start to work (I realize, aarku, that it was untested). I think the second parameter needs to be a string containing program arguments, and system_profiler doesn’t have any arguments for saving its output. Furthermore, I don’t think that Process.Start begins a process in a shell environment where file redirection could save the standard output. I’m not a systems guru, but it seems that I need to somehow start bash and tell it to run system_profiler and redirect the output.

The Windows alternative (dxdiag) seems to have a file save parameter, and so it would not suffer from this dilemma.

In two to three weeks we will be beta testing a limited portion of our first level to some of our existing customers, mostly to test platform issues with Unity. We hope to have most of the high-end shader work for the game done by then. Of course it would be great to have glString by then, but no worries if not–it is a rather arcane request.

Unity’s javascript has a little known built-in function called shell() (inherited from its Boo roots). It is a handy little wrapper around System.Diagnostics.Process, that captures the console output of the process and returns it as a string. You should be able to launch and read the output of a program like this:

Mac:

output=shell("system_profiler","-detailLevel mini");

Win32:

output=shell("dxdiag","");

This is of course assuming that the command you want to run is in PATH. If not, the first parameter should be the full path name to the execuable.