'Metal vector literal initialization

I would like to know if, in the Metal Shading Language

float3 x = 1;

is the same as:

float3 x = float3(1);

I indeed cannot find anything about it in the MSL specs.



Solution 1:[1]

They are actually the same.

From the Metal Shading Language specs:

Implicit conversions from scalar-to-vector types are supported. The scalar value is replicated in each element of the vector. The scalar may also be subject to the usual arithmetic conversion to the element type used by the vector.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pop Flamingo