Cleanup SoftwareTransform a bit more

This commit is contained in:
Henrik Rydgard 2014-09-13 13:15:18 +02:00
parent ca3ed34b44
commit 4212bbb51e
8 changed files with 74 additions and 13 deletions

View File

@ -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;
}

View File

@ -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);
};

View File

@ -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;

View File

@ -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();

View File

@ -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) {

View File

@ -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);

View File

@ -172,6 +172,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="Common\TextureCacheCommon.h" />
<ClInclude Include="Common\TransformCommon.h" />
<ClInclude Include="Common\VertexDecoderCommon.h" />
<ClInclude Include="Debugger\Breakpoints.h" />
@ -225,6 +226,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="Common\TextureCacheCommon.cpp" />
<ClCompile Include="Common\TransformCommon.cpp" />
<ClCompile Include="Common\VertexDecoderArm.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>

View File

@ -156,6 +156,9 @@
<ClInclude Include="Common\TextureDecoderNEON.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Common\TextureCacheCommon.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Common\TransformCommon.h">
<Filter>Common</Filter>
</ClInclude>
@ -296,6 +299,9 @@
<ClCompile Include="Common\TextureDecoderNEON.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="Common\TextureCacheCommon.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="Common\TransformCommon.cpp">
<Filter>Common</Filter>
</ClCompile>