citro3d
Loading...
Searching...
No Matches
buffers.h
Go to the documentation of this file.
1/**
2 * @file buffers.h
3 * @brief Configure vertex array buffers
4 */
5#pragma once
6#include "types.h"
7
8/// Vertex buffer config
9typedef struct
10{
11 u32 offset;
12 u32 flags[2];
14
15/// Vertex buffer info
16typedef struct
17{
18 u32 base_paddr;
19 int bufCount;
20 C3D_BufCfg buffers[12];
22
23/**
24 * @brief Resets and initializes \ref C3D_BufInfo structure to default values.
25 * @param[out] info Pointer to vertex buffer info structure.
26 */
28
29/**
30 * @brief Adds a buffer to the vertex buffer info struct.
31 * @note The attribute indices specified in \p permutation should be the same as the ones returned by \ref AttrInfo_AddLoader()
32 * @param[out] info Pointer to a \ref C3D_BufInfo struct.
33 * @param[in] data Pointer to buffer.
34 * @param[in] stride Distance in bytes between vertex entries in the buffer (usually set to the size of the vertex structure).
35 * @param[in] attribCount Number of attributes to load from this buffer.
36 * @param[in] permutation Specifies the order of attributes in the buffer. Each attribute index is a nibble (4 bits), and they are ordered from least significant to most significant.
37 * Padding can be specified with 0xC, 0xD, 0xE and 0xF. (See https://3dbrew.org/wiki/GPU/Internal_Registers#GPUREG_ATTRIBBUFFERi_CONFIG1 for more info)
38 * @remark Using this, one can rearrange the positions of attributes in the struct.
39 * For example, with three attributes in this buffer, setting this to 0x210 would configure the permutation to be the first attribute index,
40 * then the second, then the third. 0x120 would configure the permutation to be the first attribute index, then the third, then the second.
41 * @return Buffer index if successful, negative value on failure.
42 */
43int BufInfo_Add(C3D_BufInfo* info, const void* data, ptrdiff_t stride, int attribCount, u64 permutation);
44
45/**
46 * @brief Gets pointer to the global \ref C3D_BufInfo structure.
47 * @return Pointer to \ref C3D_BufInfo. This should not be freed.
48 */
50
51/**
52 * @brief Sets global \ref C3D_BufInfo structure.
53 * Copies values from the specified \ref C3D_BufInfo structure to the
54 * global \ref C3D_BufInfo structure.
55 * @param[in] info Pointer to user \ref C3D_BufInfo.
56 */
void C3D_SetBufInfo(C3D_BufInfo *info)
Sets global C3D_BufInfo structure. Copies values from the specified C3D_BufInfo structure to the glob...
void BufInfo_Init(C3D_BufInfo *info)
Resets and initializes C3D_BufInfo structure to default values.
int BufInfo_Add(C3D_BufInfo *info, const void *data, ptrdiff_t stride, int attribCount, u64 permutation)
Adds a buffer to the vertex buffer info struct.
C3D_BufInfo * C3D_GetBufInfo(void)
Gets pointer to the global C3D_BufInfo structure.
Vertex buffer config.
Definition buffers.h:10
Vertex buffer info.
Definition buffers.h:17
uint64_t u64
uint32_t u32