Basic Functions

Driver device management and hardware initialization / shutdown.

Summary
Basic FunctionsDriver device management and hardware initialization / shutdown.
Static functions
Device management
d2_getversionstringQuery versionID string (device independent)
d2_getversionQuery versionID (device independent)
d2_opendeviceCreate a new device handle.
d2_closedeviceDestroy a device handle.
d2_geterrorQuery device error information.
d2_geterrorstringQuery detailed device error information.
d2_inithwInitialize hardware for working with specified device.
d2_deinithwUnlink hardware currently bound by specified device.
d2_inithwburstlengthlimitSet the maximum burst lenght of the master bus interfaces.
d2_level1interfaceGet the lowlevel device handle currently used by the d2_device.
d2_getrevisionhwQuery hw revisionID.
d2_getrevisionstringhwQuery hw revisionID string.
d2_lowlocalmemmodeEnable and configure the ‘low localmem’ mode.
Rendering Mode
d2_selectrendermodeSelect a rendering mode.
d2_getrendermodeGet the rendering mode.
d2_layermergeJoin outline and solid parts of currently selected renderbuffer.
d2_outlinewidthDefine the width of geometry outlines.
d2_shadowoffsetDefine the offset of geometry shadows.
Utility Functions
d2_flushframeWait for current rendering to end.
d2_setdlistblocksizeSet blocksize for default displaylists.
d2_getdlistblocksizeGet blocksize of default displaylist.
d2_getdlistblockcountGet number of blocks of default displaylist (writelist).
d2_commandspendingCheck if there are pending commands in the current displaylist.

Static functions

Device management

d2_getversionstring

const d2_char * d2_getversionstring(void)

Query versionID string (device independent)

returns

human readable driver version as a string.

see also

d2_getversion

d2_getversion

d2_s32 d2_getversion(void)

Query versionID (device independent)

returns

driver revision as a single 32bit integer

bits 31..24branch number
bits 23..16major version number
bits 15..0minor version number

see also

d2_getversionstring

d2_opendevice

d2_device * d2_opendevice(d2_u32 flags)

Create a new device handle.

A device is the basic software object.  It contains references to objects that the drawing engine requires, (e.g.: displaylists).  All 2D drawing functions require such a device pointer as first parameter.

A device on its own is useless, unless bound to a physical hardware (i.e.: Drawing Engine).  The binding is done by the function d2_inithw.  A hardware instance can only be mapped to one device object.  It is not possible to share a single device pointer between different processes.

Creating a device will never fail (sufficient memory assumed) but binding it to a hardware (see: d2_inithw) can fail.

parameters

flagsa bitfield containing flags

flags

d2_df_no_dlistdon’t use a display list (slower single command mode)
d2_df_no_irqdon’t use an interrupt (slower polling used instead)
d2_df_no_fbcachedisable framebuffer cache (attention: see note below)
d2_df_no_texcachedisable texture cache (attention: see note below)
d2_df_no_dwcleardisable double word clearing in d2_clear
d2_df_no_registercachingdon’t use register caching
d2_df_no_blitctxbackupdon’t backup context data at blit for better performance; previous texture modes get lost and must be set again

note

Flags ‘d2_df_no_fbcache’ and ‘d2_df_no_texcache’ should only be used for debugging purposes.  Especially when multithreading is used, these flags must not be set different for devices which are bound to the same hardware instance through d2_inithw.

returns

device pointer or NULL if not enough memory was available

d2_closedevice

d2_s32 d2_closedevice(d2_device *handle)

Destroy a device handle.

All contexts associated with the device are destroyed as well.

parameters

handledevice pointer (see: d2_opendevice)

returns

errorcode (D2_OK if successfull) see list of Errorcodes for details

d2_geterror

d2_s32 d2_geterror(const d2_device *handle)

Query device error information.

See list of all Errorcodes for more details.

parameters

handledevice pointer (see: d2_opendevice)

returns

integer error code (0 is no error)

d2_geterrorstring

const d2_char * d2_geterrorstring(const d2_device *handle)

Query detailed device error information.

See list of all Errorcodes for more details.

parameters

handledevice pointer (see: d2_opendevice)

returns

string with human readable error description, or 0 if an error occurs

d2_inithw

d2_s32 d2_inithw(d2_device *handle,
d2_u32 flags)

Initialize hardware for working with specified device.  After creation a device is ‘bound’ to a hardware instance by calling inithw for this device.  A single device cannot work with multiple hardware units.

