From 2f569533f3817b413ce5ca0b0b415e8a9f2e1d28 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 13 Sep 2014 14:08:07 +0200 Subject: [PATCH] Fix burnout depth issue by dirtying the proj matrix on viewport change --- GPU/Common/SoftwareTransformCommon.h | 17 +++++++++++++ GPU/Directx9/GPU_DX9.cpp | 23 ++++++++++++----- GPU/Directx9/GPU_DX9.h | 1 + GPU/Directx9/TransformPipelineDX9.h | 38 ---------------------------- 4 files changed, 35 insertions(+), 44 deletions(-) diff --git a/GPU/Common/SoftwareTransformCommon.h b/GPU/Common/SoftwareTransformCommon.h index f59e77318..00b2b4297 100644 --- a/GPU/Common/SoftwareTransformCommon.h +++ b/GPU/Common/SoftwareTransformCommon.h @@ -1,3 +1,20 @@ +// Copyright (c) 2013- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + #pragma once #include "Common/CommonTypes.h" diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index e0854d841..8e1f7d247 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -196,12 +196,12 @@ static const CommandTableEntry commandTable[] = { {GE_CMD_PATCHCULLENABLE, FLAG_FLUSHBEFOREONCHANGE}, // Viewport. - {GE_CMD_VIEWPORTX1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE}, - {GE_CMD_VIEWPORTY1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE}, - {GE_CMD_VIEWPORTX2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE}, - {GE_CMD_VIEWPORTY2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE}, - {GE_CMD_VIEWPORTZ1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE}, - {GE_CMD_VIEWPORTZ2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE}, + {GE_CMD_VIEWPORTX1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, &DIRECTX9_GPU::Execute_ViewportType}, + {GE_CMD_VIEWPORTY1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, &DIRECTX9_GPU::Execute_ViewportType}, + {GE_CMD_VIEWPORTX2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, &DIRECTX9_GPU::Execute_ViewportType}, + {GE_CMD_VIEWPORTY2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, &DIRECTX9_GPU::Execute_ViewportType}, + {GE_CMD_VIEWPORTZ1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, &DIRECTX9_GPU::Execute_ViewportType}, + {GE_CMD_VIEWPORTZ2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, &DIRECTX9_GPU::Execute_ViewportType}, // Region {GE_CMD_REGION1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE}, @@ -684,6 +684,17 @@ void DIRECTX9_GPU::Execute_VertexTypeSkinning(u32 op, u32 diff) { } } +void DIRECTX9_GPU::Execute_ViewportType(u32 op, u32 diff) { + gstate_c.framebufChanged = true; + gstate_c.textureChanged |= TEXCHANGE_PARAMSONLY; + switch (op >> 24) { + case GE_CMD_VIEWPORTZ1: + case GE_CMD_VIEWPORTZ2: + shaderManager_->DirtyUniform(DIRTY_PROJMATRIX); + break; + } +} + void DIRECTX9_GPU::Execute_WorldMtxNum(u32 op, u32 diff) { // This is almost always followed by GE_CMD_WORLDMATRIXDATA. const u32_le *src = (const u32_le *)Memory::GetPointer(currentList->pc + 4); diff --git a/GPU/Directx9/GPU_DX9.h b/GPU/Directx9/GPU_DX9.h index f03e313d2..071ffb99f 100644 --- a/GPU/Directx9/GPU_DX9.h +++ b/GPU/Directx9/GPU_DX9.h @@ -89,6 +89,7 @@ public: void Execute_Iaddr(u32 op, u32 diff); void Execute_VertexType(u32 op, u32 diff); void Execute_VertexTypeSkinning(u32 op, u32 diff); + void Execute_ViewportType(u32 op, u32 diff); void Execute_WorldMtxNum(u32 op, u32 diff); void Execute_WorldMtxData(u32 op, u32 diff); void Execute_ViewMtxNum(u32 op, u32 diff); diff --git a/GPU/Directx9/TransformPipelineDX9.h b/GPU/Directx9/TransformPipelineDX9.h index d24f08b26..700861d08 100644 --- a/GPU/Directx9/TransformPipelineDX9.h +++ b/GPU/Directx9/TransformPipelineDX9.h @@ -224,42 +224,4 @@ private: VertexDecoderOptions decOptions_; }; -// Only used by SW transform -struct Color4 { - float a, r, g, b; - - Color4() : r(0), g(0), b(0), a(0) { } - Color4(float _r, float _g, float _b, float _a=1.0f) - : r(_r), g(_g), b(_b), a(_a) { - } - Color4(const float in[4]) {a=in[0];r=in[1];g=in[2];b=in[3];} - Color4(const float in[3], float alpha) {r=in[0];g=in[1];b=in[2];a=alpha;} - - const float &operator [](int i) const {return *(&a + i);} - - Color4 operator *(float f) const { - return Color4(f*r,f*g,f*b,f*a); - } - Color4 operator *(const Color4 &c) const { - return Color4(r*c.r,g*c.g,b*c.b,a*c.a); - } - Color4 operator +(const Color4 &c) const { - return Color4(r+c.r,g+c.g,b+c.b,a+c.a); - } - void operator +=(const Color4 &c) { - r+=c.r; - g+=c.g; - b+=c.b; - a+=c.a; - } - void GetFromRGB(u32 col) { - b = ((col>>16) & 0xff)/255.0f; - g = ((col>>8) & 0xff)/255.0f; - r = ((col>>0) & 0xff)/255.0f; - } - void GetFromA(u32 col) { - a = (col&0xff)/255.0f; - } -}; - };