4

I'm looking for an easy way of detecting errors in HLSL file at program compile time from visual studio. I want to add a custom build to my shader files that compiles them and make sure the build fail if I did something stupid like referring an undefined variable or other things that otherwise would be detected when compiling the shader in the application.

Have anyone successfully setup this before?

Laserallan
  • 11,072
  • 10
  • 46
  • 67
  • 1
    Solved it using fxc. Constructed a custom build step doing %25DXSDK_DIR%25\Utilities\bin\x86\fxc %(Identity) /E CSMain /T cs_5_0 /Fo $(TargetDir)/%(Identity).shader Note that the /E and /T parameters needs to take the name of the entry point and the shader type in consideration. – Laserallan Sep 08 '11 at 23:33
  • 1
    +1 For the detail of the command @Laserallan! In my case I had to add quotes around `"%25DXSDK_DIR%25\Utilities\bin\x86\fxc.exe"`, but it worked. – wip Aug 08 '14 at 08:21

2 Answers2

3

Note that VS2012 has automatic compilation of shader files.

ghord
  • 13,260
  • 6
  • 44
  • 69
2

For anyone coming by, here's a handy (and more wordy) guide on how to do it in VS2010:

http://takinginitiative.net/2011/02/19/debugging-hlsl/

Koarl
  • 246
  • 1
  • 2
  • 10