Directx11 tutorial (16) d3d11 pipeline (5)

Source: Internet
Author: User

In this chapter, What do we learn about?

First, let's look at our vs shader code:

Clolor.

...
Pixelinputtype colorvertexshader (vertexinputtype input)
{
Pixelinputtype output;

// Change the position vector to be 4 units for proper matrix calculations.
Input. position. W = 1.0f;

// Calculate the position of the vertex against the world, view, and projection matrices.
Output. Position = MUL (input. Position, worldmatrix );
Output. Position = MUL (output. Position, viewmatrix );
Output. Position = MUL (output. Position, projectionmatrix );

// Store the input color for the pixel shader to use.
Output. Color = input. color;

Return output;

}

The information we now know is: matrixbuffer is put in the const buffer of video memory by UMD, and is passed into the shader when vs starts execution.

The shader block is usually called Cu or SIMD. It consists of many stream cores. Generally, stream core is a one-dimensional vector that can be executed (X, Y, Z, W) the unit of floating point computation. A Cu is composed of many streamcores. We have provided many diagrams in the opencl tutorial.

In vs, many stream cores are executed in parallel. Each stream core processes a vertex's vs shader computing.

From our vs shader code, we can know that it mainly performs space conversion.

// Change the position vector to be 4 units for proper matrix calculations.
Input. position. W = 1.0f;

// Calculate the position of the vertex against the world, view, and projection matrices.
Output. Position = MUL (input. Position, worldmatrix );
Output. Position = MUL (output. Position, viewmatrix );
Output. Position = MUL (output. Position, projectionmatrix );

Converts a vertex from the world coordinate system to the same clip space. For details about the derivation, You can query the relevant information.

Mathematics. for.3d. Game. Programming. And. Computer. Graphics. lengyel.3ed. course2012 is recommended.

Note: The clip cropping space is a cube,

-R <= x <= R (r indicates the high ratio of window width)

-1 <= Y <= 1

F <= z <= N (F, N near plane and far plane distance ).

In addition, vs shader also uploads the vertex color to the next stage. In our previous tutorial, we assign the color value to the vertex directly. The general practice is to calculate the color based on the vertex direction and illumination, these codes are also in vs shader. In other subsequent tutorials, we will gradually learn this knowledge.

The vertex calculated by vs shader is placed in a FIFO. In the d3d11 logic pipeline, the next stage is Rs. In most hardware, vs FIFO (GS and tessellation operations are not considered) the content will be transmitted to a fixed pipeline called Pa (Body assembly). In this phase, perform operations such as perspective division and clip. In the next section, we will learn about the PA function.

 

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.