parameters

handledevice pointer (see: d2_opendevice)
flagshardware instance id (use 0 for default)

returns

errorcode (D2_OK if successfull) see list of Errorcodes for details

d2_deinithw

d2_s32 d2_deinithw(d2_device *handle)

Unlink hardware currently bound by specified device.  Hardware must be deinitialized before it can be reinitalized for another device.

parameters

handledevice pointer (see: d2_opendevice)

returns

errorcode (D2_OK if successfull) see list of Errorcodes for details

d2_inithwburstlengthlimit

d2_s32 d2_inithwburstlengthlimit(d2_device *handle,
d2_busburstlength burstlengthFBread,
d2_busburstlength burstlengthFBwrite,
d2_busburstlength burstlengthTX,
d2_busburstlength burstlengthDL)

Set the maximum burst lenght of the master bus interfaces.  Changing the burst length limit should be done only when Dave completely is in idle mode and all bus transfers are finished.

parameters

handledevice pointer (see: d2_opendevice)
burstlengthFBreadmax burst length of framebuffer read interface
burstlengthFBwritemax burst length of framebuffer write interface
burstlengthTXmax burst length of texture cache read interface
burstlengthDLmax burst length of displaylist read interface

d2_busburstlength

d2_bbl_1single cycle bus access
d2_bbl_2max bus burst length = 2
d2_bbl_4max bus burst length = 4
d2_bbl_8max bus burst length = 8
d2_bbl_16max bus burst length = 16
d2_bbl_32max bus burst length = 32

returns

errorcode (D2_OK if successfull) see list of Errorcodes for details

d2_level1interface

d1_device * d2_level1interface(const d2_device *handle)

Get the lowlevel device handle currently used by the d2_device.  This is necessary e.g. for allocating framebuffers using the lowlevel (d1_) interface.

parameters

handledevice pointer (see: d2_opendevice)

returns

handle for lowlevel device, or NULL if an error occurs

d2_getrevisionhw

d2_u32 d2_getrevisionhw(const d2_device *handle)

Query hw revisionID.  This information is available after calling d2_inithw.

parameters

handledevice pointer (see: d2_opendevice)

returns

HW Revision ID

HW Revision ID structure

Bit[7..0]revision number
Bit[11..8]branch number
Bit[15..12]D/AVE Type
Bit[20..16]Features

D/AVE Type

0D/AVE2DT-S
1D/AVE2DT-L

Feature bits

Bit[16]D2FB_SWDAVE (Software D/AVE)
Bit[17]D2FB_DLR (DisplayListReader available)
Bit[18]D2FB_FBCACHE (Framebuffer Cache available)
Bit[19]D2FB_TXCACHE (Texture Cache available)
Bit[20]D2FB_PERFCOUNT (Two performance counters available)
Bit[21]D2FB_TEXCLUT (Color Lookup Table for ai44 format)
Bit[22]D2FB_FBPREFETCH (frame buffer cache prefetch available)
Bit[23]D2FB_RLEUNIT (RLE unit available)
Bit[24]D2FB_TEXCLUT256 (256 entry CLUT available)
Bit[25]D2FB_COLORKEY (color keying available)
Bit[26]D2FB_HILIMITERPRECISION (limiter high precision mode available)
Bit[27]D2FB_ALPHACHANNELBLENDING (alpha channel blending available)

see also

d2_getrevisionstringhw

d2_getrevisionstringhw

const d2_char * d2_getrevisionstringhw(const d2_device *handle)

Query hw revisionID string.  This information is available after calling d2_inithw.

parameters

handledevice pointer (see: d2_opendevice)

returns

human readable hw revision string, or 0 if an error occurs (e.g.  “D/AVE 2DT-S, Revision 1.05, Features: DLR FBCACHE”).

see also

d2_getrevisionhw

d2_lowlocalmemmode

d2_s32 d2_lowlocalmemmode(d2_device *handle,
d2_u32 dlistblockfactor,
d2_u32 dlistblocks)

Enable and configure the ‘low localmem’ mode.

On systems with low local CPU memory, the display lists can not be completely assembled in the local memory.  A special mode is used in this case, which assembles small display list blocks in the local memory and copies them to the video memory, where they are concatenated to larger blocks.  In order to use this mode it is necessary to call d2_lowlocalmemmode directly after d2_opendevice and before d2_inithw.

