• This repository has been archived on 02/May/2018
  • Stars
    star
    152
  • Rank 243,239 (Top 5 %)
  • Language
    Assembly
  • Created almost 12 years ago
  • Updated about 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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

  • 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.

More Repositories

1

gemini

Gemini is an IDE framework similar in concept to the Visual Studio Shell. It uses AvalonDock and has an MVVM architecture based on Caliburn Micro.
C#
1,032
star
2

HlslTools

A Visual Studio extension that provides enhanced support for editing High Level Shading Language (HLSL) files
HLSL
500
star
3

shader-playground

Shader playground website for exploring HLSL, GLSL, SPIR-V compilers
C
494
star
4

rasterizr

Software rasterizer written in C#, with an API based on Direct3D 10 / 11. Programmable parts of the pipeline execute "real" HLSL shaders.
C#
95
star
5

mini-c

F# implementation of a Mini-C compiler targeting MSIL
F#
81
star
6

meshellator

3D asset import library for .NET 4.0. Supported formats are Autodesk 3DS and Lightwave OBJ.
C#
44
star
7

nexus

Small and lightweight 3D vector and matrix library for .NET 4.0.
C#
23
star
8

slimshader-cpp

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

monogame-samples

Collection of samples for the MonoGame framework
C#
15
star
10

hlsl-parser-nitra

HLSL parser for .NET
C
15
star
11

xbuilder

XBuilder is an extension for Visual Studio 2010 which adds the ability to preview models, effects and textures from your XNA content projects, right inside Visual Studio.
C#
12
star
12

dryrunner

Isolated integration testing for ASP.NET
C#
10
star
13

stitchup

StitchUp is an XNA 4.0 implementation of Shawn Hargreaves' article "Generating Shaders From HLSL Fragments". It integrates with the XNA Content Pipeline to provide compile-time linking of shader fragments.
C#
10
star
14

dotwarp

DotWarp is an easy-to-use 3D software rasterization library, which produces 2D rendered images from 3D mesh files. It uses WARP, a 3D software rasterizer built-in to Windows Vista / 7 / Server 2008 R2, for the actual rasterization. It is a .NET 4.0 project.
C#
9
star
15

make-santa-jump

Endless runner game written in F# using MonoGame
F#
9
star
16

CLILL

Proof-of-concept LLVM IR to MSIL translator (opposite of LLILC, hence the name)
LLVM
8
star
17

SimdDoors

Example project demonstrating SIMD intrinsics in .NET Core 3.0
C#
8
star
18

ormongo

Ormongo is a very lightweight implementation of the ActiveRecord pattern, built on top of the 10gen Mongo C# driver.
C#
5
star
19

zia.js

Object-oriented WebGL-based game framework
CSS
5
star
20

xna-tutorials

Little XNA projects that I post as tutorials on my blog
C#
5
star
21

osiris

Some XNA 4.0 Content Pipeline extensions
C#
5
star
22

DotNetDxc

NuGet package for .NET wrapper of Microsoft's DirectXShaderCompiler
C#
4
star
23

weaver

HLSL surface shader parser for XNA / MonoGame
C#
4
star
24

particlephysics

Simple XNA particle physics demo
C#
3
star
25

idx3dsharp

Port of the idx3d software rasterizer
C#
3
star
26

aether

Ray tracer in C#
C#
3
star
27

rasteracer

Hybrid ray tracer / XNA renderer
C#
3
star
28

awesome-game-2

The "sequel" to Awesome Game. It was supposed to be a resource trading game played out on a world stage...
C#
2
star
29

aemula-csharp

Emulator playground written in C#
Assembly
2
star
30

apesharp

Port of ActionScript Physics Engine into C#
C#
2
star
31

aether-fsharp

Port of PBRT ray tracer to F#
F#
2
star
32

awesome-game

A top-down racing game some friends and I wrote during a "geekathon" coding weekend
C#
2
star
33

torq2

A 3D car game I've been trying to write for a little while now. This is an old version of it. Perhaps the main point of interest is the geoclipmapping implementation.
C#
2
star
34

Hlsl2GlslSharp

.NET bindings for Aras Pranckeviฤius's hlsl2glslfork
C#
1
star
35

robosharp

RoboSharp is a very old .NET port of RoboCode
C#
1
star
36

mincamlsharp

F#
1
star
37

aether-cpp

Ray tracer
C
1
star
38

shaders-tmLanguage

Syntax grammars used for HLSL and ShaderLab colorization
1
star
39

jolt

Simple physics engine. Currently a straightforward C# port of Cyclone Physics (https://github.com/idmillington/cyclone-physics)
C#
1
star
40

software-sandbox

Miscellaneous, and quite useless, little projects
C#
1
star