graphics: hoist loop-invariant checks out of draw/attrib hot paths #807

Manually merged
github merged 2 commits from gh-pr/807/head into gh-pr/807/base 2026-11-26 09:33:13 +00:00
Owner

@⁠romainhedouin on GitHub · 2026-09-24 14:11 UTC · original
romainhedouin:optimize-drawindirect-shader-loops → main · +16 −10 · 3 files · 2 commits · merged 2026-09-24 17:02 UTC

Summary

  • CommandProcessor::DrawIndirectMulti recomputed the m_index_type_and_size switch (deriving index_size) on every sub-draw of a multi-draw-indirect call. The value is invariant across the loop, so it's now computed once before iterating.
  • ShaderApplyAttribSemantics re-evaluated Config::GraphicsDebugDumpEnabled() on every vertex attribute (up to 32 per call). Hoisted into a single local bool before the loop.
  • AcquireVertexBuffers called VertexBufferDescriptorSize twice per vertex-buffer slot on every draw call (once while collecting guest ranges, again while rebuilding slot bindings) with identical inputs both times. The first pass's result is now cached and reused.

All three are pure loop-invariant hoists / redundant-call elimination with no behavior change.

**@⁠romainhedouin** on GitHub · 2026-09-24 14:11 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/807) `romainhedouin:optimize-drawindirect-shader-loops` → `main` · +16 −10 · 3 files · 2 commits · merged 2026-09-24 17:02 UTC ## Summary - `CommandProcessor::DrawIndirectMulti` recomputed the `m_index_type_and_size` switch (deriving `index_size`) on every sub-draw of a multi-draw-indirect call. The value is invariant across the loop, so it's now computed once before iterating. - `ShaderApplyAttribSemantics` re-evaluated `Config::GraphicsDebugDumpEnabled()` on every vertex attribute (up to 32 per call). Hoisted into a single local `bool` before the loop. - `AcquireVertexBuffers` called `VertexBufferDescriptorSize` twice per vertex-buffer slot on every draw call (once while collecting guest ranges, again while rebuilding slot bindings) with identical inputs both times. The first pass's result is now cached and reused. All three are pure loop-invariant hoists / redundant-call elimination with no behavior change.
DrawIndirectMulti recomputed the index_type_and_size switch on every
sub-draw of a multi-draw-indirect call, and ShaderApplyAttribSemantics
re-checked the debug-dump config flag on every vertex attribute. Both
values are invariant across their respective loops, so compute them
once before iterating instead.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
VertexBufferDescriptorSize was computed twice per vertex-buffer slot
on every draw call: once while collecting guest ranges, and again
while rebuilding slot bindings. Both calls use identical inputs, so
cache the first pass's result and reuse it in the second.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:33:12 +00:00
github manually merged commit f1d4c6e638 into gh-pr/807/base 2026-11-26 09:33:13 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-24 14:17 UTC · original · edited 2026-09-24 14:27 UTC

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 7d74b1b8-0e3e-4661-88c3-f0f43d4dd602

📥 Commits

Reviewing files that changed from the base of the PR and between ecfa5412a5 and f1d4c6e638.

📒 Files selected for processing (1)
  • src/graphics/host_gpu/renderer/renderDraw.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

DrawIndirectMulti selects the index-element size once for indexed draws and reuses it when calculating each draw's index address. ShaderApplyAttribSemantics caches the graphics debug-dump setting before processing input semantics and uses it to gate per-attribute logging. AcquireVertexBuffers records each vertex descriptor size by slot and reuses it during binding setup.

Suggested reviewers: nmzik

Merge Risk: ⚪ Minimal · up to f1d4c

The cached values preserve the behavior described for these operations, and no actionable merge risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main change: moving loop-invariant checks out of graphics hot paths.
Description check ✅ Passed The description directly explains all three loop-invariant optimizations and states that behavior remains unchanged.

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

**@⁠coderabbitai[bot]** on GitHub · 2026-09-24 14:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/807#issuecomment-5815877460) · edited 2026-09-24 14:27 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/807"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `7d74b1b8-0e3e-4661-88c3-f0f43d4dd602` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between ecfa5412a52042d9f06a6e31bc42c42061544c83 and f1d4c6e63897461f8916fad80dbe8edb2d56eea5. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/graphics/host_gpu/renderer/renderDraw.cpp` </details> **Included review availability:** Your plan provides up to 10 included reviews per hour; 8 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough DrawIndirectMulti selects the index-element size once for indexed draws and reuses it when calculating each draw's index address. ShaderApplyAttribSemantics caches the graphics debug-dump setting before processing input semantics and uses it to gate per-attribute logging. AcquireVertexBuffers records each vertex descriptor size by slot and reuses it during binding setup. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `f1d4c` <!-- final_review_risk_coverage:{"sourceCommitId":"f1d4c6e63897461f8916fad80dbe8edb2d56eea5","coveredCommitId":"f1d4c6e63897461f8916fad80dbe8edb2d56eea5","kind":"reviewed"} --> The cached values preserve the behavior described for these operations, and no actionable merge risk remains. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :------------------------------------------------------------------------------------------------------------------- | | 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. | | Title check | ✅ Passed | The title clearly and concisely describes the main change: moving loop-invariant checks out of graphics hot paths. | | Description check | ✅ Passed | The description directly explains all three loop-invariant optimizations and states that behavior remains unchanged. | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> --- <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.