diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp new file mode 100644 index 0000000000..129ff400c0 --- /dev/null +++ b/GPU/Common/TextureCacheCommon.cpp @@ -0,0 +1,25 @@ +// 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/. + + +#include "GPU/Common/TextureCacheCommon.h" + +TextureCacheCommon::~TextureCacheCommon() {} + +bool TextureCacheCommon::SetOffsetTexture(u32 offset) { + return false; +} diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h new file mode 100644 index 0000000000..33bbe9e6a6 --- /dev/null +++ b/GPU/Common/TextureCacheCommon.h @@ -0,0 +1,27 @@ +// 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" + +class TextureCacheCommon { +public: + virtual ~TextureCacheCommon(); + + virtual bool SetOffsetTexture(u32 offset); +}; \ No newline at end of file diff --git a/GPU/GLES/SoftwareTransform.cpp b/GPU/GLES/SoftwareTransform.cpp index 962333287a..4fb5dd1216 100644 --- a/GPU/GLES/SoftwareTransform.cpp +++ b/GPU/GLES/SoftwareTransform.cpp @@ -16,6 +16,7 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "math/math_util.h" +#include "gfx_es2/gpu_features.h" #include "Core/Config.h" #include "GPU/GPUState.h" @@ -23,7 +24,7 @@ #include "GPU/Common/VertexDecoderCommon.h" #include "GPU/Common/TransformCommon.h" #include "GPU/Common/FramebufferCommon.h" -#include "GPU/GLES/TextureCache.h" +#include "GPU/Common/TextureCacheCommon.h" #include "GPU/GLES/TransformPipeline.h" // This is the software transform pipeline, which is necessary for supporting RECT @@ -82,7 +83,7 @@ static void RotateUVThrough(TransformedVertex v[4]) { // Clears on the PSP are best done by drawing a series of vertical strips // in clear mode. This tries to detect that. -bool TransformDrawEngine::IsReallyAClear(int numVerts) const { +static bool IsReallyAClear(const TransformedVertex *transformed, int numVerts) { if (transformed[0].x != 0.0f || transformed[0].y != 0.0f) return false; @@ -119,10 +120,9 @@ bool TransformDrawEngine::IsReallyAClear(int numVerts) const { return true; } - void TransformDrawEngine::SoftwareTransform( int prim, u8 *decoded, LinkedShader *program, int vertexCount, u32 vertType, void *inds, int indexType, - const DecVtxFormat &decVtxFormat, int maxIndex, FramebufferManagerCommon *fbman, TransformedVertex *&drawBuffer, int &numTrans, bool &drawIndexed, SoftwareTransformResult *result) { + const DecVtxFormat &decVtxFormat, int maxIndex, FramebufferManagerCommon *fbman, TextureCacheCommon *texCache, TransformedVertex *&drawBuffer, int &numTrans, bool &drawIndexed, SoftwareTransformResult *result) { bool throughmode = (vertType & GE_VTYPE_THROUGH_MASK) != 0; bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled(); @@ -388,7 +388,7 @@ void TransformDrawEngine::SoftwareTransform( // An alternative option is to simply ditch all the verts except the first and last to create a single // rectangle out of many. Quite a small optimization though. // Experiment: Disable on PowerVR (see issue #6290) - if (maxIndex > 1 && gstate.isModeClear() && prim == GE_PRIM_RECTANGLES && IsReallyAClear(maxIndex) && gl_extensions.gpuVendor != GPU_VENDOR_POWERVR) { + if (maxIndex > 1 && gstate.isModeClear() && prim == GE_PRIM_RECTANGLES && IsReallyAClear(transformed, maxIndex) && gl_extensions.gpuVendor != GPU_VENDOR_POWERVR) { result->color = transformed[0].color0_32; result->depth = transformed[0].z; result->action = SW_CLEAR; @@ -409,7 +409,7 @@ void TransformDrawEngine::SoftwareTransform( const u32 fb_size = bpp * fbman->GetTargetStride() * gstate_c.curTextureHeight; const u32 prevH = gstate_c.curTextureHeight; const u32 prevYOffset = gstate_c.curTextureYOffset; - if (textureCache_->SetOffsetTexture(fb_size)) { + if (texCache->SetOffsetTexture(fb_size)) { const float oldWidthFactor = widthFactor; const float oldHeightFactor = heightFactor; widthFactor = (float) w / (float) gstate_c.curTextureWidth; diff --git a/GPU/GLES/TextureCache.h b/GPU/GLES/TextureCache.h index 5c837830ea..6028f4c72a 100644 --- a/GPU/GLES/TextureCache.h +++ b/GPU/GLES/TextureCache.h @@ -24,6 +24,7 @@ #include "GPU/GPUInterface.h" #include "GPU/GPUState.h" #include "GPU/GLES/TextureScaler.h" +#include "GPU/Common/TextureCacheCommon.h" struct VirtualFramebuffer; class FramebufferManager; @@ -51,13 +52,13 @@ inline bool UseBGRA8888() { return false; } -class TextureCache { +class TextureCache : public TextureCacheCommon { public: TextureCache(); ~TextureCache(); void SetTexture(bool force = false); - bool SetOffsetTexture(u32 offset); + bool SetOffsetTexture(u32 offset) override; void Clear(bool delete_them); void StartFrame(); diff --git a/GPU/GLES/TransformPipeline.cpp b/GPU/GLES/TransformPipeline.cpp index f8513730b7..9329ba4ebd 100644 --- a/GPU/GLES/TransformPipeline.cpp +++ b/GPU/GLES/TransformPipeline.cpp @@ -769,7 +769,7 @@ rotateVBO: SoftwareTransform( prim, decoded, program, indexGen.VertexCount(), dec_->VertexType(), (void *)inds, GE_VTYPE_IDX_16BIT, dec_->GetDecVtxFmt(), - indexGen.MaxIndex(), framebufferManager_, drawBuffer, numTrans, drawIndexed, &result); + indexGen.MaxIndex(), framebufferManager_, textureCache_, drawBuffer, numTrans, drawIndexed, &result); if (result.action == SW_DRAW_PRIMITIVES) { if (result.setStencil) { diff --git a/GPU/GLES/TransformPipeline.h b/GPU/GLES/TransformPipeline.h index c5691a14fb..3ae22753c5 100644 --- a/GPU/GLES/TransformPipeline.h +++ b/GPU/GLES/TransformPipeline.h @@ -30,6 +30,7 @@ class ShaderManager; class TextureCache; class FramebufferManager; class FramebufferManagerCommon; +class TextureCacheCommon; class FragmentTestCache; struct TransformedVertex; @@ -193,14 +194,13 @@ private: void DecodeVerts(); void DecodeVertsStep(); void DoFlush(); - void SoftwareTransform(int prim, u8 *decoded, LinkedShader *program, int vertexCount, u32 vertexType, void *inds, int indexType, const DecVtxFormat &decVtxFormat, int maxIndex, FramebufferManagerCommon *fbman, TransformedVertex *&drawBuffer, int &numTrans, bool &drawIndexed, SoftwareTransformResult *result); + void SoftwareTransform(int prim, u8 *decoded, LinkedShader *program, int vertexCount, u32 vertexType, void *inds, int indexType, const DecVtxFormat &decVtxFormat, int maxIndex, FramebufferManagerCommon *fbman, TextureCacheCommon *texCache, TransformedVertex *&drawBuffer, int &numTrans, bool &drawIndexed, SoftwareTransformResult *result); void ApplyDrawState(int prim); void ApplyDrawStateLate(); void ApplyBlendState(); void ApplyStencilReplaceOnly(); bool ApplyShaderBlending(); inline void ResetShaderBlending(); - bool IsReallyAClear(int numVerts) const; GLuint AllocateBuffer(); void FreeBuffer(GLuint buf); diff --git a/GPU/GPU.vcxproj b/GPU/GPU.vcxproj index 042ae4f567..e448505257 100644 --- a/GPU/GPU.vcxproj +++ b/GPU/GPU.vcxproj @@ -172,6 +172,7 @@ true true + @@ -225,6 +226,7 @@ true true + true @@ -286,4 +288,4 @@ - \ No newline at end of file + diff --git a/GPU/GPU.vcxproj.filters b/GPU/GPU.vcxproj.filters index 280a9815f7..682a4751ec 100644 --- a/GPU/GPU.vcxproj.filters +++ b/GPU/GPU.vcxproj.filters @@ -156,6 +156,9 @@ Common + + Common + Common @@ -296,6 +299,9 @@ Common + + Common + Common @@ -321,4 +327,4 @@ - \ No newline at end of file +