Presentation is loading. Please wait.

Presentation is loading. Please wait.

EE 4993 Display Drivers in NT

Similar presentations


Presentation on theme: "EE 4993 Display Drivers in NT"— Presentation transcript:

1 EE 4993 Display Drivers in NT
Bob Reese

2 Graphics Hardware Course Goals
Understand the basics of Graphics operations. How can you understand how to build hardware if you don’t understand the problem? Understand the OS interface to Graphics Hardware. You need to be able to make the hardware useful inside of some operating system. Understand Graphics Hardware Implementation. Graphics needs hardware assistance in order to meet today’s performance expectations - how is this done?

3 Graphics Hardware Course Implementation
Understand the basics of Graphics operations. Prof. Moorhead will cover basic graphics operations, concentrating at the raster-level Understand the OS interface to Graphics Hardware. We will look at device driver interfaces for graphics accelerators under WinNT; will study some sample code. Understand Graphics Hardware Implementation. Will look at a couple of case studies; perhaps do some VHDL implementation of a couple of 2D raster algorithms. Will study mostly 2D, touch on 3D.

4 What is a Device Driver (DD)?
A Device Driver is a piece of code that manages some peripheral device. Users do not access a DD directly; Users make calls to some OS-defined Application Programming Interface (API). The API will then end up calling the Device Driver. This makes the user code independent of the Device Driver code. The Hardware Vendor writes the device driver. The device driver must supply some set of function calls to be used by the OS. This set of function calls is known as the Device Driver Interface (DDI).

5 Graphics System Architecture - WinNT 4.0
Note that 3 interfaces access the Graphics Hardware

6 Software Interfaces for Graphics Hardware under WinNT
GDI / DDI Used by any software that uses Win32 APIs (before Direct Draw, this meant ALL software). All graphics acceleration is 2D; benchmarks for this interface measure graphics performance for business software (spreadsheets, word processing, window management, etc). Direct Draw / DD Hardware Abstraction Layer (HAL) New API from Microsoft for game programming, HAL offers ‘thinner’ layer between DD API and hardware. Supports both 2D and 3D acceleration OpenGL Graphics API from Silicon Graphics that offers access to both 2D and 3D acceleration. Compete directly with Direct Draw API.

7 Application, GDI, Device Driver Interaction
GDI stands for Graphical Device Interface. Parts operate in both user mode and kernel mode DDI stands for Device Driver Interface. The DDI operates in kernel mode. Note that the Device driver (Graphics Driver) can call GDI functions - allows for the DD to take advantage of functionality in the GDI

8 Another View of the GDI / DDI Interaction
Application Subsystem Win32 Subsystem handle ("video" file object) user mode kernel mode System Services I/O Manager DDI drivers GDI display IoXxx EngXxx driver support routines routines video port driver's VideoPortXxx video miniport driver video adapter system hardware frame buffer 2vidlayr

9 Division of Responsibilities
GDI Provides software rendering support for Win32 GDI calls. Creates graphics objects for use by Device Driver. Device Driver Talks to graphics hardware; accesses graphics acceleration features. Can make use of GDI services for managing graphics Objects created by GDI. Video Port Driver/ Video MiniPort Two tightly coupled drivers; Video Port Driver is generic and provided by Microsoft. Video Miniport talks to Video Port Driver and handles device-specific functions such as graphics hardware initialization, cursor or pointer hardware on video card, mode-set and palette operations for MS-DOS sessions.

10 More on the Differences between DD and Miniport
Both the DD and Miniport access the hardware. The miniport is intended to be paired one-on-one with a particular variation of video card. As such, one of the jobs of the miniport is to return video card configuration information to the display driver. The number of required functions in the miniport is low which keeps the miniport code size small. The required display driver code is more complex than the miniport code and can work across a family of video cards. The DD can call functions in the GDI to return configuration info from the miniport. EXAMPLE : Matrox Millenneium I & II, Matrox Mystique The same display driver (Mga64.dll) is used for all three of these cards. However, there are different miniports (mga_mil.sys) for each particular card.

11 One more Picture….

12 Device Driver Development under WinNT
SDK For WinNT The WinNT Software Developers Kit (SDK) provides libraries and C/C++ Header file for doing general WinNT system development. From the ‘Start’ menu, look for topics labeled Win32 SDK DDK For WinNT The WinNT Device Driver Kit provides an environment for building (compile/link) and debugging device drivers. It also provides sample code for different driver types. From the ‘Start’ Menu, look for topics labeled Windows NT DDK

13 DDK Directory Structure
inc - include directory which contains all system header files. lib - compiled dll files are placed here src - source code examples for different driver types are contained here. We will be interested in the directory tree: src\video\displays\mga which contains a sample display driver for the Matrox Millenneium I. Also, src\video\miniport contains source code for video miniport drivers.

