Sign in to follow this  

[DX10] How to Output Shader Errors in The Output Window

This topic is 3870 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have started learning DX10 and performing the Direct3D 10 Shader Model 4.0 Workshop right now. One thing confuses me, when debugging the application with a faulty effect file (.fx); no information is presented in the output window about the nature of the error? I was able to see this in DX9, can I turn on this feature somehow? Thanks

Share this post


Link to post
Share on other sites
When you're compiling the shader, I presume with this function:

http://msdn2.microsoft.com/en-us/library/bb310586.aspx

Set ppErrorMsgs to the address of an ID3D10Blob pointer. Then just call GetBufferPointer on the returned blob and pass that to printf. So something like:

ID3D10Blob *pErrors = NULL;

CHECK_HRESULT(D3DX10Compile(..., &pErrors, ...));

if( pErrors )
{
printf("%s", pErrors->GetBufferPointer());
SAFE_RELEASE(pErrors);
}

The reason this changed is because we don't release a debug version of the compiler for DX10 (you'll notice this doesn't happen with the retail d3dx9). The rationale being that all "debug" information we would pass back should be reported via the Errors and Warnings buffer, and there's no reason to duplicate the DLL when the behavior should be exactly the same in debug and retail.

Share this post


Link to post
Share on other sites
Quote:
Original post by Jalibr
When you're compiling the shader, I presume with this function:

http://msdn2.microsoft.com/en-us/library/bb310586.aspx

Set ppErrorMsgs to the address of an ID3D10Blob pointer. Then just call GetBufferPointer on the returned blob and pass that to printf. So something like:

ID3D10Blob *pErrors = NULL;

CHECK_HRESULT(D3DX10Compile(..., &pErrors, ...));

if( pErrors )
{
printf("%s", pErrors->GetBufferPointer());
SAFE_RELEASE(pErrors);
}

The reason this changed is because we don't release a debug version of the compiler for DX10 (you'll notice this doesn't happen with the retail d3dx9). The rationale being that all "debug" information we would pass back should be reported via the Errors and Warnings buffer, and there's no reason to duplicate the DLL when the behavior should be exactly the same in debug and retail.


I tried with the code you suggested but wasn't able to get printf to print to the debug output window. Then I tried with this line:

DXUTOutputDebugString((LPCWSTR)pErrors->GetBufferPointer());

But all I got was a bunch of question mark printed "??????...".

Share this post


Link to post
Share on other sites
The error buffer will be an ascii character string, so try calling the ascii version of the function if it exists. I'm no expert on DXUT, but this might work:

DXUTOutputDebugStringA((LPCSTR)pErrors->GetBufferPointer());

Share this post


Link to post
Share on other sites
Quote:
Original post by Jalibr
The error buffer will be an ascii character string, so try calling the ascii version of the function if it exists. I'm no expert on DXUT, but this might work:

DXUTOutputDebugStringA((LPCSTR)pErrors->GetBufferPointer());


Yeah, that worked fine, great help, thanks :)

Share this post


Link to post
Share on other sites
Sign in to follow this