diff --git a/libs/RVLMiddleware/TMC_JPEG/src/texturecvtr/Texture_MCUtoRGB565.c b/libs/RVLMiddleware/TMC_JPEG/src/texturecvtr/Texture_MCUtoRGB565.c index f8af4584..ac678474 100644 --- a/libs/RVLMiddleware/TMC_JPEG/src/texturecvtr/Texture_MCUtoRGB565.c +++ b/libs/RVLMiddleware/TMC_JPEG/src/texturecvtr/Texture_MCUtoRGB565.c @@ -284,7 +284,9 @@ static void TMCJPEGDEC_converterYUV411toRGB565edge(TMCCJPEGDecWork* work, s32 x, s32 yEnd = y + height; s32 lumaSkip = 32 - width; s32 chromaSkip = lumaSkip >> 2; - s32 redOffset, greenOffset, blueOffset; + s32 redOffset; + s32 blueOffset; + s32 greenOffset; ASSERTLINE((x & 3) == 0, __LINE__); for (; y < yEnd; y++) { s32 tileRow = (y >> 2) * tileWidth; diff --git a/libs/RVLMiddleware/TMC_JPEG/src/texturecvtr/Texture_MCUtoRGBA8.c b/libs/RVLMiddleware/TMC_JPEG/src/texturecvtr/Texture_MCUtoRGBA8.c index a04ee309..2d45a3e5 100644 --- a/libs/RVLMiddleware/TMC_JPEG/src/texturecvtr/Texture_MCUtoRGBA8.c +++ b/libs/RVLMiddleware/TMC_JPEG/src/texturecvtr/Texture_MCUtoRGBA8.c @@ -641,7 +641,9 @@ static void TMCJPEGDEC_converterYUV420toRGBA8edge(TMCCJPEGDecWork* work, s32 x, s32 xEnd = x + width; s32 lumaSkip = 16 - width; s32 chromaSkip = lumaSkip >> 1; - s32 redOffset, greenOffset, blueOffset; + s32 redOffset; + s32 blueOffset; + s32 greenOffset; ASSERTLINE((x & 1) == 0, __LINE__); for (; y < yEnd; y++) { u16* output = (u16*)(texture + ((y & 3) << 3)); diff --git a/tools/decomp-assist/allhands-jpeg-rgb411edge-triple.attempts.md b/tools/decomp-assist/allhands-jpeg-rgb411edge-triple.attempts.md new file mode 100644 index 00000000..3bc39eb0 --- /dev/null +++ b/tools/decomp-assist/allhands-jpeg-rgb411edge-triple.attempts.md @@ -0,0 +1,149 @@ +# RGB565411 edge grouped offset declarations + +Base: `17130b4b` (merged RGB565411 normal improvement), 43U only. +Branch: `agent/bittle/jpeg-rgb411edge-triple`. +Target: `TMCJPEGDEC_converterYUV411toRGB565edge` in +`libs/RVLMiddleware/TMC_JPEG/src/texturecvtr/Texture_MCUtoRGB565.c`. + +## Scope and historical coverage + +The only source change splits the existing line 287 declaration in place and +orders its three uninitialized `s32` scalars as redOffset, blueOffset, +greenOffset. All assignments, initializers, expressions, types, scopes, helpers, +assertions and traversal remain unchanged. There are no new locals. + +These are the three chroma contributions shared by each four-pixel group. The +existing x-alignment assertion guarantees entry at a chroma-group boundary. +The existing branch assigns all three offsets, in its original red/green/blue +assignment order, before the first pixel reads them. No address escapes. +Declaration order changes no arithmetic or observation order. + +Current original function text SHA256 (definition through closing brace and +newline): +`ed020f92da0ea0584d9d7fc4ecbcad9f11f8f7621a8829cfcd9fabf135361207`. +This exact function hash also occurs at `180e620c`, `be7ded2f`, `6ec48a1b` +and `cdc22045`; this is not a newly changed expression context. + +Historical round4 lines 1538-1544 establish the signed chroma-pointer context +and 95.37736% baseline. Round5 lines 251, 302-306 and 698 record endpoint, +output-pointer and row-template probes. The tex1 log at lines 137-143, 243-246, +346-352 and 520-525 records structural, input-type and lifetime trials. Its +statement that declaration permutations were inert provides no individual +order manifest. The grouped-declaration inventory also cited wider split +searches containing these offsets, but did not establish exhaustive coverage +of the current internal triple with every surrounding declaration fixed. + +This trial closes that specific finite measurement gap. Possible historical +order overlap is acknowledged; no claim that these six orders were never +compiled before is made. No wider declaration search or continuation occurred. + +## Bounded experiment + +1. Preserve prior branch refs; create a fresh branch at merged `17130b4b`. +2. Copy the parent-verified idle main cache, configure the approved local + wrapper/tool overrides, and run ordinary default Ninja, explicit 43U `ok`, + and a fresh full official objdiff report. +3. Compile the same-order red/green/blue split first. The entire object and + full 1027-unit official report are exactly identical to baseline. This + prerequisite passes before any permutation is measured. +4. Enumerate exactly the six permutations of these three existing declarations. + Each source is rebuilt by ordinary Ninja with unchanged compiler arguments; + each call emits the MWCC object-build line and updates the object mtime. + Exact source stability across each compile is checked. Save each source, + object, SHA256, build output and fresh official full report. +5. Select the first highest official-fuzzy order passing the sibling/code/data + gates; then freshly rebuild the selected source with default Ninja and the + explicit 43U `ok` target. No additional variant is tested. + +The independent same-order neutrality compile is separate from the six +permutation compiles. The final selected-source rebuild is validation, not an +additional searched order. No compiler call is suppressed or replaced. + +| Order | Function fuzzy | Unit fuzzy | Sibling/exact/code/data gates | +| --- | ---: | ---: | --- | +| red, green, blue | 95.37736 | 96.84735 | pass | +| red, blue, green | 95.42453 | 96.850586 | pass; retained | +| green, red, blue | 95.37736 | 96.84735 | pass | +| green, blue, red | 95.42453 | 96.850586 | pass | +| blue, red, green | 95.42453 | 96.850586 | pass | +| blue, green, red | 95.42453 | 96.850586 | pass | + +All six raw full reports were compared against baseline. All twelve sibling +function records and raw bodies remain unchanged in every permutation; all +seven existing exact functions remain raw-byte exact and at 100%. Exact code, +data and completion measures do not decrease. No other unit changes. The +six-order space is exhausted in this exact surrounding source context; this +says nothing about broader neighborhoods or eventual exact matching. + +## Fresh selected-source gates + +- Function: **95.37736% -> 95.42453%**, 424/424 bytes, 106/106 instructions +- Normalized positional ctxdiff: **62 -> 61** +- Unit fuzzy: **96.84735% -> 96.850586%** +- Global fuzzy: **99.727745% -> 99.72777%** +- Exact functions: **7/13**, exact code **2648/6184**, unchanged +- Merged RGB565411 normal gain remains **90.89862%**, raw body unchanged +- All 1027 units and every reported function checked: no regressions +- Fresh selected whole object equals saved permutation-1 object exactly +- Fresh final full report equals saved permutation-1 full report exactly +- Seven exact functions independently checked against original bytes and + normalized disassembly: ctxdiff 0 for each +- Baseline, candidate and original have zero allocated non-code bytes; empty + pool identical. No symbol/data/relocation/configuration change +- Literal audit: 12 functions analyzed, zero candidates/errors; setter skipped + because its source/target sizes differ, as at baseline +- Ordinary default build/progress plus explicit `build/43U/ok` pass +- DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d` +- `git diff --check` passes + +## Behavior and ordering + +The existing `jpeg_differential_audit.py` passes **9,456 paired cases** across +28 JPEG functions, including preserved GPR14-GPR31, stack pointer and LR. + +A focused independent scalar RGB565411-edge model checks **12,689 vectors** +against candidate, original and saved baseline objects, for **38,067 object +executions**: + +- 1,257 vectors span every edge width and height at supported scales 1/2/4/8, + including zero extents, partial four-pixel chroma groups, aligned x origins, + tiled boundaries and differing row residues +- 256 vectors exercise both dimension-selection branches independently with + random and constant samples +- 6,400 vectors cover all 256 luminance values for all pairs of signed chroma + values in {-128, -1, 0, 1, 127}, including saturation boundaries and partial + groups across rows +- 4,776 overlap vectors cover all fitting even destination bases for the + specified full/partial groups, pitches and row starts; every store remains + within the actual 0x184-byte conversion-buffer allocation + +All non-stack bytes, including guards, agree with the sequential scalar model. +All three objects reach **106/106 instructions**. The overlap oracle reads from +its evolving buffer, preserving read/write observation order; state and +descriptor objects remain separate. These overlap arrangements are additional +machine-level diagnostics, not a new public API alias contract. Input samples +and bounded dimensions keep intermediate arithmetic within signed integer +range. The converter contains only integer arithmetic; no floating-point +reassociation is involved. The unchanged assignment/evaluation order is also +verified by the exact source replacement check. + +This is bounded execution in the repository's PPC integer interpreter, not a +formal proof or a Wii hardware run. + +## Preserved evidence + +`/tmp/jpeg-rgb411edge-triple/` contains baseline source/object/report, frozen +original object, `split-neutral.*`, `permutation-0.*` through +`permutation-5.*`, `manifest.json`, `selection.json`, `trial.py`, +`trial-output.txt`, build logs, final report, `verify.py`, `verification.txt`, +`candidate.ctx`, literal output, `audit.py`, `audit-results.json`, audit output +and the differential result log. All six source/object snapshots are retained. + +Baseline whole object SHA256: +`fec999a214f95c1f348632de53cac7672c15d70cbaea9b3566d7a7383a4e1b70`. +Retained whole object SHA256: +`f82e514864af9c85e1857e2fd59bfd976deb0aba1f651662b322730ced490ad6`. +Retained source SHA256: +`8fb0c89b7b0bcb7b0467ca1be3dfcdb70dfa43b1ec085d926d028e156470749a`. +Retained function-text SHA256: +`fff97c26d8afa6d734a253ae3b9aeaa648b3a28b682c0ef98fb8aeb7b07bb5ca`. diff --git a/tools/decomp-assist/rgba420edge-offset-orders.attempts.md b/tools/decomp-assist/rgba420edge-offset-orders.attempts.md new file mode 100644 index 00000000..8630a8be --- /dev/null +++ b/tools/decomp-assist/rgba420edge-offset-orders.attempts.md @@ -0,0 +1,131 @@ +# RGBA420 edge inner offset triple: six official-fuzzy-scored orders + +Initial base `180e620c`; branch `agent/bittle/rgba420edge-offset-orders`. +Target `TMCJPEGDEC_converterYUV420toRGBA8edge`, 43U only. The sole editable source +was `s32 redOffset, greenOffset, blueOffset;` at original line 644, inside its +existing scope. No initializer, expression, assignment, type, other declaration, +helper, or scope moved. The final source only splits this declaration in place +and orders the three variables redOffset, blueOffset, greenOffset. + +## Why the finite check was not already established + +The official 87-build search in `fz20.attempts.md:1030..1054` covered the eight +leading declarations, not this inner triple. Its body preceded both the later +OR-expression change and `e8241734`'s red-owned luminance reconstruction. Wider +historical split/declaration trials mentioning these names do not retain the +six exact current-body, fixed-surroundings orders with official scores. The +read-only grouped inventory likewise states that this coverage was unproven. +No prior exhaustive equivalent finite coverage was found; this does not claim +none of the individual orders had ever appeared in a broader old trial. + +Current baseline function SHA256: +`0c7dcbff2b82ffca9a9b1c5cf20396ab8bc6a5191844527a87a9ac13aa2d0b47`. +It is byte-identical at `e8241734` and the initial base. Original whole-source +SHA256: `d4651ae1f7dd68082c84008ecce8b12c8f9d1053bc09ec1c0694acbb114b9cba`. + +## Neutral split and exactly six ordinary permutations + +A fresh baseline object/full report reproduced 87.458336%, 480 bytes. Splitting +in the same red/green/blue order first produced an entirely byte-identical +object and complete 1,027-unit report. Only after that neutral prerequisite, +exactly six distinct permutations were compiled with ordinary real Ninja. +Each exact source/order/hash and compiler output was saved; every call invoked +MWCC successfully and source bytes were stable across compilation. + +All six successful snapshots were scored with official objdiff, without +`--deduplicate`, using a private copy of the current project configuration, +preserving its options/metadata and freezing the original object. Only unit +names and target/base paths changed for the six snapshot units. Raw target +fuzzy selected the winner; batch aggregate measures were not used. + +- red, green, blue: 87.458336% +- red, blue, green: 87.5% (retained, first minimal tied winner) +- green, red, blue: 87.458336% +- green, blue, red: 87.5% +- blue, red, green: 87.5% +- blue, green, red: 87.5% + +Every order passes sibling-byte/report, exact-sibling, allocated-data, and +unit exact/code/data/link gates. This exhausts all six internal orders with +surrounding declarations fixed. It does not cover moves across other locals, +other scopes, initialized declarations, or other source forms. No further +order trial, converter run, or restart occurred. + +## Initial fresh gates + +- Function fuzzy: 87.458336% -> 87.5%; unit: 90.58702% -> 90.59006% +- Global fuzzy on initial base: 99.72766% -> 99.72768% +- Instructions stay 120/120; structural/positional score stays (12,77) +- The gain is visible in official fuzzy despite the unchanged coarse score +- Exact stays 2/13; matched code stays 660/6596; link/data totals unchanged +- All 12 sibling bodies unchanged; both YUV400 functions raw-byte exact, + official 100%, ctxdiff zero (76/76 and 89/89 instructions) +- No 1,027-unit report regression; no allocated non-code sections +- Empty pools identical; literal audit has zero candidates/errors, twelve + functions analyzed and unchanged unequal-size setter skipped +- Fresh selected-order rebuild equals its saved snapshot object +- Full default build, explicit progress/report/43U-ok targets, and diff check pass +- DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d` + +Global completion remains incomplete; this is partial fuzzy progress only. +Retained function SHA256: +`c06a346c894ec20ff2a228498a58327c09e19c94c3c235180feee962c1e12d43`. +Retained whole-source SHA256: +`b58c82974159e852c29f437365d55fec5330676a775fc1f5e81ce418ef224978`. + +## Independent 4:2:0 edge model + +The scalar model passes 12,039 vectors / 36,117 object executions against +selected candidate, original, and saved baseline; every one of 120 instructions +is covered in all three. It models Y[16][16], Cb[8][8], Cr[8][8] at offsets +4/260/324, horizontal pixel pairs, absolute output-row-parity vertical reuse, +edge dimension branches, and real sequential reads/stores when input aliases +output. All x origins satisfy the existing even-x assertion. + +Coverage: 1,212 complete edge-size/scale/origin cases, 256 dimension-branch +cases, 64 additional row/column-residue cases, 6,400 saturation vectors, and +4,107 halfword-aligned overlaps wholly within the actual 0x184-byte convBuf. +State/descriptors remain separate. Additional odd-row tests bound height so +chroma reads remain in the logical planes. Every byte below the reserved stack +region, including guards, matches; preserved GPRs, SP, and LR pass. Additional +residue/alias cases are machine-level checks, not API-validity claims. These +bounded interpreter tests are not formal equivalence or Wii runtime tests. +The repository differential audit independently passes all 9,456 paired cases. + +## Artifacts + +`build/43U/rgba420edge-offset-orders/` holds original and split source/object/ +full reports, frozen original/config, all six source/object snapshots and +compiler logs, `enumerate.py`, `orders.json`, official scoring project/report, +`results.json`, final fresh gate files, `verify.py`, `audit.py`, and audit output. +No remote writes, linking changes, or previously frozen branch edits. + +## Clean rebase and final current-main comparison + +Initial validated commit `6d9027a5` was cleanly rebased onto `17130b4b`, producing +source/evidence commit `62a0cc5d`. That base includes the merged RGB565411 gain. +No additional order was tried. The exact base's original grouped RGBA source +was built with the rebased surrounding tree to obtain a fresh baseline, then +the already-selected source was restored and freshly built. Both RGBA baseline +and selected objects remain byte-identical to their pre-rebase counterparts. + +The merged RGB565 source is byte-identical to `17130b4b`; its entire baseline +and final unit report is unchanged (unit fuzzy 96.84735%). The fresh 1,027-unit +comparison changes only RGBA420edge's fuzzy score; all other units/functions +and exact/code/data/link measures are unchanged. RGBA420edge remains +87.458336% -> 87.5%; RGBA unit 90.58702% -> 90.59006%. Current-base global fuzzy +is 99.727745% -> 99.72777%. The source remains only the grouped triple split and +red/blue/green order, with no expression, initializer, type, or scope change. + +Full default build, explicit progress/report/43U-ok targets, sibling exactness, +pool/literal checks, source/byte checks, and diff checks pass again. DOL SHA1: +`26116613f624061ba99c8d1a299aaa6efa85670d`. The independent model again passes +all 12,039 vectors / 36,117 executions, including 4,107 contained overlaps and +all 120 instructions in all three objects. The repository audit again passes +all 9,456 paired cases. Previous bounded-test limitations still apply. + +Current-base artifacts are in `build/43U/rgba420edge-offset-orders-rebased/`, +including fresh baseline/candidate source and objects, complete baseline/final +reports, build/progress logs, `verification.log`, `final.ctx`, exact/pool/literal/ +status/completion results, and both independent/repository audit outputs. The +original six-order artifacts remain untouched in the first evidence directory.