XGL Device Handlers Guide
XGL Device Handlers Guide
Handlers
Please
Recycle
Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
1. Introduction to the Skeleton Pipeline . . . . . . . . . . . . . . . . . . . . 1
About the Skeleton Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Overview of XGL Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Design Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Files Provided With the Skeleton Pipeline . . . . . . . . . . . . . . . . . 4
2. Building the Reference Pipelines. . . . . . . . . . . . . . . . . . . . . . . . 7
Reference Pipelines Provided with the XGL DDK. . . . . . . . . . . 7
Software Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Space Requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Steps for Building the Reference Pipelines . . . . . . . . . . . . . . . . . 9
3. Implementing the Skeleton Pixel-Level Graphics Handler . 13
About Pixel-Level Rendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Steps for Implementing Pixel-Level Rendering . . . . . . . . . . . . . 14
▼ Choosing a Name for the Graphics Handler . . . . . . . . . 15
iii
▼ Copying and Renaming the Skeleton Files. . . . . . . . . . . 15
▼ Editing Files to Rename the Pipeline Binary . . . . . . . . . 16
▼ Editing the Skeleton Pipeline Interface Files . . . . . . . . . 17
▼ Implementing PixRect Support . . . . . . . . . . . . . . . . . . . . 20
▼ Building the Device Pipeline . . . . . . . . . . . . . . . . . . . . . . 22
▼ Testing the Device Pipeline . . . . . . . . . . . . . . . . . . . . . . . 22
4. Implementing Accelerated Primitives. . . . . . . . . . . . . . . . . . . . 25
About Rendering and Attribute Handling . . . . . . . . . . . . . . . . . 25
Rendering in the Skeleton Pipeline . . . . . . . . . . . . . . . . . . . . 27
Steps for Implementing the Skeleton Renderers . . . . . . . . . . . . 28
▼ Implementing the 2D Polygon Renderer . . . . . . . . . . . . 29
▼ Implementing the 3D Multipolyline Renderer . . . . . . . 35
A. Example Hardware Initialization Code. . . . . . . . . . . . . . . . . . . 43
Hardware Initialization Code for the GX Frame Buffer . . . . . . 43
v
vi Getting Started Writing XGL Device Handlers—May 1996
Tables
vii
viii Getting Started Writing XGL Device Handlers—May 1996
Preface
The Getting Started Writing XGL Device Handlers manual explains how to use
the XGL™ skeleton pipeline files to create an XGL graphics handler for a
graphics hardware device.
ix
Related Manuals
For information on the XGL architecture and the design of the loadable
pipelines, see the following manual:
• XGL Architecture Guide
Typeface or
Symbol Meaning Example
AaBbCc123 The names of commands, files, Edit your .login file.
and directories; on-screen Use ls -a to list all files.
computer output system% You have mail.
Graphics Handler
Graphics XGL
Application DI code Interface Loadable
or API objects renderers
The skeleton pipeline includes partially implemented files for the device
pipeline interface objects; these files can expedite the implementation of your
device pipeline. The skeleton pipeline also provides a simple implementation
of line and polygon accelerated renderers that you can implement for your
device.
1
1
The XGL GPI consists of three layers of device pipeline interfaces. Each layer
defines a set of rendering tasks that must be accomplished before proceeding
to the next layer in the pipeline. More complex operations, such as
transformations, lighting, and clipping, are performed in the uppermost layer;
less complex operations, such as scan conversion, are performed in the lower
layers.
The top layer of the GPI, Loadable Interface 1 (LI-1), specifies the interface that
lies directly below the XGL API. Functions in this layer take the points defining
the primitive and transform, light (in the 3D case), and clip the geometry in
preparation for the rendering operations in the next layer. The second layer
(LI-2) is responsible for scan converting more complex primitives like polygons
and polylines. The third layer (LI-3) is responsible for rendering pixels,
individually or in spans on the device. The GPI includes a complete software
implementation of the LI-1 and LI-2 layers of the pipeline for most primitives;
however, the lowest layer, which is responsible for writing pixels to the device,
is device dependent and is not included in the software implementation.
Device pipelines written at the LI-1 layer typically implement the full graphics
pipeline for each primitive, including all LI-1 operations, scan conversion, and
pixel rendering. Device pipelines written at the LI-2 layer call the software
pipeline for LI-1 operations and then take over processing at LI-2, performing
scan conversion and rendering pixels on the device. LI-3 device pipelines are
responsible only for rendering pixels; a port at this layer uses the software
pipeline for LI-1 and LI-2 operations. Hardware vendors can implement
different GPI functions at different layers to tailor a port for a particular device.
Figure 1-2 illustrates the layers of the device pipeline and software pipeline
and some components of the XGL device-independent code.
Application
XGL Core
API to Pipeline
XGL Core Layer
Library
LI-1 Layer
DI
Objects
LI-1 Software Pipeline
LI-1 Device Pipeline
LI-2 Layer
LI-3 Layer
Display Device
Design Considerations
Before you begin developing your graphics handler, you need to determine
how you will handle several important design issues:
❐ What interface layer (LI-1, LI-2, or LI-3) will you port to? A graphics
handler can include routines at all three layers, but usually the
characteristics of the device will determine what interface layer is the
primary porting layer.
❐ Do you need to port Direct Graphics Access (DGA) for your device?
For information on these issues, refer to the XGL Device Pipeline Porting Guide.
File Description
DpLibSkeleton.h Header and source files for the XglDpLib object. This object is
[Link] created at driver installation time. It creates one or more
XglDpMgr objects.
DpMgrSkeleton.h Header and source files for the XglDpMgr object. This object
[Link] manages hardware initialization and creates the XglDpDev
object. Typically, there is one XglDpMgr object per hw device.
File Description
DpDevSkeleton.h Header and source files for the XglDpDev object. This object
[Link] corresponds to the XGL window raster and creates the
XglDpCtx objects.
DpCtx2dSkeleton.h Header and source files for the 2D and 3D XglDpCtx objects.
[Link] These objects are created by the XglDpDev object once for
DpCtx3dSkeleton.h every XGL context-raster association. The XglDpCtx objects
[Link] contain the interfaces for the 2D and 3D primitives.
PixRectSkeleton.h Header and source files for a device-specific PixRect object.
[Link] Memory mapped devices do not need this object. If the device
is not memory mapped, or only one buffer can be accessed at a
time, this object is needed for pixel rendering.
[Link] Source files that contain the rendering routines for LI-3
[Link] primitives.
[Link] Source files that contain the LI-1 raster functions..
[Link]
[Link] Source file for an LI-2 accelerated polygon renderer.
[Link] Source file for an LI-1 accelerated multipolyline renderer.
This chapter describes how to build the reference XGL device pipelines
provided with the XGL DDK product. Although building the reference
pipelines is not required, you may want to build one or more pipelines to
check that the DDK product and the compilers have been properly installed.
7
2
Table 2-1 XGL Reference Pipelines (Continued)
Software Prerequisites
Before you build the XGL reference pipelines, you must have the Solaris
environment installed. In addition, the XGL runtime and XGL SDK packages
must be installed. If these packages have been installed to the default locations,
you can determine whether the necessary files are available as follows:
• For the XGL runtime [Link], check the directory
/opt/SUNWits/Graphics-sw/xgl/lib.
• For the XGL SDK include files xgl*h, check the directory
/opt/SUNWsdk/sdk_2.5.1/xgl.
Note – The cg6 pipeline depends on header files that are included in the
Solaris Sample Device Drivers package (SUNWDrvs). This package must be
installed on your system before the cg6 pipeline can be built.
Note – In Solaris 2.5.1, the XGL include files do not reside in the same directory
as the runtime binary. However, a symbolic link from
/opt/SUNWits/Graphics-sw/xgl/include/xgl to
/opt/SUNWsdk/sdk_2.5.1/xgl/include/xgl is created when the SDK
packages are installed. As a result, the XGLHOME environment variable works
as in previous releases.
Space Requirements
The reference pipelines can require up to 4 Mbytes of disk space, depending on
the number of pipelines you build. Table 2-2 shows the approximate amount of
space needed for each pipeline.
Pipeline Size
mem 305K
cfb 272K
cg6 2.3 Mbtyes
cgm 580K
p9000 500K
p9100 500K
% cd <DDK_DIR>
% bin/setup_links
7. In the file mk_cc_defs.include, edit the lines CC5 and CCC5 for the
appropriate hardware architecture so that the macros point to the location
of the ANSI C compiler and C++ compiler on your system.
For example, on SPARC hardware running in the Solaris 2.x environment,
you edit the lines as follows:
CC5-sparc = /opt/SUNWspro/SC2.0.1/acc
CCC5-sparc = /opt/SUNWspro/SC2.0.1/CC
If no “Fatal Error” messages are displayed, the pipeline builds are complete.
This chapter describes how to modify the skeleton source files provided with
the XGL DDK product to create a pixel-level XGL graphics handler for your
hardware device.
To facilitate LI-3 implementation, the XGL GPI provides a utility object called
RefDpCtx. The RefDpCtx object contains non-optimized implementations of all
the LI-3 routines and several LI-1 routines. RefDpCtx writes to the hardware
via one or more pixel objects called PixRects. A PixRect object is an abstraction
of a buffer managed by the device, for example, the image buffer, Z-buffer, or
accumulation buffer. PixRects represent the frame buffer pixel values to
RefDpCtx. The PixRect object has methods to read and write pixels to the
device, and RefDpCtx uses these methods to set pixel values on the device.
Your pipeline needs PixRects for the image buffer for a 2D pipeline, and for the
image buffer, Z-buffer, and accumulation buffer for a 3D pipeline. The type of
PixRect that you use to represent a particular buffer reflects your hardware. In
13
3
order to implement your graphics handler, you need to know the
characteristics of your hardware. In particular, before you can write an LI-3
implementation with RefDpCtx, you must determine whether your hardware
is memory-mapped and whether the Z-buffer and accumulation buffer are
supported in hardware or handled in software.
When a pixel-level graphics handler uses RefDpCtx for rendering, all geometry
and scan conversion functions are performed in the XGL software pipeline.
The software pipeline returns LI-3 vector and span data, which the RefDpCtx
object converts to pixel values. The device pipeline only accesses the hardware
to read and write single pixel values.
Implementing LI-3 using RefDpCtx is a simple, quick way to port XGL to your
hardware. Although rendering is slow, RefDpCtx provides complete coverage
of functionality, as it supports texture mapping, blending, and transparency.
Your XGL graphics handler will probably accelerate some primitives at the LI-1
and LI-2 layers, but implementing the LI-3 layer through the RefDpCtx object
is an easy way to begin porting XGL to your hardware.
The remainder of this chapter shows you how to complete these tasks.
where:
• <COMPANY NAME> is a 4-letter capitalized abbreviation for the company
that implements the device pipeline.
• <device name> is the abbreviated name of the device, which should be an
abbreviated form of the name of the corresponding kernel device driver
located in the /dev directory.
• <major version> is the major release number of the DDK associated with the
particular release of XGL that is compatible with this device pipeline.
For example, a Sun Microsystems Cg6 device pipeline for version 4 of the XGL
GPI is named [Link].4, where SUNW is the company symbol, cg6 is
the device name, and 4 is the major version number. For your pipeline, you
only need to choose a company name and device name. The xgl and version
number portions of the graphics handler name are added automatically by the
Makefile.
<DDK_DIR>/bin/convert_skeleton [My_pipeline]
3. To check that your pipeline builds, execute the make opt command.
The make opt command creates the objs directory for the skeleton pipeline
object files and compiles and links the pipeline.
If the new pipeline builds without errors, you are ready to begin modifying the
skeleton files for your pipeline.
Note – In the remainder of this guide, skeleton pipeline refers to your pipeline.
LIB_NAME = xglSYMBOLskeleton
domain “xglSYMBOLskeleton”
msgid “SYMBOLskeleton-1”
msgid “SYMBOLskeleton-2”
Table 3-1 shows which skeleton device pipeline files require modification and
which are provided ready to use. For more information on the device pipeline
interface objects, see the XGL Device Pipeline Porting Guide. Comments in the
skeleton source files provide information on how the skeleton pipeline
implements these objects.
Tip ➼ If your hardware has a hardware Z buffer, but you want to get your port
working quickly, leave the hwZBuffer variable set to FALSE to use the
software pipeline Z buffer.
Tip ➼ You may want to implement acceleration on your device before updating
the values in inquire(). Be sure to update this routine; one way that
applications know how to use your hardware is by checking the values
returned in xgl_inquire().
Setting up PixRect support in the skeleton pipeline has been designed so that
you only have to:
• Set Boolean variables that indicate whether your hardware image buffer or
Z buffer are memory mapped, and set additional Boolean variables that
indicate whether your device has a hardware Z buffer or accumulation
buffer. You should have already set these Boolean values in the
[Link] file.
• Set the hardware address for the image buffer, and, if applicable, for a
hardware Z buffer or hardware accumulation buffer. Where you set these
addresses depends on whether your hardware is memory mapped or not.
♦ To associate the frame buffer PixRect with your device, edit the
[Link] constructor to set the fb_address variable to the base
address of your frame buffer.
The DpMgrSkeleton class constructor uses Xlib calls to get the height and
width of your frame buffer and the depth of the window. In
[Link], the XglPixRectMemAssigned method reassign()
initializes this PixRect with the correct information for your hardware.
1. Override the setValue() method with code to write the value of a single
pixel to the screen.
3. If both the image buffer and the Z buffer are non-memory-mapped, edit
the validateBuffer() method to set the hardware registers to the
appropriate buffer.
When both the image buffer and Z buffer are not memory-mapped,
validateBuffer() determines whether the image buffer or Z buffer is the
current buffer and sets the hardware registers to the appropriate buffer. The
setValue() and getValue() methods then render to or read from the
correct buffer.
4. If your frame buffer is more than 32 bits deep, override the methods
getValueByPointer() and setValueByPointer().
You can also run the Denizen Test Suite provided with the XGL DDK product.
The Denizen Test Suite is a set of verification programs that enables you to test
the accuracy of your implementation. Denizen is a set of shell scripts and C
programs that uses the XGL library to render objects and evaluate results. It
creates a log of events, errors, and failures that can be compared to logs
provided by XGL.
The Denizen Test Suite is installed from the DDK CD. Its default installation
location is /opt/SUNWddk/ddk_2.5.1/xgl/src/test_suite/denizen.
This directory contains reference images used for comparison testing,
documentation on the test programs, and the run_denizen.sh shell script
that executes the Denizen test suite. The README file contains information on
run_denizen.sh.
For more detailed information on running Denizen and comparing test results,
see the XGL Test Suite User’s Guide.
You should now be able to render pixels to your hardware using the RefDpCtx
utility object. If pixel rendering is working, you are ready to implement
accelerated renderers on your device. This chapter discusses the
implementation of accelerated primitives. It also presents information on
design issues to consider when implementing your pipeline
.....
opsVec[XGLI_LI1_MULTIMARKER] = XGLI_OPS(XglDpCtx3d::li1MultiMarker);
opsVec[XGLI_LI1_MULTIPOLYLINE] = XGLI_OPS(XglDpCtx3d::li1MultiPolyline);
.....
opsVec[XGLI_LI_OBJ_SET] = XGLI_OPS(XglDpCtx3d::objectSet);
opsVec[XGLI_LI_MSG_RCV] = XGLI_OPS(XglDpCtx3d::messageReceive);
When the device pipeline is instantiated, its XglDpCtx object contains a set of
opsVec array pointers specific to the device. In its version of the array, the
device pipeline overrides some or all of the LI-1 and LI-2 entries to install
25
4
function pointers to its own accelerated renderers. Renderers that are not
overriden remain set to the default software pipeline renderers. The device
pipeline must fill in pointers to LI-3 functions, since these routines are device
dependent and not provided by XGL.
The device pipeline can set opsVec entries at object creation or at any time
during program execution. Installing opsVec array entries during program
execution is usually a result of attribute changes and can be done from the
objectSet() routine. As an example, the skeleton pipeline sets opsVec array
entries by doing the following:
In your implementation, you will set the opsVec array entries to your
accelerated renderers. For some primitives, you may want to have a pair of
renderers as shown in the skeleton pipeline. For other renderers, you may need
a family of renderers to handle optimized cases of attributes or point types.
The sections that follow describe the implementation of the skeleton renderers
in detail. If you plan to implement accelerated rendering at the LI-1 layer, read
the section on LI-1 multipolyline on page 35; if your hardware is suited for LI-2
acceleration, read the section on LI-2 polygon on page 29. How you modify the
skeleton code will vary depending on your implementation.
The following steps take you through the sections of these routines in detail
and examine the kinds of modifications you might need to make to implement
them for your hardware.
Note – At the LI-2 level, data is given to device pipelines under the control of
the XglPrimData object. At LI-2, the software pipeline has performed LI-1
processing and stored the API data internally in XglLevel format. The LI-2
device pipeline must extract point and facet data from the XglLevel object. The
skeleton pipeline provides an example of the use of the XglLevel methods. For
more information on how the software pipeline stores data and on the methods
the device pipeline can use to extract this data, see the XGL Device Pipeline
Porting Guide.
// Lock window.
WIN_LOCK(drawable) ;
if (drawable->windowIsObscured()) {
WIN_UNLOCK(drawable) ;
return; // Window is obscured; don’t render
}
④ Xgl_boolean accelerate =
(surfFrontFillStyle == XGL_SURF_FILL_SOLID) &&
For your implementation, consider what point types and facet types the
hardware can accelerate. Then modify statement 1 as needed so that your
pipeline corresponds with the capabilities of your hardware. For
information on the complete set of XGL data types, see the XGL Reference
Manual.
If your hardware has only one hardware context, use this statement to keep
track of context switches. If your hardware has multiple hardware contexts,
you may want to associate each hardware context with an XGL Context. In
this case, you do not need to check for context changes. Note, however, that
some applications may define many XGL Context objects, so you may want
to monitor context changes even if your hardware has multiple contexts.
Modify this section if you implement other values for these attributes. For
example, if your hardware handles fill styles, your pipeline should check the
fill attributes. If your hardware handles the ROP mode XOR, your renderer
should check the ROP attributes.
if (!accelerate) {
// Unlock window.
WIN_UNLOCK(drawable);
return;
}
// Unlock window.
WIN_UNLOCK(drawable);
Note – In your implementation, you can call the software pipeline directly as
swp->li2GeneralPolygon(pd) rather than through the opsVec array.
In your implementation, add code in the fast renderer to send data to the
hardware. Note that the skeleton renderer does not handle surface edges. An
example of how to access LI-2 edge flag data in a renderer that supports edges
is provided in the [Link] comments.
WIN_UNLOCK(localDrawable);
li2GeneralPolygon(pd);
return;
}
Xgl_pt_i2d *pts;
Xgl_sgn32 num_pts; // Number of points
Xgl_usgn32 num_pl = level->getNumPointLists();
Xgl_sgn32 pt_size = pt_list->geom_ptr.step_size;
pts = (Xgl_pt_i2d*)pt_list[i].geom_ptr.base_ptr;
flags = (Xgl_usgn32*)pt_list[i].flag_ptr.base_ptr;
// my_hw = BEGINNING_OF_POLYGON
for (Xgl_usgn32 j = 0; j < num_pts; j++) {
} // end for(j)
} // end for(i)
// Unlock window
WIN_UNLOCK(localDrawable);
}
1. Modify the routine to add your renderer. You can uncomment the following
line in objectSet():
// opsVec[XGLI_LI2_POLYGON = XGLI_OPS(XglDpCtx2dSkeleton::li2GeneralPolygon);
2. Add code to the objectSet() routine to update your hardware context for
all the XGL Context attributes that your pipeline is concerned with.
The routine retrieves the current attribute values and sends them to the
hardware. It also sets a flag, li2_generalpolygon_change_renderer,
that indicates whether the generic renderer should be reinstalled.
When you have made these changes, your implementation of the skeleton 2D
polygon renderers is complete. Use the Denizen test suite to test your
implementation.
The following steps take you through the sections of these routines in detail
and examine the kinds of modifications you might need to make to implement
them for your hardware.
// Lock window.
WIN_LOCK(drawable) ;
if (drawable->windowIsObscured()) {
WIN_UNLOCK(drawable) ;
return; // Window is obscured.
}
④ Xgl_boolean accelerate =
(lineStyle == XGL_LINE_SOLID) &&
(ctx->getRop() == XGL_ROP_SRC) &&
(ctx->getPlaneMask() == (Xgl_usgn32)-1) &&
(ctx->getDepthCueMode() == XGL_DEPTH_CUE_OFF) &&
(cur_stroke->getAaBlendEq() == XGL_BLEND_NONE)&&
(cur_stroke->getAaFilterShape() == XGL_FILTER_GAUSSIAN) &&
(cur_stroke->getAaFilterWidth() == 1) &&
For your implementation, consider what point types your hardware can
accelerate. Then modify statement 1 as needed so that your pipeline
corresponds with the capabilities of your hardware. For information on the
complete set of XGL data types, see the XGL Reference Manual.
If your hardware has only one hardware context, use this statement to keep
track of context switches. If your hardware has multiple hardware contexts,
you may want to associate a hardware context with an XGL Context. In this
case, you do not need to check for context changes. Note, however, that
some applications may define many XGL Context objects, so you may want
to monitor context changes even if your hardware has multiple hardware
contexts.
Modify this section if you implement other values for these attributes. For
example, if your hardware handles line patterns, your pipeline will be
concerned with the line pattern attributes.
The last section of li1MultiPolyline sets the opsVec entry to the fast
renderer, if acceleration is possible, or calls the software pipeline if acceleration
is not possible. The routine also determines whether model clipping is enabled.
If so, it sets the opsVec entry to the li1MplineMC routine, which uses the
XgliUtModelClipMpline utility to model clip the application data and calls
li1MplineRenderer to perform the rendering. If your hardware doesn’t
handle model clipping, you can use the XgliUtModelClipMpline utility to
do model clipping in software. The utility returns model clipped data.
The opsVec entry remains set to the software pipeline or the fast renderer
until an attribute changes. At that time, the objectSet routine sends the
attribute changes to the hardware and reinstalls the generic renderer in the
opsVec array. After an attribute change, the next time rendering occurs, the
generic renderer again tests for changes, and determines which renderer to call.
if (!accelerate) {
WIN_UNLOCK(drawable);
return;
}
WIN_UNLOCK(drawable) ;
}
Note – In your implementation, you can call the software pipeline directly as
swp->li1MultiPolyline() rather than through the opsVec array.
In your implementation, add code in the fast renderer to send the application
data to the hardware.
if (!api_pt_list |
(int)dpMgr->lastDpCtx - (int)this |
api_pt_list->pt_type - lastPtTypeInfo.pt_type |
float *pts;
Xgl_sgn32 num_pts;
Xgl_sgn32 pt_size = lastPtTypeInfo.pt_size;
pts = (float*)api_pt_list[i].pts.f3d;
// my_hw = BEGINNING_OF_MULTIPOLYLINE
for (Xgl_usgn32 j = 0; j < num_pts; j++) {
} // end for(j)
} // end for(i)
WIN_UNLOCK(localDrawable);
}
1. Modify the routine to add your renderer. You can simply uncomment the
following line in the skeleton pipeline objectSet():
// opsVec[XGLI_LI1_MULTIPOLYLINE =
XGLI_OPS(XglDpCtx3dSkeleton::li1MultiPolyline);
2. Add code to the objectSet() routine to update your hardware context for
all the XGL Context attributes that your pipeline is concerned with.
The routine retrieves the current attribute values and sends them to the
hardware. It also sets a flag, li1_multipolyline_change_renderer,
that indicates whether the generic renderer should be reinstalled.
When you have made these changes, your implementation of the skeleton 3D
polygon renderers is complete. Use the Denizen test suite to test your
implementation.
This appendix shows hardware initialization code for a GX frame buffer. The
file consists of include files and the constructor for the XglDpMgr object for
the GX frame buffer.
Note – If you are running on a GX frame buffer, and you built the GX reference
pipeline [Link].4 , and you want to build your pipeline using the
GX intialization code listed below, you need to rename the cg6 binary
[Link].4 and link your pipeline to the cg6 name using the
command ln -s [Link].4 [Link].4.
// **********************************************************
// *
// * Filename:[Link]
// *
// * Purpose:This is a C++ source file that contains a routine
// * used to initialize a physical hardware device managed by
// * the Dp manager and a routine that creates a Dp device object.
// *
// **********************************************************
#include “xgli/Drawable.h”
#include “xgli/SysState.h”// for XGLI_ERROR()
#include “DpMgrGXexample.h”
43
A
#include “DpDevGXexample.h”
#include <sysent.h>
#include <sys/mman.h>
#include <sys/cg6reg.h>
const int MegaByte = 0x100000;
class XglDpDev;
class XglRasterWin;
// *------------------------------------------------------
// *
// * XglDpMgrGXexample::XglDpMgrGXexample
// *
// * The constructor for the Dp manager object is called when
// * a new DpMgr object is created by the DpLib. This is done
// * once per physical device that is accessed.
// * Use this routine to initialize your hardware and to store
// * device-specific information.
// *
// *-------------------------------------------------------
XglDpMgrGXexample::XglDpMgrGXexample(XglDrawable* drawable)
{
creationOk = TRUE; // flag indicating successful hardware
// initialization. Default value is TRUE
//
// File descriptor or device name for opening your device.
//
int fd = drawable->getDevFd();
const char* name = drawable->getDeviceName();
hwZBuffer = FALSE;
hwAccumBuffer = FALSE;
if(gx_base_addr == (Xgl_usgn8*)-1) {
XGLI_DI_ERROR( (XglSysState*)NULL, “di-6”, XGL_OBJ,
NULL, NULL);
creationOk = FALSE;
return;
}
// ^^^^^^^^^^^^^^^^^^ GX example ^^^^^^^^^^^^^^^^^^
//
// End hardware initialization here
//=======================================================
//=======================================================
//
// FOR MEMORY-MAPPED FRAME BUFFERS:
// This section begins the initialization of the RefDpCtx
// tilitisy for memory-mapped frame buffers. If your frame
// buffer is not memory-mapped, you can ignore or delete
// this section.
//
Xgl_usgn32linebytes; // # bytes from one scan line to next
Xgl_usgn32fb_width; // Frame buffer width
Xgl_usgn32fb_height; // Frame buffer height
//=========================================================
//=========================================================
// EDIT HERE:
// If image buffer is memory mapped, set fb_address to
// the base address of the image buffer; otherwise,
// leave as NULL.
// If z buffer is memory mapped, set z_buffer_address to
// the base address of the z buffer; otherwise, leave as NULL.
//
// vvvvvvvvvvvvvvvvvv GX example vvvvvvvvvvvvvvvvvv
Xgl_usgn8*fb_address = gx_base_addr;
// ^^^^^^^^^^^^^^^^^^ GX example ^^^^^^^^^^^^^^^^^^
Xgl_usgn8*z_buffer_address = NULL;
//========================================================
//========================================================
// X11 attributes
Xgl_X_window user_win;
XWindowAttributes wattrs;
Window window;
Display* dpy;
intscreen;
//
// If image and/or Z buffer is memory mapped, this initializes the
// XglPixRectMemAssigned class. The PixRect object is
// instantiated by the DpDevGXexample class.
//
if (memoryMappedImageBuffer)
[Link](fb_address, fb_width, fb_height,
[Link], linebytes);
if (memoryMappedZBuffer)
[Link](z_buffer_address, fb_width, fb_height,
[Link], linebytes);
} // End of XglDpMgrGXexample::XglDpMgrGXexample