spacehamster / DXDecompiler

Other
57 stars 16 forks source link

Support shader array and some more registers in DX9 effect #3

Closed lanyizi closed 3 years ago

lanyizi commented 3 years ago

There are some registers with the same id, but are actually different types between different shader models, which should be properly handled with this pull request. This pull request will also support shader array in EffectHlslWriter.cs and few more opcodes in HlslWriter.cs

spacehamster commented 3 years ago

Thankyou for the pull request. I think you should be aware that I intend to eventually remove the DX9 HlslWriters and change the architecture so that both DX9 and DX10 shaders are converted into a common intermediate format to better allow for code reuse, type reconstruction analysis and instruction lifting. Instruction lifting being converting patterns like:

dp4 r0.x, v0, v0
rsq r0.x, r0.x
mul o0, r0.x, v0

to

output = normalize(input);

for better readability.

I currently do not have a good model of the intermediate format, so I don't have a clear way of moving forward yet, but it is something I am researching currently.

I don't plan to get rid of the DX9 writer at least until the intermediate format can produce better decompiled output, so I will accept pull requests to it in the mean time.

Also note that I dislike the DX9 tokens storing data in an untyped uint array as it makes debugging difficult and has trouble handing variable-sized operands (operands that use array indexing), and so I plan to have the DX9 bytecode format fully parse the data into typed fields during the parsing step, but it is very low on my priorities.