KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
Texturing

API for managing PowerVR textures More...

Topics

 Flags
 Texture loading constants
 
 Formats
 PowerVR texture formats
 

Files

file  pvr_txr.h
 Texture management with the PVR 3D API.
 

Functions

pvr_ptr_t pvr_get_front_buffer (void)
 Get a pointer to the front buffer.
 
pvr_ptr_t pvr_get_back_buffer (void)
 Get a pointer to the back buffer.
 
void pvr_txr_set_stride (size_t texture_width)
 Set the global stride width for non-power-of-two textures in PVR RAM.
 
size_t pvr_txr_get_stride (void)
 Get the current texture stride width in pixels as set in the PVR.
 
void pvr_txr_load (const void *src, pvr_ptr_t dst, size_t count)
 Load raw texture data from an SH-4 buffer into PVR RAM.
 
void pvr_txr_load_ex (const void *src, pvr_ptr_t dst, uint32_t w, uint32_t h, uint32_t flags)
 Load texture data from an SH-4 buffer into PVR RAM, twiddling it in the process.
 
void pvr_txr_load_kimg (const kos_img_t *img, pvr_ptr_t dst, uint32_t flags)
 Load a KOS Platform Independent Image (subject to constraint checking).
 

Detailed Description

API for managing PowerVR textures

Helper functions for handling texture tasks of various kinds.

Function Documentation

◆ pvr_get_back_buffer()

pvr_ptr_t pvr_get_back_buffer ( void )

Get a pointer to the back buffer.

This function can be used to retrieve a pointer to the back buffer, aka. the frame buffer that will be rendered to.

Note that the frame buffers lie in 32-bit memory, while textures lie in 64-bit memory. The address returned will point to 64-bit memory, but the back buffer cannot be used directly as a regular texture.

Returns
A pointer to the back buffer.

◆ pvr_get_front_buffer()

pvr_ptr_t pvr_get_front_buffer ( void )

Get a pointer to the front buffer.

This function can be used to retrieve a pointer to the front buffer, aka. the last fully rendered buffer that is either being displayed right now, or is queued to be displayed.

Note that the frame buffers lie in 32-bit memory, while textures lie in 64-bit memory. The address returned will point to 64-bit memory, but the front buffer cannot be used directly as a regular texture.

Returns
A pointer to the front buffer.

◆ pvr_txr_get_stride()

size_t pvr_txr_get_stride ( void )

Get the current texture stride width in pixels as set in the PVR.

This function reads the PVR_TEXTURE_MODULO register and calculates the texture stride width in pixels. The value returned is the width in pixels that has been configured for all textures using the PVR_TXRFMT_X32_STRIDE flag in the same frame.

The stride width is computed by taking the current multiplier in PVR_TEXTURE_MODULO (which stores the width divided by 32), and multiplying it back by 32 to return the full width in pixels.

Returns
The current texture stride width in pixels. Or 0 if not set
See also
pvr_txr_set_stride()

◆ pvr_txr_load()

void pvr_txr_load ( const void * src,
pvr_ptr_t dst,
size_t count )

Load raw texture data from an SH-4 buffer into PVR RAM.

This essentially just acts as a memcpy() from main RAM to PVR RAM, using the Store Queues and 64-bit TA bus.

Parameters
srcThe location in main RAM holding the texture.
dstThe location in PVR RAM to copy to.
countThe size of the texture in bytes (must be a multiple of 32).

◆ pvr_txr_load_ex()

void pvr_txr_load_ex ( const void * src,
pvr_ptr_t dst,
uint32_t w,
uint32_t h,
uint32_t flags )

Load texture data from an SH-4 buffer into PVR RAM, twiddling it in the process.

This function loads a texture to the PVR's RAM with the specified set of flags. It will currently always twiddle the data, whether you ask it to or not, and many of the parameters are just plain not supported at all... Pretty much the only supported flag, other than the format ones is the PVR_TXRLOAD_INVERT_Y one.

This will be slower than using pvr_txr_load() in pretty much all cases, so unless you need to twiddle your texture, just use that instead.

Parameters
srcThe location to copy from.
dstThe location to copy to.
wThe width of the texture, in pixels.
hThe height of the texture, in pixels.
flagsSome set of flags, ORed together.
See also
Flags

◆ pvr_txr_load_kimg()

void pvr_txr_load_kimg ( const kos_img_t * img,
pvr_ptr_t dst,
uint32_t flags )

Load a KOS Platform Independent Image (subject to constraint checking).

This function loads a KOS Platform Independent image to the PVR's RAM with the specified set of flags. This function, unlike pvr_txr_load_ex() supports everything in the flags available, other than what's explicitly marked as not supported.

Parameters
imgThe image to load.
dstThe location to copy to.
flagsSome set of flags, ORed together.
See also
Flags
Note
Unless you explicitly tell this function to not twiddle the texture (by ORing PVR_TXRLOAD_FMT_NOTWIDDLE or it's equivalent PVR_TXRLOAD_FMT_TWIDDLED with flags), this function will twiddle the texture while loading. Keep that in mind when setting the texture format in polygon headers later.
You cannot specify both PVR_TXRLOAD_FMT_NOTWIDDLE (or equivalently PVR_TXRLOAD_FMT_TWIDDLED) and PVR_TXRLOAD_INVERT_Y in the flags.
DMA and Store Queue based loading is not available from this function if it twiddles the texture while loading.

◆ pvr_txr_set_stride()

void pvr_txr_set_stride ( size_t texture_width)

Set the global stride width for non-power-of-two textures in PVR RAM.

This function configures the register PVR_TEXTURE_MODULO, whose first five bits define the row width in VRAM for non-power-of-two textures. The setting applies to all textures rendered with the PVR_TXRFMT_X32_STRIDE flag in the same frame.

The stride width configured here is only supported for textures with widths that are multiples of 32 pixels and up to a maximum of 992 pixels.

Warning
  • Textures that are twiddled cannot use the PVR_TXRFMT_X32_STRIDE flag so the stride set here will not apply to them. This includes all paletted and mipmap textures.
Parameters
texture_widthThe width of the texture in pixels. Must be a multiple of 32 and up to 992 pixels.
See also
pvr_txr_get_stride()