mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 12:51:42 +00:00
Get rid of texture copying for shadow maps.
This commit is contained in:
parent
52c5822977
commit
dfc498cbd6
2 changed files with 64 additions and 0 deletions
|
|
@ -6948,6 +6948,52 @@ PPC_FUNC(sub_825E2F78)
|
||||||
__imp__sub_825E2F78(ctx, base);
|
__imp__sub_825E2F78(ctx, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Game shares surfaces with identical descriptions. We don't want to share shadow maps,
|
||||||
|
// so we can set its format to a depth format that still resolves to the same type in recomp,
|
||||||
|
// but manages to keep the surfaces actually separated in guest code.
|
||||||
|
void FxShadowMapInitMidAsmHook(PPCRegister& r11)
|
||||||
|
{
|
||||||
|
uint8_t* base = g_memory.base;
|
||||||
|
|
||||||
|
uint32_t surface = PPC_LOAD_U32(PPC_LOAD_U32(PPC_LOAD_U32(r11.u32 + 0x24) + 0x4));
|
||||||
|
PPC_STORE_U32(surface + 0x20, D3DFMT_D24FS8);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Re-render objects in the terrain shadow map instead of copying the texture.
|
||||||
|
static bool g_jumpOverStretchRect;
|
||||||
|
|
||||||
|
void FxShadowMapNoTerrainMidAsmHook(PPCRegister& r4, PPCRegister& r30)
|
||||||
|
{
|
||||||
|
// Set the no terrain shadow map as the render target.
|
||||||
|
uint8_t* base = g_memory.base;
|
||||||
|
r4.u64 = PPC_LOAD_U32(r30.u32 + 0x58);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FxShadowMapMidAsmHook(PPCRegister& r4, PPCRegister& r5, PPCRegister& r6, PPCRegister& r30)
|
||||||
|
{
|
||||||
|
if (g_jumpOverStretchRect)
|
||||||
|
{
|
||||||
|
// Reset for the next time shadow maps get rendered.
|
||||||
|
g_jumpOverStretchRect = false;
|
||||||
|
|
||||||
|
// Jump over the stretch rect call.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Mark to jump over the stretch call the next time.
|
||||||
|
g_jumpOverStretchRect = true;
|
||||||
|
|
||||||
|
// Jump to the beginning. Set registers accordingly to set the terrain shadow map as the render target.
|
||||||
|
uint8_t* base = g_memory.base;
|
||||||
|
r6.u64 = 0;
|
||||||
|
r5.u64 = 0;
|
||||||
|
r4.u64 = PPC_LOAD_U32(r30.u32 + 0x50);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GUEST_FUNCTION_HOOK(sub_82BD99B0, CreateDevice);
|
GUEST_FUNCTION_HOOK(sub_82BD99B0, CreateDevice);
|
||||||
|
|
||||||
GUEST_FUNCTION_HOOK(sub_82BE6230, DestructResource);
|
GUEST_FUNCTION_HOOK(sub_82BE6230, DestructResource);
|
||||||
|
|
|
||||||
|
|
@ -918,3 +918,21 @@ jump_address = 0x822C111C
|
||||||
[[midasm_hook]]
|
[[midasm_hook]]
|
||||||
name = "PressStartSaveLoadThreadMidAsmHook"
|
name = "PressStartSaveLoadThreadMidAsmHook"
|
||||||
address = 0x822C4358
|
address = 0x822C4358
|
||||||
|
|
||||||
|
[[midasm_hook]]
|
||||||
|
name = "FxShadowMapInitMidAsmHook"
|
||||||
|
address = 0x82BAD8F4
|
||||||
|
registers = ["r11"]
|
||||||
|
|
||||||
|
[[midasm_hook]]
|
||||||
|
name = "FxShadowMapNoTerrainMidAsmHook"
|
||||||
|
address = 0x82BAD9EC
|
||||||
|
registers = ["r4", "r30"]
|
||||||
|
after_instruction = true
|
||||||
|
|
||||||
|
[[midasm_hook]]
|
||||||
|
name = "FxShadowMapMidAsmHook"
|
||||||
|
address = 0x82BADADC
|
||||||
|
registers = ["r4", "r5", "r6", "r30"]
|
||||||
|
jump_address_on_true = 0x82BAD9F0
|
||||||
|
jump_address_on_false = 0x82BADAFC
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue