Real-Time Rendering 3rd 读书笔记(二) The Graphics Processing Unit

3.The Graphics Processing Unit

GPU实现的渲染管线的流程: 绿色可编程,黄色只可配置,蓝色是不可操作的.

可编程阶段:

Shaders are programmed using C-like shading languages such as HLSL, Cg, and GLSL. These are compiled to a machine-independent assembly language, also called the intermediate language (IL).

两种输入类型:

uniform inputs, with values that remain constant throughout a draw call (but can be changed between draw calls). varying inputs, which are different for each vertex or pixel processed by the shader.

 

运算符:

加,乘,点乘等非常高效

reciprocal, square root, sine, cosine, exponentiation, logarithm等,相对比较耗时,不过也挺快的.

flow control:(这里就提及到了shader中的分支)

可编程shader演进

Shader model (sm)对比

顶点着色器 The Vertex Shader

顶点的属性值包括:颜色值,法线,纹理坐标,位置信息, 其中位置信息是顶点着色器必须要输出的

现在的GUP都是支持顶点着色器的.

这个过程中不能创建或销毁顶点数据,数据也不能在顶点间相互传递,而是相互独立的,保证了并行性.

The vertex shader can neither create nor destroy vertices, and results generated by one vertex cannot be passed on to another vertex. Since each vertex is treated independently, any number of shader processors on the GPU can be applied in parallel to the incoming stream of vertices.

几何着色器 The Geometry Shader

要求:Shader Model 4.0

Similar to the vertex shader, the geometry shader must output a homogeneous clip space location for each vertex produced.

流输出 Stream Output

像素着色器 The Pixel Shader

因为并行处理,逐片段处理,每个像素的处理结果都不允许传递给相邻数据的,而是采用的插值运算,有一种情况下可以访问到相邻像素的数据,求梯度或求导.

The Merging Stage

不可编程阶段,但有高的可配置属性.

Effect

发布了23 篇原创文章 · 获赞 6 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/Vitens/article/details/82024139
今日推荐