chore: add shader compile settings for development#2234
Conversation
📝 WalkthroughWalkthroughAdds two developer shader-compiler toggles to the Advanced Settings UI (Partial Precision and Avoid Flow Control), exposes them as atomic flags in State (Partial Precision persisted; Avoid Flow Control transient), clears shader cache when toggled, and applies corresponding D3DCompile flags (plus SKIP_VALIDATION when disk cache is used) during shader compilation. Changes
Sequence DiagramsequenceDiagram
participant User
participant UI as Advanced Settings UI
participant State as State (atomics)
participant Cache as Shader Cache
participant Compiler as D3D Compiler
User->>UI: Toggle Half Precision / Avoid Flow Control
UI->>State: atomic store (enablePartialPrecision / enableAvoidFlowControl)
UI->>Cache: globals::shaderCache->Clear()
Note over Cache: Shader cache invalidated
User->>Compiler: Request shader build
Compiler->>State: atomic load (partialPrecision, avoidFlowControl)
Compiler->>Cache: IsDiskCache()
alt disk cache active
Compiler->>Compiler: add D3DCOMPILE_SKIP_VALIDATION
end
Compiler->>Compiler: add D3DCOMPILE_PARTIAL_PRECISION / D3DCOMPILE_AVOID_FLOW_CONTROL as needed
Compiler->>Cache: Store compiled shader
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
Automated formatting by clang-format, prettier, and other hooks. See https://pre-commit.ci for details.
|
No actionable suggestions for changed features. |
Changed enablePartialPrecision from true to false.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/State.h`:
- Around line 144-155: Change the two plain bool fields enablePartialPrecision
and enableAvoidFlowControl in State (declared in State.h) to std::atomic_bool to
avoid data races, and update every access site (UI thread stores and shader
compilation worker thread reads) to use .store(...) for writes and .load() for
reads; search for references to enablePartialPrecision and
enableAvoidFlowControl and replace direct assignments/reads with the atomic
.store/.load patterns so all thread interactions are synchronized.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a4e3a611-ff58-467a-8d75-f25ff04d9e91
📒 Files selected for processing (4)
src/Menu/AdvancedSettingsRenderer.cppsrc/State.cppsrc/State.hsrc/Utils/D3D.cpp
|
✅ A pre-release build is available for this PR: |
Compilation runs on a worker pool while the toggles are written from the UI thread; convert enablePartialPrecision and enableAvoidFlowControl to std::atomic_bool so the cross-thread access is well-defined. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/Utils/D3D.cpp`:
- Around line 201-205: The
CreatePixelShader/CreateVertexShader/CreateHullShader/CreateDomainShader calls
currently return directly when D3DCOMPILE_SKIP_VALIDATION is set, leaving
HRESULTs unchecked; wrap each of these four ID3D11Device::Create*Shader calls
with DX::ThrowIfFailed (like the existing compute shader paths) so failures
throw on error instead of returning potentially invalid pointers, preserving the
existing behavior for the ComputeShader paths that already use DX::ThrowIfFailed
and keeping D3DCOMPILE_SKIP_VALIDATION logic intact.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b639bc2b-3e1f-4d24-ae43-cc4b61bbe0cb
📒 Files selected for processing (4)
src/Menu/AdvancedSettingsRenderer.cppsrc/State.cppsrc/State.hsrc/Utils/D3D.cpp
✅ Files skipped from review due to trivial changes (1)
- src/State.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
- src/Menu/AdvancedSettingsRenderer.cpp
Summary by CodeRabbit