Home

Awesome

SlimShader

SlimShader is a Direct3D shader bytecode parser for .NET and C++. It is a Portable Class Library (PCL), compatible with .NET Framework 4.0+ and .NET for Windows Store apps. This is the repository for the .NET version; the C++ version can be found at tgjones/slimshader-cpp.

Usage

var fileBytes = File.ReadAllBytes("CompiledShader.o");
var bytecodeContainer = BytecodeContainer.Parse(fileBytes);

Console.WriteLine(bytecodeContainer.InputSignature.Parameters.Count);
Console.WriteLine(bytecodeContainer.Statistics.InstructionCount);
Console.WriteLine(bytecodeContainer.Statistics.StaticFlowControlCount);
Console.WriteLine(bytecodeContainer.Shader.Tokens.Count);

Virtual Machine

SlimShader also includes a virtual machine, which can execute HLSL shaders on the CPU. See the source code here. SlimShader.VirtualMachine includes both an interpreter and a just-in-time (JIT) compiler.

HlslUnit

HlslUnit is a .NET library that allows you to unit test your HLSL shaders. It is built on top of SlimShader and SlimShader.VirtualMachine. I blogged about it here.

GUI

I've written a simple GUI to showcase SlimShader. You can open a compiled (binary) shader file, view the disassembled version, and view various properties (from the STAT chunk).

Screenshot

Acknowledgements

License

SlimShader is released under the MIT License.