Skip to content

fix(tooltips): significantly improve rendering performance#321

Open
olisikh wants to merge 4 commits intosven-n:mainfrom
olisikh:fix/tooltips_fps
Open

fix(tooltips): significantly improve rendering performance#321
olisikh wants to merge 4 commits intosven-n:mainfrom
olisikh:fix/tooltips_fps

Conversation

@olisikh
Copy link
Copy Markdown
Contributor

@olisikh olisikh commented Apr 9, 2026

optimize ground item tooltip rendering with cached labels and progressive builds

  • replace per-frame ground label text rebuild/upload path with a cache-backed texture render path
  • split label flow into descriptor building and cached ground rendering in ZzzInventory.cpp
  • key cache entries by label-affecting item state (type, level, excellent, ancient, skill/luck/option)
  • add cache lifecycle controls: max 1500 entries + 10s idle eviction (LRU-style removal)
  • add per-frame build budget (32) in NewUINameWindow.cpp for progressive warm-up under heavy drop density
  • keep selected-item tooltip path immediate (no delayed budget path)
  • optimize text renderer upload in UIControls.cpp from full texture re-upload to partial glTexSubImage2D
  • preserve correct upload row stride for partial updates via tight repack buffer
  • align cached label sampling/positioning with original text rendering for crisp contrast and focus

result: significantly reduced ALT-tooltip frame-time cost in crowded scenes while preserving tooltip naming/styling behavior and eventual full label visibility

The performance gain is substantial on devices like Steam Deck, where spots with a lot of items had FPS reduced by 15-30, while now the hit is marginal (0-3 fps) and all tooltips are visible as before.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the rendering performance of ground item tooltips, especially in scenarios with high item density. By introducing a robust caching mechanism for item labels and optimizing texture upload processes, the changes aim to significantly reduce frame-time costs associated with displaying tooltips. The implementation includes progressive label building and intelligent cache management to maintain smooth performance without altering the visual fidelity or naming conventions of the tooltips.

Highlights

  • Ground Item Tooltip Caching: Implemented a cache for ground item tooltip labels, replacing per-frame text rebuilding and texture uploads with a more efficient cache-backed texture rendering path.
  • Progressive Label Building: Introduced a per-frame build budget (32 labels) for ground item tooltips, enabling progressive warm-up under heavy item density and preventing performance spikes.
  • Optimized Text Texture Uploads: Modified the text renderer to use glTexSubImage2D for partial texture updates instead of full glTexImage2D re-uploads, significantly reducing GPU bandwidth usage.
  • Cache Management: Added lifecycle controls for the ground item label cache, including a maximum of 1500 entries and a 10-second idle eviction policy (LRU-style removal).
  • Selected Item Tooltip Behavior: Ensured that tooltips for selected items continue to render immediately, bypassing the progressive build budget for an uncompromised user experience.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new caching mechanism for ground item labels to optimize rendering performance. This involves refactoring the RenderItemName function to use a texture cache for item names, including logic for building label descriptors, creating textures, and pruning the cache. It also updates NewUINameWindow.cpp to set a budget for label building and modifies UIControls.cpp to use glTexSubImage2D for more efficient texture uploads. The review identified a potential buffer overflow vulnerability in string formatting, suggested replacing a magic number with a named constant for better readability, and pointed out an inefficiency in the cache pruning algorithm that could be optimized.

@olisikh
Copy link
Copy Markdown
Contributor Author

olisikh commented Apr 9, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request significantly optimizes ground item label rendering by introducing a texture-based caching mechanism. The RenderItemName function has been refactored to build and store item label textures, reducing redundant text rendering. A per-frame budget is implemented to control new texture creation. Additionally, UploadText in UIControls.cpp was updated to use glTexSubImage2D for more efficient texture updates. Feedback suggests addressing potential thread safety and performance issues with the static std::vector in UIControls.cpp, encapsulating the new caching logic in ZzzInventory.cpp within a dedicated class for better maintainability, and using wcslen for improved string manipulation.

@olisikh olisikh changed the title fix(tooltips): improve rendering performance fix(tooltips): significantly improve rendering performance Apr 9, 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