Open lanyizi opened 3 years ago
Thanks a lot for this PR, it's extremely useful for a project I'm currently working on to decompile some DX9 shader bytecode. The output is the best I've seen so far and makes it much easier to understand what's going on. I was wondering if you were planning to add support for the last few unsupported instructions soon or if I should try to fix it myself, I have a few pixel shaders that have unsupported ones (they disassemble without problems though).
Thanks a lot for this PR, it's extremely useful for a project I'm currently working on to decompile some DX9 shader bytecode. The output is the best I've seen so far and makes it much easier to understand what's going on.
You're welcome, and thanks for the compliment, I feel so happy when reading them xD
I was wondering if you were planning to add support for the last few unsupported instructions soon or if I should try to fix it myself, I have a few pixel shaders that have unsupported ones (they disassemble without problems though).
You can try to fix them yourself, just remember to run the unit tests after the changes (currently my version passes 992 out of 1008 test cases in DX9Tests
). Since spacehamster seems to be busy at the moment, you can consider creating pull request on my forked repository instead.
Got it thanks ! I'm not super familiar with shaders but hopefully I should be able to study your code and add the missing instructions (I think it's the saturate one that wasn't implemented in my case). I'll make a PR when I have the time, thanks again for your great work !
@lanyizi , can I disassemble a shader in this format? CubeBlend.shader.txt
@Albeoris from what I see, that file is already disassembled, isn't it? If you mean decompiling, then it's a bit harder,
However, there are existing projects like AssetRipper which should be able to extract many types of Unity Assets, including shaders IIRC. I suggest you to take a look at those projects, they also have a Discord channel.
@lanyizi , yeah. As far as I understand, this is the format of precompiled shaders that used older versions of Unity. Accordingly, inside the resources of the game they are in the same format. And I don't know how to make them work on a modern version of Unity. I need to either disassemble them or compile them. And I have not found any tool that is capable of this. :С
Judging by the instructions, this is HLSL: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx9-graphics-reference-asm-vs-3-0
Hello! @lanyizi I noticed that you made a pull request for a DirectX9 Shader Decompiler at GitHub, and I was wondering if you could maybe help with this? I'm currently attempting to Decompile a Shader for Guitar Hero: World Tour on PC but I get this traceback whenever I try to decompile it, I would appreciate the help if you can since it would be really great to have this Shader fixed, thank you and have a great day!
System.NotImplementedException: Saturate, PartialPrecision
at DXDecompiler.DX9Shader.HlslWriter.
Update:
I was looking at the shader's assembly and I noticed that it had an odd assembly line that's most likely not supported by your decompiler....
from HairShader_0_ps0.fxc
'dp3_sat_pp r1.w, r1, r2' 'mul_sat_pp r0.w, r0.w, r2.w' 'mul_sat_pp r1.xyz, r1.w, c14.xyyw'
These three assembly lines uses '_sat_pp' in their file, and it's mostly likely a combination of PartialPrecision and Saturate.
AsmMatchesFxc
passes! (https://github.com/spacehamster/DXDecompiler/issues/9)DX9Tests
, 992 cases have succeeded, only 16 cases have failed (mainly because there are still some unimplemented instructions).The
HlslAst
has been broken by me (mainly because I don't know how to let its nodes to support relative addressing), soHlslWriter
'sdoAstAnalysis
option will no longer work, but in my opinion that won't be a big deal since you're working on a new common IR design anyway ;)c0 c1 c2
RegisterState.CtabOverride
(since preshader would overwrite constant buffer)