91typedef enum pvr_mip_bias {
128typedef enum pvr_uv_flip {
146typedef enum pvr_uv_clamp {
304#define PVR_TXRFMT_NONE 0
305#define PVR_TXRFMT_VQ_DISABLE (0 << 30)
306#define PVR_TXRFMT_VQ_ENABLE (1 << 30)
307#define PVR_TXRFMT_ARGB1555 (0 << 27)
308#define PVR_TXRFMT_RGB565 (1 << 27)
309#define PVR_TXRFMT_ARGB4444 (2 << 27)
310#define PVR_TXRFMT_YUV422 (3 << 27)
311#define PVR_TXRFMT_BUMP (4 << 27)
312#define PVR_TXRFMT_PAL4BPP (5 << 27)
313#define PVR_TXRFMT_PAL8BPP (6 << 27)
314#define PVR_TXRFMT_TWIDDLED (0 << 26)
315#define PVR_TXRFMT_NONTWIDDLED (1 << 26)
316#define PVR_TXRFMT_POW2_STRIDE (0 << 25)
317#define PVR_TXRFMT_X32_STRIDE (1 << 25)
330#define PVR_TXRFMT_8BPP_PAL(x) ((x) << 25)
335#define PVR_TXRFMT_4BPP_PAL(x) ((x) << 21)
353#define PVR_MODIFIER_OTHER_POLY 0
354#define PVR_MODIFIER_INCLUDE_LAST_POLY 1
355#define PVR_MODIFIER_EXCLUDE_LAST_POLY 2
371#define pvr_poly_ic_hdr pvr_poly_hdr
381#define pvr_poly_mod_hdr pvr_poly_hdr
391#define pvr_sprite_hdr pvr_poly_hdr
401#define pvr_mod_hdr pvr_poly_hdr
420typedef struct pvr_vertex {
448typedef struct pvr_vertex_pcm {
468typedef struct pvr_vertex_tpcm {
500typedef struct pvr_sprite_txr {
525typedef struct pvr_sprite_col {
550typedef struct pvr_modifier_vol {
581#define PVR_CMD_POLYHDR 0x80840000
583#define PVR_CMD_VERTEX 0xe0000000
584#define PVR_CMD_VERTEX_EOL 0xf0000000
585#define PVR_CMD_USERCLIP 0x20000000
586#define PVR_CMD_MODIFIER 0x80000000
587#define PVR_CMD_SPRITE 0xA0000000
599#define PVR_TA_CMD_TYPE GENMASK(26, 24)
600#define PVR_TA_CMD_USERCLIP GENMASK(17, 16)
601#define PVR_TA_CMD_MODIFIER BIT(7)
602#define PVR_TA_CMD_MODIFIERMODE BIT(6)
603#define PVR_TA_CMD_CLRFMT GENMASK(5, 4)
604#define PVR_TA_CMD_TXRENABLE BIT(3)
605#define PVR_TA_CMD_SPECULAR BIT(2)
606#define PVR_TA_CMD_SHADE BIT(1)
607#define PVR_TA_CMD_UVFMT BIT(0)
608#define PVR_TA_PM1_DEPTHCMP GENMASK(31, 29)
609#define PVR_TA_PM1_CULLING GENMASK(28, 27)
610#define PVR_TA_PM1_DEPTHWRITE BIT(26)
611#define PVR_TA_PM1_TXRENABLE BIT(25)
612#define PVR_TA_PM1_MODIFIERINST GENMASK(30, 29)
613#define PVR_TA_PM2_SRCBLEND GENMASK(31, 29)
614#define PVR_TA_PM2_DSTBLEND GENMASK(28, 26)
615#define PVR_TA_PM2_SRCENABLE BIT(25)
616#define PVR_TA_PM2_DSTENABLE BIT(24)
617#define PVR_TA_PM2_FOG GENMASK(23, 22)
618#define PVR_TA_PM2_CLAMP BIT(21)
619#define PVR_TA_PM2_ALPHA BIT(20)
620#define PVR_TA_PM2_TXRALPHA BIT(19)
621#define PVR_TA_PM2_UVFLIP GENMASK(18, 17)
622#define PVR_TA_PM2_UVCLAMP GENMASK(16, 15)
623#define PVR_TA_PM2_FILTER GENMASK(14, 13)
624#define PVR_TA_PM2_MIPBIAS GENMASK(11, 8)
625#define PVR_TA_PM2_TXRENV GENMASK(7, 6)
626#define PVR_TA_PM2_USIZE GENMASK(5, 3)
627#define PVR_TA_PM2_VSIZE GENMASK(2, 0)
628#define PVR_TA_PM3_MIPMAP BIT(31)
629#define PVR_TA_PM3_TXRFMT GENMASK(30, 21)
646#define PVR_BINSIZE_0 0
647#define PVR_BINSIZE_8 8
648#define PVR_BINSIZE_16 16
649#define PVR_BINSIZE_32 32
960extern uint32_t pvr_dr_addr;
972#define pvr_dr_target(...) __builtin_assume_aligned((void *)((pvr_dr_addr ^= 32)), 32)
979#define pvr_dr_commit(addr) sq_flush(addr)
1127 int textureformat,
int tw,
int th,
pvr_ptr_t textureaddr,
1170 int textureformat,
int tw,
int th,
pvr_ptr_t textureaddr,
1242 int textureformat,
int tw,
int th,
1244 int textureformat2,
int tw2,
int th2,
int mode
Definition 2ndmix.c:539
pvr_init_params_t params
Definition 2ndmix.c:820
static struct @70 data[BARRIER_COUNT]
static pvr_ptr_t txr
Definition bump.c:28
Various common macros used throughout the codebase.
Constants for areas of the system memory map.
void pvr_poly_cxt_txr(pvr_poly_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, pvr_filter_mode_t filtering)
Fill in a polygon context for a textured polygon.
void pvr_poly_cxt_col_mod(pvr_poly_cxt_t *dst, pvr_list_t list)
Fill in a polygon context for non-textured polygons affected by a modifier volume.
void pvr_sprite_cxt_txr(pvr_sprite_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, pvr_filter_mode_t filtering)
Fill in a sprite context for a textured sprite.
void pvr_poly_cxt_txr_mod(pvr_poly_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, pvr_filter_mode_t filtering, int textureformat2, int tw2, int th2, pvr_ptr_t textureaddr2, pvr_filter_mode_t filtering2)
Fill in a polygon context for a textured polygon affected by modifier volumes.
void pvr_poly_cxt_col(pvr_poly_cxt_t *dst, pvr_list_t list)
Fill in a polygon context for non-textured polygons.
void pvr_sprite_cxt_col(pvr_sprite_cxt_t *dst, pvr_list_t list)
Fill in a sprite context for non-textured sprites.
void pvr_send_to_ta(void *data)
Upload a 32-byte payload to the Tile Accelerator.
int pvr_shutdown(void)
Shut down the PVR chip from ready status.
int pvr_init_defaults(void)
Simple PVR initialization.
int pvr_init(const pvr_init_params_t *params)
Initialize the PVR chip to ready status.
void * pvr_set_vertbuf(pvr_list_t list, void *buffer, size_t len)
Setup a vertex buffer for one of the list types.
int pvr_list_flush(pvr_list_t list)
Flush the buffered data of the given list type to the TA.
int pvr_prim(const void *data, size_t size)
Submit a primitive of the current list type.
int pvr_list_finish(void)
End collecting data for the current list type.
int pvr_list_prim(pvr_list_t list, const void *data, size_t size)
Submit a primitive of the given list type.
int pvr_list_begin(pvr_list_t list)
Begin collecting data for the given list type.
pvr_mip_bias_t
Definition pvr.h:91
@ PVR_MIPBIAS_1_50
Definition pvr.h:97
@ PVR_MIPBIAS_3_25
Definition pvr.h:104
@ PVR_MIPBIAS_3_50
Definition pvr.h:105
@ PVR_MIPBIAS_2_00
Definition pvr.h:99
@ PVR_MIPBIAS_0_75
Definition pvr.h:94
@ PVR_MIPBIAS_1_00
Definition pvr.h:95
@ PVR_MIPBIAS_0_50
Definition pvr.h:93
@ PVR_MIPBIAS_2_50
Definition pvr.h:101
@ PVR_MIPBIAS_0_25
Definition pvr.h:92
@ PVR_MIPBIAS_3_75
Definition pvr.h:106
@ PVR_MIPBIAS_2_25
Definition pvr.h:100
@ PVR_MIPBIAS_1_25
Definition pvr.h:96
@ PVR_MIPBIAS_NORMAL
Definition pvr.h:107
@ PVR_MIPBIAS_2_75
Definition pvr.h:102
@ PVR_MIPBIAS_1_75
Definition pvr.h:98
@ PVR_MIPBIAS_3_00
Definition pvr.h:103
void pvr_mod_compile(pvr_mod_hdr_t *dst, pvr_list_t list, uint32_t mode, uint32_t cull)
Create a modifier volume header.
void pvr_poly_compile(pvr_poly_hdr_t *dst, const pvr_poly_cxt_t *src)
Compile a polygon context into a polygon header.
void pvr_poly_mod_compile(pvr_poly_mod_hdr_t *dst, const pvr_poly_cxt_t *src)
Compile a polygon context into a polygon header that is affected by modifier volumes.
void pvr_sprite_compile(pvr_sprite_hdr_t *dst, const pvr_sprite_cxt_t *src)
Compile a sprite context into a sprite header.
int pvr_scene_finish(void)
Call this after you have finished submitting all data for a frame.
void pvr_scene_begin_txr(pvr_ptr_t txr, uint32_t *rx, uint32_t *ry)
Begin collecting data for a frame of 3D output to the specified texture.
void pvr_scene_begin(void)
Begin collecting data for a frame of 3D output to the off-screen frame buffer.
int pvr_check_ready(void)
Check if the PVR system is ready for another frame to be submitted.
int pvr_wait_ready(void)
Block the caller until the PVR system is ready for another frame to be submitted.
int pvr_wait_render_done(void)
Block the caller until the PVR has finished rendering the previous frame.
#define PVR_TXRFMT_POW2_STRIDE
Stride is a power-of-two.
Definition pvr.h:316
static const uint32_t PVR_TXRFMT_NOSTRIDE
Definition pvr.h:320
static const uint32_t PVR_TXRFMT_STRIDE
Definition pvr.h:321
#define PVR_TXRFMT_X32_STRIDE
Stride is multiple of 32.
Definition pvr.h:317
pvr_ptr_t pvr_get_back_buffer(void)
Get a pointer to the back buffer.
pvr_ptr_t pvr_get_front_buffer(void)
Get a pointer to the front buffer.
pvr_uv_clamp_t
Definition pvr.h:146
@ PVR_UVCLAMP_UV
Clamp U and V.
Definition pvr.h:150
@ PVR_UVCLAMP_NONE
Disable clamping.
Definition pvr.h:147
@ PVR_UVCLAMP_U
Clamp U only.
Definition pvr.h:149
@ PVR_UVCLAMP_V
Clamp V only.
Definition pvr.h:148
pvr_uv_flip_t
Definition pvr.h:128
@ PVR_UVFLIP_NONE
No flipped coordinates.
Definition pvr.h:129
@ PVR_UVFLIP_UV
Flip U and V.
Definition pvr.h:132
@ PVR_UVFLIP_V
Flip V only.
Definition pvr.h:130
@ PVR_UVFLIP_U
Flip U only.
Definition pvr.h:131
void pvr_vertbuf_written(pvr_list_t list, size_t amt)
Notify the PVR system that data have been written into the output buffer for the given list.
int pvr_vertex_dma_enabled(void)
Is vertex DMA enabled?
void * pvr_vertbuf_tail(pvr_list_t list)
Retrieve a pointer to the current output location in the DMA buffer for the requested list.
void * pvr_ptr_t
PVR texture memory pointer.
Definition pvr_mem.h:45
Platform-independent image type.
static char buffer[256]
Definition porthelper.c:11
API for utilizing the DMA with the PVR for rendering.
Public API for the PVR's hardware fog.
All deprecated PVR API Constants.
VRAM Management and Access.
Miscellaneous utilities for the PVR API.
Palette API for the PowerVR.
Texture management with the PVR 3D API.
Macros to help dealing with register fields.
static pvr_list_t list
Definition shadow.c:25
Functions to access the SH4 Store Queues.
PVR initialization structure.
Definition pvr.h:663
int fsaa_enabled
Enable horizontal scaling?
Definition pvr.h:687
int vbuf_doublebuf_disabled
Disable vertex buffer double-buffering.
Definition pvr.h:713
int dma_enabled
Enable vertex DMA?
Definition pvr.h:680
int vertex_buf_size
Vertex buffer size (should be a nice round number)
Definition pvr.h:672
int autosort_disabled
Disable translucent polygon autosort?
Definition pvr.h:695
int opb_overflow_count
OPB Overflow Count.
Definition pvr.h:706
PVR vertex type: Modifier volume.
Definition pvr.h:550
uint32_t d1
Dummy value.
Definition pvr.h:562
uint32_t d4
Dummy value.
Definition pvr.h:565
float by
Second Y coordinate.
Definition pvr.h:557
float ay
First Y coordinate.
Definition pvr.h:554
float ax
First X coordinate.
Definition pvr.h:553
uint32_t d3
Dummy value.
Definition pvr.h:564
float cz
Third Z coordinate.
Definition pvr.h:561
float bz
Second Z coordinate.
Definition pvr.h:558
float cy
Third Y coordinate.
Definition pvr.h:560
uint32_t d6
Dummy value.
Definition pvr.h:567
uint32_t d2
Dummy value.
Definition pvr.h:563
uint32_t d5
Dummy value.
Definition pvr.h:566
float bx
Second X coordinate.
Definition pvr.h:556
float az
First Z coordinate.
Definition pvr.h:555
float cx
Third X coordinate.
Definition pvr.h:559
PVR polygon context.
Definition pvr.h:171
pvr_list_t list_type
Primitive list.
Definition pvr.h:172
bool specular
Enable offset color outside modifier.
Definition pvr.h:181
pvr_blend_mode_t src
Source blending mode outside modifier.
Definition pvr.h:187
pvr_uv_clamp_t uv_clamp
Enable/disable U/V clamping.
Definition pvr.h:211
pvr_cull_mode_t culling
Culling mode.
Definition pvr.h:177
bool mipmap
Enable/disable mipmaps.
Definition pvr.h:208
pvr_fog_type_t fog_type2
Fog type inside modifier.
Definition pvr.h:183
bool modifier_mode
True normal; false: cheap shadow.
Definition pvr.h:180
bool alpha2
Enable alpha inside modifier.
Definition pvr.h:182
pvr_uv_flip_t uv_flip
Enable/disable U/V flipping.
Definition pvr.h:210
bool color_clamp
Enable color clamping outside modifer.
Definition pvr.h:178
pvr_filter_mode_t filter
Filtering mode.
Definition pvr.h:207
struct pvr_poly_cxt_t::@32 txr2
Texturing params inside modifier.
bool write
Enable depth writes.
Definition pvr.h:203
pvr_ptr_t base
Texture pointer.
Definition pvr.h:218
pvr_blend_mode_t src2
Source blending mode inside modifier.
Definition pvr.h:191
bool enable
Enable/disable texturing.
Definition pvr.h:206
bool shading
Enable gourad shading.
Definition pvr.h:175
pvr_mip_bias_t mipmap_bias
Mipmap bias.
Definition pvr.h:209
int width
Texture width (requires a power of 2)
Definition pvr.h:214
pvr_blend_mode_t dst
Dest blending mode outside modifier.
Definition pvr.h:188
bool color_clamp2
Enable color clamping inside modifer.
Definition pvr.h:184
int height
Texture height (requires a power of 2)
Definition pvr.h:215
bool uv
True: 16-bit floating-point U/Vs; False: 32-bit.
Definition pvr.h:198
pvr_depthcmp_mode_t comparison
Depth comparison mode.
Definition pvr.h:202
bool src_enable2
Source blending mode inside modifier.
Definition pvr.h:193
pvr_blend_mode_t dst2
Dest blending mode inside modifier.
Definition pvr.h:192
bool modifier
Enable modifier effects.
Definition pvr.h:199
bool src_enable
Source blending enable outside modifier.
Definition pvr.h:189
pvr_color_fmts_t color
Color format in vertex.
Definition pvr.h:197
pvr_txr_shading_mode_t env
Texture color contribution.
Definition pvr.h:213
pvr_fog_type_t fog_type
Fog type outside modifier.
Definition pvr.h:176
bool alpha
Enable alpha outside modifier.
Definition pvr.h:174
pvr_clip_mode_t clip_mode
Clipping mode.
Definition pvr.h:179
bool dst_enable2
Dest blending mode inside modifier.
Definition pvr.h:194
bool dst_enable
Dest blending enable outside modifier.
Definition pvr.h:190
int format
Texture format.
Definition pvr.h:216
PVR polygon header.
Definition pvr_header.h:312
PVR vertex type: Untextured sprite.
Definition pvr.h:525
float bz
Second Z coordinate.
Definition pvr.h:533
float ay
First Y coordinate.
Definition pvr.h:529
uint32_t d3
Dummy value.
Definition pvr.h:541
float cz
Third Z coordinate.
Definition pvr.h:536
float bx
Second X coordinate.
Definition pvr.h:531
uint32_t d1
Dummy value.
Definition pvr.h:539
float cy
Third Y coordinate.
Definition pvr.h:535
float ax
First X coordinate.
Definition pvr.h:528
float by
Second Y coordinate.
Definition pvr.h:532
uint32_t d4
Dummy value.
Definition pvr.h:542
float dy
Fourth Y coordinate.
Definition pvr.h:538
uint32_t d2
Dummy value.
Definition pvr.h:540
float cx
Third X coordinate.
Definition pvr.h:534
float az
First Z coordinate.
Definition pvr.h:530
float dx
Fourth X coordinate.
Definition pvr.h:537
PVR sprite context.
Definition pvr.h:236
bool alpha
Enable alpha.
Definition pvr.h:239
bool mipmap
Enable/disable mipmaps.
Definition pvr.h:259
bool enable
Enable/disable texturing.
Definition pvr.h:257
pvr_mip_bias_t mipmap_bias
Mipmap bias.
Definition pvr.h:260
bool src_enable
Source blending enable.
Definition pvr.h:249
pvr_uv_clamp_t uv_clamp
Enable/disable U/V clamping.
Definition pvr.h:262
pvr_blend_mode_t dst
Dest blending mode.
Definition pvr.h:248
pvr_fog_type_t fog_type
Fog type.
Definition pvr.h:240
bool write
Enable depth writes.
Definition pvr.h:254
pvr_uv_flip_t uv_flip
Enable/disable U/V flipping.
Definition pvr.h:261
bool specular
Enable offset color.
Definition pvr.h:244
bool color_clamp
Enable color clamp.
Definition pvr.h:242
pvr_list_t list_type
Primitive list.
Definition pvr.h:237
pvr_clip_mode_t clip_mode
Clipping mode.
Definition pvr.h:243
int width
Texture width (requires a power of 2)
Definition pvr.h:265
pvr_txr_shading_mode_t env
Texture color contribution.
Definition pvr.h:264
pvr_ptr_t base
Texture pointer.
Definition pvr.h:269
pvr_blend_mode_t src
Source blending mode.
Definition pvr.h:247
pvr_filter_mode_t filter
Filtering mode.
Definition pvr.h:258
pvr_cull_mode_t culling
Culling mode.
Definition pvr.h:241
pvr_depthcmp_mode_t comparison
Depth comparison mode.
Definition pvr.h:253
int height
Texture height (requires a power of 2)
Definition pvr.h:266
bool dst_enable
Dest blending enable.
Definition pvr.h:250
int format
Texture format.
Definition pvr.h:267
PVR vertex type: Textured sprite.
Definition pvr.h:500
float bz
Second Z coordinate.
Definition pvr.h:508
float dx
Fourth X coordinate.
Definition pvr.h:512
float az
First Z coordinate.
Definition pvr.h:505
float ax
First X coordinate.
Definition pvr.h:503
uint32_t buv
Second U/V texture coordinates.
Definition pvr.h:516
float cz
Third Z coordinate.
Definition pvr.h:511
uint32_t dummy
Dummy value.
Definition pvr.h:514
float by
Second Y coordinate.
Definition pvr.h:507
uint32_t auv
First U/V texture coordinates.
Definition pvr.h:515
float dy
Fourth Y coordinate.
Definition pvr.h:513
float cx
Third X coordinate.
Definition pvr.h:509
uint32_t cuv
Third U/V texture coordinates.
Definition pvr.h:517
float bx
Second X coordinate.
Definition pvr.h:506
float cy
Third Y coordinate.
Definition pvr.h:510
float ay
First Y coordinate.
Definition pvr.h:504
PVR vertex type: Non-textured, packed color, affected by modifier volume.
Definition pvr.h:448
float z
Z coordinate.
Definition pvr.h:453
uint32_t d1
Dummy value.
Definition pvr.h:456
uint32_t argb0
Vertex color (outside volume)
Definition pvr.h:454
float x
X coordinate.
Definition pvr.h:451
float y
Y coordinate.
Definition pvr.h:452
uint32_t d2
Dummy value.
Definition pvr.h:457
uint32_t argb1
Vertex color (inside volume)
Definition pvr.h:455
Generic PVR vertex type.
Definition pvr.h:420
float z
Z coordinate.
Definition pvr.h:425
float y
Y coordinate.
Definition pvr.h:424
float u
Texture U coordinate.
Definition pvr.h:428
uint32_t oargb
Vertex offset color.
Definition pvr.h:437
uint32_t argb1
Vertex color when modified, inside area.
Definition pvr.h:433
float x
X coordinate.
Definition pvr.h:423
float v
Texture V coordinate.
Definition pvr.h:429
uint32_t argb
Vertex color.
Definition pvr.h:436
uint32_t argb0
Vertex color when modified, outside area.
Definition pvr.h:432
PVR vertex type: Textured, packed color, affected by modifier volume.
Definition pvr.h:468
float z
Z coordinate.
Definition pvr.h:473
uint32_t oargb1
Vertex offset color (inside)
Definition pvr.h:481
uint32_t oargb0
Vertex offset color (outside)
Definition pvr.h:477
float x
X coordinate.
Definition pvr.h:471
float u0
Texture U coordinate (outside)
Definition pvr.h:474
uint32_t d2
Dummy value.
Definition pvr.h:483
float v0
Texture V coordinate (outside)
Definition pvr.h:475
uint32_t d4
Dummy value.
Definition pvr.h:485
float u1
Texture U coordinate (inside)
Definition pvr.h:478
float y
Y coordinate.
Definition pvr.h:472
float v1
Texture V coordinate (inside)
Definition pvr.h:479
uint32_t argb0
Vertex color (outside)
Definition pvr.h:476
uint32_t argb1
Vertex color (inside)
Definition pvr.h:480
uint32_t d1
Dummy value.
Definition pvr.h:482
uint32_t d3
Dummy value.
Definition pvr.h:484