2D图形架构

早期Linux图形系统的显示全部依赖X Server,X Client调用Xlib提供的借口向 X Server发送渲染命令,X Server根据 X Client的命令请求向硬件设备绘制图形,X Client与X Server之间通过X11协议通讯。通过这种方式,X Server屏蔽了所有的硬件差异,保证同一个X程序能够在不同的硬件设备上运行。

X Server需要与多种多样的硬件打交道,每个硬件提供自己的DDX驱动程序,X Server最后调用DDX的接口将图形发送给硬件设备。

3D图形架构

通过3D硬件执行3D加速能够大大提高绘制效率,根据不同的模式有两种架构:

Indirect Rendering

这种模式下,仅仅X Server能够访问3D硬件设备,X Client需要绘图时通过X11扩展协议将3D命令发送给X Server,然后由X Server控制3D硬件设备执行,这种模式称为“非直接渲染”。

这种模式与2D模式类似。

但是这种模式无法发挥出3D硬件的效率

Direct Rendering

DRI(Direct Rendering Infrastructure)架构允许X Client直接控制3D硬件设备,所以这种模式下要求X Client与X Server必须位于同一个设备上。

DRM(Direct Rendering Manager)是DRI架构下的Kernel实现,DRM负责:hardware locking, access synchronization, video memory and more.

DRM also provides userspace with an API that it can use to submit commands and data in a format that is adequate for modern GPUs, which effectively allows userspace to communicate with the graphics hardware.

Notice that many of these things have to be done specifically for the target hardware so there are different DRM drivers for each GPU.

DRI/DRM provide the building blocks that enable userspace applications to access the graphics hardware directly in an efficient and safe manner, but in order to use OpenGL we need another piece of software that, using the infrastructure provided by DRI/DRM, implements the OpenGL API while respecting the X server requirements.

Mesa

Mesa is a free software implementation of the OpenGL specification, and as such, it provides a libGL.so, which OpenGL based programs can use to output 3D graphics in Linux. Mesa can provide accelerated 3D graphics by taking advantage of the DRI architecture to gain direct access to the underlying graphics hardware in its implementation of the OpenGL API.

When our 3D application runs in an X11 environment it will output its graphics to a surface (window) allocated by the X server. Notice, however, that with DRI this will happen without intervention of the X server, so naturally there is some synchronization to do between the two, since the X server still owns the window Mesa is rendering to and is the one in charge of displaying its contents on the screen. This synchronization between the OpenGL application and the X server is part of DRI. Mesa’s implementation of GLX (the extension of the OpenGL specification that addresses the X11 platform) uses DRI to talk to the X server and accomplish this.

Mesa also has to use DRM for many things. Communication with the graphics hardware happens by sending commands (for example “draw a triangle”) and data (for example the vertex coordinates of the triangle, their color attributes, normals, etc). This process usually involves allocating a bunch of buffers in the graphics hardware where all these commands and data are copied so that the GPU can access them and do its work. This is enabled by the DRM driver, which is the one piece that takes care of managing video memory and which offers APIs to userspace (Mesa in this case) to do this for the specific target hardware. DRM is also required whenever we need to allocate and manage video memory in Mesa, so things like creating textures, uploading data to textures, allocating color, depth or stencil buffers, etc all require to use the DRM APIs for the target hardware.

引用原文:https://blogs.igalia.com/itoral/2014/07/29/a-brief-introduction-to-the-linux-graphics-stack/

