Introduction to the Direct Rendering Infrastructure

来源:互联网 发布:淘宝达人注册 编辑:程序博客网 时间:2024/05/29 11:07

http://dri.sourceforge.net/doc/design_high_level.html

Introduction to the Direct Rendering Infrastructure

Brian Paul (brian@tungstengraphics.com)

10 August 2000

 


This document is an introduction and high-level user guide for the Direct Rendering Infrastructure (DRI). It describes the goals of the DRI project, some of its history, the current state, the development environment and future plans.

1. Copyright

Copyright (c) 2000 by Brian Paul. All Rights Reserved.

Permission is granted to make and distribute verbatim copies of this document provided the copyright notice and this permission notice are preserved on all copies.

Permission to modify this document may be granted to those who get approval from Brian Paul.

 

2. Trademarks

OpenGL is a registered trademark and SGI is a trademark of Silicon Graphics, Inc. Unix is a registered trademark of The Open Group. The `X' device and X Window System are trademarks of The Open Group. XFree86 is a trademark of The XFree86 Project. Linux is a registered trademark of Linus Torvalds. Intel is a registered trademark of Intel Corporation. 3Dlabs, GLINT, and Oxygen are either registered trademarks or trademarks of 3Dlabs Inc. Ltd. 3dfx, Voodoo3, Voodoo4, and Voodoo5 are registered trademarks of 3dfx Interactive, Incorporated. Matrox is a registered trademark of Matrox Electronic Systems Ltd. Rage is a registered trademark of ATI Technologies, Inc. All other trademarks mentioned are the property of their respective owners.

 

 

 

3. Introduction

简单来说,DRI是用来使能Linux上面的3D图形加速硬件的。更准确的说,它是用来协调Linux内核、X Window、3D图形硬件、基于OpenGL的渲染引擎的软件架构。

DRI的设计目标包括:

 

  • 允许利用图形硬件的高性能
  • 支持不同的各种图形硬件设计
  • 支持同时多个客户端的渲染
  • 防止恶意滥用系统的安全措施
  • 可靠性,以防止系统死机或死锁
  • 可移植性,以允许实现在其他操作系统和系统架构
  • 遵守OpenGL和GLX规范
  • 集成于XFree86项目
  • 开放源代码的实现

 

 

 

4. History

Hardware-accelerated 3D computer graphics is not new - workstation vendors developed this technology over a decade ago. But now, inexpensive and powerful graphics hardware is commonplace. The technology is now available to anyone with a personal computer, not just professional engineers and researchers.

Anyone familiar with interactive graphics who was watching the development of Linux could see the need for (and indeed the potential of) implementing 3D graphics acceleration on Linux. The problem is that implemention of this technology is very complex. It would take a number of talented people working together to solve the problem.

 

 

4.1 OpenGL and Mesa

In 1993 Brian Paul began writing an implementation of the OpenGL specification, both for practical and personal reasons. Brian had been using an IRIS GL subset emulator called VOGL for a scientific visualization project when the OpenGL 1.0 specification was announced. As a graphics hobbyist, Brian thought it would be fun to implement a simple 3D graphics library using the OpenGL API, which he might then use instead of VOGL. After eighteen months of part-time development and checking with Silicon Graphic's legal department, Brian released his project, named Mesa, on the Internet. People quickly latched onto it and began contributing to its development.

Designed with correctness as a higher priority than performance, users soon recognized Mesa as a reliable and useful substitute for OpenGL on systems which did not otherwise have an OpenGL implementation.

In 1997 the first graphics hardware support was added to Mesa in the form of a Glide driver for the new 3dfx Voodoo graphics card. Suddenly, high performance 3D graphics was available at a modest price. This caught the attention of people who wanted to use inexpensive Linux systems instead of proprietary workstations for their daily work. But at this stage there was clearly a long way to go before Linux could replace or even compete with the graphics workstations of the day.

Both the hardware and the software had to be improved. The 3dfx Voodoo card was limited to full-screen operation at relatively low resolution, both in terms of pixels and color palette. The Mesa/Glide driver was not integrated with the window system and only a subset of OpenGL applications could benefit from the hardware acceleration.

In time the hardware would shed these limitations but on the software front, there was a tremendous challenge ahead. A real 3D workstation solution would require work in the Linux kernel, the X server, hardware drivers and the rendering core.

 

 

4.2 Precision Insight and the DRI

Precision Insight, Inc. (PI) was founded to develop hardware drivers for XFree86 through contracts with various IHVs and ISVs. PI had also set themselves a goal: to expand into 3D graphics in the future. Over time, PI was able to secure both funding and the personel to begin development of the Direct Rendering Infrastructure- the foundation for 3D graphics support on Linux.

The DRI would provide the infrastructure needed to integrate 3D hardware support into the X server and Linux kernel. Furthermore, it would provide a framework for building modular device drivers.

As of mid-2000 the DRI has been incorporated into XFree86 4.0 and at least five distinct hardware device drivers have been developed.

Nevertheless, the DRI is not "finished". The DRI was designed to be flexible in order to accomodate a variety of hardware architectures. Since the hardware designs are changing and growing more sophisticated the DRI will also evolve to accomodate these changes.

The initial development and ongoing evolution of the DRI is a prime example of the power of open-source development. A cooperative effort by the XFree86, Mesa, GLX and Linux kernel developers took several individual projects and combined them into a powerful new system.

 

 

 

5. DRI Components

DRI并不是单一的相对隔离的软件。相反,它是一系列的独立模块组合起来的。下面将简要介绍这些模块以及这些模块是如何加入到 Linux系统的。

 

5.1 Kernel Modules

3D硬件驱动都是内核模块。这个模块处理DMA,AGP内存管理、资源锁以及安全的访问硬件。为了支持多个3D应用同时访问图形硬件,3D硬件必须被当作共享的资源。为了保证互斥性锁是很必要的。DMA传输和AGP接口发送图形命令缓冲给硬件。最后,需要有安全机制来保证客户端来有序的使用硬件,以免系统崩溃。

由于Linux内核接口和数据结构随时可能发生改变,DRI内核模块需要为特定的内核版本进行编译。DRI内核模块通常位于/lib/modules/kernel-version/misc/,其命名通常是device.o,这里的device就是是被明,譬如tdfx, mga, r128等。

通常,X Serve会自动加载需要的DRI模块。

 

 

5.2 The 2D XFree86 Driver

每种类型的显卡都有 XFree86 2D (or DDX)驱动负责初始化、显示屏的管理以及进行2D渲染。XFree86 4.0引入了一种新的设备驱动接口即XAA,这将运行XFree86驱动和未来X Server的后向兼容性。

XFree86通常位于/usr/X11R6/lib/modules/drivers/,其命名规则是:device_drv.o。

Each 2D driver has a bit of code to bootstrap the 3D/DRI features.

 

 

5.3 The 3D DRI Driver

显卡的3D计算能力是通过3D DRI驱动访问显卡得到的。这个驱动主要将OpenGL命令序列转化为硬件命令。然后使用内核模块将这些命令发送给硬件。3D驱动和内核模块基本上实现了完整的OpenGL渲染流水线。3D驱动大部分都实现在用户空间,而内核模块实现在内核空间。

3D DRI驱动通常位于: /usr/X11R6/lib/modules/dri/ ,device_dri.so.

libGL.so将会加载这些3D驱动。(libGL.so实现了OpenGL接口)

大多数DRI 3D驱动基于Mesa。然后,DRI对于Mesa并不是必需的。驱动开发者可以使用OpenGL兼容框架实现他们自己的3D DRI。

 

 

5.4 The libGL Library

基于OpenGL的程序必须链接libGL库。libGL实现了GLX接口和主要的OPenGL API入口。当使用非直接渲染时,libGL创建GLX协议消息并将这些消息通过Socket送给X Server。当使用直接渲染,libGL会加载3D DRI驱动,然后将OpenGL库请求分发给对应的驱动。

libGL函数也有能力支持异构,多头配置。这意味着系统可以配置2个以上的显卡(同类型或者不同类型),libGL允许程序同时来使用所有的显卡。

通常libGL从路径/usr/X11R6/lib/modules/dri 来加载3D DRI驱动。当然,查找路径也因环境变量LIBGL_DRIVERS_PATH而已。

 

 

5.5 XFree86 DRI Extension

XFree86-DRI X server extension主要用于其他DRI组件(the X server, the kernel module, libGL.so and the 3D DRI drivers)之间的通信。

DRI module维护了DRI特有的数据结构,这些数据结构和screens, windows, and rendering contexts相关。譬如,当用户移动一个窗口,其他DRI模块需要得知这些信息以便渲染在正确的地方。

The XFree86-DRI module usually resides at /usr/X11R6/lib/modules/extensions/libdri.a.

 

 

5.6 XFree86 GLX Extension

X server  GLX 扩展处理服务器端的GLX协议。包括:设置GLX-enhanced visuals, GLX context creation, context binding and context destruction.

当使用间接渲染时,GLX扩展解码GLX命令,并将这些命令分发到核心渲染引擎。

The extension usually resides at /usr/X11R6/lib/modules/extensions/libglx.a.

 

 

5.7 XFree86 GLcore Extension

GLcore模块负责间接和非本地客户端的渲染。当前,Mesa是一个软件渲染,在将来,间接渲染也可能使用硬件加速。

位置: /usr/X11R6/lib/modules/extensions/libGLcore.a.

 

 

5.8 Modularity and Version Checking

Each of the DRI components has version numbers which are checked by all dependents. If there are any version mismatches between the DRI components the system will recover gracefully and provide diagnostic messages.

Errors detected on the server side will be logged with the normal X server messages.

Errors detected on the client side by libGL will be printed to stderr if the LIBGL_DEBUG environment variable is set.

Finally, thanks to the modularity of XFree86 and the DRI it is also possible to change the graphics hardware in the system, power-up, and resume using the system without having to install any new software.

 

 

 

6. Using the DRI

当所有的部件都安装并正确配置后,3D渲染就可以被使用了。你只需要平常一样启动X Server。

链接了libGL的程序会自动使用硬件加速。如果没有安装3D硬件,OpenGL程序可以使用GLX和软件渲染来保证程序的正常运行。

当前,大多数DRI驱动都是基于Mesa的,不能被叫做官方的Open GL实现。然而,Mesa和OpenGL是基本一致的,并且Mesa一直在被改进。绝大部分OpenGL的程序在Mesa上可以正常运行。某些情况下, Mesa比其他OpenGL实现更加“准确”,譬如某些实现移植困难,或者使用了错误的假设。

DRI现在被用来运行所有的OpenGL程序。3D游戏在Linux上是很流行的。现在有很多3D建模、模拟、视觉化以及3D内容创建工具运行在Linux DRI之上。有意思的是,单一的硬件/OS平台可以运行最流行的3D游戏和大量的3D生产应用软件。

 

 

 

7. Supported Hardware

The original DRI and 3D driver work was done for the Intel x86 architecture. Support for Alpha-based systems is underway and support for other CPU architectures will probably arrive in time.

With the release of XFree86 4.0.1 there is support for the following 3D graphics hardware:

 

  • 3dfx Voodoo3 and Voodoo5 series
  • Matrox G200 and G400
  • Intel i810
  • ATI Rage 128
  • 3Dlabs Oxygen

At this point in time, the drivers have not been fully optimized for performance. The limited development resources have been focused on dependability, correctness and functionality. In the long term, performance will optimized.

 

 

 

8. Supported Operating Systems

The initial DRI development was targetted for Linux, but with an eye toward portability to other Unix-like operating systems. FreeBSD is the first non-Linux port of the DRI. It is included in XFree86 4.0.1 with support for 3dfx and Matrox graphics hardware.

Since most hardware drivers require AGP support, a recent Linux kernel is needed. Until Linux 2.4.0 is released, the recent 2.3.x kernels must be used. Older kernels such as 2.2.14, patched with AGP support may also work.

 

 

9. Open Source Development

The DRI is open source, copyrighted under the XFree86 license terms. The benefits of open source development, which have been well-documented elsewhere, have certainly applied to the DRI project. Some particular benefits to the DRI project follow.

 

 

9.1 Quality Assurance

Since the latest DRI source code can always be downloaded at any time, users are able to closely track new DRI development. Enthusiastic users often update their DRI installation on a daily basis and provide constant feedback to the developers.

The user community is able to test the software on a far wider variety of systems than the developers could themselves. There are innumerable combinations of motherboards, processors, graphics cards and software installations. Thanks to the users, the developers can be sure of substantial coverage testing.

 

 

9.2 New Development Projects

There are several instances of new DRI 3D drivers being developed by parties outside the core DRI development team. In a closed development environment the core DRI team would have to develop all drivers, which clearly would be a bottleneck. With open-source anyone is free to implement new drivers.

In another instance, the DRI infrastructure has been ported to FreeBSD by an independent developer. In many cases, porting software to new a hardware or OS environment can help to improve the overall design and quality of that software.

 

 

9.3 Shared Code Base

Since many of the DRI drivers are build using Mesa as their rendering core, all those drivers can simultaneously benefit from Mesa development. For example, Mesa bug fixes, optimizations and extensions can generally benefit all drivers, not just one. Similarly, improvements to the core DRI modules will be of benefit to all hardware drivers.

Contrast that to proprietary development: none of the development effort invested in one vendor's driver will benenfit another vendor's.

 

 

9.4 Community Communication

The communication between the developers and end users is very important. In closed/proprietary development the software developers are seldom known by name nor develop a rapport with the end users.

It's encouraging to the DRI developers to get positive feedback from users about the latest features, bug fixes and performance improvements. The developers know how their work is being used and, indeed, how well it's working.

An on-going dialog with end users can also bring about new innovations. For example, when users have a problem that can't be solved by "off the shelf" software, it's possible for the users and developers to collaborate on solutions to those problems. This might result in new rendering extensions, for example. This level of cooperation is exciting for both parties.

 

 

 

10. Future Work

The term direct rendering infrastructure does not only imply 3D graphics support. From the beginning, the DRI was designed with flexibility such that it may also be used in other areas such as video I/O. That's a potential future project.

As stated before, the immediate goal of the DRI drivers has been stability and correctness, not maximum performance. With maturity, the drivers will also become faster. Some of that work is now underway.

There are always new 3D cards coming to market. The DRI team expects to develop drivers for many of them.

OpenGL is always growing with new extensions. In order to remain competitive with other operating systems, the Linux 3D driver writers need to implement those new features. Thanks to open source and shared code bases many new extensions may be made available even in hardware drivers which may have been considered to be finished.

In the near future major Linux vendors will be incorporating Linux 2.4.x and XFree86 4.0.x into their products. At that time, 3D hardware acceleration will be widely available without need to manually install 3D support piece-by-piece. Hardware 3D will finally become a staple of the Linux experience.

 

 

 

11. References

 

  1. A Multipipe Direct Rendering Architecture for 3D, Precision Insight, Inc. (http://www.precisioninsight.com/dr/dr.html)
  2. Direct Rendering Infrastructure, Low-Level Design Document, Precision Insight, Inc. (http://www.precisioninsight.com/dr/drill.html)
  3. The Direct Rendering Manager: Kernel Support for the Direct Rendering Infrastructure Precision Insight, Inc. (http://www.precisioninsight.com/dr/drm.html)
  4. Hardware Locking for the Direct Rendering Infrastructure Precision Insight, Inc. (http://www.precisioninsight.com/dr/locking.html)
  5. A Security Analysis of the Direct Rendering Infrastructure Precision Insight, Inc. (http://www.precisioninsight.com/dr/security.html)
  6. DRI Extension for supporting Direct Rendering Protocol Specification Precision Insight, Inc. (http://www.precisioninsight.com/dr/XFree86-DRI.txt)
  7. DRI Home Page (http://dri.sourceforge.net)
  8. DRI User Guide Precision Insight, Inc. (http://dri.sourceforge.net/DRI.html)
  9. DRI Compilation Guide Precision Insight, Inc. (http://dri.sourceforge.net/DRIcompile.html)