Skip to content

psyqo: split GPU register setup into reinitialize()#2050

Open
nicolasnoble wants to merge 1 commit into
grumpycoders:mainfrom
nicolasnoble:psyqo-gpu-reinit
Open

psyqo: split GPU register setup into reinitialize()#2050
nicolasnoble wants to merge 1 commit into
grumpycoders:mainfrom
nicolasnoble:psyqo-gpu-reinit

Conversation

@nicolasnoble

Copy link
Copy Markdown
Member

Factor the re-runnable part of initialize() - the display-mode, range and
display-area register writes plus the derived width/height/refresh state -
into a new reinitialize(), so the video mode can be reconfigured without
re-installing the VBlank handler, DMA events and timers. initialize() keeps
the one-time setup and calls reinitialize(). Behavior is unchanged: the
register values and write order are identical; only the Timer1 (COUNTERS[1])
setup moves ahead of the register writes, which is independent.

Factor the re-runnable part of initialize() - the display-mode, range and
display-area register writes plus the derived width/height/refresh state -
into a new reinitialize(), so the video mode can be reconfigured without
re-installing the VBlank handler, DMA events and timers. initialize() keeps
the one-time setup and calls reinitialize(). Behavior is unchanged: the
register values and write order are identical; only the Timer1 (COUNTERS[1])
setup moves ahead of the register writes, which is independent.

Co-authored-by: Elias Daler <eliasdaler@protonmail.com>
Signed-off-by: Nicolas 'Pixel' Noble <nicolas@nobis-crew.org>
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 30bca617-2962-409a-a99c-1664ddbb3bbe

📥 Commits

Reviewing files that changed from the base of the PR and between e909cc3 and 1a3ce1e.

📒 Files selected for processing (2)
  • src/mips/psyqo/gpu.hh
  • src/mips/psyqo/src/gpu.cpp

📝 Walkthrough

Walkthrough

A new reinitialize(const Configuration&) method is added to psyqo::GPU, extracting GPU control register programming and display/interlace state derivation previously inline in initialize. initialize now sets up COUNTERS[1] and calls reinitialize before continuing its remaining setup steps.

Changes

GPU reinitialize refactor

Layer / File(s) Summary
Public API declaration
src/mips/psyqo/gpu.hh
Adds a reinitialize(const Configuration&) method declaration to the GPU class alongside initialize.
Extract and wire reinitialize logic
src/mips/psyqo/src/gpu.cpp
Moves hardware reset, GPU control register programming, and display/interlace state derivation into new GPU::reinitialize; removes the now-relocated COUNTERS[1] setup from that block; updates GPU::initialize to initialize COUNTERS[1] then call reinitialize(config) before continuing with VBlank, VRAM, and DMA setup.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant GPU_initialize as GPU::initialize
  participant GPU_reinitialize as GPU::reinitialize

  Caller->>GPU_initialize: initialize(config)
  GPU_initialize->>GPU_initialize: set COUNTERS[1].mode/value
  GPU_initialize->>GPU_reinitialize: reinitialize(config)
  GPU_reinitialize->>GPU_reinitialize: program GPU control registers
  GPU_reinitialize->>GPU_reinitialize: derive display/interlace state
  GPU_reinitialize-->>GPU_initialize: return
  GPU_initialize->>GPU_initialize: continue VBlank/DMA setup
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: moving GPU register setup into a new reinitialize() method.
Description check ✅ Passed The description matches the implemented refactor and one-time setup split in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant