本文主要是介绍KWin全解析 —— overview.md(3),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
接前一篇文章:KWin全解析 —— overview.md(2)
本文继续解析KWin源码src/backends/drm/overview.md文件的其余内容。
第16段
# gbm
The generic buffer manager API allows us to allocate buffers in graphics memory with a few properties. It's a relatively straight forward API:
- `gbm_bo` is a gbm buffer. It can be manually created and destroyed
- `gbm_surface` is a gbm surface, which allows us to create an egl surface that's using gbm buffers. With it we can render in egl and then create framebuffers from the things rendered in egl and present them on the display
- the `GBM_FORMAT_*` defines are just copies of the `DRM_FORMAT_*` defines in drm_fourcc.h and describe a buffer format. For example `DRM_FORMAT_XRGB8888` describes a buffer with 8 bits of red, 8 bits of green, 8 bits of blue and 8 bits of unused alpha (that's what the `X` stands for). Do not use the `GBM_BO_FORMAT_*` enum, it can cause problems! In general, ignore the buffer formats from the gbm header and instead use what drm_fourcc.h provides
- modifiers describe the actual memory layout that needs to be assumed for accessing the buffer. Older drivers like `radeon` don't support modifiers at all, on the other end of the spectrum the NVidia driver requires them. When we don't use functions that have us explicitly provide modifiers that's called an "implicit modifier" - that means the driver automatically picks a modifier for the use case. With implicit modifiers we have no guarantees about multi-gpu compatibility by default, instead the `GBM_BO_USE_LINEAR` usage flag has to be set when creating the buffer to enforce a linear format that all drivers can access without messing up the image
gbm(通用缓冲区管理器)
通用缓冲区管理器API允许我们使用一些属性在图形内存中分配缓冲区。这是一个相对直接的API:
- gbm_bo
gbm_bo是一个gbm缓冲区。它可以被手动创建和销毁。
- gbm_surface
gbm_surface是一个gbm表面,它允许我们创建一个使用gbm缓冲区的egl表面。有了它,我们可以在egl中进行渲染,然后由egl中渲染的内容创建帧缓冲区,并将其显示在显示器上。
- GBM_FORMAT_*
“GBM_FORMAT_*”定义只是drm_fourcc.h中定义的`DRM_FORMAT_*`的副本,描述缓冲区格式。例如:DRM_FORMAT_XRGB8888描述了一个具有8位红色、8位绿色、8位蓝色和8位未使用阿尔法(透明度)(这就是“X”的含义)的缓冲区。不要使用“GBM_BO_FORMAT_*”枚举,它可能会导致问题!通常,忽略gbm头文件中的缓冲区格式,而是使用drm_fourcc.h提供的内容。
- modifiers(修饰符、修改器)
modifiers描述实际内存布局,其用来访问缓冲区。像“radeon”这样的老款驱动程序根本不支持modifier,另一方面,英伟达驱动程序需要它们。当不使用让我们显式提供被称为“隐式修饰符”的修饰符的函数时,这意味着驱动程序会自动为用例选择一个修饰符。使用隐式修饰符,默认情况下我们不能保证多gpu兼容性,相反,在创建缓冲区时必须设置“GBM_BO_USE_LINEAR”使用标志,以强制执行所有驱动程序都可以访问的线性格式,而不会弄乱图像。
第17段
For gbm most of the upstream documentation is contained in https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/gbm/main/gbm.c
对于gbm,大部分上游文档包含在:
https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/gbm/main/gbm.c
至此,KWin下src/backends/drm/overview.md文件内容就全部解析完了。
这篇关于KWin全解析 —— overview.md(3)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!