How to identify a DirectX shader model higher than v3 supported by a graphics card?

I am writing a small utility that reports on the capabilities of the system. One of them is the highest shader model supported by the installed graphics card, and I am currently detecting it using Direct3D 9.0c features and checking the VertexShaderVersion and PixelShaderVersion structure of D3DCAPS9 .

 HRESULT hrDCaps = poD3D9->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &oCaps); if (!FAILED(hrDCaps)) { // Pixel and vertex shader model versions. Use the minimum number of each for "the" shader model version const int iVertexShaderModel = D3DSHADER_VERSION_MAJOR(oCaps.VertexShaderVersion); const int iPixelShaderModel = D3DSHADER_VERSION_MAJOR(oCaps.PixelShaderVersion); 

However, both of these values ​​return shader model 3 even for cards supporting higher models. This is what the GPU-Z returns for the same card, for example:

GPU-Z showing shader model 4.1

This question indicates that DX9 will never report more than SM3, even on cards supporting a higher model, but does not actually mention how to solve it.

How to get the shader model supported by the installed card? That is, the capabilities of the card, not the installed capabilities of the DirectX driver.

The utility should work in Windows 2000 and higher and work with systems in which a graphics card and even DirectX are not installed. I am currently dynamically loading DX9, so on these systems the check gracefully fails (this is normal). But I'm looking for a similar solution: something that will still work on all systems and work correctly (detect the SM version) on most systems.


Change - purpose: I do not use this code to dynamically change program functions, i.e. shader selection. I use it to communicate hardware capabilities as a “ping” to the server, which is used so that we have a good idea of ​​the typical equipment that our customers use, which can inform about future product solutions. (For example: how many clients has SM4 or higher? How many of them use a 64-bit OS? And so on) That's why either (a) gracefully fails, so we know that it failed, or (b) getting accurate shader model number - two preferred modes.

Edit - answers so far:. The answer provided by SigTerm suggests creating a DirectX 11, 10.1, 10, and 9.0c instance in order and based on the specified shader model on which the instance was created without failures (model 5, 4.1, 4 and DXCAPS shader in that order.) If possible, I would appreciate a sample DX11 code and 10 ways to do this.

This may not be a reliable solution. For example, I am running Windows on a VMWare Fusion virtual machine on OSX. Fusion drivers report DX11 to DxDiag, but I know from the Fusion specifications that it only supports DX9.0c and shader model 3 . However, with this exception, this method seems to be the best way so far.

+4
source share
2 answers

version 4 is only supported on Direct3D10. Therefore, D3D9 api will not report this. Use the D3D10 / D3D11 api to determine a higher version.

something that will work on all systems and work correctly (detect the SM version) on most systems.

Try to initialize D3D10 / D3D11 to test functionality if init D3D9 did not work. Use LoadLibrary + GetProcAddress to load D3D10 functions, because if you communicate with D3D10 using a .lib file, your application will not be able to start if d3d10 is missing.

Or use OpenGL and try to match the capabilities provided by OpenGL with the capabilities of D3D (perhaps a very bad idea).

Or create a GPU database and use it.

where the graphics card and even DirectX are not installed.

I think that you are asking for impossibility, since shaders are provided by DirectX, and the driver / GPU may not even have the concept of a “shader model” under the hood. In this case, the only way to detect abilities is to create some kind of GPU database, detect installed devices, and return a response from the database. Of course, this will not be relabile.

+5
source

Here is a link about DirectX versions and supported shader models.

+1
source

Source: https://habr.com/ru/post/1494943/


All Articles