mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Transform rects using indices.
Not a hge difference. Minor cleanup.
This commit is contained in:
parent
b9b96f1416
commit
d663cda2de
4 changed files with 48 additions and 36 deletions
|
@ -121,7 +121,7 @@ static bool IsReallyAClear(const TransformedVertex *transformed, int numVerts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftwareTransform(
|
void SoftwareTransform(
|
||||||
int prim, u8 *decoded, int vertexCount, u32 vertType, void *inds, int indexType,
|
int prim, u8 *decoded, int vertexCount, u32 vertType, u16 *&inds, int indexType,
|
||||||
const DecVtxFormat &decVtxFormat, int maxIndex, FramebufferManagerCommon *fbman, TextureCacheCommon *texCache, TransformedVertex *transformed, TransformedVertex *transformedExpanded, TransformedVertex *&drawBuffer, int &numTrans, bool &drawIndexed, SoftwareTransformResult *result) {
|
const DecVtxFormat &decVtxFormat, int maxIndex, FramebufferManagerCommon *fbman, TextureCacheCommon *texCache, TransformedVertex *transformed, TransformedVertex *transformedExpanded, TransformedVertex *&drawBuffer, int &numTrans, bool &drawIndexed, SoftwareTransformResult *result) {
|
||||||
bool throughmode = (vertType & GE_VTYPE_THROUGH_MASK) != 0;
|
bool throughmode = (vertType & GE_VTYPE_THROUGH_MASK) != 0;
|
||||||
bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled();
|
bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled();
|
||||||
|
@ -462,36 +462,35 @@ void SoftwareTransform(
|
||||||
numTrans = 0;
|
numTrans = 0;
|
||||||
drawBuffer = transformedExpanded;
|
drawBuffer = transformedExpanded;
|
||||||
TransformedVertex *trans = &transformedExpanded[0];
|
TransformedVertex *trans = &transformedExpanded[0];
|
||||||
TransformedVertex saved;
|
const u16 *indsIn = (const u16 *)inds;
|
||||||
u32 stencilValue = 0;
|
u16 *newInds = inds + vertexCount;
|
||||||
|
u16 *indsOut = newInds;
|
||||||
for (int i = 0; i < vertexCount; i += 2) {
|
for (int i = 0; i < vertexCount; i += 2) {
|
||||||
int index = ((const u16*)inds)[i];
|
const TransformedVertex &transVtxTL = transformed[indsIn[i + 0]];
|
||||||
saved = transformed[index];
|
const TransformedVertex &transVtxBR = transformed[indsIn[i + 1]];
|
||||||
int index2 = ((const u16*)inds)[i + 1];
|
|
||||||
TransformedVertex &transVtx = transformed[index2];
|
// We have to turn the rectangle into two triangles, so 6 points.
|
||||||
if (i == 0)
|
// This is 4 verts + 6 indices.
|
||||||
stencilValue = transVtx.color0[3];
|
|
||||||
// We have to turn the rectangle into two triangles, so 6 points. Sigh.
|
|
||||||
|
|
||||||
// bottom right
|
// bottom right
|
||||||
trans[0] = transVtx;
|
trans[0] = transVtxBR;
|
||||||
|
|
||||||
// bottom left
|
|
||||||
trans[1] = transVtx;
|
|
||||||
trans[1].y = saved.y;
|
|
||||||
trans[1].v = saved.v;
|
|
||||||
|
|
||||||
// top left
|
|
||||||
trans[2] = transVtx;
|
|
||||||
trans[2].x = saved.x;
|
|
||||||
trans[2].y = saved.y;
|
|
||||||
trans[2].u = saved.u;
|
|
||||||
trans[2].v = saved.v;
|
|
||||||
|
|
||||||
// top right
|
// top right
|
||||||
trans[3] = transVtx;
|
trans[1] = transVtxBR;
|
||||||
trans[3].x = saved.x;
|
trans[1].y = transVtxTL.y;
|
||||||
trans[3].u = saved.u;
|
trans[1].v = transVtxTL.v;
|
||||||
|
|
||||||
|
// top left
|
||||||
|
trans[2] = transVtxBR;
|
||||||
|
trans[2].x = transVtxTL.x;
|
||||||
|
trans[2].y = transVtxTL.y;
|
||||||
|
trans[2].u = transVtxTL.u;
|
||||||
|
trans[2].v = transVtxTL.v;
|
||||||
|
|
||||||
|
// bottom left
|
||||||
|
trans[3] = transVtxBR;
|
||||||
|
trans[3].x = transVtxTL.x;
|
||||||
|
trans[3].u = transVtxTL.u;
|
||||||
|
|
||||||
// That's the four corners. Now process UV rotation.
|
// That's the four corners. Now process UV rotation.
|
||||||
if (throughmode)
|
if (throughmode)
|
||||||
|
@ -504,21 +503,34 @@ void SoftwareTransform(
|
||||||
// else
|
// else
|
||||||
// RotateUV(trans);
|
// RotateUV(trans);
|
||||||
|
|
||||||
// bottom right
|
// Triangle: BR-TR-TL
|
||||||
trans[4] = trans[0];
|
indsOut[0] = i * 2 + 0;
|
||||||
|
indsOut[1] = i * 2 + 1;
|
||||||
// top left
|
indsOut[2] = i * 2 + 2;
|
||||||
trans[5] = trans[2];
|
// Triangle: BL-BR-TL
|
||||||
trans += 6;
|
indsOut[3] = i * 2 + 3;
|
||||||
|
indsOut[4] = i * 2 + 0;
|
||||||
|
indsOut[5] = i * 2 + 2;
|
||||||
|
trans += 4;
|
||||||
|
indsOut += 6;
|
||||||
|
|
||||||
numTrans += 6;
|
numTrans += 6;
|
||||||
}
|
}
|
||||||
|
inds = newInds;
|
||||||
|
drawIndexed = true;
|
||||||
|
|
||||||
// We don't know the color until here, so we have to do it now, instead of in StateMapping.
|
// We don't know the color until here, so we have to do it now, instead of in StateMapping.
|
||||||
// Might want to reconsider the order of things later...
|
// Might want to reconsider the order of things later...
|
||||||
if (gstate.isModeClear() && gstate.isClearModeAlphaMask()) {
|
if (gstate.isModeClear() && gstate.isClearModeAlphaMask()) {
|
||||||
result->setStencil = true;
|
result->setStencil = true;
|
||||||
result->stencilValue = stencilValue;
|
if (vertexCount > 1) {
|
||||||
|
// Take the bottom right alpha value of the first rect as the stencil value.
|
||||||
|
// Technically, each rect should individually fill its stencil, but most of the
|
||||||
|
// time they use the same one.
|
||||||
|
result->stencilValue = transformed[indsIn[1]].color0[3];
|
||||||
|
} else {
|
||||||
|
result->stencilValue = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,5 +38,5 @@ struct SoftwareTransformResult {
|
||||||
u8 stencilValue;
|
u8 stencilValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SoftwareTransform(int prim, u8 *decoded, int vertexCount, u32 vertexType, void *inds, int indexType, const DecVtxFormat &decVtxFormat, int maxIndex, FramebufferManagerCommon *fbman, TextureCacheCommon *texCache, TransformedVertex *transformed, TransformedVertex *transformedExpanded, TransformedVertex *&drawBuffer,
|
void SoftwareTransform(int prim, u8 *decoded, int vertexCount, u32 vertexType, u16 *&inds, int indexType, const DecVtxFormat &decVtxFormat, int maxIndex, FramebufferManagerCommon *fbman, TextureCacheCommon *texCache, TransformedVertex *transformed, TransformedVertex *transformedExpanded, TransformedVertex *&drawBuffer,
|
||||||
int &numTrans, bool &drawIndexed, SoftwareTransformResult *result);
|
int &numTrans, bool &drawIndexed, SoftwareTransformResult *result);
|
||||||
|
|
|
@ -833,7 +833,7 @@ rotateVBO:
|
||||||
|
|
||||||
SoftwareTransform(
|
SoftwareTransform(
|
||||||
prim, decoded, indexGen.VertexCount(),
|
prim, decoded, indexGen.VertexCount(),
|
||||||
dec_->VertexType(), (void *)inds, GE_VTYPE_IDX_16BIT, dec_->GetDecVtxFmt(),
|
dec_->VertexType(), inds, GE_VTYPE_IDX_16BIT, dec_->GetDecVtxFmt(),
|
||||||
indexGen.MaxIndex(), framebufferManager_, textureCache_, transformed, transformedExpanded, drawBuffer, numTrans, drawIndexed, &result);
|
indexGen.MaxIndex(), framebufferManager_, textureCache_, transformed, transformedExpanded, drawBuffer, numTrans, drawIndexed, &result);
|
||||||
|
|
||||||
if (result.action == SW_DRAW_PRIMITIVES) {
|
if (result.action == SW_DRAW_PRIMITIVES) {
|
||||||
|
|
|
@ -823,7 +823,7 @@ rotateVBO:
|
||||||
|
|
||||||
SoftwareTransform(
|
SoftwareTransform(
|
||||||
prim, decoded, indexGen.VertexCount(),
|
prim, decoded, indexGen.VertexCount(),
|
||||||
dec_->VertexType(), (void *)inds, GE_VTYPE_IDX_16BIT, dec_->GetDecVtxFmt(),
|
dec_->VertexType(), inds, GE_VTYPE_IDX_16BIT, dec_->GetDecVtxFmt(),
|
||||||
indexGen.MaxIndex(), framebufferManager_, textureCache_, transformed, transformedExpanded, drawBuffer, numTrans, drawIndexed, &result);
|
indexGen.MaxIndex(), framebufferManager_, textureCache_, transformed, transformedExpanded, drawBuffer, numTrans, drawIndexed, &result);
|
||||||
|
|
||||||
if (result.action == SW_DRAW_PRIMITIVES) {
|
if (result.action == SW_DRAW_PRIMITIVES) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue