From 2c76e6d023f1c4c4a5d4e19ca00f7df2c26c9f2b Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Mon, 24 Mar 2014 11:19:11 +0100 Subject: [PATCH] Correctly keep track of "full alpha" in vertices (x86 jit only). --- GPU/GLES/TransformPipeline.cpp | 13 ++++++++----- GPU/GLES/TransformPipeline.h | 6 ++++++ GPU/GLES/VertexDecoderX86.cpp | 22 ++++++++++++++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/GPU/GLES/TransformPipeline.cpp b/GPU/GLES/TransformPipeline.cpp index 0b01d00a3a..263fdfb4b1 100644 --- a/GPU/GLES/TransformPipeline.cpp +++ b/GPU/GLES/TransformPipeline.cpp @@ -265,11 +265,6 @@ void TransformDrawEngine::SetupVertexDecoder(u32 vertType) { if (vertTypeID != lastVType_) { dec_ = GetVertexDecoder(vertTypeID); lastVType_ = vertTypeID; - - // TODO: Add functionality to VertexDecoder to scan for non-full alpha in the two other formats, - // which are quite common. - int colorType = vertTypeID & GE_VTYPE_COL_MASK; - gstate_c.vertexFullAlpha = colorType == GE_VTYPE_COL_NONE || colorType == GE_VTYPE_COL_565; } } @@ -566,6 +561,8 @@ void TransformDrawEngine::DoFlush() { vai->numVerts = indexGen.VertexCount(); vai->prim = indexGen.Prim(); vai->maxIndex = indexGen.MaxIndex(); + vai->flags = gstate_c.vertexFullAlpha ? VAI_FLAG_VERTEXFULLALPHA : 0; + goto rotateVBO; } @@ -645,6 +642,8 @@ void TransformDrawEngine::DoFlush() { vertexCount = vai->numVerts; maxIndex = vai->maxIndex; prim = static_cast(vai->prim); + + gstate_c.vertexFullAlpha = vai->flags & VAI_FLAG_VERTEXFULLALPHA; break; } @@ -665,6 +664,8 @@ void TransformDrawEngine::DoFlush() { vertexCount = vai->numVerts; maxIndex = vai->maxIndex; prim = static_cast(vai->prim); + + gstate_c.vertexFullAlpha = vai->flags & VAI_FLAG_VERTEXFULLALPHA; break; } @@ -717,6 +718,7 @@ rotateVBO: glBindBuffer(GL_ARRAY_BUFFER, 0); } else { DecodeVerts(); + LinkedShader *program = shaderManager_->ApplyFragmentShader(vshader, prim, lastVType_); gpuStats.numUncachedVertsDrawn += indexGen.VertexCount(); prim = indexGen.Prim(); @@ -737,6 +739,7 @@ rotateVBO: decodeCounter_ = 0; dcid_ = 0; prevPrim_ = GE_PRIM_INVALID; + gstate_c.vertexFullAlpha = true; #ifndef MOBILE_DEVICE host->GPUNotifyDraw(); diff --git a/GPU/GLES/TransformPipeline.h b/GPU/GLES/TransformPipeline.h index a9c16eaca8..bee7621bd3 100644 --- a/GPU/GLES/TransformPipeline.h +++ b/GPU/GLES/TransformPipeline.h @@ -43,6 +43,10 @@ struct DecVtxFormat; // DRAWN_ONCE -> death // DRAWN_RELIABLE -> death +enum { + VAI_FLAG_VERTEXFULLALPHA = 1, +}; + // Try to keep this POD. class VertexArrayInfo { public: @@ -57,6 +61,7 @@ public: lastFrame = gpuStats.numFlips; numVerts = 0; drawsUntilNextFullHash = 0; + flags = 0; } ~VertexArrayInfo(); @@ -85,6 +90,7 @@ public: int numFrames; int lastFrame; // So that we can forget. u16 drawsUntilNextFullHash; + u8 flags; }; // Handles transform, lighting and drawing. diff --git a/GPU/GLES/VertexDecoderX86.cpp b/GPU/GLES/VertexDecoderX86.cpp index 32223cf42e..0c770903da 100644 --- a/GPU/GLES/VertexDecoderX86.cpp +++ b/GPU/GLES/VertexDecoderX86.cpp @@ -556,6 +556,11 @@ void VertexDecoderJitCache::Jit_TcFloatThrough() { void VertexDecoderJitCache::Jit_Color8888() { MOV(32, R(tempReg1), MDisp(srcReg, dec_->coloff)); MOV(32, MDisp(dstReg, dec_->decFmt.c0off), R(tempReg1)); + + CMP(32, R(tempReg1), Imm32(0xFF000000)); + FixupBranch skip = J_CC(CC_GE, false); + MOV(8, M(&gstate_c.textureFullAlpha), Imm8(0)); + SetJumpTarget(skip); } static const u32 MEMORY_ALIGNED16(nibbles[4]) = { 0x0f0f0f0f, 0x0f0f0f0f, 0x0f0f0f0f, 0x0f0f0f0f, }; @@ -625,6 +630,11 @@ void VertexDecoderJitCache::Jit_Color4444() { OR(32, R(tempReg2), R(tempReg3)); MOV(32, MDisp(dstReg, dec_->decFmt.c0off), R(tempReg2)); + + CMP(32, R(tempReg2), Imm32(0xFF000000)); + FixupBranch skip = J_CC(CC_AE, false); + MOV(8, M(&gstate_c.textureFullAlpha), Imm8(0)); + SetJumpTarget(skip); } void VertexDecoderJitCache::Jit_Color565() { @@ -696,6 +706,11 @@ void VertexDecoderJitCache::Jit_Color5551() { OR(32, R(tempReg2), R(tempReg1)); MOV(32, MDisp(dstReg, dec_->decFmt.c0off), R(tempReg2)); + + CMP(32, R(tempReg2), Imm32(0xFF000000)); + FixupBranch skip = J_CC(CC_AE, false); + MOV(8, M(&gstate_c.textureFullAlpha), Imm8(0)); + SetJumpTarget(skip); } void VertexDecoderJitCache::Jit_Color8888Morph() { @@ -890,6 +905,13 @@ void VertexDecoderJitCache::Jit_WriteMorphColor(int outOff) { PACKSSDW(fpScratchReg, R(fpScratchReg)); PACKUSWB(fpScratchReg, R(fpScratchReg)); MOVD_xmm(MDisp(dstReg, outOff), fpScratchReg); + + // TODO: May be a faster way to do this without the MOVD. + MOVD_xmm(R(tempReg1), fpScratchReg); + CMP(32, R(tempReg1), Imm32(0xFF000000)); + FixupBranch skip = J_CC(CC_AE, false); + MOV(8, M(&gstate_c.textureFullAlpha), Imm8(0)); + SetJumpTarget(skip); } // Copy 3 bytes and then a zero. Might as well copy four.