Detect Hardware Acceleration with C#

Started by
5 comments, last by Palidine 16 years, 11 months ago
Hello, I was wondering if there was any way I could write a C# program that would test for the following features on a video card: 3d acceleration <- most important. amount of memory video hw transform and lighting video hw rasterization pixel shader version vertex shader version I think DirectX can do it but I need a way that would not require DirectX. I've taken a look through the forum archives and came accross these threads: http://www.gamedev.net/community/forums/topic.asp?topic_id=332735 http://www.gamedev.net/community/forums/topic.asp?topic_id=152450 It seems like the only ways I can find out these things about the video card is to use DirectX or do benchmarking. Is this correct? I've also taken a look at WMI but that doesn't seem to return the things that I'm looking for. Another thing, I've tried finding out whether or not the card supports 3d acceleration with the WMI through the CIM_VideoController AcceleratorCapabilities properties but it's returning a null value. Anyone have an idea on what the problem might be? Thanks again, Mark
Advertisement
Well if you're using C# then it's highly likely you're running on a Windows OS (unless you're wanting to go via the Mono project?) and you can guarantee that a version of DirectX will be present. You can work up from there to retrieve the information...

I haven't tried it myself, but I'm pretty sure late-binding will allow you to remove any compile-time dependencies on a specific DirectX version if thats what you're worried about.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Given up on the C#. Using C now. Still hesitant with relying on DX.
I stumbled on this http://www.opengl.org/resources/faq/technical/mswindows.htm#0030

I'm trying to do it the win32 way that the site suggested but I'm not sure if I'm doing this correctly.

My code:
---------------------------------------------------------------
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"The title of my window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
NULL, NULL, hInstance, NULL);


hDC = GetDC(hwnd);
DescribePixelFormat(hDC, 1, sizeof(PIXELFORMATDESCRIPTOR), &pixelDesc);
---------------------------------------------------------------

The value for dwFlags in pixelDesc is 0x00000034. From what I understand, this means that PFD_GENERIC_ACCELERATED (5th bit) and PFD_GENERIC_FORMAT (6th bit) are set - thus the machine is hardware accelerated. Does this mean that the machine this code is running on IS using hardware acceleration?

Or does this procedure only tell me that the machine is NOT using hw acceleration if PFD_GENERIC_ACCELERATED is clear and PFD_GENERIC_FORMAT is set.

I am a little confused here since according to http://msdn2.microsoft.com/en-us/library/ms537569.aspx the 4th bit (PFD_SUPPORT_OPENGL) is not set, implying that my buffer does not support OpenGL drawing, which I thought it would.


Thanks in advance,
Mark
JollyJeffers: Are you positive every version of Windows has some version of DirectX running on it?

I know that sounds really stupid by I have a colleague that's telling me otherwise.
Well, no 3D app is going to be hardware accelerated unless you are using either DirectX or OpenGL anyway. That's just how video card drivers are implemented.

You can also always ship with a DirectX installer.

-me
One more thing, if I do use DX, how would I know which version of DX is running on the machine?
Quote:Original post by krammark23
One more thing, if I do use DX, how would I know which version of DX is running on the machine?


There's a way to query the DX version number in Windows. Search on msdn.microsoft.com to find out how.

However, what most games do is just bundle the correct DirectX installer into the game's installer. The DirectX installer will update the user's machine if their current version of DX is lower than the installer's version. That way no one can install your game without also having installed the correct version of DX.

It's good practice to have the application query the DX version also, but bundling the installer with your game is just a nicer user experience.

-me

This topic is closed to new replies.

Advertisement