Repository navigation
Shaders: arithmetic on a vector constant is evaluated - #3454
Merged
Merged
Conversation
`static const float3 X = float3(1, 2, 3) * 0.5;` or `-float2(...)` use OpFMul/OpFNegate, which SPIR-V does not allow in a constant of a shader module, and ConstantEvaluator only knew scalars: the constant could not be resolved. It now applies an operation per component of a vector. The value becomes an OpConstantComposite preceded by the constants of its components, when the shader is compiled, or when mixing if it depends on a generic.
xen2
force-pushed
the
feature/vector-constant-math
branch
from
September 20, 2026 13:26
1580e9c to
1c3cedf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR details
Stacked on the shader constants PR #3453 : only the last commit is new.
static const float3 X = float3(1, 2, 3) * 0.5;and-float2(...)did not compile. They useOpFMul/OpFNegate, which SPIR-V does not allow in a shader constant, so the compiler has to compute the value, andConstantEvaluatoronly knew scalars.It now applies an operation per component of a vector. The result is written as an
OpConstantComposite, when the shader is compiled, or when mixing if it depends on a generic.Tests: a render test (
ConstVectorMath) and evaluator unit tests.Stride.Shaders.Testspasses (929 tests).