graphics acceleration l.
Skip this Video
Loading SlideShow in 5 Seconds..
Graphics acceleration PowerPoint Presentation
Download Presentation
Graphics acceleration

Loading in 2 Seconds...

play fullscreen
1 / 23

Graphics acceleration - PowerPoint PPT Presentation

  • Uploaded on

Graphics acceleration An example of line-drawing by the ATI Radeon’s 2D graphics engine Bresenham’s algorithm Recall this iterative algorithm for doing a ‘scanline conversion’ for a straight line It required five parameters: The starting endpoint coordinates: (X0,Y0)

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Graphics acceleration' - oshin

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
graphics acceleration

Graphics acceleration

An example of line-drawing by the ATI Radeon’s 2D graphics engine

bresenham s algorithm
Bresenham’s algorithm
  • Recall this iterative algorithm for doing a ‘scanline conversion’ for a straight line
  • It required five parameters:
    • The starting endpoint coordinates: (X0,Y0)
    • The ending endpoint coordinates: (X1,Y1)
    • The foreground color for the solid-color line
  • It begins by initializing a decision-variable
    • errorTerm = 2*deltaY - deltaX;
algorithm s main loop
Algorithm’s main loop

for (int y = Y0, x = X0; x <= X1; x++)


drawPixel( x, y, color );

if ( errorTerm >= 0 ) { errorTerm += 2*delY; }

else { y += 1; errorTerm += 2*(delY – delX); }


how much work for cpu
How much work for CPU?
  • Example: To draw the longest visible line (in 1024x768 graphics mode) will require approximately 10,000 CPU instructions
  • The loop gets executed once for each of the 1024 horizontal pixels, and each pass through that loop requires about ten CPU operations: moves, compares, branches, adds and subtracts, plus the function-calls
is acceleration possible
Is acceleration possible?
  • The IBM 8514/A appeared in late 1980s
  • It could do line-drawing (and some other common graphics operations) if just a few parameters were supplied
  • So instead of requiring the CPU to do ten thousand operations, the CPU could do maybe ten operations, then let the 8514/A graphics engine do the rest of the work!
8514 a block diagram
8514/A Block Diagram








Display Monitor

Display processor

CRT controller

Drawing engine



PC Bus Interface

PC Bus

ati improved on ibm s 8514 a
ATI improved on IBM’s 8514/A
  • Various OEM vendors soon introduced their own graphics accelerator designs
  • Because IBM had not released details of its design, others had to create their own programming interfaces – all are different
  • Early PC graphics software was therefore NOT portable between hardware platforms
how does x300 draw lines
How does X300 draw lines?
  • To demonstrate the line-drawing ability of our classroom’s Radeon X300 graphics processors, we wrote ‘drawline.cpp’ demo
  • We did not have access to ATI’s official Radeon programming manual, but we had several such manuals from other vendors, and we found ‘clues’ in source-code files for the Linux Radeon device-driver
programming concepts
Programming concepts
  • Our demo-program must first verify that it is running on a Radeon-equipped machine
  • It must determine how it can communicate with the Radeon’s graphics accelerator
  • Normal VGA registers are at ‘standard’ I/O port-addresses, but the graphics engine is outside the scope of established standards
peripheral component interconnect
Peripheral Component Interconnect
  • An industry committee (led by Intel) has established a standard mechanism that PC device-drivers can use to identify the peripheral devices that a workstation has, and their mechanisms for communication
  • To simplify the Pre-Boot Execution code, modern PC’s provide ROM-BIOS routines that can be called to identify peripherals
pci configuration space
PCI Configuration Space

Each peripheral device has a set of nonvolatile memory-locations

which store information about that device using a standard layout


256 bytes







This device-information is accessed via I/O Port-Addresses 0x3C8-0x3CF

pci configuration header
PCI Configuration Header

Sixteen longword entries (256 bytes)













VENDOR-ID = 0x1002: Advanced Technologies, Incorporated

DEVICE-ID = 0x5B60: ATI Radeon X300 graphics processor

BASE-ADDRESS for RESOURCE 1 is the 2D engine’s I/O port

Our ‘findsvga.cpp’ utility will show you the PCI Configuration Space for any

peripheral devices of Class 0x030000 (i.e., VGA-compatible graphics cards)

interface to pci bios
Interface to PCI BIOS
  • Our ‘dosio.c’ device-driver (and ‘int86.cpp’ companion code) allow us access to BIOS
  • The PCI BIOS services are accessible (in the Pentium’s virtual-8086 mode) using function 0xB1 of software interrupt 0x1A
  • There are several subfunctions – you can find documentation online – for example, Professor Ralf Brown’s Interrupt List
return radeon port address
  • Our demo invokes these PCI ROM-BIOS subfunctions to discover which I/O Port our Radeon’s 2D graphics engine uses
    • Subfunction 1: Detect BIOS presence
    • Subfunction 3: Find Device in a Class
    • Subfunction A: Read Configuration Dword
  • Configuration Dword at offset 0x14 holds I/O Port-Address for 2D graphics engine
the ati i o port interface
The ATI I/O Port Interface

iobase + 0 iobase + 4



You output a register’s index

to the iobase + 0 address

Then you have read or write access to

that register at the iobase + 4 address

many 2d engine registers
Many 2D engine registers!
  • You can peruse the ‘radeon.h’ header-file to see names and register-index numbers for the Radeon 2D graphics accelerator
  • You could also write a programming loop to input the contents from various offsets and thereby get some idea of which ones appear to hold ‘live’ values (i.e.,hundreds!)
  • Only a small number used in line-drawing
main line drawing registers
Main Line-Drawing registers
others that affect drawing
Others that affect drawing
cpu gpu synchronization
CPU/GPU synchronization







When CPU off-loads the work of drawing lines (and doing other common

Graphical operations) tp the Graphics Processing Unit, then this frees up

the CPU to execute other instructions – but it opens up the possibility that

the CPU will send more drawing commands to the GPU, even before the

GPU is finished doing earlier commands. Some mechanism is needed to

prevent the GPU from becoming overwhelmed by work the CPU sends it.

Solution is a FIFO for pending commands, plus a Status Register

engine has 64 fifo slots
Engine has 64 FIFO slots
  • Before the CPU initiates a new drawing command, it checks to see if there are enough free slots in the command FIFO for storing that command’s parameters
  • The CPU can do ‘busy-waiting’ until the GPU reports that enough FIFO slots are ready to accept new command-arguments
  • An alternative is ‘interrupt-driven’ drawing
testing drawline cpp
Testing ‘drawline.cpp’
  • We developed our ‘drawline.cpp’ demo on a Radeon 7000 graphics card, then tested it on a newer and faster Radeon 9250
  • Our code worked fine
  • Tonight we shall try it on the Radeon X300
  • If these various models of the Radeon are fully compatible with one another, we can expect our demo to work fine on the X300
hardware changes
Hardware changes?
  • But if any significant differences exist in the various Radeon design-generations, then we may discover that our ‘drawline’ fails to perform properly on an X300
  • We would then have to explore the ways in which Radeon designs have changed, and try to devise ‘fixes’ for any flaws that we have found in our software application
in class exercises
In-class exercises
  • Try running the ‘drawline.cpp’ application on our classroom or CS Lab workstation: maybe it works fine, maybe it doesn’t
  • Look at the source-code files for the Linux ‘open-source’ ATI Radeon device-driver
  • If our ‘drawline’ work ok, see if you can add code that programs the engine to fill rectangles or copy screen-areas; or, if ‘drawline’ fails, see if you can devise a ‘fix’