mirror of
https://github.com/HackerN64/HackerOoT.git
synced 2026-01-21 10:37:37 -08:00
Merge pull request #130 from HackerN64/F3DEX3Memset
Use F3DEX3 memset to clear Z buffer for RDP time savings
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1086,6 +1086,7 @@ Gfx* Gfx_TwoTexScrollEnvColor(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1
|
||||
u32 x2, u32 y2, s32 width2, s32 height2, s32 r, s32 g, s32 b, s32 a);
|
||||
Gfx* Gfx_EnvColor(GraphicsContext* gfxCtx, s32 r, s32 g, s32 b, s32 a);
|
||||
void Gfx_SetupFrame(GraphicsContext* gfxCtx, s32 clearFB, u8 r, u8 g, u8 b);
|
||||
void Gfx_ClearZBuffer(GraphicsContext* gfxCtx);
|
||||
void func_80095974(GraphicsContext* gfxCtx);
|
||||
void func_80095AA0(PlayState* play, Room* room, Input* input, s32 arg3);
|
||||
void Room_DrawBackground2D(Gfx** gfxP, void* tex, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tlutMode,
|
||||
|
||||
@@ -44,6 +44,7 @@ of warnings if you use -Wpedantic. */
|
||||
/*#define G_SPECIAL_3 0xD3 no-op in F3DEX2 */
|
||||
/*#define G_SPECIAL_2 0xD4 no-op in F3DEX2 */
|
||||
/*#define G_SPECIAL_1 0xD5 triggered MVP recalculation, not supported in F3DEX3 */
|
||||
#define G_MEMSET 0xD5
|
||||
#define G_DMA_IO 0xD6
|
||||
#define G_TEXTURE 0xD7
|
||||
#define G_POPMTX 0xD8
|
||||
@@ -2385,6 +2386,25 @@ _DW({ \
|
||||
#define gSPDmaWrite(pkt,dmem,dram,size) gSPDma_io((pkt),1,(dmem),(dram),(size))
|
||||
#define gsSPDmaWrite(dmem,dram,size) gsSPDma_io( 1,(dmem),(dram),(size))
|
||||
|
||||
/**
|
||||
* Use RSP DMAs to set a region of memory to a repeated 16-bit value. This can
|
||||
* clear the color framebuffer or Z-buffer faster than the RDP can in fill mode.
|
||||
* SPMemset overwrites the DMEM vertex buffer, so vertices loaded before this
|
||||
* command cannot be used after it (though this would not normally be done).
|
||||
*
|
||||
* dram: Segmented or physical start address. Must be aligned to 16 bytes.
|
||||
* value: 16-bit value to fill the memory with. e.g. 0 for color, 0xFFFC for Z.
|
||||
* size: Size in bytes to fill, must be nonzero and a multiple of 16 bytes.
|
||||
*/
|
||||
#define gSPMemset(pkt, dram, value, size) \
|
||||
_DW({ \
|
||||
gImmp1(pkt, G_RDPHALF_1, ((value) & 0xFFFF)); \
|
||||
gDma0p(pkt, G_MEMSET, (dram), ((size) & 0xFFFFF0)); \
|
||||
})
|
||||
|
||||
#define gsSPMemset(pkt, dram, value, size) \
|
||||
gsImmp1(G_RDPHALF_1, ((value) & 0xFFFF)), \
|
||||
gsDma0p(G_MEMSET, (dram), ((size) & 0xFFFFF0))
|
||||
|
||||
/*
|
||||
* RSP short command (no DMA required) macros
|
||||
|
||||
@@ -223,13 +223,7 @@ extern volatile s8 gLoadedF3DEX3Version;
|
||||
extern volatile s8 gF3DEX3ProfVersion;
|
||||
extern volatile s8 gF3DEX3NOCVersion;
|
||||
extern s8 gF3DEX3OccMode;
|
||||
#endif
|
||||
|
||||
#if ENABLE_F3DEX3
|
||||
extern u8 gF3DEX3TextBuffer[];
|
||||
extern volatile s8 gF3DEX3ProfVersion;
|
||||
extern volatile s8 gF3DEX3NOCVersion;
|
||||
extern s8 gF3DEX3OccMode;
|
||||
extern u8 gUseMemsetForZBuffer;
|
||||
#endif
|
||||
|
||||
extern SfxBankEntry D_8016BAD0[9];
|
||||
|
||||
@@ -1258,7 +1258,7 @@ void Play_Draw(PlayState* this) {
|
||||
clearG = this->lightCtx.fogColor[1];
|
||||
clearB = this->lightCtx.fogColor[2];
|
||||
}
|
||||
// Clear the fb only if we aren't drawing a skybox, but always clear zb
|
||||
// Clear the fb only if we aren't drawing a skybox
|
||||
Gfx_SetupFrame(gfxCtx, clearFB, clearR, clearG, clearB);
|
||||
}
|
||||
|
||||
@@ -1378,6 +1378,15 @@ void Play_Draw(PlayState* this) {
|
||||
Environment_DrawSkyboxFilters(this);
|
||||
}
|
||||
|
||||
// The Z buffer has to be cleared at some point before anything using it
|
||||
// is drawn (lighting strike is the first which does). But if we are
|
||||
// using F3DEX3's SPMemset to clear it, it should be done as late as
|
||||
// possible, after the RSP has already sent commands to the RDP for the
|
||||
// skybox or framebuffer clear. This is so that the RSP can clear the Z
|
||||
// buffer while the RDP is working on the framebuffer, without making
|
||||
// the RDP wait for new work to be available.
|
||||
Gfx_ClearZBuffer(gfxCtx);
|
||||
|
||||
if (!IS_DEBUG || (R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_LIGHTNING)) {
|
||||
Environment_UpdateLightningStrike(this);
|
||||
Environment_DrawLightning(this, 0);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user