revel8n / slimshader-cpp

SlimShader is a Direct3D shader bytecode parser for .NET and C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

SlimShader is a Direct3D shader bytecode parser for .NET and C++


Languages

Language:C++ 94.1%Language:Assembly 5.5%Language:FLUX 0.2%Language:Shell 0.1%Language:C 0.0%Language:Perl 0.0%