1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
For more complete decompile of Monster Hunter World shaders.
diff --git a/BinaryDecompiler/decode.cpp b/BinaryDecompiler/decode.cpp
index 89ac94f0..9356d27b 100644
--- a/BinaryDecompiler/decode.cpp
+++ b/BinaryDecompiler/decode.cpp
@@ -333,7 +333,7 @@ uint32_t DecodeOperand (const uint32_t *pui32Tokens, Operand* psOperand)
}
default:
{
- ASSERT(0);
+ //ASSERT(0);
break;
}
}
diff --git a/HLSLDecompiler/DecompileHLSL.cpp b/HLSLDecompiler/DecompileHLSL.cpp
index 6175e733..24913e88 100644
--- a/HLSLDecompiler/DecompileHLSL.cpp
+++ b/HLSLDecompiler/DecompileHLSL.cpp
@@ -1493,7 +1493,7 @@ public:
{
int in[4] = { 0, 0, 0, 0 };
- numRead = sscanf_s(c + pos, "// = %i %i %i %i", in + 0, in + 1, in + 2, in + 3);
+ numRead = sscanf_s(c + pos, "// = %d %d %d %d", in + 0, in + 1, in + 2, in + 3);
NextLine(c, pos, size);
if (structLevel < 0)
@@ -1510,10 +1510,37 @@ public:
for (int i = 0; i < numRead - 1; ++i)
{
- sprintf(buffer, "%i,", in[i]);
+ sprintf(buffer, "%d,", in[i]);
mOutput.insert(mOutput.end(), buffer, buffer + strlen(buffer));
}
- sprintf(buffer, "%i};\n", in[numRead - 1]);
+ sprintf(buffer, "%d};\n", in[numRead - 1]);
+ mOutput.insert(mOutput.end(), buffer, buffer + strlen(buffer));
+ }
+ else if (e.bt == DT_uint || e.bt == DT_uint2 || e.bt == DT_uint3 || e.bt == DT_uint4)
+ {
+ unsigned in[4] = { 0, 0, 0, 0 };
+
+ numRead = sscanf_s(c + pos, "// = %u %u %u %u", in + 0, in + 1, in + 2, in + 3);
+ NextLine(c, pos, size);
+
+ if (structLevel < 0)
+ {
+ if (suboffset == 0)
+ sprintf(buffer, " %s%s %s : packoffset(c%u) = {", modifier.c_str(), type, name, packoffset);
+ else
+ sprintf(buffer, " %s%s %s : packoffset(c%u.%c) = {", modifier.c_str(), type, name, packoffset, INDEX_MASK[suboffset]);
+ }
+ else
+ sprintf(buffer, " %s%s%s %s = {", structSpacing.c_str(), modifier.c_str(), type, name);
+
+ mOutput.insert(mOutput.end(), buffer, buffer + strlen(buffer));
+
+ for (int i = 0; i < numRead - 1; ++i)
+ {
+ sprintf(buffer, "%u,", in[i]);
+ mOutput.insert(mOutput.end(), buffer, buffer + strlen(buffer));
+ }
+ sprintf(buffer, "%u};\n", in[numRead - 1]);
mOutput.insert(mOutput.end(), buffer, buffer + strlen(buffer));
}
else if (e.bt == DT_float || e.bt == DT_float2 || e.bt == DT_float3 || e.bt == DT_float4)
@@ -2510,7 +2537,7 @@ public:
else if (!strncmp(textype, "TextureCubeArray<", strlen("TextureCubeArray<"))) pos = 5; // float4 .xyzw
else logDecompileError(" unknown texture type for truncation: " + string(textype));
cpos = strrchr(op, '.');
- cpos[pos] = 0;
+ if (cpos) cpos[pos] = 0;
}
}
|