refactor(ibl): move DisableInInteriors to settings#2042
Conversation
📝 WalkthroughWalkthroughThis PR refactors the "disable in interiors" IBL feature by consolidating its control into the serialized settings structure. The Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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. Comment |
|
No actionable suggestions for changed features. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/Features/IBL.h (1)
44-58: Add a compile-time layout guard for the cbuffer mirror.
IBL::Settingsis copied into the feature buffer viasizeof-based packing (src/FeatureBuffer.cpp:22-36), so a future drift againstSharedData::IBLSettingscan silently break shader reads.🛡️ Proposed guard
struct Settings { uint EnableIBL = 0; uint PreserveFogLuminance = 0; uint UseStaticIBL = 1; float DALCAmount = 1.0f; float EnvIBLScale = 1.0f; float SkyIBLScale = 1.0f; float EnvIBLSaturation = 1.0f; float SkyIBLSaturation = 1.0f; float FogAmount = 0.0f; uint DALCMode = 2; // 0: Luminance Ratio, 1: Color Ratio, 2: DALC + Sky uint DisableInInteriors = 1; float pad1 = 0.0f; } settings; + + static_assert(sizeof(Settings) == 48, "IBL::Settings must match SharedData::IBLSettings layout");🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Features/IBL.h` around lines 44 - 58, IBL::Settings is memcpy'd into the GPU feature buffer by size, so add a compile-time guard to prevent layout drift against the shader-side mirror (SharedData::IBLSettings): after the struct Settings declaration add a static_assert that sizeof(IBL::Settings) == sizeof(SharedData::IBLSettings) (and optionally alignof checks or offsetof checks for critical members) so mismatches are caught at compile time; reference IBL::Settings and SharedData::IBLSettings and the copy site in FeatureBuffer.cpp (the sizeof-based packing) when adding the assertion.
🤖 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/Features/IBL.h`:
- Line 56: The field DisableInInteriors was given a default value of 1 which
alters runtime behavior; revert this to the prior default (remove or change the
initializer on DisableInInteriors in IBL.h so it matches the original default
value used before this PR) so refactor-only changes do not change
behavior—locate the DisableInInteriors declaration in class/struct IBL and
restore its previous default initialization (or leave uninitialized if that was
the prior state) to preserve existing behavior.
---
Nitpick comments:
In `@src/Features/IBL.h`:
- Around line 44-58: IBL::Settings is memcpy'd into the GPU feature buffer by
size, so add a compile-time guard to prevent layout drift against the
shader-side mirror (SharedData::IBLSettings): after the struct Settings
declaration add a static_assert that sizeof(IBL::Settings) ==
sizeof(SharedData::IBLSettings) (and optionally alignof checks or offsetof
checks for critical members) so mismatches are caught at compile time; reference
IBL::Settings and SharedData::IBLSettings and the copy site in FeatureBuffer.cpp
(the sizeof-based packing) when adding the assertion.
🪄 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: 4ae097b6-e9c2-486e-9537-3fe0c3824021
📒 Files selected for processing (3)
package/Shaders/Common/SharedData.hlslisrc/Features/IBL.cppsrc/Features/IBL.h
| float FogAmount = 0.0f; | ||
| uint DALCMode = 2; // 0: Luminance Ratio, 1: Color Ratio, 2: DALC + Sky | ||
| float pad0 = 0.0f; | ||
| uint DisableInInteriors = 1; |
There was a problem hiding this comment.
Preserve prior default unless behavior change is intentional.
Line 56 initializes DisableInInteriors to 1. If this PR is refactor-only, this changes default runtime behavior for missing/new configs.
🔧 Proposed fix
- uint DisableInInteriors = 1;
+ uint DisableInInteriors = 0;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/Features/IBL.h` at line 56, The field DisableInInteriors was given a
default value of 1 which alters runtime behavior; revert this to the prior
default (remove or change the initializer on DisableInInteriors in IBL.h so it
matches the original default value used before this PR) so refactor-only changes
do not change behavior—locate the DisableInInteriors declaration in class/struct
IBL and restore its previous default initialization (or leave uninitialized if
that was the prior state) to preserve existing behavior.
|
✅ A pre-release build is available for this PR: |
Summary by CodeRabbit
New Features
Improvements