nxdk_pgraph_tests
A collection of tests for the Xbox nv2a graphics processor
 
Loading...
Searching...
No Matches
pbkit_ext.h
1#ifndef NXDK_PGRAPH_TESTS_PBKIT_EXT_H
2#define NXDK_PGRAPH_TESTS_PBKIT_EXT_H
3
4#include <cstdint>
5#include <list>
6
7#define MASK(mask, val) (((val) << (__builtin_ffs(mask) - 1)) & (mask))
8
9constexpr float kF16Max = 511.9375f;
10constexpr float kF24Max = 3.4027977E38;
11
12// Converts a float to the format used by the 16-bit fixed point Z-buffer.
13uint16_t float_to_z16(float val);
14
15// Converts a 16-bit fixed point Z-buffer value to a float.
16float z16_to_float(uint32_t val);
17
18// Converts a float to the format used by the 24-bit fixed point Z-buffer.
19uint32_t float_to_z24(float val);
20
21// Converts a 24-bit fixed point Z-buffer value to a float.
22float z24_to_float(uint32_t val);
23
24#define PGRAPH_REGISTER_BASE 0xFD400000
25#define PGRAPH_REGISTER_ARRAY_SIZE 0x2000
26
27// Fetches (most of) the PGRAPH region from the nv2a hardware.
28// `registers` must be an array of at least size PGRAPH_REGISTER_ARRAY_SIZE bytes.
29void pb_fetch_pgraph_registers(uint8_t* registers);
30
31void pb_diff_registers(const uint8_t* a, const uint8_t* b, std::list<uint32_t>& modified_registers);
32
33#if defined(__cplusplus)
34extern "C" {
35#endif
36
37// Versions of pb_print that use a full-featured printf implementation instead of the PCDLIB one that does not yet
38// support floats.
39void pb_print_with_floats(const char* format, ...);
40#define pb_print pb_print_with_floats
41
42#if defined(__cplusplus)
43} // extern "C"
44#endif
45
46#endif // NXDK_PGRAPH_TESTS_PBKIT_EXT_H