Skip to content

Three small fixes: MAC address, redundant shader rebuild, unused edge list - #2751

Open
Umberto-DEV wants to merge 3 commits into
melonDS-emu:masterfrom
Umberto-DEV:melonds-three-small-fixes
Open

Three small fixes: MAC address, redundant shader rebuild, unused edge list#2751
Umberto-DEV wants to merge 3 commits into
melonDS-emu:masterfrom
Umberto-DEV:melonds-three-small-fixes

Conversation

@Umberto-DEV

Copy link
Copy Markdown

Three unrelated fixes, one commit each.

1. Only two of the six bytes of the MAC address are written — src/SPI.cpp

When a DSi game boots directly, melonDS writes the address to the same spot three times instead of moving along. Four of the six bytes never arrive, so the emulated console ends up with an address its firmware never gave it.

What changes for you: fixes a bug. I don't know of a game that misbehaves because of it, and I'm not claiming there is one.

2. Changing a video setting rebuilds every shader, even when nothing changed — src/GPU3D_Compute.cpp

Every time the renderer is handed its settings it throws away all its shaders and rebuilds them, even when the values are the ones it is already using. The OpenGL renderer already checks for this; the compute one doesn't.

What changes for you: faster. On a test device, changing video settings rebuilt 33 shaders ten times in one session. After the fix: none. It still rebuilds on startup, where it has to.

3. The renderer prepares data for a drawing step that is switched off — src/GPU3D_OpenGL.cpp

The edge outlines step has been commented out for years, but the list of edges it would need is still built for every polygon and sent to the graphics card every frame. This doesn't turn the step back on — it just stops paying for it while it's off.

What changes for you: removes work that has no effect. I haven't measured how much.

What this doesn't prove

Fixes 1 and 3 aren't backed by a measurement — I can show the bug in the code, not its effect on screen. Fix 2 was measured on Android only.

SetupDirectBoot() writes the six MAC bytes in three 16-bit stores, but the
destination address is fixed, so all three land on 0x02FFFCF4 and only the
last two bytes end up in memory.

The next field starts at 0x02FFFCFA, which leaves exactly six bytes for the
address, and the user settings loop below uses 0x02FFFC80+i in the same way.
SetRenderSettings() deletes and recompiles every shader and reallocates the
buffers on each call, even when it is called with the values already in use.
The GL renderer bails out on the same condition; the compute one does not.

ScaleFactor starts at 0, which is not a valid scale, so the first call still
goes through and the renderer is always initialised.
The edge marking pass in RenderSceneChunk() has been commented out since the
OpenGL renderer landed, so RenderPolygonEdgeBatch() has no callers and nothing
ever reads the edge index list. The list is still built for every polygon and
uploaded to the GPU on every frame.

Gate both the build and the commented-out draw on one constant, so whoever
restores the pass flips it in the same commit and the two cannot disagree.
This does not change what is drawn.
@Umberto-DEV
Umberto-DEV deleted the melonds-three-small-fixes branch September 11, 2026 21:56
@Umberto-DEV
Umberto-DEV restored the melonds-three-small-fixes branch September 11, 2026 21:57
@Umberto-DEV Umberto-DEV reopened this Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant