Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CreateComputeShader returns E_INVALIDARG when using doubles

I need double precision for some GPGPU calculations using DirectCompute. When I make everything a float, the shader compiles and runs just fine. However, when I try to use doubles anywhere in my shader, it will compile, but calling ID3D11Device::CreateComputeShader() at runtime fails with E_INVALIDARG. The C++ side code is exactly the same, mind you, I've just changed a few variables in the shader to double.

When I call ID3D11Device::CheckFeatureSupport() with D3D11_FEATURE_DOUBLES, it reports that doubles are supported on my adapter, which is an AMD Radeon R9 270x. According to a couple of Google searches, AMD cards are actually great at double precision calculations - IE, my card can use doubles, but DirectX doesn't seem to want to let me do that.

I figured that maybe DirectCompute doesn't have that ability (which would be weird, since a lot of scientific GPGPU processes need doubles), so I tried using a pixel shader instead. The same thing happens.

Is this a driver bug, or is there something I'm missing?

EDIT: I just searched for the latest Catalyst driver, and apparently I'm behind a couple versions. This is interesting, considering I've gone to the control center and checked for updates several times recently. I'm going to update and see what happens.

EDIT2: The update had no effect. Either I'm doing something wrong, or DirectX has a bug of sorts.

like image 838
NmdMystery Avatar asked Oct 19 '22 07:10

NmdMystery


1 Answers

The basic double-precision shader model 5.0 support as indicated by D3D11_FEATURE_DOUBLES only includes support for the following operations:

  • dadd - Addition/Negation/Subtraction
  • deq, dge, dlt, dne- Comparison
  • dmax - Max
  • dmin - Min
  • dmov, dmovc - Moves
  • dmul - Multiply
  • dtof, ftod - Conversion double <-> float

You need to check D3D11_FEATURE_DATA_D3D11_OPTIONS.ExtendedDoublesShaderInstructions which includes all the ones above plus:

  • dfma - Fused multiply-add
  • ddiv - Division
  • drcp - Reciprocal

Shader Model 5 Assembly

RE: DirectX 11.1

D3D11_FEATURE_DATA_D3D11_OPTIONS.ExtendedDoublesShaderInstructions is part of the DirectX 11.1 API and is a hardware feature that requires WDDM 1.2 drivers. Therefore, as per Microsoft Docs, even with the DirectX 11.1 runtime installed on Windows 7 via KB2670838 this hardware feature requires Windows 8 or later to be TRUE.

DirectX 11.1 and Windows 7 Update
DirectX 11.1 and Windows 7

like image 116
Chuck Walbourn Avatar answered Oct 22 '22 00:10

Chuck Walbourn