Try HLSL online

1 minute read

While developing HLSL Tools for Visual Studio, I often want to check whether various bits of HLSL are valid using the official compiler. I could create and compile an HLSL file on my computer, but that sounds like a lot of work, so I made a website to make my life easier. Here it is:

Screenshot of TryHLSL website

You can choose to compile your HLSL code using either of Microsoft’s official HLSL compilers:

  • The old fxc.exe compiler that has been around for years
  • DirectXShaderCompiler, the shiny new open source compiler

You can select the shader profile and specify the shader entry point (i.e. PSMain, etc.). I plan to add the ability to choose other compiler options, but that’s not there yet.

At the moment, the only output option is to view the shader disassembly. I plan to add the option to view the abstract syntax tree (AST) from the new compiler. I’m also interested in supporting 3rd party shader processors, such as AMD’s CodeXLAnalyzer.exe. Joshua Barczak’s Pyramid is a really nice implementation of this sort of multiple-input/multiple-output type of shader compiler tool.

Implementation notes

I initially wanted to use the Monaco text editor, but I couldn’t get it to fit properly within a flexbox layout. So I ended up using CodeMirror. To make the input and output look nicer, I wrote a couple of CodeMirror grammars that might be interesting to others:

Updated:

Leave a Comment