HSLS float1,..., float4 and its fields

123*_*ing 3 hlsl directx-11

I see that HSLS has float and a number after float (1-4) and a lot of fields (r, rr, rrrr, arar,...) (I see these fields with the help of HLSL Tool Thanks to Tim Jones :D - I can't imagine (for now) how can we programming HSLS without this tool).

I try to find references about this data type and its field but I can't find anything about it(why the number 1-4 and the meanings of its fields. In C++ float is just float number, here, what is float)

Below is my progress so far:

According to this article

float - 32-bit floating point value.

For example, here is a 4-component signed-normalized float-variable declaration.

snorm float4 fourComponentIEEEFloat;

It doesn't answer my question: What does this code mean

RWTexture2D<float4> testTexture         : register(u0);

[numthreads(@value( threads_per_group_x ), @value( threads_per_group_y ), @value( threads_per_group_z ))]
void main
(
    uint3 gl_LocalInvocationID : SV_GroupThreadID,
    uint3 gl_GlobalInvocationID : SV_DispatchThreadId
)
{
    testTexture[gl_GlobalInvocationID.xy].xyzw = float4( float2(gl_LocalInvocationID.xy) / 16.0f, 0.0f, 1.0f );
}
Run Code Online (Sandbox Code Playgroud)

I may slightly understand that float2(gl_LocalInvocationID.xy) is 2 float

testTexture[gl_GlobalInvocationID.xy].xyzw = float4( float2(gl_LocalInvocationID.xy) / 16.0f, 0.0f, 1.0f );
Run Code Online (Sandbox Code Playgroud)

is equal

testTexture[gl_GlobalInvocationID.xy].xyzw = float4(gl_LocalInvocationID.x / 16.0f, gl_LocalInvocationID.y / 16.0f, 0.0f, 1.0f);
Run Code Online (Sandbox Code Playgroud)

But I don't know if it's right, beside, how about fields r, rr, rrrr, arar,... I mention earlier.

Thanks for reading.

Gni*_*how 5

这些字段不是真正的字段,而是 Source Register Swizzling ( doc )。

Afloat4是一个四分量浮点向量,其中分量是 x、y、z 和 w。由于 float4 也经常用作颜色,因此这些组件也可以通过 r、g、b 和 a 寻址(因此 .xyzw 相当于 .rgba)。

来源混写,您可以互换,减少或内联重复成分,因此,如果你只需要你的XY组件float3 vec,你可以只写vec.xy,而不是像一些float2(vec.x, vec.y)。例如,如果您想float4 color为某些计算交换颜色通道,您可以轻松编写color.bgra以交换红色和蓝色分量。最后,你也可以复制渠道,例如vec.xxxx获得float4vec.x在所有四个组件。也允许组合这些方法,例如vec.yzxx.