feat: rawmax 2.0 (5) - fix

This commit is contained in:
zhoubinjia committed 2026-08-07 15:13:37 +08:00
1 parent 270b2840c6
commit a2700c2d9e
27 files changed
+8540 -3859

No files matched your search

@@ -39,6 +39,36 @@ class CodeRange:
CODE_RANGES = (
CodeRange(
"ComputeBayerNoiseModelF32TileSize16",
0x037A6E14,
0x037AAB68,
0x037B9AF4,
),
CodeRange(
"ComputeRGBNoiseModelF32TileSize16",
0x037B9AF4,
0x037B9AF4,
0x037BECDC,
),
CodeRange(
"DownsampleRawF16ToFloatTileSize16",
0x037BECDC,
0x037BECDC,
0x037C1A8C,
),
CodeRange(
"DownsampleRgbF16ToFloatTileSize16",
0x037C1A8C,
0x037C1A8C,
0x037DB248,
),
CodeRange(
"DownsampleRgbF16ToFloatTileSize16CopyHelper",
0x038561A4,
0x03856414,
0x0385642C,
),
CodeRange("BayerRawToYuv1xS16", 0x049C3484, 0x049C7B64, 0x049CAA54),
CodeRange("RgbRawToYuv1xS16", 0x04A17EA8, 0x04A198B8, 0x04A1C3E8),
CodeRange(
@@ -67,6 +97,18 @@ CODE_RANGES = (
0x054DCD34,
0x054DE730,
),
CodeRange(
"DownsampleRgbF16ToFloatTileSize16Mode0",
0x05DACC58,
0x05DACC58,
0x05DAD588,
),
CodeRange(
"DownsampleRgbF16ToFloatTileSize16Mode1",
0x05DAD588,
0x05DAD588,
0x05DAE16C,
),
)
# Successful oracle runs reached only malloc/free/trace/par-for. memset is
@@ -78,6 +120,7 @@ HOST_TARGETS = {
0x05EF54BC: "halide_trace",
0x05A7FEF0: "halide_do_par_for",
0x05FB8540: "memset",
0x05DAE16C: "downsample_rgb_dispatch",
}
@@ -0,0 +1,52 @@
#include <idc.idc>
static dump_function_containing(ea)
{
auto start, end, result;
start = get_func_attr(ea, FUNCATTR_START);
end = get_func_attr(ea, FUNCATTR_END);
msg("\n===== callsite %x function %x..%x =====\n", ea, start, end);
if (start == BADADDR)
return;
result = decompile(start);
if (result != 0)
msg("%s\n", result.text);
else
msg("Decompile failed\n");
}
static force_and_dump(start, end)
{
auto result;
del_func(start);
if (!add_func(start, end))
{
msg("Unable to create function %x..%x\n", start, end);
return;
}
msg("\n===== forced function %x..%x =====\n", start, end);
result = decompile(start);
if (result != 0)
msg("%s\n", result.text);
else
msg("Decompile failed\n");
}
static dump_callers(target)
{
auto ref;
ref = get_first_cref_to(target);
while (ref != BADADDR)
{
dump_function_containing(ref);
ref = get_next_cref_to(target, ref);
}
}
static main()
{
load_and_run_plugin("hexarm64", 0);
force_and_dump(0x35A8E84, 0x35AC470);
force_and_dump(0x35B027C, 0x35B325C);
qexit(0);
}
@@ -0,0 +1,17 @@
#include <idc.idc>
static main()
{
auto result;
load_and_run_plugin("hexarm64", 0);
del_items(0x22C5BBC, DELIT_EXPAND, 0x22C60EC - 0x22C5BBC);
create_insn(0x22C5BBC);
add_func(0x22C5BBC, 0x22C60EC);
plan_and_wait(0x22C5BBC, 0x22C60EC);
result = decompile(0x22C5BBC);
if (result != 0)
msg("%s\n", result.text);
else
msg("Decompile failed for Spatial options constructor\n");
qexit(0);
}
@@ -0,0 +1,26 @@
#include <idc.idc>
static dump_containing(ea)
{
auto start, end, result;
start = get_func_attr(ea, FUNCATTR_START);
end = get_func_attr(ea, FUNCATTR_END);
msg("\n===== candidate %x function %x..%x =====\n", ea, start, end);
if (start == BADADDR)
return;
result = decompile(start);
if (result != 0)
msg("%s\n", result.text);
else
msg("Decompile failed\n");
}
static main()
{
load_and_run_plugin("hexarm64", 0);
dump_containing(0x235C23C);
dump_containing(0x24E2B88);
dump_containing(0x35AA0B0);
dump_containing(0x35ABE80);
qexit(0);
}
@@ -0,0 +1,24 @@
#include <idc.idc>
static dump_function(start, end)
{
auto result;
del_items(start, DELIT_EXPAND, end - start);
create_insn(start);
add_func(start, end);
plan_and_wait(start, end);
msg("\n===== function %x..%x =====\n", start, end);
result = decompile(start);
if (result != 0)
msg("%s\n", result.text);
else
msg("Decompile failed\n");
}
static main()
{
load_and_run_plugin("hexarm64", 0);
dump_function(0x37AAB68, 0x37B9AF4);
dump_function(0x37B9AF4, 0x37BECDC);
qexit(0);
}
@@ -0,0 +1,24 @@
#include <idc.idc>
static dump_function(start, end, label)
{
auto result;
del_items(start, DELIT_EXPAND, end - start);
create_insn(start);
add_func(start, end);
plan_and_wait(start, end);
msg("\n===== %s %x..%x =====\n", label, start, end);
result = decompile(start);
if (result != 0)
msg("%s\n", result.text);
else
msg("Decompile failed\n");
}
static main()
{
load_and_run_plugin("hexarm64", 0);
dump_function(0x37A99BC, 0x37AAB68, "Bayer strength task");
dump_function(0x37B8948, 0x37B9AF4, "RGB strength task");
qexit(0);
}
@@ -0,0 +1,22 @@
#include <idc.idc>
static dump_refs(target)
{
auto ref;
msg("\n===== xrefs to %x =====\n", target);
ref = get_first_cref_to(target);
while (ref != BADADDR)
{
msg("%08x %s %s\n", ref, print_insn_mnem(ref), print_operand(ref, 0));
ref = get_next_cref_to(target, ref);
}
}
static main()
{
dump_refs(0x35A4B00);
dump_refs(0x35A8E84);
dump_refs(0x3631290);
dump_refs(0x3629BAC);
qexit(0);
}
@@ -0,0 +1,41 @@
#include <idc.idc>
static main()
{
auto ea, end, mnem, op0, op1, op2;
ea = 0;
end = 0x4000000;
while (ea != BADADDR && ea < end)
{
mnem = print_insn_mnem(ea);
if (mnem == "LDR" || mnem == "STR" ||
mnem == "LDUR" || mnem == "STUR" ||
mnem == "LDP" || mnem == "STP")
{
op0 = print_operand(ea, 0);
op1 = print_operand(ea, 1);
op2 = print_operand(ea, 2);
if (strstr(op1, "#0x2B4") != -1 ||
strstr(op2, "#0x2B4") != -1 ||
strstr(op1, "#0x298") != -1 ||
strstr(op2, "#0x298") != -1 ||
strstr(op1, "#0x2A8") != -1 ||
strstr(op2, "#0x2A8") != -1 ||
strstr(op1, "#0x5B8") != -1 ||
strstr(op2, "#0x5B8") != -1 ||
strstr(op1, "#0x2B8") != -1 ||
strstr(op2, "#0x2B8") != -1 ||
strstr(op1, "#0x2BC") != -1 ||
strstr(op2, "#0x2BC") != -1 ||
strstr(op1, "#0x2C0") != -1 ||
strstr(op2, "#0x2C0") != -1 ||
strstr(op1, "#0xFB0") != -1 ||
strstr(op2, "#0xFB0") != -1)
{
msg("%08x %s %s, %s, %s\n", ea, mnem, op0, op1, op2);
}
}
ea = next_head(ea, end);
}
qexit(0);
}
@@ -37,6 +37,40 @@ class CodeRange:
CODE_RANGES = (
CodeRange(
"ComputeBayerNoiseModelF32TileSize16",
0x037A6E14,
0x037AAB68,
0x037B9AF4,
"photon_mgc_compute_bayer_noise_model_f32_tile_size_16",
),
CodeRange(
"ComputeRGBNoiseModelF32TileSize16",
0x037B9AF4,
0x037B9AF4,
0x037BECDC,
"photon_mgc_compute_rgb_noise_model_f32_tile_size_16",
),
CodeRange(
"DownsampleRawF16ToFloatTileSize16",
0x037BECDC,
0x037BECDC,
0x037C1A8C,
"photon_mgc_downsample_raw_f16_to_float_tile_size_16",
),
CodeRange(
"DownsampleRgbF16ToFloatTileSize16",
0x037C1A8C,
0x037C1A8C,
0x037DB248,
"photon_mgc_downsample_rgb_f16_to_float_tile_size_16",
),
CodeRange(
"DownsampleRgbF16ToFloatTileSize16CopyHelper",
0x038561A4,
0x03856414,
0x0385642C,
),
CodeRange("BayerRawToYuv1xS16", 0x049C3484, 0x049C7B64, 0x049CAA54),
CodeRange(
"RgbRawToYuv1xS16",
@@ -85,6 +119,20 @@ CODE_RANGES = (
0x054DE730,
"photon_mgc_compute_denoise_strength_maps_u16",
),
CodeRange(
"DownsampleRgbF16ToFloatTileSize16Mode0",
0x05DACC58,
0x05DACC58,
0x05DAD588,
"photon_mgc_downsample_rgb_mode_0",
),
CodeRange(
"DownsampleRgbF16ToFloatTileSize16Mode1",
0x05DAD588,
0x05DAD588,
0x05DAE16C,
"photon_mgc_downsample_rgb_mode_1",
),
)
HOST_TARGETS = {
@@ -93,6 +141,7 @@ HOST_TARGETS = {
0x05EF54BC: "photon_mgc_halide_trace",
0x05A7FEF0: "photon_mgc_halide_do_par_for",
0x05FB8540: "memset",
0x05DAE16C: "photon_mgc_downsample_rgb_dispatch",
}
@@ -312,26 +361,41 @@ def generate(
lines.append(f" .hidden {symbol}")
lines.append("")
for code_range in CODE_RANGES:
code_groups: list[list[CodeRange]] = []
for code_range in sorted(CODE_RANGES, key=lambda value: value.start):
section_start = page_floor(code_range.start)
section_end = page_ceil(code_range.end)
if (
not code_groups
or section_start >= max(
page_ceil(value.end) for value in code_groups[-1]
)
):
code_groups.append([code_range])
else:
code_groups[-1].append(code_range)
for code_group in code_groups:
section_start = min(page_floor(value.start) for value in code_group)
section_end = max(page_ceil(value.end) for value in code_group)
section_name = "__".join(value.name for value in code_group)
lines.extend(
[
(
f'.section .text.photon_mgc.{code_range.name},'
f'.section .text.photon_mgc.{section_name},'
'"ax",@progbits'
),
" .p2align 12",
]
)
if code_range.symbol is not None:
lines.extend(
[
f" .global {code_range.symbol}",
f" .hidden {code_range.symbol}",
f" .type {code_range.symbol}, %function",
]
)
for code_range in code_group:
if code_range.symbol is not None:
lines.extend(
[
f" .global {code_range.symbol}",
f" .hidden {code_range.symbol}",
f" .type {code_range.symbol}, %function",
]
)
events = set(range(section_start, section_end, PAGE_SIZE))
events.update(
@@ -1,5 +1,35 @@
{
"code_ranges": [
{
"end": "0x37b9af4",
"entry": "0x37aab68",
"name": "ComputeBayerNoiseModelF32TileSize16",
"start": "0x37a6e14"
},
{
"end": "0x37becdc",
"entry": "0x37b9af4",
"name": "ComputeRGBNoiseModelF32TileSize16",
"start": "0x37b9af4"
},
{
"end": "0x37c1a8c",
"entry": "0x37becdc",
"name": "DownsampleRawF16ToFloatTileSize16",
"start": "0x37becdc"
},
{
"end": "0x37db248",
"entry": "0x37c1a8c",
"name": "DownsampleRgbF16ToFloatTileSize16",
"start": "0x37c1a8c"
},
{
"end": "0x385642c",
"entry": "0x3856414",
"name": "DownsampleRgbF16ToFloatTileSize16CopyHelper",
"start": "0x38561a4"
},
{
"end": "0x49caa54",
"entry": "0x49c7b64",
@@ -47,6 +77,18 @@
"entry": "0x54dcd34",
"name": "ComputeDenoiseStrengthMapsU16",
"start": "0x54dbe04"
},
{
"end": "0x5dad588",
"entry": "0x5dacc58",
"name": "DownsampleRgbF16ToFloatTileSize16Mode0",
"start": "0x5dacc58"
},
{
"end": "0x5dae16c",
"entry": "0x5dad588",
"name": "DownsampleRgbF16ToFloatTileSize16Mode1",
"start": "0x5dad588"
}
],
"direct_external_targets": {
@@ -326,6 +368,76 @@
"target": "0x5ef6bd8"
}
],
"ComputeBayerNoiseModelF32TileSize16": [
{
"host": "halide_do_par_for",
"target": "0x5a7fef0"
},
{
"host": "halide_malloc",
"target": "0x5ef2634"
},
{
"host": "halide_free",
"target": "0x5ef2650"
},
{
"host": "halide_trace",
"target": "0x5ef54bc"
},
{
"host": "halide_error_path",
"target": "0x5ef61ac"
},
{
"host": "halide_error_path",
"target": "0x5ef6294"
},
{
"host": "halide_error_path",
"target": "0x5ef636c"
},
{
"host": "halide_error_path",
"target": "0x5ef63f8"
},
{
"host": "halide_error_path",
"target": "0x5ef64dc"
},
{
"host": "halide_error_path",
"target": "0x5ef6568"
},
{
"host": "halide_error_path",
"target": "0x5ef6600"
},
{
"host": "halide_error_path",
"target": "0x5ef6794"
},
{
"host": "halide_error_path",
"target": "0x5ef6a74"
},
{
"host": "halide_error_path",
"target": "0x5ef6a94"
},
{
"host": "halide_error_path",
"target": "0x5ef6b6c"
},
{
"host": "halide_error_path",
"target": "0x5ef6bd8"
},
{
"host": "memset",
"target": "0x5fb8540"
}
],
"ComputeDenoiseStrengthMapsU16": [
{
"host": "halide_do_par_for",
@@ -396,6 +508,286 @@
"target": "0x5fb8540"
}
],
"ComputeRGBNoiseModelF32TileSize16": [
{
"host": "halide_do_par_for",
"target": "0x5a7fef0"
},
{
"host": "halide_malloc",
"target": "0x5ef2634"
},
{
"host": "halide_free",
"target": "0x5ef2650"
},
{
"host": "halide_trace",
"target": "0x5ef54bc"
},
{
"host": "halide_error_path",
"target": "0x5ef61ac"
},
{
"host": "halide_error_path",
"target": "0x5ef6294"
},
{
"host": "halide_error_path",
"target": "0x5ef636c"
},
{
"host": "halide_error_path",
"target": "0x5ef63f8"
},
{
"host": "halide_error_path",
"target": "0x5ef64dc"
},
{
"host": "halide_error_path",
"target": "0x5ef6568"
},
{
"host": "halide_error_path",
"target": "0x5ef6600"
},
{
"host": "halide_error_path",
"target": "0x5ef6794"
},
{
"host": "halide_error_path",
"target": "0x5ef6a74"
},
{
"host": "halide_error_path",
"target": "0x5ef6a94"
},
{
"host": "halide_error_path",
"target": "0x5ef6b6c"
},
{
"host": "halide_error_path",
"target": "0x5ef6bd8"
}
],
"DownsampleRawF16ToFloatTileSize16": [
{
"host": "halide_do_par_for",
"target": "0x5a7fef0"
},
{
"host": "halide_trace",
"target": "0x5ef54bc"
},
{
"host": "halide_error_path",
"target": "0x5ef61ac"
},
{
"host": "halide_error_path",
"target": "0x5ef6294"
},
{
"host": "halide_error_path",
"target": "0x5ef636c"
},
{
"host": "halide_error_path",
"target": "0x5ef63f8"
},
{
"host": "halide_error_path",
"target": "0x5ef64dc"
},
{
"host": "halide_error_path",
"target": "0x5ef6568"
},
{
"host": "halide_error_path",
"target": "0x5ef6600"
},
{
"host": "halide_error_path",
"target": "0x5ef6794"
},
{
"host": "halide_error_path",
"target": "0x5ef6a94"
},
{
"host": "halide_error_path",
"target": "0x5ef6b6c"
},
{
"host": "halide_error_path",
"target": "0x5ef6bd8"
},
{
"host": "memset",
"target": "0x5fb8540"
}
],
"DownsampleRgbF16ToFloatTileSize16": [
{
"host": "halide_do_par_for",
"target": "0x5a7fef0"
},
{
"host": "halide_malloc",
"target": "0x5ef2634"
},
{
"host": "halide_free",
"target": "0x5ef2650"
},
{
"host": "halide_trace",
"target": "0x5ef54bc"
},
{
"host": "halide_error_path",
"target": "0x5ef604c"
},
{
"host": "halide_error_path",
"target": "0x5ef6140"
},
{
"host": "halide_error_path",
"target": "0x5ef61ac"
},
{
"host": "halide_error_path",
"target": "0x5ef6294"
},
{
"host": "halide_error_path",
"target": "0x5ef636c"
},
{
"host": "halide_error_path",
"target": "0x5ef63f8"
},
{
"host": "halide_error_path",
"target": "0x5ef64dc"
},
{
"host": "halide_error_path",
"target": "0x5ef6568"
},
{
"host": "halide_error_path",
"target": "0x5ef6600"
},
{
"host": "halide_error_path",
"target": "0x5ef6794"
},
{
"host": "halide_error_path",
"target": "0x5ef6a94"
},
{
"host": "halide_error_path",
"target": "0x5ef6b6c"
},
{
"host": "halide_error_path",
"target": "0x5ef6bd8"
}
],
"DownsampleRgbF16ToFloatTileSize16CopyHelper": [
{
"host": "downsample_rgb_dispatch",
"target": "0x5dae16c"
}
],
"DownsampleRgbF16ToFloatTileSize16Mode0": [
{
"host": "halide_error_path",
"target": "0x20239a0"
},
{
"host": "halide_error_path",
"target": "0x256406c"
},
{
"host": "halide_error_path",
"target": "0x5dac60c"
},
{
"host": "halide_error_path",
"target": "0x5daca0c"
},
{
"host": "halide_error_path",
"target": "0x5dae204"
},
{
"host": "halide_error_path",
"target": "0x5dae37c"
},
{
"host": "halide_error_path",
"target": "0x5f57538"
},
{
"host": "halide_error_path",
"target": "0x5f59544"
},
{
"host": "halide_error_path",
"target": "0x5f595a0"
},
{
"host": "memset",
"target": "0x5fb8540"
}
],
"DownsampleRgbF16ToFloatTileSize16Mode1": [
{
"host": "halide_error_path",
"target": "0x20239a0"
},
{
"host": "halide_error_path",
"target": "0x256406c"
},
{
"host": "halide_error_path",
"target": "0x5dac85c"
},
{
"host": "halide_error_path",
"target": "0x5dae540"
},
{
"host": "halide_error_path",
"target": "0x5dae6b8"
},
{
"host": "halide_error_path",
"target": "0x5f57538"
},
{
"host": "halide_error_path",
"target": "0x5f59544"
},
{
"host": "halide_error_path",
"target": "0x5f595a0"
},
{
"host": "memset",
"target": "0x5fb8540"
}
],
"PecanLumaDenoiseS16": [
{
"host": "halide_do_par_for",
@@ -607,11 +999,22 @@
}
]
},
"do_par_for_call_count": 12,
"do_par_for_call_count": 23,
"format": "mgc-full-resolution-denoise-static-lift-v1",
"page_count": 181,
"page_count": 257,
"page_size": 4096,
"pages": [
"0x4fd000",
"0x50f000",
"0x53e000",
"0x54e000",
"0x56e000",
"0x5bf000",
"0x5e3000",
"0x614000",
"0x634000",
"0x687000",
"0x6a7000",
"0x6a8000",
"0x6a9000",
"0x6aa000",
@@ -627,10 +1030,16 @@
"0x6b5000",
"0x6b6000",
"0x6b7000",
"0x6b8000",
"0x6b9000",
"0x6ba000",
"0x6bb000",
"0x6bc000",
"0x6bd000",
"0xbc0000",
"0xbc1000",
"0xbc2000",
"0xbc3000",
"0xd4d000",
"0xd51000",
"0xd5f000",
@@ -644,6 +1053,61 @@
"0xf39000",
"0xf3a000",
"0x10a9000",
"0x37a6000",
"0x37a7000",
"0x37a8000",
"0x37a9000",
"0x37aa000",
"0x37ab000",
"0x37ac000",
"0x37ad000",
"0x37ae000",
"0x37af000",
"0x37b0000",
"0x37b1000",
"0x37b2000",
"0x37b3000",
"0x37b4000",
"0x37b5000",
"0x37b6000",
"0x37b7000",
"0x37b8000",
"0x37b9000",
"0x37ba000",
"0x37bb000",
"0x37bc000",
"0x37bd000",
"0x37be000",
"0x37bf000",
"0x37c0000",
"0x37c1000",
"0x37c2000",
"0x37c3000",
"0x37c4000",
"0x37c5000",
"0x37c6000",
"0x37c7000",
"0x37c8000",
"0x37c9000",
"0x37ca000",
"0x37cb000",
"0x37cc000",
"0x37cd000",
"0x37ce000",
"0x37cf000",
"0x37d0000",
"0x37d1000",
"0x37d2000",
"0x37d3000",
"0x37d4000",
"0x37d5000",
"0x37d6000",
"0x37d7000",
"0x37d8000",
"0x37d9000",
"0x37da000",
"0x37db000",
"0x3856000",
"0x49c3000",
"0x49c4000",
"0x49c5000",
@@ -790,6 +1254,10 @@
"0x54dc000",
"0x54dd000",
"0x54de000",
"0x5dac000",
"0x5dad000",
"0x5dae000",
"0x6146000",
"0x614f000",
"0x6150000",
"0x6152000"
@@ -871,6 +1339,17 @@
"source": "MGC/MGC_9.6.080_V24_MGC/lib/arm64-v8a/libgcastartup.so",
"source_sha256": "2103c54ebba1627733b79e3646105595ed1ccefa2b1629f63fb7e1785a48d6a0",
"task_relocations": {
"0x6146550": "0x37a6e14",
"0x6146558": "0x37a99bc",
"0x6146560": "0x37ae9a8",
"0x6146568": "0x37b1150",
"0x6146570": "0x37b61a0",
"0x6146578": "0x37b8948",
"0x6146580": "0x37bd934",
"0x6146588": "0x37bea94",
"0x6146590": "0x37bfc00",
"0x6146598": "0x37c1348",
"0x61465a0": "0x37c298c",
"0x614fd58": "0x49c3484",
"0x614fda8": "0x4a17ea8",
"0x614ffb0": "0x4bee520",