Closed chaoticbob closed 16 hours ago
Implementation note:
If implementing by adding constructors to struct vector
the permutation count will be quite large. This is likely not the approach which should be taken.
edit: no longer applies
It appears that this is a duplicate issue to #4461. I am closing this as a duplicate and it will be followed up by #4461.
All lines in the given shader works except ones that uses the list-initializer. The following two lines are supposed to call the same constructor but the second one fails to call the constructor,
float3 g0 = float3(v2, 1); // WORKS
float3 h0 = {v2, 1}; // FAILS
The error message is following,
a.slang(12): error 30019: expected an expression of type 'float', got 'vector<float,2>'
float3 h0 = {v2, 1};
^~
It looks like that the list-initializer is trying to assign the values to the member variables directly rather than calling the constructor.
It looks like that the list-initializer is trying to assign the values to the member variables directly rather than calling the constructor.
This is a correct analysis on how initializer-lists in Slang work, they (unlike C++) do not call a constructor:
{}
), they set all member variables to their respective initExpr, all other variables are zeroed (does not always zero values due to a bug?)Looking at the problem again, I think this is actually a bug in _readAggregateValueFromInitializerList
.
Specifically the else if (auto toVecType = as<VectorExpressionType>(toType))
part of code which should allow vector initialization using {...}
.
Using
float2
vars in initialization list forfloat3
andfloat4
fails to compile. Usingfloat3
in initialization list forfloat4
fails to compile. Error msg:Was expecting that whatever I can pass into a vector's constructor, I should be able to pass into an initialization list.
CMD
Shader