From 45fc19fd050b1296cb782316f3e1ef8e17c52e15 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 2 Dec 2019 17:03:55 +1000 Subject: [PATCH] GPU: Only latch texpage/mode on polygon/set draw mode Driver seems to draw an off-screen polygon to set up the parameters, instead of the set draw mode command. Fixes broken sprites in Driver/Driver 2. --- src/core/gpu_commands.cpp | 3 ++- src/core/gpu_hw.cpp | 2 -- src/core/gpu_sw.cpp | 5 ----- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/core/gpu_commands.cpp b/src/core/gpu_commands.cpp index b1f394580..d8cd71c39 100644 --- a/src/core/gpu_commands.cpp +++ b/src/core/gpu_commands.cpp @@ -128,6 +128,7 @@ bool GPU::HandleSetDrawModeCommand(const u32*& command_ptr, u32 command_size) // 0..10 bits match GPUSTAT const u32 MASK = ((1 << 11) - 1); + m_render_state.SetFromPageAttribute(param & MASK); m_GPUSTAT.bits = (m_GPUSTAT.bits & ~MASK) | (param & MASK); m_GPUSTAT.texture_disable = (param & (1 << 11)) != 0; m_render_state.texture_x_flip = (param & (1 << 12)) != 0; @@ -292,7 +293,7 @@ bool GPU::HandleRenderCommand(const u32*& command_ptr, u32 command_size) static constexpr std::array primitive_names = {{"", "polygon", "line", "rectangle"}}; - Log_DebugPrintf("Render %s %s %s %s %s (%u verts, %u words per vert)", rc.quad_polygon ? "four-point" : "three-point", + Log_TracePrintf("Render %s %s %s %s %s (%u verts, %u words per vert)", rc.quad_polygon ? "four-point" : "three-point", rc.transparency_enable ? "semi-transparent" : "opaque", rc.texture_enable ? "textured" : "non-textured", rc.shading_enable ? "shaded" : "monochrome", primitive_names[static_cast(rc.primitive.GetValue())], ZeroExtend32(num_vertices), diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 2f42f21c8..2fa024cde 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -284,7 +284,6 @@ void GPU_HW::DispatchRenderCommand(RenderCommand rc, u32 num_vertices, const u32 case Primitive::Rectangle: { m_render_state.SetFromRectangleTexcoord(command_ptr[2]); - m_render_state.SetFromPageAttribute(Truncate16(m_GPUSTAT.bits)); } break; @@ -316,7 +315,6 @@ void GPU_HW::DispatchRenderCommand(RenderCommand rc, u32 num_vertices, const u32 } else { - m_render_state.SetFromPageAttribute(Truncate16(m_GPUSTAT.bits)); texture_mode = TextureMode::Disabled; } diff --git a/src/core/gpu_sw.cpp b/src/core/gpu_sw.cpp index e7692ca05..75dd5f90d 100644 --- a/src/core/gpu_sw.cpp +++ b/src/core/gpu_sw.cpp @@ -171,10 +171,6 @@ void GPU_SW::DispatchRenderCommand(RenderCommand rc, u32 num_vertices, const u32 else m_render_state.SetFromPolygonTexcoord(command_ptr[2], command_ptr[4]); } - else - { - m_render_state.SetFromPageAttribute(Truncate16(m_GPUSTAT.bits)); - } u32 buffer_pos = 1; for (u32 i = 0; i < num_vertices; i++) @@ -214,7 +210,6 @@ void GPU_SW::DispatchRenderCommand(RenderCommand rc, u32 num_vertices, const u32 const u32 texcoord_and_palette = rc.texture_enable ? command_ptr[buffer_pos++] : 0; const auto [texcoord_x, texcoord_y] = UnpackTexcoord(Truncate16(texcoord_and_palette)); - m_render_state.SetFromPageAttribute(Truncate16(m_GPUSTAT.bits)); m_render_state.SetFromPaletteAttribute(Truncate16(texcoord_and_palette >> 16)); s32 width;