KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
pvr_txr.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 dc/pvr/pvr_txr.h
4 Copyright (C) 2002 Megan Potter
5 Copyright (C) 2014 Lawrence Sebald
6 Copyright (C) 2023 Ruslan Rostovtsev
7 Copyright (C) 2024 Falco Girgis
8*/
9
10/** \file dc/pvr/pvr_txr.h
11 \brief Texture management with the PVR 3D API
12 \ingroup pvr_txr_mgmt
13
14 \author Megan Potter
15 \author Roger Cattermole
16 \author Paul Boese
17 \author Brian Paul
18 \author Lawrence Sebald
19 \author Benoit Miller
20 \author Ruslan Rostovtsev
21 \author Falco Girgis
22*/
23
24#ifndef __DC_PVR_PVR_TEXTURE_H
25#define __DC_PVR_PVR_TEXTURE_H
26
27#include <stdint.h>
28
29#include <sys/cdefs.h>
30__BEGIN_DECLS
31
32#include <kos/img.h>
33
34/** \defgroup pvr_txr_mgmt Texturing
35 \brief API for managing PowerVR textures
36 \ingroup pvr
37
38 Helper functions for handling texture tasks of various kinds.
39*/
40
41/** \brief Load raw texture data from an SH-4 buffer into PVR RAM.
42 \ingroup pvr_txr_mgmt
43
44 This essentially just acts as a memcpy() from main RAM to PVR RAM, using
45 the Store Queues and 64-bit TA bus.
46
47 \param src The location in main RAM holding the texture.
48 \param dst The location in PVR RAM to copy to.
49 \param count The size of the texture in bytes (must be a multiple
50 of 32).
51*/
52void pvr_txr_load(const void *src, pvr_ptr_t dst, uint32_t count);
53
54/** \defgroup pvr_txrload_constants Flags
55 \brief Texture loading constants
56 \ingroup pvr_txr_mgmt
57
58 These are constants for the flags parameter to pvr_txr_load_ex() or
59 pvr_txr_load_kimg().
60
61 @{
62*/
63#define PVR_TXRLOAD_4BPP 0x01 /**< \brief 4BPP format */
64#define PVR_TXRLOAD_8BPP 0x02 /**< \brief 8BPP format */
65#define PVR_TXRLOAD_16BPP 0x03 /**< \brief 16BPP format */
66#define PVR_TXRLOAD_FMT_MASK 0x0f /**< \brief Bits used for basic formats */
67
68#define PVR_TXRLOAD_VQ_LOAD 0x10 /**< \brief Do VQ encoding (not supported yet, if ever) */
69#define PVR_TXRLOAD_INVERT_Y 0x20 /**< \brief Invert the Y axis while loading */
70#define PVR_TXRLOAD_FMT_VQ 0x40 /**< \brief Texture is already VQ encoded */
71#define PVR_TXRLOAD_FMT_TWIDDLED 0x80 /**< \brief Texture is already twiddled */
72#define PVR_TXRLOAD_FMT_NOTWIDDLE 0x80 /**< \brief Don't twiddle the texture while loading */
73#define PVR_TXRLOAD_DMA 0x8000 /**< \brief Use DMA to load the texture */
74#define PVR_TXRLOAD_NONBLOCK 0x4000 /**< \brief Use non-blocking loads (only for DMA) */
75#define PVR_TXRLOAD_SQ 0x2000 /**< \brief Use Store Queues to load */
76/** @} */
77
78/** \brief Load texture data from an SH-4 buffer into PVR RAM, twiddling it in
79 the process.
80 \ingroup pvr_txr_mgmt
81
82 This function loads a texture to the PVR's RAM with the specified set of
83 flags. It will currently always twiddle the data, whether you ask it to or
84 not, and many of the parameters are just plain not supported at all...
85 Pretty much the only supported flag, other than the format ones is the
86 PVR_TXRLOAD_INVERT_Y one.
87
88 This will be slower than using pvr_txr_load() in pretty much all cases, so
89 unless you need to twiddle your texture, just use that instead.
90
91 \param src The location to copy from.
92 \param dst The location to copy to.
93 \param w The width of the texture, in pixels.
94 \param h The height of the texture, in pixels.
95 \param flags Some set of flags, ORed together.
96
97 \see pvr_txrload_constants
98*/
99void pvr_txr_load_ex(const void *src, pvr_ptr_t dst,
100 uint32_t w, uint32_t h, uint32_t flags);
101
102/** \brief Load a KOS Platform Independent Image (subject to constraint
103 checking).
104 \ingroup pvr_txr_mgmt
105
106 This function loads a KOS Platform Independent image to the PVR's RAM with
107 the specified set of flags. This function, unlike pvr_txr_load_ex() supports
108 everything in the flags available, other than what's explicitly marked as
109 not supported.
110
111 \param img The image to load.
112 \param dst The location to copy to.
113 \param flags Some set of flags, ORed together.
114
115 \see pvr_txrload_constants
116 \note Unless you explicitly tell this function to not
117 twiddle the texture (by ORing
118 \ref PVR_TXRLOAD_FMT_NOTWIDDLE or it's equivalent
119 \ref PVR_TXRLOAD_FMT_TWIDDLED with flags), this
120 function will twiddle the texture while loading.
121 Keep that in mind when setting the texture format in
122 polygon headers later.
123 \note You cannot specify both
124 \ref PVR_TXRLOAD_FMT_NOTWIDDLE (or equivalently
125 \ref PVR_TXRLOAD_FMT_TWIDDLED) and
126 \ref PVR_TXRLOAD_INVERT_Y in the flags.
127 \note DMA and Store Queue based loading is not available
128 from this function if it twiddles the texture while
129 loading.
130*/
131void pvr_txr_load_kimg(const kos_img_t *img, pvr_ptr_t dst, uint32_t flags);
132
133__END_DECLS
134#endif /* __DC_PVR_PVR_TEXTURE_H */
void pvr_txr_load(const void *src, pvr_ptr_t dst, uint32_t count)
Load raw texture data from an SH-4 buffer into PVR RAM.
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).
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_ptr_t
PVR texture memory pointer.
Definition pvr_mem.h:45
Platform-independent image type.
Platform-indpendent image type.
Definition img.h:51