KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
pvr_mem.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 dc/pvr/pvr_mem.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_mem.h
11 \brief VRAM Management and Access
12 \ingroup pvr_vram
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_MEM_H
25#define __DC_PVR_PVR_MEM_H
26
27#include <stdint.h>
28
29#include <sys/cdefs.h>
30__BEGIN_DECLS
31
32/** \defgroup pvr_vram VRAM
33 \brief Video memory access and management
34 \ingroup pvr
35*/
36
37/** \brief PVR texture memory pointer.
38 \ingroup pvr_vram
39
40 Unlike the old "TA" system, PVR pointers in the new system are actually SH-4
41 compatible pointers and can be used directly in place of ta_txr_map().
42
43 Not that anyone probably even remembers the old TA system anymore...
44*/
45typedef void *pvr_ptr_t;
46
47/** \defgroup pvr_mem_mgmt Allocator
48 \brief Memory management API for VRAM
49 \ingroup pvr_vram
50
51 PVR memory management in KOS uses a modified dlmalloc; see the
52 source file pvr_mem_core.c for more info.
53*/
54
55/** \brief Allocate a chunk of memory from texture space.
56 \ingroup pvr_mem_mgmt
57
58 This function acts as the memory allocator for the PVR texture RAM pool. It
59 acts exactly as one would expect a malloc() function to act, returning a
60 normal pointer that can be directly written to if one desires to do so. All
61 allocations will be aligned to a 32-byte boundary.
62
63 \param size The amount of memory to allocate
64
65 \return A pointer to the memory on success, NULL on error
66*/
68
69/** \brief Free a block of allocated memory in the PVR RAM pool.
70 \ingroup pvr_mem_mgmt
71
72 This function frees memory previously allocated with pvr_mem_malloc().
73
74 \param chunk The location of the start of the block to free
75*/
77
78/** \brief Return the number of bytes available still in the PVR RAM pool.
79 \ingroup pvr_mem_mgmt
80
81 \return The number of bytes available
82*/
83size_t pvr_mem_available(void);
84
85/** \brief Reset the PVR RAM pool.
86 \ingroup pvr_mem_mgmt
87
88 This will essentially free any blocks allocated within the pool. There's
89 generally not many good reasons for doing this.
90*/
91void pvr_mem_reset(void);
92
93/** \brief Print the list of allocated blocks in the PVR RAM pool.
94 \ingroup pvr_mem_mgmt
95
96 This function only works if you've enabled KM_DBG in pvr_mem.c.
97*/
99
100/** \brief Print statistics about the PVR RAM pool.
101 \ingroup pvr_mem_mgmt
102
103 This prints out statistics like what malloc_stats() provides. Also, if
104 KM_DBG is enabled in pvr_mem.c, it prints the list of allocated blocks.
105*/
106void pvr_mem_stats(void);
107
108__END_DECLS
109
110#endif /* __DC_PVR_PVR_MEM_H */
void pvr_mem_reset(void)
Reset the PVR RAM pool.
size_t pvr_mem_available(void)
Return the number of bytes available still in the PVR RAM pool.
void pvr_mem_free(pvr_ptr_t chunk)
Free a block of allocated memory in the PVR RAM pool.
void pvr_mem_stats(void)
Print statistics about the PVR RAM pool.
void pvr_mem_print_list(void)
Print the list of allocated blocks in the PVR RAM pool.
pvr_ptr_t pvr_mem_malloc(size_t size)
Allocate a chunk of memory from texture space.
void * pvr_ptr_t
PVR texture memory pointer.
Definition pvr_mem.h:45