ee 4993 display drivers in nt

25
E 4993 Display Dirivers in NT.1 BR Jan 1998 EE 4993 Display Drivers in NT Bob Reese

Upload: octavia-green

Post on 03-Jan-2016

34 views

Category:

Documents


1 download

DESCRIPTION

EE 4993 Display Drivers in NT. Bob Reese. 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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.1 BR Jan 1998

EE 4993Display Drivers in NT

Bob Reese

Page 2: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.2 BR Jan 1998

Graphics Hardware Course Goals

Understand the basics of Graphics operations.How can you understand how to build hardwareif you don’t understand the problem?

Understand the OS interface to Graphics Hardware.You need to be able to make the hardware usefulinside of some operating system.

Understand Graphics Hardware Implementation.Graphics needs hardware assistance in orderto meet today’s performance expectations - howis this done?

Page 3: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.3 BR Jan 1998

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 graphicsaccelerators under WinNT; will study some samplecode.

Understand Graphics Hardware Implementation.Will look at a couple of case studies; perhaps dosome VHDL implementation of a couple of 2D raster algorithms. Will study mostly 2D, touch on3D.

Page 4: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.4 BR Jan 1998

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 callsto 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 callsis known as the Device Driver Interface (DDI).

Page 5: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.5 BR Jan 1998

Graphics System Architecture - WinNT 4.0

Win

32

Su

bs

ys

tem

Application

Kernel Mode

User Mode

NT

Ex

ec

uti

ve

System Services

Parallel orSerial Driver

I/O Manager

Graphics and Print Requests

Graphics Engine(GDI)

UnidriverPrintDriver Mini

Print

KMDirectDraw

Win32 APIs

Win

Spool

GD

I32

Spooler

PrintProcessor

Port Monitor

Language Monitor

Hardware

System-supplied service

VideoMiniport

VideoPort

DisplayDriver

Direct DrawHW

Interface

Note that 3 interfaces access the Graphics Hardware

Page 6: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.6 BR Jan 1998

Software Interfaces for Graphics Hardware under WinNTGDI / DDI

Used by any software that uses Win32 APIs(before Direct Draw, this meant ALL software). All graphics acceleration is 2D; benchmarks forthis interface measure graphics performance forbusiness software (spreadsheets, word processing,window management, etc).

Direct Draw / DD Hardware Abstraction Layer (HAL)New API from Microsoft for game programming, HALoffers ‘thinner’ layer between DD API and hardware. Supports both 2D and 3D acceleration

OpenGL Graphics API from Silicon Graphics that offers accessto both 2D and 3D acceleration. Compete directly withDirect Draw API.

Page 7: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.7 BR Jan 1998

Application, GDI, Device Driver Interaction

Note that the Device driver (Graphics Driver) can call GDI functions - allows for the DD to take advantage of functionality in the GDI

Application

Graphics Engine(GDI)

GraphicsDriver

GDI32

graphics requests

Kernel Mode

User Mode

DDI calls GDI calls

GDI stands for Graphical DeviceInterface. Parts operate in bothuser mode and kernel mode

DDI stands for Device DriverInterface. The DDI operatesin kernel mode.

Page 8: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.8 BR Jan 1998

Another View of the GDI / DDI Interaction

I/O Manager

IoXxxsupport routines

Application Subsystem

Win32 Subsystem

System Services

user mode

kernel mode

handle ("video" file object)

DDI drivers

displaydriver

GDI

EngXxxroutines

video port driver'sVideoPortXxx

system hardwarevideo adapterframe buffer

2vidlayr

videominiport driver

Page 9: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.9 BR Jan 1998

Division of ResponsibilitiesGDI Provides software rendering support for Win32 GDI calls. Creates graphics objects for use by Device Driver.

Device DriverTalks to graphics hardware; accesses graphics acceleration features. Can make use of GDI servicesfor managing graphics Objects created by GDI.

Video Port Driver/ Video MiniPortTwo tightly coupled drivers; Video Port Driver is generic and provided by Microsoft. Video Miniporttalks to Video Port Driver and handles device-specificfunctions such as graphics hardware initialization,cursor or pointer hardware on video card, mode-set andpalette operations for MS-DOS sessions.

Page 10: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.10 BR Jan 1998

More on the Differences between DD and MiniportBoth the DD and Miniport access the hardware.

The miniport is intended to be paired one-on-onewith a particular variation of video card. As such, one of the jobs of the miniport is to return videocard configuration information to the display driver.The number of required functions in the miniportis 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 inthe GDI to return configuration info from the miniport.

EXAMPLE : Matrox Millenneium I & II, Matrox MystiqueThe same display driver (Mga64.dll) is used for all three of these cards. However, there are differentminiports (mga_mil.sys) for each particular card.

Page 11: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.11 BR Jan 1998

One more Picture….

Kernel Mode

User Mode

Application

I/O Manager

DDIcalls Video Port

