Detect if the GPU supports Pixel Shader 2.0 at run time (Firemonkey)

This question comes from my previous question:

Delphi XE7 Abstract error in StyleLookup with effect (FireMonkey)

Basically, I have some stylized controls with effects. Effects work on most systems, so I don’t want to bring them out of my styles together for a select few clients that they won’t work with. Is there a way to determine if the DirectX 9 client has And the installed GPU supports Pixel Shader 2.0?

+4
source share
1 answer

AFAIK DirectX, Microsoft GetDXVersion, DirectX SDK. DirectX. , DSPack.

, , IDirect3D9::GetDeviceCaps, PixelShaderVersion D3DCAPS9.

FMX

uses
  Winapi.Windows,
  Winapi.Direct3D9,
  FMX.Context.DX9;


procedure TForm1.Button1Click(Sender: TObject);
var
    LCaps: TD3DCaps9;
    LPixelShaderVersionMajor, LPixelShaderVersionMinor : Cardinal;
begin
  ZeroMemory(@LCaps, SizeOf(LCaps));
  if TCustomDX9Context.Direct3D9Obj.GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, LCaps) = S_OK then
  begin
    LPixelShaderVersionMajor:= D3DSHADER_VERSION_MAJOR(LCaps.PixelShaderVersion);
    LPixelShaderVersionMinor:= D3DSHADER_VERSION_MINOR(LCaps.PixelShaderVersion);
    ShowMessage(Format('PixelShaderVersion %d.%d', [LPixelShaderVersionMajor, LPixelShaderVersionMinor]));
  end;

   //also you can use the D3DPS_VERSION function to determine if the version returned meets the requirements
  if (LCaps.PixelShaderVersion >= D3DPS_VERSION(2, 0)) then
   ShowMessage('Hey your PixelShaderVersion is compatible');
end;
+6

All Articles