Querying the number of effectively used display list blocks can be done using d2_getdlistblockcount, which gives the number of display list blocks used so far (in units of the local display list block size).  The application developer must take care that the maximum display list size configured using d2_lowlocalmemmode is sufficient.

parameters

handledevice pointer (see: d2_opendevice)
dlistblockfactorsize of a dlist block in vidmem is this factor * local size (configurable using d2_setdlistblocksize)
dlistblocksmaximum number of dlist blocks in vidmem

returns

errorcode (D2_OK if successful) see list of Errorcodes for details

see also

d2_setdlistblocksize

Rendering Mode

d2_selectrendermode

d2_s32 d2_selectrendermode(d2_device *handle,
d2_u32 mode)

Select a rendering mode.  Dave can automatically generate and render geometry outlines and shadows.  A different rendering context is used for interior (solid context) and addons (outline context) so that both parts can have entirely different materials.

Note that primitives which are issued while rendermode ‘postprocess’ is active are buffered and put into the commandlist after all normal commands.  Combined rendermodes like ‘solid_outlined’ and ‘solid_shadow’ internally use postprocessing to sort solid and outline parts.

parameters

handledevice pointer (see: d2_opendevice)
moderendering mode

available rendering modes

d2_rm_solidDirect rendering of primitives (default mode)
d2_rm_outlineOnly outlines are rendered
d2_rm_solid_outlinedInterior and outlines are rendered
d2_rm_shadowOnly shadows are rendered
d2_rm_solid_shadowInterior and shadows are rendered
d2_rm_postprocessDirect rendering of primitives as a postprocess

returns

errorcode (D2_OK if successfull) see list of Errorcodes for details

see also

d2_outlinewidth, d2_shadowoffset

d2_getrendermode

d2_u32 d2_getrendermode(const d2_device *handle)

Get the rendering mode.  This function can be used to get the rendering mode used for a specified d2_device.

parameters

handledevice pointer (see: d2_opendevice)

available rendering modes

d2_rm_solidDirect rendering of primitives (default mode)
d2_rm_outlineOnly outlines are rendered
d2_rm_solid_outlinedInterior and outlines are rendered
d2_rm_shadowOnly shadows are rendered
d2_rm_solid_shadowInterior and shadows are rendered
d2_rm_postprocessDirect rendering of primitives as a postprocess

returns

integer specifying the rendering mode, or 0 if an error occurs

d2_layermerge

d2_s32 d2_layermerge(d2_device *handle)

Join outline and solid parts of currently selected renderbuffer.  When using rendermode d2_rm_postprocess (see: d2_selectrendermode) the postprocess buffer can be flushed using a call to d2_layermerge.

parameters

handledevice pointer (see: d2_opendevice)

returns

errorcode (D2_OK if successfull) see list of Errorcodes for details

see also

d2_selectrendermode

d2_outlinewidth

d2_s32 d2_outlinewidth(d2_device *handle,
d2_width width)

Define the width of geometry outlines.  Used only when using outline or solid_outlined rendering modes.

parameters

handledevice pointer (see: d2_opendevice)
widthoutline width in pixels (fixedpoint)

returns

errorcode (D2_OK if successfull) see list of Errorcodes for details

see also

d2_selectrendermode, d2_shadowoffset

d2_shadowoffset

d2_s32 d2_shadowoffset(d2_device *handle,
d2_point x,
d2_point y)

Define the offset of geometry shadows.  Used only when using shadow or solid_shadow rendering modes.

parameters

handledevice pointer (see: d2_opendevice)
xx axis offset in pixels (fixedpoint)
yy axis offset in pixels (fixedpoint)

returns

errorcode (D2_OK if successfull) see list of Errorcodes for details

see also

d2_selectrendermode, d2_outlinewidth

Utility Functions

d2_flushframe

d2_s32 d2_flushframe(d2_device *handle)

Wait for current rendering to end.

Function will not return until the hardware has finished executing all currently active rendering operations.  Note that no rendering operations are started until a renderbuffer is executed.  (See Render Buffers)

parameters

handledevice pointer (see: d2_opendevice)

returns

errorcode (D2_OK if successfull) see list of Errorcodes for details

d2_setdlistblocksize

d2_s32 d2_setdlistblocksize(d2_device *handle,
d2_u32 size)

Set blocksize for default displaylists.

Sets the number of displaylist entries per block (aka page).  The value given is effectively used for internal calls to d2_newrenderbuffer as both ‘initialsize’ and ‘stepsize’.  For hints on how to optimize this size see documentation of d2_newrenderbuffer.

