From 5ecc39763927f370faf6d74b7efc0f3387384a6f Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Mon, 11 Nov 2024 16:01:25 +0300 Subject: [PATCH] Fix Chip not appearing transparent in "To The Surface" cutscene. --- UnleashedRecomp/gpu/video.cpp | 36 ++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/UnleashedRecomp/gpu/video.cpp b/UnleashedRecomp/gpu/video.cpp index f3ac935..b08ca8e 100644 --- a/UnleashedRecomp/gpu/video.cpp +++ b/UnleashedRecomp/gpu/video.cpp @@ -2023,12 +2023,37 @@ static void ProcStretchRect(const RenderCommand& cmd) AddBarrier(args.texture, RenderTextureLayout::SHADER_READ); } +static void SetDefaultViewport(GuestDevice* device, GuestSurface* surface) +{ + if (surface != nullptr) + { + RenderCommand cmd; + cmd.type = RenderCommandType::SetViewport; + cmd.setViewport.x = 0.0f; + cmd.setViewport.y = 0.0f; + cmd.setViewport.width = float(surface->width); + cmd.setViewport.height = float(surface->height); + cmd.setViewport.minDepth = 0.0f; + cmd.setViewport.maxDepth = 1.0f; + g_renderQueue.enqueue(cmd); + + device->viewport.x = 0.0f; + device->viewport.y = 0.0f; + device->viewport.width = float(surface->width); + device->viewport.height = float(surface->height); + device->viewport.minZ = 0.0f; + device->viewport.maxZ = 1.0f; + } +} + static void SetRenderTarget(GuestDevice* device, uint32_t index, GuestSurface* renderTarget) { RenderCommand cmd; cmd.type = RenderCommandType::SetRenderTarget; cmd.setRenderTarget.renderTarget = renderTarget; g_renderQueue.enqueue(cmd); + + SetDefaultViewport(device, renderTarget); } static void ProcSetRenderTarget(const RenderCommand& cmd) @@ -2049,6 +2074,8 @@ static void SetDepthStencilSurface(GuestDevice* device, GuestSurface* depthStenc cmd.type = RenderCommandType::SetDepthStencilSurface; cmd.setDepthStencilSurface.depthStencil = depthStencil; g_renderQueue.enqueue(cmd); + + SetDefaultViewport(device, depthStencil); } static void ProcSetDepthStencilSurface(const RenderCommand& cmd) @@ -3695,9 +3722,13 @@ static void SetResolution(be* device) device[47] = height == 0 ? 720 : height; } -static uint32_t StubFunction() +// The game does some weird stuff to render targets if they are above +// 1024x1024 resolution, setting this bool at address 20 seems to avoid all that. +PPC_FUNC(sub_82E9F048) { - return 0; + PPC_STORE_U8(ctx.r4.u32 + 20, 1); + PPC_STORE_U32(ctx.r4.u32 + 44, PPC_LOAD_U32(ctx.r4.u32 + 8)); // Width + PPC_STORE_U32(ctx.r4.u32 + 48, PPC_LOAD_U32(ctx.r4.u32 + 12)); // Height } static GuestShader* g_movieVertexShader; @@ -3892,7 +3923,6 @@ GUEST_FUNCTION_HOOK(sub_82C00910, D3DXFillVolumeTexture); GUEST_FUNCTION_HOOK(sub_82E43FC8, MakePictureData); GUEST_FUNCTION_HOOK(sub_82E9EE38, SetResolution); -GUEST_FUNCTION_HOOK(sub_82BE77B0, StubFunction); GUEST_FUNCTION_HOOK(sub_82AE2BF8, ScreenShaderInit);