VideoMiniport

Video Adapter

ENGcalls

NT

Exe

cutiv

e

System-supplied service

DisplayDriver

GraphicsEngine(GDI)

Win32 (including GDI 32)

Page 12: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.12 BR Jan 1998

Device Driver Development under WinNTSDK For WinNT

The WinNT Software Developers Kit (SDK) provideslibraries and C/C++ Header file for doing generalWinNT system development.

From the ‘Start’ menu, look for topics labeledWin32 SDK

DDK For WinNTThe WinNT Device Driver Kit provides an environmentfor building (compile/link) and debugging device drivers. It also provides sample code for differentdriver types.

From the ‘Start’ Menu, look for topics labeled Windows NT DDK

Page 13: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.13 BR Jan 1998

DDK Directory Structure

inc - include directory which containsall system header files.

lib - compiled dll files are placed here

src - source code examples for differentdriver types are contained here. Wewill be interested in the directory tree:

src\video\displays\mga

which contains a sample display driverfor the Matrox Millenneium I.

Also,

src\video\miniport

contains source code for video miniportdrivers.

Page 14: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.14 BR Jan 1998

Interesting Files in src/displays/mga

enable.c specifics to GDI what functions will be hardware assistant

ddraw.c support for Direct Draw

driver.h data structures used by driver code.ddk/inc/windi.h general GDI/DDI definitionsbitblt.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)

MCD*.c many files to implement OpenGL mini client driver.

Page 15: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.15 BR Jan 1998

To Build the MGA display driver1. 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 hasthe 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.

Page 16: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.16 BR Jan 1998

What will we try to learn about Device Drivers?It is a big topic!!

Lots of complicated code; will try to get feel for theGDI/DirectDraw/OpenGL interfaces to the hardware.

BitBltsBitBlts are very important for 2D performance. Wetry to look at this code in some detail. For 3D, stillto be decided.

Performance/CapabilityWill 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.

Page 17: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.17 BR Jan 1998

GDI / DDI

CapabilitiesIn 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 thedisplay driver for its capabilities. This is necessary because different graphics adapters will be able to handle different sets of operations.

PerformanceIf a display driver elects to handle an operation suchas a BitBlt, then it should do so at faster performance than the what the system can provide. Usually, the display driver will handle the operationonly if hardware assistance is provided.

Page 18: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.18 BR Jan 1998

GDI / DDI (cont.)

Hooking, PuntingElecting to handle a drawing function in the displaydriver 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 checkfor the cases it does handle (e.g., all BitBlts exceptfor 24-bit color cases) and if it can’t handle the call, the driver can punt the call back to the GDI. The GDIwill then do the operation.

DrvBitBlt versus EngBitBltAs an example, the DrvBitBlt call is the bitblt operation done via the display driver. The EngBitBlt call is the GDI simulation of this operation.

Page 19: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.19 BR Jan 1998

Display Driver Exercise #1

Determine Performance difference between hardwareaccelerated BitBlt and GDI-emulated BitBlt

Need a Benchmark for 2D Graphics - Use the Ziff Davis WinBench 98 benchmarks

Ziff Davis WinBench 98Under WinBench 98, many different tests can be run:

Disk, Business Graphics, Direct Draw, Video….We will be interested in the Business Graphics sincethese basically measure GDI32 2D graphics performance.

Page 20: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.20 BR Jan 1998

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 underWinBench 98 to measure the resulting performancewith BitBLT being performed by the GDI.

When you run the Graphics WinMark, you will get awarning about some ‘unnecessary processes’ currentlyexecuting; don’t worry about this. You may also haveto turn off the ‘always on top’ flag on the bottom taskbarin order for the benchmark to run.

Page 21: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.21 BR Jan 1998

WinBench 98/Business Graphics WinMark 98 s 65.8 1,2

WinBench 98/Business Browsers Graphics s 7.92 1,2

WinBench 98/Business Publishing Graphics s 5.23 1,2

WinBench 98/Business SS/Database Graphics s 5.9 1,2

WinBench 98/Business Task Switching Graphics s 4.03 1,2

WinBench 98/Business WP Graphics s 10.1 1,2

Business Graphics Results

200 Mhz Pentium, MGA checked build, Hardware BitBlt, NT 4.0

Units are in Million Pixels/sec

Page 22: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.22 BR Jan 1998

What from GDI can be accelerated by Display Driver?

BitBlt, Stretched BitBltA stretched BitBlt is when the destination rectangleis not the same size as the source rectangle

Pointer ManagementCan also be accelerated via Video miniport.

Line Drawing

General Path Drawing/Filling (this means curves and lines)

Memory Transfers

Text output

Page 23: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.23 BR Jan 1998

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 infoto be sent to Host via serial Port.

Page 24: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.24 BR Jan 1998

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……..

Page 25: EE 4993 Display Drivers in NT

EE 4993 Display Dirivers in NT.25 BR Jan 1998