Skip to content

Conversation

wheremyfoodat
Copy link
Collaborator

@wheremyfoodat wheremyfoodat commented Aug 15, 2025

  • Displays a static splash screen with usage instructions when the emulator starts
  • Adds a Python script for generating splash screen data from an image file
  • Fixes glTexParameteri usage. The UI offscreen textures are no longer written to before min/mag filters are set, which would make Apple's drivers error.

The current splash screen is a sample and not necessarily final. This code will also likely be replaced when nanovg/nanosvg are replaced. Also worth noting that this relies on stb-image-resize2 for resizing the splash image to the render resolution. This can be avoided, but might require adding a fair bit of code.

Screen.Recording.2025-08-15.at.2.54.46.PM.mov

Image used for the splash screen in the video (Made in Canva, so I sadly can't share the project files easily)
redux-splash

Copy link
Contributor

coderabbitai bot commented Aug 15, 2025

Walkthrough

Adds a splash-screen path to the GUI: a private m_enableSplashScreen flag and getSplashScreen helper; uploads a generated RGBA splash into both offscreen textures with GL_NEAREST filtering (using unique_ptr-managed data); disables splash on ExecutionFlow::Run; adds a splash data generator script and integrates splash.cc into the VS project.

Changes

Cohort / File(s) Summary
GUI splash implementation
src/gui/gui.cc, src/gui/gui.h
Adds private m_enableSplashScreen (default true) and getSplashScreen(uint32_t,uint32_t) returning std::unique_ptr<uint32_t[]>; on StartFrame uploads splash image to both offscreen textures when clearing or splash enabled using glTexSubImage2D with GL_RGBA/GL_UNSIGNED_BYTE; sets texture filters to GL_NEAREST during splash upload; removes per-frame texture parameterization in flip(); disables splash at ExecutionFlow::Run start; replaces raw heap buffer with unique_ptr.
Splash source & build
src/gui/splash.cc, vsprojects/gui/gui.vcxproj, vsprojects/gui/gui.vcxproj.filters
Adds new translation unit src/gui/splash.cc; updates Visual Studio GUI project and filters to include splash.cc.
Tooling for splash data
tools/splash-generator/splash.py
New Python script that loads an image with Pillow, converts to RGBA, packs pixels into little-endian 32-bit RGBA8888 values and prints a formatted static const uint32_t C array beginning with width and height; usage check for single argument.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant ExecutionFlow
    participant GUI
    participant Textures
    App->>ExecutionFlow: Run()
    ExecutionFlow->>GUI: Initialize / StartFrame()
    alt first frame or clear with splash enabled
        GUI->>GUI: getSplashScreen(w,h) -> unique_ptr data
        GUI->>Textures: glBind + glTexSubImage2D(upload splash)
        GUI->>Textures: set GL_TEXTURE_MIN/MAG_FILTER = NEAREST
        GUI->>App: flip() (present offscreen texture)
    end
    ExecutionFlow->>ExecutionFlow: m_enableSplashScreen = false
    loop subsequent frames
        GUI->>Textures: render normal frame content
        GUI->>App: flip()
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–20 minutes

Poem

I painted dawn on two small panes,
With nearest stars and no soft grains—
A hop, a flip, the splash is gone,
The frames now race, the work goes on.
Nose twitch, ears perk—byte-brushed dawn. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 23ee14c and cdec82a.

📒 Files selected for processing (3)
  • tools/splash-generator/splash.py (1 hunks)
  • vsprojects/gui/gui.vcxproj (1 hunks)
  • vsprojects/gui/gui.vcxproj.filters (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • vsprojects/gui/gui.vcxproj.filters
  • vsprojects/gui/gui.vcxproj
  • tools/splash-generator/splash.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: macos-intel-build-and-test
  • GitHub Check: pcsx-redux (x86_64-linux)
  • GitHub Check: pcsx-redux (aarch64-linux)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: toolchain
  • GitHub Check: coverage
  • GitHub Check: cross-arm64
  • GitHub Check: build
  • GitHub Check: asan
  • GitHub Check: macos-build-and-test-toolchain
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
src/gui/gui.h (1)

461-462: Consider annotating getSplashScreen for intent and misuse prevention

Optional refinements:

  • Mark as [[nodiscard]] to prevent accidental ignoring of the returned buffer.
  • Mark noexcept if you’re confident stbir won’t throw in this context (it shouldn’t).
  • Since it doesn’t depend on object state, consider making it static.
-    std::unique_ptr<uint32_t[]> getSplashScreen(uint32_t destWidth, uint32_t destHeight);
+    [[nodiscard]] static std::unique_ptr<uint32_t[]> getSplashScreen(uint32_t destWidth, uint32_t destHeight) noexcept;
tools/splash-generator/splash.py (3)

1-1: Use python3 in the shebang for portability

Many environments map python to Python 2 or don’t provide it at all. Using python3 avoids ambiguity.

-#!/usr/bin/env python
+#!/usr/bin/env python3

12-15: Use a context manager to ensure the image file is closed and add basic error handling

This avoids leaking file descriptors on exceptions and provides a clearer error if Pillow can’t open the file.

-img = Image.open(filename).convert("RGBA")
-width, height = img.size
-pixels = list(img.getdata())
+try:
+    with Image.open(filename) as img:
+        img = img.convert("RGBA")
+        width, height = img.size
+        pixels = list(img.getdata())
+except Exception as e:
+    print(f"Error: failed to open or process image '{filename}': {e}", file=sys.stderr)
+    sys.exit(2)

25-25: Remove extraneous f-string prefix (Ruff F541)

There are no placeholders; drop the f to satisfy linters and avoid confusion.

-print(f"static const uint32_t s_splashImageData[] = {{")
+print("static const uint32_t s_splashImageData[] = {")
src/gui/gui.cc (1)

956-969: Texture parameterization before data upload fixes the macOS driver issue

Setting GL_TEXTURE_MAG_FILTER/MIN_FILTER to GL_NEAREST before calling glTexSubImage2D addresses the Apple driver error where writes occur before filters are set. Uploading the splash to both offscreen textures is sound.

Two small optional improvements:

  • Avoid recomputing the resized splash if m_setupScreenSize toggles repeatedly (e.g., during window resizing): cache the last (w,h) and the buffer to reuse within a frame or until size changes.
  • Consider documenting that glTexImage2D is used solely to allocate storage (pixels=0), so it’s not considered a “write” in the context of the driver issue.
-            std::unique_ptr<uint32_t[]> splashImageData = getSplashScreen(m_renderSize.x, m_renderSize.y);
+            // Optional: cache the resized splash per (w,h) to avoid recompute storms during resize.
+            std::unique_ptr<uint32_t[]> splashImageData = getSplashScreen(m_renderSize.x, m_renderSize.y);
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4f4a00f and 23ee14c.

📒 Files selected for processing (5)
  • src/gui/gui.cc (3 hunks)
  • src/gui/gui.h (2 hunks)
  • tools/splash-generator/splash.py (1 hunks)
  • vsprojects/gui/gui.vcxproj (1 hunks)
  • vsprojects/gui/gui.vcxproj.filters (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/gui/gui.h (1)
src/gui/splash.cc (2)
  • getSplashScreen (38411-38424)
  • getSplashScreen (38411-38411)
src/gui/gui.cc (1)
src/gui/splash.cc (2)
  • getSplashScreen (38411-38424)
  • getSplashScreen (38411-38411)
🪛 Ruff (0.12.2)
tools/splash-generator/splash.py

25-25: f-string without any placeholders

Remove extraneous f prefix

(F541)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: pcsx-redux (aarch64-linux)
  • GitHub Check: pcsx-redux (x86_64-linux)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: macos-build-and-test-toolchain
  • GitHub Check: coverage
  • GitHub Check: toolchain
  • GitHub Check: build
  • GitHub Check: cross-arm64
  • GitHub Check: asan
🔇 Additional comments (6)
vsprojects/gui/gui.vcxproj.filters (1)

106-108: Include of splash.cc in filters looks correct

The new translation unit is properly categorized under "Source Files". This aligns with the project file change and will make the file show up correctly in the VS Solution Explorer.

src/gui/gui.h (2)

28-28: Include is appropriate for unique_ptr usage

This is needed for the new helper returning std::unique_ptr. No issues here.


458-458: m_enableSplashScreen defaulting to true fits the startup-flow

This keeps the splash visible until emulation starts (disabled on Run). Looks good.

vsprojects/gui/gui.vcxproj (1)

131-131: splash.cc added to the GUI build

This ensures the splash functionality is compiled in all configurations. Good.

tools/splash-generator/splash.py (1)

16-21: Endianness and channel order note (FYI)

Packing as 0xAABBGGRR for each pixel is correct for little-endian RGBA8888 consumption (bytes in memory: R G B A). This matches the downstream use with STBIR_RGBA and GL_RGBA/GL_UNSIGNED_BYTE.

src/gui/gui.cc (1)

556-559: Disable splash on Run event is correct and low-risk

This ensures the splash is only shown prior to execution. Clean, simple, and consistent with the PR description.

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