c++ - 如何调试HLSL编写的shader?
PHP中文网
PHP中文网 2017-04-17 13:25:45
0
3
488

D3D11初学者,最近在尝试实现一些光照模型。可是有个问题就是.fx文件里面的HLSL代码不知道该如何去调试,我能定位到某个值出了问题,我想打印看一下值是什么,但是却没有办法,断点什么的也没用,求指点。

PHP中文网
PHP中文网

认证0级讲师

reply all(3)
小葫芦

https://msdn.microsoft.com/zh-cn/library/hh873197.aspx There are instructions on this, but... I don’t know how to use it either

左手右手慢动作

Do you use the D3DCompileFromFile function to compile your hlsl source code? The hlsl bytecode generated by this function does not contain compilation information by default, so it cannot be debugged in VS (can only be debugged by disassembly) .

Function prototype:

HRESULT  D3DXCompileShaderFromFile(
  __in   LPCSTR pSrcFile,
  __in   const D3DXMACRO *pDefines,
  __in   LPD3DXINCLUDE pInclude,
  __in   LPCSTR pFunctionName,
  __in   LPCSTR pProfile,
  __in   DWORD Flags,
  __out  LPD3DXBUFFER *ppShader,
  __out  LPD3DXBUFFER *ppErrorMsgs,
  __out  LPD3DXCONSTANTTABLE *ppConstantTable
);

Set the fourth parameter from the last to: D3DXSHADER_DEBUG or D3D10_SHADER_DEBUG depending on your sdk

    // Compile the vertex shader code.
    result = D3DCompileFromFile(
                                vsFilename, 
                                NULL, 
                                NULL, 
                                "TextureVertexShader", 
                                "vs_5_0", 
                                D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_DEBUG ,
                                 0,
                                &vertexShaderBuffer, 
                                &errorMessage);
洪涛

For VS2015, go to Debugging->Graphics->Start graphics debugging and then you can debug the program like debugging C++ code

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template