Mesa后端添加考察随笔

找资料看资料随笔,吐槽提问向;


已知

compiler

Mesa src目录下有compiler目录,compiler目录下是glsl nir 以及 spirv;

  1. glsl: glsl ir,glsl ir并不是我第一次接触,这是否是一个通用的ir呢,glsl ir的特征是vec4的4 component访问吗?
  2. nir: 并不熟悉,应该是本次学习的重要内容
  3. spirv: vulkan相关 早有耳闻,但也不熟悉

gallium

gallium下有auxiliary,该目录下有nir 以及 tgsi,要了解nir或许需要了解一下tgsi
gallium下还有driver目录,该目录下有各厂商的支持代码,本次想添加一个backend


TGSI和NIR

这节看的是这个PPT:
https://www.x.org/wiki/Events/XDC2015/Program/turner_glsl_compiler.pdf

image
image

从这张图片看GLSL IR是shader的第一站。GLSLIR可以转换为NIR或者直接的TGSI,NIR可以转为TGSI,从位置看TGSI要比NIR更加 low level?
时间是2015,NIR的提出时间是14;
然后是future:
image

mesa IR消失,NIR的位置更加重要,glsl ir需要经过nir再转换为tgsi或其他target;
所以如果有厂商想添加自己的设备,完成nir到target的生成即可,tgsi并不像是必需的;
那么这里的疑问,tgsi留在这是什么原因呢?是原来的厂商并没有更新吗?
而看到描述如下:

TGSI 是 Gallium 框架中的所有驱动程序使用着色器的唯一中间表示形式,这里特指的是着色器的中间形式,着色器对驱动而言的所有格式将是 TGSI。

或许TGSI是gallium框架下的driver都需要做的内容?

而如果我要添加一个后端,或许需要了解tgsi spec:https://freedesktop.org/wiki/Software/gallium/tgsi-specification.pdf
另外LLVM是有教程writeABackEnd的,或许mesa也有:https://gallium.readthedocs.io/en/latest/

image
nir和tgsi从图中讲述看是可以相互转换的;

BackEnd

看的文档是这个:https://gallium.readthedocs.io/en/latest/

  • 开头:The public interface of a Gallium3D driver is described by the src/gallium/include/*.h header files.
    如果想在gallium添加一个backend似乎是在上述文件有描述,有的抄了(悲)。

  • The TGSI module provides a universal representation of shaders and CPU-based execution of shaders. All Mesa vertex/fragment programs and shaders are translated into the TGSI representation before being passed to the driver. In turn, the driver will convert the TGSI instructions into GPU-specific instructions. For hardware that lacks vertex or fragment shader support, the TGSI's executor can be used. The TGSI executor includes support for SSE code generation. Support for other processors (such as Cell) will be added in the future.
    TGSI看起来非常强大,shader转TGSI再转machinecode,如果不支持VSFS还有TGSI executor(这就是CPU-based?);那么NIR呢?是时间线的问题吗?还是gallium就是只用TGSI,nir不属于gallium的部分呢?从描述Last edited Fri May 7 01:22:37 2021看,gallium与NIR的关系不大

GPU pipeline

讲GLSL,这我会,没想到看了一眼竟然还是很有收获,得谦虚:
文档链接:https://www.researchgate.net/publication/232626644_Introduction_to_GPU_Programming_with_GLSL
image
这个图片非常有帮助,我一直以为vtxprocessor和pixlprocessor是不一样的东西,但理论告诉我应该一样才会高效,这张图终于给了我答案虽然它来自2009;

链接

这位老哥的文档也十分有帮助:
https://winddoing.github.io/post/58638.html
gallium学习视频和PPT,感觉...不如原*,错了,没啥帮助,可能是年代久远的原因也可能是我资质不行吧:
https://www.freedesktop.org/wiki/Software/gallium/GAOnlineWorkshop/

posted @ 2022-07-27 15:06  无聊的白色骷髅头画家  阅读(640)  评论(0)    收藏  举报