The default blocksize is: 204

parameters

handledevice pointer (see: d2_opendevice)
sizenumber of displaylist entries per block (minimum is 3)

returns

errorcode (D2_OK if successful) see list of Errorcodes for details

note

The minimum number of displaylist entries per block is 3.  This limitation is required to terminate a list correctly, there must be enough space to insert a dlist jump and a special termination entry.

see also

d2_getdlistblocksize, d2_newrenderbuffer

d2_getdlistblocksize

d2_u32 d2_getdlistblocksize(const d2_device *handle)

Get blocksize of default displaylist.

Function will return the number of displaylist entries per block

parameters

handledevice pointer (see: d2_opendevice)

returns

number of displaylist entries per block, or 0 if an error occurs

see also

d2_setdlistblocksize, d2_newrenderbuffer

d2_getdlistblockcount

d2_u32 d2_getdlistblockcount(d2_device *handle)

Get number of blocks of default displaylist (writelist).

Function will return the number of used blocks for current displaylist

parameters

handledevice pointer (see: d2_opendevice)

returns

number of used blocks

see also

d2_setdlistblocksize, d2_newrenderbuffer

d2_commandspending

d2_s32 d2_commandspending(d2_device *handle)

Check if there are pending commands in the current displaylist.

parameters

handledevice pointer (see: d2_opendevice)

returns

boolean value: true when there are commands pending, also 0 if an error occurs

see also

d2_getdlistblockcount

const d2_char * d2_getversionstring(void)
Query versionID string (device independent)
d2_s32 d2_getversion(void)
Query versionID (device independent)
d2_device * d2_opendevice(d2_u32 flags)
Create a new device handle.
d2_s32 d2_closedevice(d2_device *handle)
Destroy a device handle.
d2_s32 d2_geterror(const d2_device *handle)
Query device error information.
const d2_char * d2_geterrorstring(const d2_device *handle)
Query detailed device error information.
d2_s32 d2_inithw(d2_device *handle,
d2_u32 flags)
Initialize hardware for working with specified device.
d2_s32 d2_deinithw(d2_device *handle)
Unlink hardware currently bound by specified device.
d2_s32 d2_inithwburstlengthlimit(d2_device *handle,
d2_busburstlength burstlengthFBread,
d2_busburstlength burstlengthFBwrite,
d2_busburstlength burstlengthTX,
d2_busburstlength burstlengthDL)
Set the maximum burst lenght of the master bus interfaces.
d1_device * d2_level1interface(const d2_device *handle)
Get the lowlevel device handle currently used by the d2_device.
d2_u32 d2_getrevisionhw(const d2_device *handle)
Query hw revisionID.
const d2_char * d2_getrevisionstringhw(const d2_device *handle)
Query hw revisionID string.
d2_s32 d2_lowlocalmemmode(d2_device *handle,
d2_u32 dlistblockfactor,
d2_u32 dlistblocks)
Enable and configure the ‘low localmem’ mode.
d2_s32 d2_selectrendermode(d2_device *handle,
d2_u32 mode)
Select a rendering mode.
d2_u32 d2_getrendermode(const d2_device *handle)
Get the rendering mode.
d2_s32 d2_layermerge(d2_device *handle)
Join outline and solid parts of currently selected renderbuffer.
d2_s32 d2_outlinewidth(d2_device *handle,
d2_width width)
Define the width of geometry outlines.
d2_s32 d2_shadowoffset(d2_device *handle,
d2_point x,
d2_point y)
Define the offset of geometry shadows.
d2_s32 d2_flushframe(d2_device *handle)
Wait for current rendering to end.
d2_s32 d2_setdlistblocksize(d2_device *handle,
d2_u32 size)
Set blocksize for default displaylists.
d2_u32 d2_getdlistblocksize(const d2_device *handle)
Get blocksize of default displaylist.
d2_u32 d2_getdlistblockcount(d2_device *handle)
Get number of blocks of default displaylist (writelist).
d2_s32 d2_commandspending(d2_device *handle)
Check if there are pending commands in the current displaylist.
List of all dave driver errorcodes.
Renderbuffers (similar in concept to OpenGL display lists) are the main interface between driver and hardware.
d2_renderbuffer * d2_newrenderbuffer(d2_device *handle,
d2_u32 initialsize,
d2_u32 stepsize)
Create a new renderbuffer.
Close