These functions are used to control the PlayStation 2 DMA system in coexistance with RenderWare Graphics. They are exposed predominantly so that the PlayStation 2 specific parts of plugins and toolkits can be written. These function and macros replace the swe* functions and macros in versions of RenderWare Graphics previous to 3.4.
If you do not use any of the DMA functions directly (search your code for the regular expression "[Ss][Ww][Ee]") these changes should have no impact, except better memory and CPU performance.
If you need to port code that used the old functions, the following notes will help:
|
RWDMA_ADD_TO_ASYNC_PKT is used to add a quadword to a packet opened by _rwDMAAddImageUpload. |
|
RWDMA_ADD_TO_PKT is used to add a quadword to a packet opened by _rwDMAOpenGIFPkt or _rwDMAOpenVIFPkt. |
|
RWDMA_CRITICAL_SECTION_BEGIN is used to mark the beginning of a critical section in the code, for example a reference count increment. |
|
RWDMA_CRITICAL_SECTION_END is used to mark the end of a critical section in the code. |
|
RWDMA_FIXUP is passed to _rwDMAOpenVIFPkt to request a path 2 packet. |
|
RWDMA_HALF_OFFSET returns the value of the half offset required in this frame to take account of interlacing. It should be used when building values for the GS XYOFFSET registers. |
|
RWDMA_LOCAL_ASYNC_BLOCK_BEGIN can be used to make the code generated for a sequence of RWDMA_ADD_TO_ASYNC_PKT macros more efficient. The code segment should be bracketed by RWDMA_LOCAL_ASYNC_BLOCK_BEGIN and RWDMA_LOCAL_ASYNC_BLOCK_END. It works by shadowing the global packet pointer in a local variable. As such, no code that depends on the global pointer, such as calls to functions that use RWDMA_ADD_TO_ASYNC_PKT, should be used within the bracketed block. |
|
RWDMA_LOCAL_ASYNC_BLOCK_END is used to close a RWDMA_LOCAL_ASYNC_BLOCK_BEGIN code block. |
|
RWDMA_LOCAL_BLOCK_BEGIN can be used to make the code generated for a sequence of RWDMA_ADD_TO_PKT macros more efficient. The code segment should be bracketed by RWDMA_LOCAL_BLOCK_BEGIN and RWDMA_LOCAL_BLOCK_END. It works by shadowing the global packet pointer in a local variable. As such, no code that depends on the global pointer, such as calls to functions that use RWDMA_ADD_TO_PKT, should be used within the bracketed block. |
|
RWDMA_LOCAL_BLOCK_END is used to close a RWDMA_LOCAL_BLOCK_BEGIN code block. |
|
RWDMA_MOD_CHAIN indicates that source chain mode DMA should be used. |
|
RWDMA_MOD_CHAIN_TTE indicates that source chain mode with TTE DMA should be used. |
|
RWDMA_MOD_MASK is the mask used to extract the transfer mode from the _rwDMAAddPkt type argument. Interleave mode is not supported. |
|
RWDMA_MOD_NORM indicates that normal mode DMA should be used. The quad word count should be stored in the RWDMA_PKT_IMM_MASK field. |
|
RWDMA_MOD_TTE_MASK is the mask used to extract the transfer mode including the chain mode TTE bit from the _rwDMAAddPkt type argument. Interleave mode is not supported. |
|
RWDMA_PKT_CALL is used to add a call back of type rwDMACallback to the chain. When this packet is "dispatched" it will call the function specified by the address argument of _rwDMAAddPkt with interrupts disabled. |
|
RWDMA_PKT_GIF is used to request a transfer on DMA channel 2 using chain mode. |
|
RWDMA_PKT_GIF_NORM is used to request a transfer on DMA channel 2. |
|
RWDMA_PKT_IMM_MASK is the mask used to extract an immediate integer argument required by some packet types from the _rwDMAAddPkt type argument. |
|
RWDMA_PKT_IMM_MAX is the maximum immediate argument that may be specified as part of the type argument to _rwDMAAddPkt |
|
RWDMA_PKT_IMM_SHIFT is the shift required to move an integer into the RWDMA_PKT_IMM_MASK field. |
|
RWDMA_PKT_RASUREF is used to add a reference count decrement packet. When this packet is "dispatched" it will decrement the 32 bit number pointed to by the address argument of _rwDMAAddPkt by the number in the RWDMA_PKT_IMM_MASK field. If this number is 0, 1 is assumed. In general, it is better to use _rwDMAAddPURef, rather than this type. |
|
RWDMA_PKT_TYPE_MASK is the mask used to extract a packet type from the _rwDMAAddPkt type argument. |
|
RWDMA_PKT_VIF_NORM is used to request a transfer on DMA channel 1. |
|
RWDMA_PKT_VIF_TTE is used to request a transfer on DMA channel 1 using chain mode with TTE enabled. |
|
RWDMA_SPR_CPY_FROM is used to copy SIZE quad words to memory. This should only be used when channel 8 is not busy. |
|
RWDMA_SPR_CPY_TO is used to copy SIZE quad words to SPR. This should only be used when channel 9 is not busy. |
|
RWDMA_SPR_MAX_PKT_SIZE is the maximum quad word packet chunk that can be built at one time. |
|
RWDMA_SPR_WAIT_ON_FROM waits until a transfer on channel 8 completes. It assumes that interrupts on the channel are not enabled and that CIS8 was cleared before the transfer started. |
|
RWDMA_SPR_WAIT_ON_TO waits until a transfer on channel 9 completes. It assumes that interrupts on the channel are not enabled and that CIS9 was cleared before the transfer started. |
|
rwDMA_flipData holds the data used by the VSYNC handler to flip frames. The display env is updated from dc, read circuit 1 from tcaaDisp, and if non NULL, the DMA packet pointed to by dmaPkt[(rwDMAFlipId | ((DGET_GS_CSR() >> 12) & 0x2))] will be dispatched to DMA channel 2 using chain mode.
|
|
rwDMACallback is the type of the function called when a RWDMA_PKT_CALL packet is "dispatched". The function is invoked with interrupts disabled. If the callback needs to perform more work than can reasonably occur within an interrupt handler, it should raise another thread and then return FALSE.
|
|
_rwDMAAddImageUpload starts/extends a DMA channel 2 chain to permit an image upload to be performed. It also starts/extends a DMA channel 1 chain and modifies it to permit the image upload to be synchronized with the chain.
The caller is required to fill the space allocated in the channel 2 chain with suitable DMA/GIF tags using RWDMA_ADD_TO_ASYNC_PKT. Only the final GIF tag should have its EOP bit set. The function assumes that the channel 2 chain will end with a DMA cnt 2 tag followed by a GIF a+d 1 tag and a GS nop. This is important as when this chain is extended, the DMA tag needs to be overwritten.
|
|
_rwDMAAddPkt is used to add a packet to the dispatch chain. As well as data to be dispatched to a DMA channel, pseudo-packet types are also avaliable to perform reference counting, callbacks, etc. If a packet is open, it will be closed and added before the chains passed to this function.
|
|
_rwDMAAddPkt2 adds a chain-tte channel 1 DMA chain and a channel 2 chain to the dispatch list. These will be dispatched together with GS path 3 initially masked to allow interrupt free texture synchronization. If a packet is open, it will be closed and added before the chains passed to this function.
|
|
_rwDMAAddPURef is used to procrastinate an un-ref. This allows reference counting of objects referenced by DMA chains, without causing the chains to be broken by an immediate decrement comand. Typically, the reference count on an object would be incremented with interrupts disabled. With interrupts re-enabled, the decrement count would then be incremented, and if that count becomes 1, then this function would be called.
|
|
_rwDMACallbackRestart is used to restart dispatch after a callback that took too long to execute with interrupts disabled.
|
|
_rwDMAClosePkt is used to close packets opened by _rwDMAOpenVIFPkt, etc. It will add a closing end tag to the open packets and fixup if required. It adds the just closed packet to the dispatch chain, and flushes any outstanding procrastinated un-ref to the dispatch list. It may be safely called even if no packets are open.
|
|
_rwDMADMAAlloca is used to allocate space in the current DMA build buffer when no packets are open. It is guaranteed that there will be space to call _rwDMAAddPkt or _rwDMAAddPkt2 after the space is allocated without a buffer swap occurring, so this function can be used to allocate space in which temporary dispatchable data will be placed. The resultant block will be cache aligned and not in cache.
|
|
_rwDMADMAPktAllocHigh is used to allocate some space in the current DMA chain build space, outside of a currently open packet. It is used by _rwDMAAddImageUpload to allocate space for the parallel channel 2 chain which needs to be built while a partially constructed channel 1 chain is being built. Immediate mode constructs a temporary dispatch buffer using the function which it then calls from the open channel 1 chain. This function is a convient way of overcomming the RWDMA_SPR_MAX_PKT_SIZE limit on the size of packet segments. It can only be called if a packet is currently open. The resultant block will be cache aligned and not in cache.
|
|
_rwDMAForceBufferSwap closes any open packets, flushes them from SPR and starts the dispatch of the buffered dispatch list. It sets up the other buffer for use and returns. If a dispatch is already in progress when this function is called, the function will block until the dispatching buffer drains, so calling this function twice in succession will guarantee that all data has dispatched. |
|
_rwDMAMinVsyncCntSet is used to specify the minimum number of of VSYNCs that must occur before a frame flip will be processed. This can be used to lock an application to a maximum frame rate.
|
|
_rwDMAOpenGIFPkt is use to open/extend a channel 2 DMA packet. The packet will be transfered in chain mode. When initially opened, the packet will be 128-16 byte aligned for maximum transfer speed. Once opened, RWDMA_ADD_TO_PKT may be used to add quad words to the packet. Packets are built in SPR and flushed to the chain as required.
|
|
_rwDMAOpenVIFPkt is use to open/extend a channel 1 DMA packet. The packet will be transfered with tag transfer enabled. If a type of RWDMA_FIXUP is specified, the system will allocate space for a DMA tag with a DIRECT command in its top word, and will fix this up when the packet is closed or the type of open packet is changed. If not, all DMA tags must be provided with the data. When initially opened, the packet will be 128 byte aligned for maximum transfer speed. Once opened, RWDMA_ADD_TO_PKT may be used to add quad words to the packet. Packets are built in SPR and flushed to the chain as required.
|
|
_rwDMAPreAlloc is used to specify the size of the buffer and the maximum number of outstanding procrastinated un-refs. It can optionally be used to specify an area of memory to be used by the system, rather than having it malloc a block. The single block currently defaults to 1Mb in size with a maximum of 1k outstanding procrastinated un-refs.
|
|
_rwDMAYieldCallbackSet sets a callback to be called from _rwDMAForceBufferSwap. This permits free CPU to be yielded to the application when the library would normally block, and monitoring of the amount of free space in the dma dispatch space.
|
|
_rwDMAFlipData is used to hold data about the video mode used by the VSYNC handler to flip frames.
|
|
_rwDMAGateSlot points to the location of the current gate slot for parallel texture upload. It is used by _rwDMAAddImageUpload. It may be necessary to set it to NULL to prevent a parallel upload overlapping part of a channel 1 transfer. To mark a safe point to start a parallel upload, insert a count 0 DMA tag in the channel 1 chain, and make this variable point to it. |
Converted from CHM to HTML with chm2web Pro 2.85 (unicode) |