Skip to content

fix: mismatched shadercache compiler flags#2277

Merged
alandtse merged 3 commits into
community-shaders:devfrom
davo0411:fix/shader-cache-compile-flags-parity
May 10, 2026
Merged

fix: mismatched shadercache compiler flags#2277
alandtse merged 3 commits into
community-shaders:devfrom
davo0411:fix/shader-cache-compile-flags-parity

Conversation

@davo0411
Copy link
Copy Markdown
Collaborator

@davo0411 davo0411 commented May 4, 2026

fixes mismatch between live & disk caching respecting compiler flags. Developer mode remains unchanged.
Allows greater comparison to disk caching and also the end user's experience, where live compiling is slower than the disk cause it doesn't inherit the flags correctly.

Summary by CodeRabbit

  • Refactor
    • Improved shader compilation behavior to produce more consistent and optimized shaders across normal and developer modes. Compilation now respects runtime precision and flow-control toggles and adapts when disk caching is enabled, yielding more reliable rendering, faster builds, and smoother iteration for developers.

Review Change Stack

Copilot AI review requested due to automatic review settings May 4, 2026 07:18
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 97b7df23-4344-43ff-8ca9-c247b65dda70

📥 Commits

Reviewing files that changed from the base of the PR and between a91421a and 6f40d79.

📒 Files selected for processing (1)
  • src/ShaderCache.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/ShaderCache.cpp

📝 Walkthrough

Walkthrough

CompileShader's D3DCompile flag construction was revised: developer mode uses D3DCOMPILE_DEBUG; non-developer mode uses D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_OPTIMIZATION_LEVEL3; D3DCOMPILE_PARTIAL_PRECISION and D3DCOMPILE_AVOID_FLOW_CONTROL are set from atomic toggles in globals::state; D3DCOMPILE_SKIP_VALIDATION is added when useDiskCache is true.

Changes

Shader Compilation Flags

Layer / File(s) Summary
Flag Configuration Logic
src/ShaderCache.cpp
Replaced previous strict/dev toggle with policy-driven flag assembly: non-developer path adds D3DCOMPILE_ENABLE_STRICTNESS + D3DCOMPILE_OPTIMIZATION_LEVEL3; developer path uses D3DCOMPILE_DEBUG.
Optional Toggles
src/ShaderCache.cpp
Conditionally add D3DCOMPILE_PARTIAL_PRECISION and D3DCOMPILE_AVOID_FLOW_CONTROL when globals::state->enablePartialPrecision / enableAvoidFlowControl are set.
Disk-cache behavior
src/ShaderCache.cpp
When useDiskCache is true, append D3DCOMPILE_SKIP_VALIDATION to the flags.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • alandtse
  • jiayev

Poem

🐰 I nudged the flags with careful paws,
Debug for devs, strictness for laws,
Partial hops and flow-control nips,
Cache skips checks on disk-bound trips,
Happy shaders, floppy ears and applause!

🚥 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: mismatched shadercache compiler flags' directly and clearly summarizes the main change in the PR, which is fixing a mismatch in shader cache compiler flags between live and disk caching.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 OpenGrep (1.20.0)

OpenGrep fatal error (exit code 2): [00.18][ERROR]: Error: exception Unix_error: No such file or directory stat src/ShaderCache.cpp
Raised by primitive operation at UTmp.replace_named_pipe_by_regular_file_if_needed in file "libs/commons/UTmp.ml", line 145, characters 8-27
Called from Scan_CLI.replace_target_roots_by_regular_files_where_needed.(fun) in file "src/osemgrep/cli_scan/Scan_CLI.ml", lines 1086-1087, characters 19-65
Called from List_.fast_map in file "libs/commons/List_.ml", line 81, characters 17-20
Called from Scan_CLI


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

@davo0411 davo0411 changed the title fix: shader-cache-compile-flags fix: shadercache compiler flags for live compiling May 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

No actionable suggestions for changed features.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Aligns ShaderCache’s runtime shader compilation flags with the established policy used by src/Utils/D3D.cpp::CompileShader, so live compilation behavior matches disk-cache expectations and user-facing compile settings.

Changes:

  • Update ShaderCache.cpp compilation flags to include strictness + optimization in non-developer mode.
  • Respect enablePartialPrecision and enableAvoidFlowControl toggles when compiling via ShaderCache.
  • Skip FXC validation when disk cache is enabled (to match the existing Utils/D3D.cpp behavior).

Comment thread src/ShaderCache.cpp
Comment thread src/ShaderCache.cpp Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
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: 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/ShaderCache.cpp`:
- Around line 1453-1462: The shader cache must include a snapshot of the compile
flags in the shader identity so in-flight compiles cannot repopulate the cache
with stale-flag blobs; capture the exact flags computed here (the uint32_t flags
built from globals::state->enablePartialPrecision,
globals::state->enableAvoidFlowControl, globals::state->IsDeveloperMode(), and
useDiskCache) when creating/enqueuing the compile task and include that snapshot
in the cache key/Task identity (the enqueue/lookup path in ShaderCache and any
task/Job struct) so both lookup and later insertion use the same flag bits
rather than reading atomics at completion time.
🪄 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 Plus

Run ID: 9d599f9d-1dad-4734-9e2d-864e018f222e

📥 Commits

Reviewing files that changed from the base of the PR and between 77f9118 and a91421a.

📒 Files selected for processing (1)
  • src/ShaderCache.cpp

Comment thread src/ShaderCache.cpp
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

✅ A pre-release build is available for this PR:
Download

@alandtse alandtse changed the title fix: shadercache compiler flags for live compiling fix: mismatched shadercache compiler flags May 5, 2026
@alandtse
Copy link
Copy Markdown
Collaborator

alandtse commented May 6, 2026

Please resolve the conversations so we know it's done.

@davo0411
Copy link
Copy Markdown
Collaborator Author

davo0411 commented May 7, 2026

Resolved

@alandtse
Copy link
Copy Markdown
Collaborator

alandtse commented May 8, 2026

You need to literally click on the resolve conversation button. They're still open.

@alandtse alandtse merged commit 0a6ad65 into community-shaders:dev May 10, 2026
14 checks passed
SkrubbySkrubInAShrub pushed a commit that referenced this pull request May 14, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: doodlum <15017472+doodlum@users.noreply.github.com>
ParticleTroned pushed a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 15, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: doodlum <15017472+doodlum@users.noreply.github.com>
(cherry picked from commit 0a6ad65)
ParticleTroned pushed a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 16, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: doodlum <15017472+doodlum@users.noreply.github.com>
(cherry picked from commit 0a6ad65)
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.

4 participants