AFAIK there is not a direct way to determine the DirectX version, however Microsoft provides a sample function called GetDXVersion which is part of the DirectX SDK. This function runs a set of checks to determine the DirectX version. Luckily you can found a Delphi translation of that function in the DSPack
project.
Now to detect the pixel shader version you must use the IDirect3D9::GetDeviceCaps
method and then check the value of the PixelShaderVersion
field of the D3DCAPS9
record.
Try this FMX sample
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;