Merge pull request #5083 from unknownbrackets/softgpu

Rotate UVs and fix crash in softgpu
This commit is contained in:
Henrik Rydgård 2014-01-11 14:26:44 -08:00
commit 76915d0fac
2 changed files with 20 additions and 4 deletions

View File

@ -15,10 +15,12 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "../GPUState.h"
#include <algorithm>
#include "Clipper.h"
#include "Rasterizer.h"
#include "GPU/GPUState.h"
#include "GPU/Software/Clipper.h"
#include "GPU/Software/Rasterizer.h"
namespace Clipper {
@ -123,6 +125,17 @@ static inline int CalcClipMask(const ClipCoords& v)
} \
}
static void RotateUVThrough(VertexData &tl, VertexData &tr, VertexData &bl, VertexData &br) {
const fixed16 x1 = tl.screenpos.x;
const fixed16 x2 = br.screenpos.x;
const fixed16 y1 = tl.screenpos.y;
const fixed16 y2 = br.screenpos.y;
if ((x1 < x2 && y1 > y2) || (x1 > x2 && y1 < y2)) {
std::swap(bl.texturecoords, tr.texturecoords);
}
}
void ProcessQuad(const VertexData& v0, const VertexData& v1)
{
if (!gstate.isModeThrough()) {
@ -198,6 +211,8 @@ void ProcessQuad(const VertexData& v0, const VertexData& v1)
bottomright = &buf[i];
}
RotateUVThrough(*topleft, *topright, *bottomleft, *bottomright);
// Four triangles to do backfaces as well. Two of them will get backface culled.
Rasterizer::DrawTriangle(*topleft, *topright, *bottomright);
Rasterizer::DrawTriangle(*bottomright, *topright, *topleft);

View File

@ -172,7 +172,8 @@ SoftGPU::~SoftGPU()
}
void SoftGPU::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) {
displayFramebuf_ = framebuf;
// Seems like this can point into RAM, but should be VRAM if not in RAM.
displayFramebuf_ = (framebuf & 0xFF000000) == 0 ? 0x44000000 | framebuf : framebuf;
displayStride_ = stride;
displayFormat_ = format;
host->GPUNotifyDisplay(framebuf, stride, format);