Linux graphics stack的更多相关文章

  1. Monitoring and Tuning the Linux Networking Stack: Receiving Data

    http://blog.packagecloud.io/eng/2016/06/22/monitoring-tuning-linux-networking-stack-receiving-data/ ...

  2. Queueing in the Linux Network Stack !!!!!!!!!!!!!!!

    https://www.coverfire.com/articles/queueing-in-the-linux-network-stack/ Queueing in the Linux Networ ...

  3. Linux Storage Stack Diagram存储堆栈图

    这是一个描述非常好的存储栈,版本为:Linux Storage Stack Diagram v4.10,我在这里转载下图片,可以提升大家对存储栈的理解. https://www.thomas-kren ...

  4. Linux Kernel Stack

    整理一些杂乱的内容.以下x86架构. Linux 内核栈大小 内核栈大小是固定的,默认为8k,曾经有选项可以设置为4k栈.由于大小固定,申请过大的栈内存,或者函数调用层次过深,都可能导致栈溢出. 关注 ...

  5. 《Monitoring and Tuning the Linux Networking Stack: Receiving Data》翻译

    Overview 从宏观的角度来看,一个packet从网卡到socket接收缓冲区的路径如下所示: 驱动加载并初始化 packet到达网卡 packet通过DMA被拷贝到内核中的一个ring buff ...

  6. The Linux Storage Stack Diagram

    相关文章: 如何提高Linux下块设备IO的整体性能?

  7. linux io stack

  8. The Linux Storage Stack Diagram 内核 4.0 版的 I/O 栈

  9. Linux Storage Stack Diagram 4.0

    https://www.thomas-krenn.com/en/wiki/Linux_Storage_Stack_Diagram

随机推荐

  1. springboot中扩展ModelAndView实现net mvc的ActionResult效果

    最近在写spring boot项目,写起来感觉有点繁琐,为了简化spring boot中的Controller开发,对ModelAndView进行简单的扩展,实现net mvc中ActionResul ...

  2. Sqoop export参数updatemode两种模式updateonly和allowinsert区别

    1.更新导出(updateonly模式)1.1参数说明-- update-key,更新标识,即根据某个字段进行更新,例如id,可以指定多个更新标识的字段,多个字段之间用逗号分隔. -- updatem ...

  3. Codeforces301D. Yaroslav and Divisors

    题意:2e5的全排列 每次询问一个区间有多少对数 满足一个数是另一个数的倍数 题解:考虑离线来做 看到有个说法说 在处理有两种约束的问题时 一般用数据结构边插入边询问的方式 这个题正是如此 我们用su ...

  4. 【bzoj 3333】排队计划(线段树)

    n个数,求一次逆序对.接着有m次修改操作,把每次输入的位置p的数之后<=它的数取出来,从小到大排序后再放回空位里,求逆序对.(N,M<=500,000 , Ai<=10^9)思路:1 ...

  5. lca讲解 && 例题 HDU - 4547

    一. 最普通的找树中两个点x,y最近公共祖先: 在进行lca之前我们要先对这一颗树中的每一个点进行一个编号,像下图一样.这个编号就是tarjan算法中的dfn[]数组 这样的话我们可以在跑tarjan ...

  6. UVA - 12295 最短路(迪杰斯特拉)——求按对称路线最短路条数

    题意: 给你一个n,然后给你一个n*n的正方形w[i][j],你需要找到一个从(1,1)点走到(n,n)点的最短路径数量.而且这个路径必须按照y=x对称 题解: 我们把左上角的点当作(0,0)点,右下 ...

  7. ACM International Collegiate Programming Contest, Egyptian Collegiate Programming Contest (ECPC 2015) G. It is all about wisdom (二分,单源最短路)

    题意:有\(n\)个点,\(m\)条边,只有当你的智力值大于这条边的\(w\)才能走,问在花费不超过\(k\)的情况下,从\(1\)走到\(n\)的所需的最小智力值. 题解:这题比赛为什么没想出来呢? ...

  8. oranges-给mini os 添加内存管理,进程多级反馈队列,进程内存完整性度量

    参考: 内存管理: https://www.jianshu.com/p/49cbaccd38c5 crc校验 https://www.cnblogs.com/zzdbullet/p/9580502.h ...

  9. 23. 合并K个排序链表 分治

    这种k个相同的子问题,可以两两分治,总的运算次数为logk 关键部分 int dis=1; int len=lists.size(); while(dis<=len) { for(int i=0 ...

  10. C++动态申请一维数组和二维数组

    在平时的编程过程中,我们经常会用到数组来存放数据,我们可以直接申请足够大空间的数组来保证数组访问不会越界,但是即便这样,我们依然不能保证空间分配的足够,而且非常的浪费空间.有时候我们需要根据上面得到的 ...