slimshader-cpp
slimshader-cpp copied to clipboard
SlimShader is a Direct3D shader bytecode parser for .NET and C++
SlimShader
SlimShader is a Direct3D shader bytecode parser for .NET and C++. This is the repository for the C++ version; the .NET version can be found at tgjones/slimshader.
Usage
auto fileBytes = ReadFileBytes("CompiledShader.o");
auto bytecodeContainer = DxbcContainer::Parse(fileBytes);
cout << bytecodeContainer.GetInputSignature()->GetParameters().size() << endl;
cout << bytecodeContainer.GetStatistics()->GetInstructionCount() << endl;
cout << bytecodeContainer.GetStatistics()->GetStaticFlowControlCount() << endl;
cout << bytecodeContainer.GetShader()->GetTokens().size() << endl;
Acknowledgements
- SlimShader uses several test shaders from the HLSLCrossCompiler project, by kind permission of James Jones.
- The Nuclex Framework, in particular the HlslShaderReflector class, was very helpful when figuring out the RDEF, ISGN and OSGN chunks.
- The Wine project, in particular Wine's shader reflection code, had some good tips for decoding the STAT chunk.
- FXDIS was useful to look at when getting started, but the techniques used in that project (casting raw bytes to struct types) don't translate well from C++ to C#.
- For the SHDR chunk, I mostly just used D3D11TokenizedProgramFormat.hpp, a header file that comes with the Windows DDK.
License
SlimShader is released under the MIT License.