89#ifndef LIBDRAGON_RDPQ_MODE_H
90#define LIBDRAGON_RDPQ_MODE_H
101inline void __rdpq_mode_change_som(uint64_t mask, uint64_t val);
131typedef enum rdpq_filter_s {
198typedef enum rdpq_dither_s {
223typedef enum rdpq_tlut_s {
245typedef enum rdpq_mipmap_s {
256typedef enum rdpq_antialias_s {
467 extern void __rdpq_fixup_mode4(uint32_t cmd_id, uint32_t w0, uint32_t w1, uint32_t w2, uint32_t w3);
471 (comb >> 32) & 0x00FFFFFF,
475 if (((comb >> 0 ) & 7) == 1) comb1_mask ^= 1ull << 0;
476 if (((comb >> 3 ) & 7) == 1) comb1_mask ^= 1ull << 3;
477 if (((comb >> 6 ) & 7) == 1) comb1_mask ^= 1ull << 6;
478 if (((comb >> 18) & 7) == 1) comb1_mask ^= 1ull << 18;
479 if (((comb >> 21) & 7) == 1) comb1_mask ^= 1ull << 21;
480 if (((comb >> 24) & 7) == 1) comb1_mask ^= 1ull << 24;
481 if (((comb >> 32) & 31) == 1) comb1_mask ^= 1ull << 32;
482 if (((comb >> 37) & 15) == 1) comb1_mask ^= 1ull << 37;
485 (comb >> 32) & 0x00FFFFFF,
487 (comb1_mask >> 32) & 0x00FFFFFF,
488 comb1_mask & 0xFFFFFFFF);
499#define RDPQ_BLENDER_MULTIPLY RDPQ_BLENDER((IN_RGB, IN_ALPHA, MEMORY_RGB, INV_MUX_ALPHA))
521#define RDPQ_BLENDER_MULTIPLY_CONST RDPQ_BLENDER((IN_RGB, FOG_ALPHA, MEMORY_RGB, INV_MUX_ALPHA))
531#define RDPQ_BLENDER_ADDITIVE RDPQ_BLENDER((IN_RGB, IN_ALPHA, MEMORY_RGB, ONE))
607#define RDPQ_FOG_STANDARD RDPQ_BLENDER((IN_RGB, SHADE_ALPHA, FOG_RGB, INV_MUX_ALPHA))
653 if (fog) assertf((fog &
SOMX_BLEND_2PASS) == 0,
"Fogging cannot be used with two-pass blending formulas");
673 __rdpq_mode_change_som(
699 if (threshold == 0) {
701 }
else if (threshold > 0) {
725 __rdpq_mode_change_som(
751 __rdpq_mode_change_som(
880inline void __rdpq_mode_change_som(uint64_t mask, uint64_t val)
887 extern void __rdpq_fixup_mode3(uint32_t cmd_id, uint32_t w0, uint32_t w1, uint32_t w2);
889 __rdpq_fixup_mode3(RDPQ_CMD_MODIFY_OTHER_MODES, 0 | (1<<15), ~(mask >> 32), val >> 32);
891 __rdpq_fixup_mode3(RDPQ_CMD_MODIFY_OTHER_MODES, 4 | (1<<15), ~(uint32_t)mask, (uint32_t)val);
#define RGBA32(rx, gx, bx, ax)
Create a color_t from the R,G,B,A components in the RGBA32 range (0-255).
Definition graphics.h:74
Generic color structure.
Definition graphics.h:52
void rdpq_set_prim_depth_raw(uint16_t primitive_z, int16_t primitive_delta_z)
Set a fixed Z value to be used instead of a per-pixel value (RDP command; SET_PRIM_DEPTH)
Definition rdpq.h:464
void rdpq_set_fill_color(color_t color)
Enqueue a SET_FILL_COLOR RDP command.
Definition rdpq.h:837
void rdpq_set_blend_color(color_t color)
Set the RDP BLEND blender register.
Definition rdpq.h:917
#define SOM_TEXTURE_DETAIL
Texture: enable "detail".
Definition rdpq_macros.h:529
#define SOM_TEXTURE_SHARPEN
Texture: enable "sharpen".
Definition rdpq_macros.h:530
#define SOM_TLUT_MASK
TLUT mask.
Definition rdpq_macros.h:537
#define SOMX_LOD_INTERPOLATE
RDPQ special state: mimap interpolation (aka trilinear) requested.
Definition rdpq_macros.h:571
#define SOM_Z_WRITE
Activate Z-buffer write.
Definition rdpq_macros.h:594
#define SOM_TLUT_SHIFT
TLUT mask shift.
Definition rdpq_macros.h:538
#define SOM_ALPHACOMPARE_THRESHOLD
Alpha Compare: use blend alpha as threshold.
Definition rdpq_macros.h:606
#define SOM_RGBDITHER_MASK
RGB Dithering mask.
Definition rdpq_macros.h:558
#define SOM_ALPHADITHER_MASK
Alpha Dithering mask.
Definition rdpq_macros.h:565
#define SOM_TEXTURE_LOD
Texture: enable LODs.
Definition rdpq_macros.h:531
#define RDPQ_COMB1_MASK
Combiner: mask to isolate settings related to cycle 1.
Definition rdpq_macros.h:259
#define SOM_TEXTURE_PERSP
Texture: enable perspective correction.
Definition rdpq_macros.h:528
uint64_t rdpq_combiner_t
A combiner formula, created by RDPQ_COMBINER1 or RDPQ_COMBINER2.
Definition rdpq_macros.h:18
#define SOMX_BLEND_2PASS
RDPQ special state: record that the blender is made of 2 passes.
Definition rdpq_macros.h:577
#define SOM_RGBDITHER_NONE
RGB Dithering: none.
Definition rdpq_macros.h:557
#define SOM_SAMPLE_SHIFT
Texture sampling mask shift.
Definition rdpq_macros.h:544
#define SOM_AA_ENABLE
Enable anti-alias.
Definition rdpq_macros.h:612
#define SOM_ALPHADITHER_SHIFT
Alpha Dithering mask shift.
Definition rdpq_macros.h:566
#define SOM_Z_COMPARE
Activate Z-buffer compare.
Definition rdpq_macros.h:597
#define SOMX_AA_REDUCED
RDPQ special state: reduced antialiasing is enabled.
Definition rdpq_macros.h:570
#define SOM_SAMPLE_MEDIAN
Texture sampling: mid-texel average (2x2)
Definition rdpq_macros.h:542
#define SOM_ALPHADITHER_NONE
Alpha Dithering: none.
Definition rdpq_macros.h:564
#define SOM_ALPHACOMPARE_NOISE
Alpha Compare: use noise as threshold.
Definition rdpq_macros.h:607
#define SOM_ALPHADITHER_INVERT
Alpha Dithering: invert pattern compared to RG.
Definition rdpq_macros.h:562
#define SOM_SAMPLE_BILINEAR
Texture sampling: bilinear interpolation (2x2)
Definition rdpq_macros.h:541
#define SOMX_FOG
RDPQ special state: fogging is enabled.
Definition rdpq_macros.h:568
#define SOM_ZSOURCE_PRIM
Z-source: fixed value.
Definition rdpq_macros.h:601
#define SOM_BLENDING
Activate blending for all pixels.
Definition rdpq_macros.h:579
#define SOM_SAMPLE_POINT
Texture sampling: point sampling (1x1)
Definition rdpq_macros.h:540
#define SOM_ALPHACOMPARE_MASK
Alpha Compare mask.
Definition rdpq_macros.h:608
#define SOM_ALPHADITHER_NOISE
Alpha Dithering: noise.
Definition rdpq_macros.h:563
#define SOM_ALPHADITHER_SAME
Alpha Dithering: same as RGB.
Definition rdpq_macros.h:561
#define SOMX_NUMLODS_MASK
Rdpq extension: number of LODs.
Definition rdpq_macros.h:516
uint32_t rdpq_blender_t
A blender formula, created by RDPQ_BLENDER or RDPQ_BLENDER2.
Definition rdpq_macros.h:20
#define SOM_RGBDITHER_SQUARE
RGB Dithering: square filter.
Definition rdpq_macros.h:554
#define SOM_SAMPLE_MASK
Texture sampling mask.
Definition rdpq_macros.h:543
#define RDPQ_COMBINER_2PASS
Flag to mark the combiner as requiring two passes.
Definition rdpq_macros.h:272
#define SOM_RGBDITHER_BAYER
RGB Dithering: bayer filter.
Definition rdpq_macros.h:555
#define SOM_RGBDITHER_NOISE
RGB Dithering: noise.
Definition rdpq_macros.h:556
#define SOMX_NUMLODS_SHIFT
Rdpq extension: number of LODs shift.
Definition rdpq_macros.h:517
void __rdpq_fixup_mode(uint32_t cmd_id, uint32_t w0, uint32_t w1)
Write a fixup that changes the current render mode (8-byte command)
Definition rdpq_mode.c:29
void __rdpq_fixup_mode3(uint32_t cmd_id, uint32_t w0, uint32_t w1, uint32_t w2)
Write a fixup that changes the current render mode (12-byte command)
Definition rdpq_mode.c:37
void __rdpq_fixup_mode4(uint32_t cmd_id, uint32_t w0, uint32_t w1, uint32_t w2, uint32_t w3)
Write a fixup that changes the current render mode (16-byte command)
Definition rdpq_mode.c:46
void __rdpq_set_mode_fill(void)
Like rdpq_set_mode_fill, but without fill color configuration.
Definition rdpq_mode.c:75
void rdpq_mode_push(void)
Push the current render mode into the stack.
Definition rdpq_mode.c:62
rdpq_tlut_t rdpq_tlut_from_format(tex_format_t format)
Converts the specified texture format to the TLUT mode that is needed to draw a texture of this forma...
Definition rdpq_mode.h:232
void rdpq_mode_mipmap(rdpq_mipmap_t mode, int num_levels)
Activate mip-mapping.
Definition rdpq_mode.h:808
rdpq_antialias_t
Types of antialiasing supported by RDP.
Definition rdpq_mode.h:256
@ AA_STANDARD
Standard antialiasing.
Definition rdpq_mode.h:258
@ AA_REDUCED
Reduced antialiasing.
Definition rdpq_mode.h:259
@ AA_NONE
No antialiasing.
Definition rdpq_mode.h:257
void rdpq_mode_persp(bool perspective)
Activate perspective correction for textures.
Definition rdpq_mode.h:829
void rdpq_mode_blender(rdpq_blender_t blend)
Configure the formula to use for blending.
Definition rdpq_mode.h:599
void rdpq_set_mode_yuv(bool bilinear)
Reset render mode to YUV mode.
Definition rdpq_mode.c:112
void rdpq_mode_fog(rdpq_blender_t fog)
Enable or disable fog.
Definition rdpq_mode.h:650
void rdpq_mode_combiner(rdpq_combiner_t comb)
Configure the color combiner.
Definition rdpq_mode.h:465
rdpq_filter_t
Texture filtering types.
Definition rdpq_mode.h:131
@ FILTER_POINT
Point filtering (aka nearest)
Definition rdpq_mode.h:132
@ FILTER_BILINEAR
Bilinear filtering.
Definition rdpq_mode.h:133
@ FILTER_MEDIAN
Median filtering.
Definition rdpq_mode.h:134
void rdpq_set_mode_copy(bool transparency)
Reset render mode to COPY type.
Definition rdpq_mode.c:84
void rdpq_mode_antialias(rdpq_antialias_t mode)
Activate antialiasing.
Definition rdpq_mode.h:387
void rdpq_mode_dithering(rdpq_dither_t dither)
Change dithering mode.
Definition rdpq_mode.h:672
void rdpq_set_mode_fill(color_t color)
Reset render mode to FILL type.
Definition rdpq_mode.h:299
void rdpq_mode_zbuf(bool compare, bool update)
Activate z-buffer usage.
Definition rdpq_mode.h:724
rdpq_dither_t
Dithering configuration.
Definition rdpq_mode.h:198
@ DITHER_BAYER_BAYER
Dithering: RGB=Bayer, Alpha=Bayer.
Definition rdpq_mode.h:204
@ DITHER_SQUARE_NOISE
Dithering: RGB=Square, Alpha=Noise.
Definition rdpq_mode.h:201
@ DITHER_BAYER_NONE
Dithering: RGB=Bayer, Alpha=None.
Definition rdpq_mode.h:207
@ DITHER_BAYER_NOISE
Dithering: RGB=Bayer, Alpha=Noise.
Definition rdpq_mode.h:206
@ DITHER_SQUARE_SQUARE
Dithering: RGB=Square, Alpha=Square.
Definition rdpq_mode.h:199
@ DITHER_NOISE_NOISE
Dithering: RGB=Noise, Alpha=Noise.
Definition rdpq_mode.h:211
@ DITHER_NONE_NONE
Dithering: RGB=None, Alpha=None.
Definition rdpq_mode.h:217
@ DITHER_NOISE_INVSQUARE
Dithering: RGB=Noise, Alpha=InvSquare.
Definition rdpq_mode.h:210
@ DITHER_NOISE_NONE
Dithering: RGB=Noise, Alpha=None.
Definition rdpq_mode.h:212
@ DITHER_NONE_INVBAYER
Dithering: RGB=None, Alpha=InvBayer.
Definition rdpq_mode.h:215
@ DITHER_BAYER_INVBAYER
Dithering: RGB=Bayer, Alpha=InvBayer.
Definition rdpq_mode.h:205
@ DITHER_SQUARE_NONE
Dithering: RGB=Square, Alpha=None.
Definition rdpq_mode.h:202
@ DITHER_SQUARE_INVSQUARE
Dithering: RGB=Square, Alpha=InvSquare.
Definition rdpq_mode.h:200
@ DITHER_NONE_NOISE
Dithering: RGB=None, Alpha=Noise.
Definition rdpq_mode.h:216
@ DITHER_NOISE_SQUARE
Dithering: RGB=Noise, Alpha=Square.
Definition rdpq_mode.h:209
@ DITHER_NONE_BAYER
Dithering: RGB=None, Alpha=Bayer.
Definition rdpq_mode.h:214
void rdpq_mode_filter(rdpq_filter_t filt)
Activate texture filtering.
Definition rdpq_mode.h:788
void rdpq_mode_begin(void)
Start a batch of RDP mode changes.
Definition rdpq_mode.c:134
void rdpq_mode_zoverride(bool enable, float z, int16_t deltaz)
Set a fixed override of Z value.
Definition rdpq_mode.h:749
void rdpq_set_mode_standard(void)
Reset render mode to standard.
Definition rdpq_mode.c:93
void rdpq_mode_end(void)
Finish a batch of RDP mode changes.
Definition rdpq_mode.c:144
void rdpq_mode_pop(void)
Pop the current render mode from the stack.
Definition rdpq_mode.c:69
void rdpq_mode_alphacompare(int threshold)
Activate alpha compare feature.
Definition rdpq_mode.h:698
void rdpq_mode_tlut(rdpq_tlut_t tlut)
Activate palette lookup during drawing.
Definition rdpq_mode.h:770
rdpq_mipmap_t
Types of mipmap supported by RDP.
Definition rdpq_mode.h:245
@ MIPMAP_NEAREST
Choose the nearest mipmap level.
Definition rdpq_mode.h:247
@ MIPMAP_INTERPOLATE
Interpolate between the two nearest mipmap levels (also known as "trilinear")
Definition rdpq_mode.h:248
@ MIPMAP_NONE
Mipmap disabled.
Definition rdpq_mode.h:246
@ MIPMAP_INTERPOLATE_DETAIL
Interpolate between the two nearest mipmap levels (also known as "trilinear") with detail texture ena...
Definition rdpq_mode.h:250
@ MIPMAP_INTERPOLATE_SHARPEN
Interpolate between the two nearest mipmap levels (also known as "trilinear") with sharpening enabled...
Definition rdpq_mode.h:249
rdpq_tlut_t
Types of palettes supported by RDP.
Definition rdpq_mode.h:223
@ TLUT_RGBA16
Palette made of FMT_RGBA16 colors.
Definition rdpq_mode.h:225
@ TLUT_IA16
Palette made of FMT_IA16 colors.
Definition rdpq_mode.h:226
@ TLUT_NONE
No palette.
Definition rdpq_mode.h:224
tex_format_t
Pixel format enum.
Definition surface.h:103
@ FMT_CI8
Format CI8: color index 8-bit (paletted, 1 index per byte)
Definition surface.h:110
@ FMT_CI4
Format CI4: color index 4-bit (paletted, 2 indices per byte)
Definition surface.h:109