FLOAT4 Data types

Source: Internet
Author: User

Vector of 4 consecutive 32-bit float types

HLSL data type

The GPU is calculated using four-dimensional vectors as the basic unit. The FLOAT4 vector, which consists of 4 floating-point numbers, is the most basic type built into the GPU. Using the GPU to calculate the two float4 vectors is as simple as the CPU for two integers or two floating-point numbers, all with just one instruction to complete.

Hlsh's basic data types define non-vector types such as float, int, and bool, but they will actually be converted to float4 vectors by complier, and the FLOAT4 type can be used as a scalar as long as the 3 values of the FLOAT4 vector are ignored. When mapping coordinates are used, only two-dimensional vectors are required, and HLSL defines the FLOAT2 type as a two-dimensional vector. Shader often use matrices, HLSL has a built-in type, float4x4, which can be used to represent a 4*4 matrix. Float4x4 is not a built-in type of GPU, float4x4 is actually an array of 4 float4. Others are float3x3 and float2x2, which represent 3*3 matrices and 2*2 matrices. Shader can also declare an array, and the 4*4 matrix is actually an array of float4 m[4]. Note that all variables in the shader use registers, and no other memory space is available, so the larger the array will occupy the more registers, and even the limit of the number of registers will be exceeded. When using individual values in the FLOAT4 vector, you can use XYZW or RGBA to represent the values in the four-dimensional vector. But cannot mix them, for example cannot use XYBA, treats it as color to use RGBA, otherwise is uses the XYZW, cannot mix these two.

FLOAT4 Data types

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.