build(hlsl): fix warnings#1370
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThis change set applies explicit absolute value operations to inputs of power functions across multiple HLSL shader files. It ensures that negative values are converted to non-negative before exponentiation, addressing potential issues with invalid or undefined results. Additionally, several shader variables are now explicitly zero-initialized, and a minor vector calculation bug is fixed. Changes
Sequence Diagram(s)sequenceDiagram
participant ShaderFunction
participant InputValue
participant AbsFunction
participant PowFunction
participant Output
ShaderFunction->>InputValue: Receives input (may be negative)
ShaderFunction->>AbsFunction: Applies abs(input)
AbsFunction->>PowFunction: Passes non-negative value
PowFunction->>Output: Raises to power and returns result
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes various HLSL compiler warnings by addressing initialization issues and negative base value warnings in power functions across multiple shader files.
- Proper initialization of output structures and variables to prevent uninitialized variable warnings
- Wrapping power function bases with
abs()to avoid warnings about negative values raised to fractional powers - Fixing syntax errors in function calls and variable declarations
Reviewed Changes
Copilot reviewed 15 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| package/Shaders/Water.hlsl | Standardizes float initialization format and fixes function call syntax |
| package/Shaders/RunGrass.hlsl | Initializes PS_OUTPUT structure to zero |
| package/Shaders/Effect.hlsl | Initializes PS_OUTPUT structure to zero |
| package/Shaders/DistantTree.hlsl | Initializes VS_OUTPUT structure to zero |
| package/Shaders/Common/PBR.hlsli | Wraps BaseColor with abs() in pow() calls |
| package/Shaders/Common/FrameBuffer.hlsli | Wraps linearColor with abs() in pow() call |
| package/Shaders/Common/DisplayMapping.hlsli | Wraps pow() function bases with abs() |
| package/Shaders/Common/Color.hlsli | Wraps color values with abs() in pow() calls |
| features/Terrain Shadows/Shaders/TerrainShadows/ShadowUpdate.cs.hlsl | Initializes float2 variable to zero |
| features/Skylighting/Shaders/Skylighting/UpdateProbesCS.hlsl | Fixes type conversion issues with signed/unsigned comparisons |
| features/Light Limit Fix/Shaders/LightLimitFix/ClusterCullingCS.hlsl | Renames loop variable to avoid conflicts |
| features/Light Limit Fix/Shaders/LightLimitFix/ClusterBuildingCS.hlsl | Wraps division result with abs() in pow() calls |
| features/IBL/Shaders/IBL/DiffuseIBLCS.hlsl | Adds explicit .xyz swizzle to texture sample |
| features/Hair Specular/Shaders/Hair/Hair.hlsli | Wraps subtraction result with abs() in pow() call |
| features/Extended Materials/Shaders/ExtendedMaterials/ExtendedMaterials.hlsli | Wraps weights with abs() in pow() call |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
✅ A pre-release build is available for this PR: |
Summary by CodeRabbit