3

Example: Here's the debug log for CreateGraphicsPipelineState, it tells me what went wrong:

D3D12 ERROR: ID3D12Device::CreateGraphicsPipelineState: Root Signature doesn't match Vertex Shader: Shader CBV descriptor range (RegisterSpace=0, NumDescriptors=1, BaseShaderRegister=0) is not fully bound in root signature

However, a call to windows FormatMessage(MESSAGE_FROM_SYSTEM...) will return this for the exact same error:

The parameter is incorrect.

The first is obviously far more useful... We used to have dxerr.lib, and we have source for dxerr.cpp in DXUT. But this doesn't cover DX12. I can't see any way for a shader-tool to retrieve the error and present it to the user from the API.

cmaughan
  • 2,596
  • 5
  • 30
  • 35
  • Yeah, whatever happened to `DXGetErrorDescription`? You might have some luck with [`FormatMessage`](https://learn.microsoft.com/en-us/windows/win32/cossdk/interpreting-error-codes) – bobobobo Aug 12 '21 at 01:37

2 Answers2

1

This can be done with the ID3D12InfoQueue interface, as documented here:

https://learn.microsoft.com/en-us/windows/win32/api/d3d12sdklayers/nn-d3d12sdklayers-id3d12infoqueue

As far as I can tell it's currently not possible to set a callback, which means that you'll need to explicitly query for feedback.

ObsequiousNewt
  • 260
  • 2
  • 5
  • I'm voting this the answer until I have time to confirm it, since it does seem to be a new feature implementing what I needed. Thanks for the link. – cmaughan Sep 01 '22 at 08:25
-1

There are two different sources of error/status information involved here. The error code you have returned from the API call is E_INVALIDARG and you obtained a good string for it. This is the status code from the API.

The descriptive message you see in debug output is emitted by Direct3D 12 debug layer, which you loaded during API initialization. It is, generally speaking, an optional component and might be not available in the system while the API itself is available.

To intercept debug output programmatically you can either

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Neither of these is practical for a tool. Suppose you are building a tool that lets the user create shaders, or your game engine displays errors when testing on new machines. How can it display a useful error? In my experience, on a release build this is hard; there is very little error reporting surfaced in the API. I get that the debug runtime is an optional component, but even on a retail build, the runtime often knows more than "The parameter is incorrect" – cmaughan Nov 07 '19 at 12:57
  • Regardless of how practical these are, this is what is known to be working. – Roman R. Nov 07 '19 at 14:02
  • Indeed, and it is a shame that there is no way to do what I ask. Hooking up a debugger is of course what I already did; but it doesn't answer my question. And I disagree that 'parameter is incorrect' is a 'good string' (your words). It gives no clue at all to what went wrong. – cmaughan Nov 08 '19 at 13:46
  • Given that status code returned from API is `E_INVALIDARG`, the associated string the one you are getting. A link in my answer under bullet with debugger explains how to "self debug" programmatically, without need to attach fully featured interactive debugger. It is a sort of a day of development work to implement a basic app that uses debugging API and attaches to your application just for the purpose of debug output extraction. – Roman R. Nov 08 '19 at 13:51