Supporting Multiple PDEVs

A graphics driver enables a PDEV for the default desktop upon which applications can run. A graphics driver must also support the enabling of additional PDEVs since it is possible for an application to create a new PDEV with a new desktop. This requirement is placed on the display driver by the Display applet contained within the Control Panel. This applet allows the user to run a brief test of selected changes to such things as the size, number of colors, and refresh rate of the screen. The Display applet creates a temporary desktop to test the changes made by the user to the display settings.

Figure 5.2    Creating and Destroying a Second PDEV with the Display Applet.

Figure 5.2 shows that an application can create a new PDEV while the current PDEV is still loaded. In the second stage of this example, the Display applet temporarily disables the current PDEV and, when the user clicks the Test button, creates a second PDEV that matches the display mode selections in the dialog box. After a brief period of use, where the user views a bitmap on the display screen under the test mode, the second PDEV is destroyed and Display applet restores the original PDEV for the desktop. Without the ability to revert back to the original display settings, the system would become unusable if settings incompatible with the installed hardware and driver were chosen.

Note GDI will not call the driver to create a second PDEV if the DDI version number of the driver, returned in DRVENABLEDATA, is 1.0 since this version number indicates lack of support for a second PDEV.

A PDEV is private to a driver and contains all the information and data that represents the associated physical device. To accommodate the creation of multiple PDEVs, the graphics driver must meet a pair of requirements. The first is that the driver must not use global varibles in lieu of dereferencing members of a PDEV structure. If global variables are used, they may contain or point to random data when a new PDEV is created, or an old one restored. All state information must be saved in the PDEV. The PDEV is always passed down on any graphics operation and so is used to get or set global data.

Secondly, DrvDisableSurface and DrvDisablePDEV must be implemented in the graphics driver so that an application can create and destroy additional PDEVs, and in some cases load more than one driver.

 

Note In some cases with the Display applet, the test bitmap will be displayed using a different driver than the currently-loaded driver. For example, the user’s system could be running in 16-color mode with the VGA driver and test 64K-color mode with the VGA64K display driver. In this case, the VGA64K driver is loaded dynamically and unloaded when the test is completed.