I’m having trouble debugging my DX11 code. I use VS2013 Update 3, Win 8.1 x64, drivers 340.52, GTX 580. I need to step through shader and see what’s wrong. First I could not get nSight to run with my app (solved by removing DEBUG flag from device creation, weird though), now when I want to step through shader code, Shader List shows shaders (all named as “No Name”), they also have debug information present and I can step through them, but all of them are in ASM. Why is that so? I use D3DCompileFromFile to compile shaders, compile flags for my debug build are D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION | D3DCOMPILE_WARNINGS_ARE_ERRORS, but changing them had no effect. Please help, I need to step through HLSL.
Please try this macros: D3DCOMPILE_PREFER_FLOW_CONTROL | D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION. If it still have issue, it’s better to have your sample to do more detail investigate.
I am having the same issue, I use D3DCompile with flags D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION | D3DCOMPILE_PREFER_FLOW_CONTROL to save a shader binary to a file and then read in this file at runtime.
Is it possible that using D3DCompile instead of the legacy function D3DXCompileShader as stated in the documentation causes this issue?
D3DXCompileShader should do exactly same job as D3DCompile, if you are in the same d3dcompiler_xx.dll. D3DXCompileShader just make shader compile job easier.
I am think there should be something else for your issue, also please note, Nsight don’t support shader debug on D3D9 samples.
It looks like I am having exactly the same issue. Compiling at runtime using D3DCompileFromFile with D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_DEBUG | D3DCOMPILE_PREFER_FLOW_CONTROL | D3DCOMPILE_SKIP_OPTIMIZATION
As above I can debug shaders but only see the asm. While this is functional I would like to solve this problem and make my life a little easier. Please let me know what info I can provide that would help work out what the problem is.
Some details:
Windows 7 x64
VisualStudio 2010
DirectX 11.0, using Windows 8.1 SDK, x86 target
d3dcompiler_47.dll
Nvidia GT 640
Driver Version: 344.60
Nsight ver: 4.1, build number 4.1.0.14255
I assume the ‘saved capture solution’ you mean the serialized project from nsight, I am afraid it may not suit for solve your issue about compile shaders. please show some sample which can repro your issue directly, that may save many time.
can you share me your email, I can send some ftp address to you.
I’m curious as to what the result of your test is! My code is not very trivial, but I’ll try to create a reproduction project over the weekend when I have time.
PM sent on the 7th. For the record I found this sample from MS
that (making sure to set the flags correctly as above) suffers exactly the same problem, so no point spending time stripping down what you or I have as an example. This is about as simple as it gets.
No reply so far, but would very much like to move this along. Precompiling my shaders is on my todo list but if this can be made to work then it’s priority drops significantly.
The sample you mentioned works smoothly on my side, I tried both the default flags in this Direct3D-Tutorial and the flags Nsight Shader Debug required [as mentioned above], I can set bp and get the corresponding variables in shaders as expected.
I am thinking that maybe some other issue in your side which block your shader debug:
Driver and Nsight are up to date, version 344.65 and 4.1.0.14255 respectively. My gpu was a GT 640 which wasn’t explicitly named on the list of supported cards, so I have installed a GTX 680 which is and am still not seeing any shader source.
I have always been able to set breakpoints and look at register variables in the watch window, I just don’t have the hlsl source available.
What version of Visual Studio did you use to test? As mentioned above I am using VS2010 SP1. I’m at a loss as to how to debug this further, do you have any suggestions?
Interestingly if you save a frame capture then you can see that the hlsl source is in the .bin file generated. So my guess would be that it isn’t a compilation problem.
Settings were fine, but strangely I was never asked to show the disassembly so decided to do a full uninstall and re-install. After that it is working as expected, HLSL included.
A result for sure, but a pity I don’t have anything more definitive for anyone else with the same problem; except try an uninstall/re-install. I wonder if something installed by Nvidia went astray when I switched from the old Win7 DX11 SDK to the Win8 SDK.
Anyway, all’s well that ends well I suppose, thanks for you help.
nSight (4.2 too) don’t want to show source (only disasm) for d3dcompiler_47.dll compiled shaders. We tested it with our app - d3dcompiler_46.dll shows ok, d3dcompiler_47.dll - only disasm. d3dcompiler_46 don’t compile some of our shaders (not supporting latest hlsl), so we stuck with asm debugging…
This dll is latest and is inbox in Windows 8.1, for other windows versions it have to be placed in app folder. To test this, you have to compile samples with Windows 8.1 SDK selected.
I just tried two same sample, one is using d3dcompiler_47.dll and another one is using d3dcompiler_46.dll [I also do some double check by attach debugger and check the loaded dll files], I see no difference in Shader Debug, I can view HLSL, set BP in it, etc.
For better and effective help, could you open a new thread and share your sample codes to us? We can do some repro/debug on the same page, since I don’t see the same issue as yours in my local machine.
This problem occures only for compiling from memory, not from file. For testing I changed BasicHLSL11 sample from ms d3dsdk in such way:
HRESULT CompileShaderFromFile( WCHAR* szFileName, LPCSTR szEntryPoint, LPCSTR szShaderModel, ID3DBlob** ppBlobOut )
{
HRESULT hr = S_OK;
// find the file
WCHAR str[MAX_PATH];
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, szFileName ) );
DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
#if defined( DEBUG ) || defined( _DEBUG )
// Set the D3DCOMPILE_DEBUG flag to embed debug information in the shaders.
// Setting this flag improves the shader debugging experience, but still allows
// the shaders to be optimized and to run exactly the way they will run in
// the release configuration of this program.
dwShaderFlags |= D3DCOMPILE_DEBUG;
#endif
FILE* fp = _wfopen(str, L"rb");
if(!fp)
return S_FALSE;
fseek(fp, 0, SEEK_END);
long size = ftell(fp);
fseek(fp, 0, SEEK_SET);
unsigned char* Buffer = new unsigned char;
fread(Buffer, 1, size, fp);
fclose(fp);
ID3DBlob* pErrorBlob;
hr = D3DCompile(Buffer, size, "Test", NULL, NULL, szEntryPoint, szShaderModel,
dwShaderFlags, 0, ppBlobOut, &pErrorBlob);
if( FAILED(hr) )
{
if( pErrorBlob != NULL )
OutputDebugStringA( (char*)pErrorBlob->GetBufferPointer() );
SAFE_RELEASE( pErrorBlob );
delete[] Buffer;
return hr;
}
SAFE_RELEASE( pErrorBlob );
delete[] Buffer;
return S_OK;
}
If I use d3dcompiler_43 (default for this sample) - I can see source in nSight,
if i use d3dcompiler_47 (changed project’s lib path search order $(DXSDK_DIR)Lib\x64;$(LibraryPath) → $(LibraryPath);$(DXSDK_DIR)Lib\x64 ) - there is only disasm.
I use VS2013, Windows 8.1 sdk, Windows 8.1 OS, 64 bit build.