Command line HLSL decompiler
I spent some time making the HLSL compiler standalone and runable from the console. I integrated it into my shader console application. I have not done a lot with it yet except for converting a lot of dumped Crysis 1 shaders into hlsl. Error checking is pretty non-existing. It will not detect any flaws in the HLSL decompiler. To make sure that the produced HLSL really is equivalent to the original binary shader is not very easy. Saw an abandoned command line decompiler so I thought I would make an attempt.
I spent some time making the HLSL compiler standalone and runable from the console.

I integrated it into my shader console application.

I have not done a lot with it yet except for converting a lot of dumped Crysis 1 shaders into hlsl.
Error checking is pretty non-existing. It will not detect any flaws in the HLSL decompiler.
To make sure that the produced HLSL really is equivalent to the original binary shader is not very easy.

Saw an abandoned command line decompiler so I thought I would make an attempt.
Attachments

crysis.zip.jpg

Thanks to everybody using my assembler it warms my heart.
To have a critical piece of code that everyone can enjoy!
What more can you ask for?

donations: ulfjalmbrant@hotmail.com

#1
Posted 01/30/2015 09:59 PM   
Hey nice, that should be interesting. That wasn't an abandoned console decompiler, that was a work in progress. Hadn't gotten a chance to finish it. You can always look at the check-in history to see status. When I'm comparing and manually fixing shaders, this seemed like a handy tool for doing back to back compiles. The ultimate goal there was to make a series of unit-tests using the game shaders as source. So for example, we'd be able to batch run the decompiler against a known set of shaders like for AC4. Then we could compare the output with the previous output- which would show whether any new changes to the decompiler broke something older. If you get a chance, please go ahead and check your changes into the project. That'll make it viable.
Hey nice, that should be interesting.

That wasn't an abandoned console decompiler, that was a work in progress. Hadn't gotten a chance to finish it. You can always look at the check-in history to see status.

When I'm comparing and manually fixing shaders, this seemed like a handy tool for doing back to back compiles.


The ultimate goal there was to make a series of unit-tests using the game shaders as source. So for example, we'd be able to batch run the decompiler against a known set of shaders like for AC4. Then we could compare the output with the previous output- which would show whether any new changes to the decompiler broke something older.


If you get a chance, please go ahead and check your changes into the project. That'll make it viable.

Acer H5360 (1280x720@120Hz) - ASUS VG248QE with GSync mod - 3D Vision 1&2 - Driver 372.54
GTX 970 - i5-4670K@4.2GHz - 12GB RAM - Win7x64+evilKB2670838 - 4 Disk X25 RAID
SAGER NP9870-S - GTX 980 - i7-6700K - Win10 Pro 1607
Latest 3Dmigoto Release
Bo3b's School for ShaderHackers

#2
Posted 01/31/2015 04:52 AM   
I'm not even sure how to use the code in 3Dmigoto context. The current workflow is to dump binary cbo files. Convert into asm using MS decompile. With these two together drive the HLSLdecompile to produce hlsl. Unless I'm missing something you need the cbo file. I'm not aware what happens if you channge the asm file. In the current workflow there is no asm file to change. To me it feels like D3D_shaders project which have remained unused which is where I implemented the new code. The implementation should take the targeted use into account. What you're aiming for appears more difficult. Not sure how my cbo based command-line tool will help.
I'm not even sure how to use the code in 3Dmigoto context.

The current workflow is to dump binary cbo files.
Convert into asm using MS decompile.

With these two together drive the HLSLdecompile to produce hlsl.

Unless I'm missing something you need the cbo file.
I'm not aware what happens if you channge the asm file.
In the current workflow there is no asm file to change.

To me it feels like D3D_shaders project which have remained unused which is where I implemented the new code.
The implementation should take the targeted use into account. What you're aiming for appears more difficult.
Not sure how my cbo based command-line tool will help.

Thanks to everybody using my assembler it warms my heart.
To have a critical piece of code that everyone can enjoy!
What more can you ask for?

donations: ulfjalmbrant@hotmail.com

#3
Posted 01/31/2015 09:29 AM   
That's OK, I'm not sure how it would all work either. ;-) I don't know exactly how a command line tool would be built, but was thinking something along the lines of making it callable via batch/cmd files. Presumably using stdin parameters. That would allow for unit testing of older shaders. This was intended to be another standalone build-target, not included with normal builds. For the cbo+asm requirement, the right thing to do there is to just generate the ASM from the cbo file that is input. The input to the command line tool would be a single cbo file. (presently marked .bin in 3Dmigoto, but we'll probably switch that to .cbo soonish, as well as .txt->.hlsl)
That's OK, I'm not sure how it would all work either. ;-) I don't know exactly how a command line tool would be built, but was thinking something along the lines of making it callable via batch/cmd files. Presumably using stdin parameters. That would allow for unit testing of older shaders. This was intended to be another standalone build-target, not included with normal builds.

For the cbo+asm requirement, the right thing to do there is to just generate the ASM from the cbo file that is input. The input to the command line tool would be a single cbo file. (presently marked .bin in 3Dmigoto, but we'll probably switch that to .cbo soonish, as well as .txt->.hlsl)

Acer H5360 (1280x720@120Hz) - ASUS VG248QE with GSync mod - 3D Vision 1&2 - Driver 372.54
GTX 970 - i5-4670K@4.2GHz - 12GB RAM - Win7x64+evilKB2670838 - 4 Disk X25 RAID
SAGER NP9870-S - GTX 980 - i7-6700K - Win10 Pro 1607
Latest 3Dmigoto Release
Bo3b's School for ShaderHackers

#4
Posted 01/31/2015 11:02 AM   
Having a unity test for the HLSL decompiler where you take the original cbo run it through the tester where it is turned into HLSL and then compile the HLSL with the same shader model and compare ASM code. If these match we have provable working decompiling. I tried to commit the new D3D_shader Project but something goes wrong. It is not hard to implement the code given access to cbo file. Would probably be better integrated into a framework aimed at the desired goal.
Having a unity test for the HLSL decompiler where you take the original cbo run it through the tester where it is turned into HLSL and then compile the HLSL with the same shader model and compare ASM code. If these match we have provable working decompiling. I tried to commit the new D3D_shader Project but something goes wrong.

It is not hard to implement the code given access to cbo file. Would probably be better integrated into a framework aimed at the desired goal.

Thanks to everybody using my assembler it warms my heart.
To have a critical piece of code that everyone can enjoy!
What more can you ask for?

donations: ulfjalmbrant@hotmail.com

#5
Posted 01/31/2015 11:34 AM   
Scroll To Top