How to do pageflipping - PowerPoint PPT Presentation

About This Presentation
Title:

How to do pageflipping

Description:

... ATI Radeon's 2D drawing engine -- allowing the Start-Address to be reprogrammed ... vm.regs.edx = VENDOR_ID; // ATI. vm.regs.esi = 0; // device index ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 12
Provided by: ProfessorA2
Learn more at: https://www.cs.usfca.edu
Category:
Tags: ati | pageflipping

less

Transcript and Presenter's Notes

Title: How to do pageflipping


1
How to do page-flipping
  • The steps needed when revising our wfmodel1.cpp
    prototype to achieve smooth animation

2
How page-flipping works
The user sees this part of video memory
The visible page
CRTC START-ADDRESS
Your program draws to this part of video
memory
The drawing page
When the drawing page is ready to be viewed,
your program changes the CRTC
START-ADDRESS and thus the roles of these
two pages are flipped
VRAM
3
Use a Radeon-specific register
  • The CRT Controllers Start-Address can be
    accessed via a 32-bit register (called
    CRTC_START) which is part of the ATI Radeons 2D
    drawing engine -- allowing the Start-Address to
    be reprogrammed as a single atomic operation
  • define CRTC_START 0x0224

4
Installation check
  • The software must detect the presence of a Radeon
    X300 graphics adapter, and it must discover which
    i/o port-address got assigned to the Radeon 2D
    engine during the Operating Systems startup
    process
  • define VENDOR_ID 0x1002 // ATI
  • define DEVICE_ID 0x5B60 // X300

5
PCI Find Device service
  • init8086() // initialization for vm8086
  • vm.regs.eax 0x1B02 // PCI Find Device
  • vm.regs.ecx DEVICE_ID // X300
  • vm.regs.edx VENDOR_ID // ATI
  • vm.regs.esi 0 // device index
  • int86( 0x1A, vm ) // invoke PCI BIOS
  • if ( vm.regs.eax 0xFF00 ) exit(1) // failed

6
PCI Read Configuration Dword
  • vm.regs.eax 0x1B0A // PCI Read Dwd
  • vm.regs.edi 0x0014 // Resource 1 Adr
  • int86( 0x1A, vm ) // invoke PCI BIOS
  • iobase vm.regs.ecx 0xFFFFFFFC

7
Global Variables
  • int iobase // value is filled in at runtime
  • int page_size (2 ltlt 20) // 2-megabytes
  • int drawing_page 0 // page 0 or page 1
  • int visible_page 0 // page 0 or page 1

8
Hardware helper-function
  • void set_visible_page( void )
  • int start_addr visible_page page_size
  • outl( CRTC_START, iobase 0 )
  • outl( start_addr, iobase 4 )

9
Pixel-drawing helper-function
  • void draw_pixel( int x, int y, int color )
  • int offset drawing_page pagesize
  • unsigned char dstn vram offset
  • dstn y vres x color

10
The page-flipping algorithm
  • Main loop
  • Compute the new image
  • Set drawing_page to (visible_page 1)2
  • Draw next screen image onto drawing page
  • Set visible_page to equal the drawing_page

11
In-class exercise
  • Create a revision of the wfmodel2 demo (named
    wfmodel3.cpp) to automatically spin the
    wireframe model contiunuously, until the user
    hits the ltESCAPEgt-key
  • You will need to use a signal-handler and
    asynchronous keyboard-input notification (as in
    our earlier persists.cpp demo)
Write a Comment
User Comments (0)
About PowerShow.com