14 Interesting Files in src/displays/mga
enable.c specifics to GDI what functions will be hardware assistant driver.h data structures used by driver code. ddk/inc/windi.h general GDI/DDI definitions bitblt.c highlevel bitblt interface code to GDI bltmga.c low level bitblt code for MGA Millenenium (actually, for all of this family except for ‘Storm’). hw.h hardware definitions (registers, bitmasks, etc) ddraw.c support for Direct Draw MCD*.c many files to implement OpenGL mini client driver.

15 To Build the MGA display driver
1. Execute Start > Programs > WinNT DDK > Checked Build 2. You will be in the C:\DDK directory. cd to src\video\displays\mga 3. Type ‘build’ - this will compile all files. ‘.obj’ files will go in the obj\i386 directory. The mga.dll will be placed in the c:\ddk\lib\i386\checked directory. 4. To install, you must be on a system that has the Matrox Millennenium I card. Copy the mga.dll file to the c:\winnt\system32 directory. Before copying, make a copy of the old driver. Reboot the machine to test the new driver.

16 What will we try to learn about Device Drivers?
It is a big topic!! Lots of complicated code; will try to get feel for the GDI/DirectDraw/OpenGL interfaces to the hardware. BitBlts BitBlts are very important for 2D performance. We try to look at this code in some detail. For 3D, still to be decided. Performance/Capability Will look at standard ways for testing performance and capability of graphics display drivers by looking at the Microsoft Hardware Compatibility Tests and the Ziff-Davis Benchmarks. Debugging Will look at Device Driver debugging using WinDBG.

17 GDI / DDI Capabilities In graphics display driver speak, capabilities refers to the list of graphics operations which a device driver will handle rather than letting the system perform the operation. The GDI will query the display driver for its capabilities. This is necessary because different graphics adapters will be able to handle different sets of operations. Performance If a display driver elects to handle an operation such as a BitBlt, then it should do so at faster performance than the what the system can provide. Usually, the display driver will handle the operation only if hardware assistance is provided.

18 GDI / DDI (cont.) Hooking, Punting Electing to handle a drawing function in the display driver is known as hooking. When a call is hooked, ie., DrvBitBlt (does a BitBlt), the GDI will call the driver to handle this operation. However, the driver does not handle to all cases. The driver can check for the cases it does handle (e.g., all BitBlts except for 24-bit color cases) and if it can’t handle the call, the driver can punt the call back to the GDI. The GDI will then do the operation. DrvBitBlt versus EngBitBlt As an example, the DrvBitBlt call is the bitblt operation done via the display driver. The EngBitBlt call is the GDI simulation of this operation.

19 Display Driver Exercise #1
Determine Performance difference between hardware accelerated BitBlt and GDI-emulated BitBlt Need a Benchmark for 2D Graphics - Use the Ziff Davis WinBench 98 benchmarks Ziff Davis WinBench 98 Under WinBench 98, many different tests can be run: Disk, Business Graphics, Direct Draw, Video…. We will be interested in the Business Graphics since these basically measure GDI32 2D graphics performance.

20 Display Driver Exercise #1 (cont)
The mga driver supplied in the DDK hooks the BitBlt operation from the GDI. Read the DDK documentation and determine how to unhook the BitBLT operation (hint: you will have to modify enable.c ). Use the Business Graphics WinMark 98 test under WinBench 98 to measure the resulting performance with BitBLT being performed by the GDI. When you run the Graphics WinMark, you will get a warning about some ‘unnecessary processes’ currently executing; don’t worry about this. You may also have to turn off the ‘always on top’ flag on the bottom taskbar in order for the benchmark to run.

21 Business Graphics Results
200 Mhz Pentium, MGA checked build, Hardware BitBlt, NT 4.0 Units are in Million Pixels/sec

22 What from GDI can be accelerated by Display Driver?
BitBlt, Stretched BitBlt A stretched BitBlt is when the destination rectangle is not the same size as the source rectangle Pointer Management Can also be accelerated via Video miniport. Line Drawing General Path Drawing/Filling (this means curves and lines) Memory Transfers Text output

23 Device Driver Debugging
Debugging a Device Driver, especially a display driver, is difficult. A program called WinDBG is used for this purpose. Null Modem Cable Target Host DD to be debugged is on Target. Host runs WinDBG. Special NT boot option on Target enables debug info to be sent to Host via serial Port.

24 WinDBG Capabilities Via WinDBG, you can: Set a break point in a DD Single Step a DD Watch order in which systems DDs are being loaded Examine Memory areas Data display in WinDBG is limited to Hex memory dumps (YAARRRRG). However, you add ‘extension functions’ to WinDBG via user DLLs. These extension functions are mostly used to print out various data structures when passed an address. You will become very familiar with WinDBG……..

25


Download ppt "EE 4993 Display Drivers in NT"

Similar presentations


Ads by Google