(How) can a scalar be cast to another scalar without conversion in GLSL?
The definition of "cast" used in this question is changing the interpretation of the exact same data without changing the data itself, assuming the two types are of the same number of bits. i.e. (float)B00101111 == B00101111
The definition of "conversion" used in this question is changing both the interpretation of the data as well as reformatting said data to some mathematical approximation of the original value, i.e. (float)1 == 1.0
5.4.3 of GLSL 4.30.6 spec implies that scalar float-to-int and int-to-float constructors perform only conversion: "When constructors are used to convert any floating-point type to an integer type, the fractional part of the floating-point value is dropped." - pg. 87
Another nail in the coffin is with this line on section 5.1, pg. 85: "There is no typecast operator; constructors are used instead."
The goal is to use a Buffer-Texture/Texture-Buffer and texelFetch(...) to obtain float vec4s (128bit) and fill a struct such as:
struct MyStruct
{
int foo; //32bit
float bar; //32bit
int baz; //32bit
short blah; //16bit
short hmm; //16bit
} // 128bit total
...but there is trouble pinning down how to break apart that vec4 into the binary sub-chunks and re-cast them to set said struct values.
Would the following, in theory work?
MyStruct myUuberChunk = MyStruct(myVec4);
The rationale behind using float vec4s (or int vec4s for that matter), pending it is correct, is to get all values in one 128bit fetch for bandwidth performance purposes (most cards have four 32-bit memory buses).