Reduce some repetitive code.

This commit is contained in:
Unknown W. Brackets 2016-04-10 13:07:08 -07:00
parent 868bbb8ebe
commit e95b2cf0d5
6 changed files with 22 additions and 70 deletions

View file

@ -836,16 +836,7 @@ void GPU_DX9::Execute_Prim(u32 op, u32 diff) {
// After drawing, we advance the vertexAddr (when non indexed) or indexAddr (when indexed).
// Some games rely on this, they don't bother reloading VADDR and IADDR.
// The VADDR/IADDR registers are NOT updated.
if (inds) {
int indexSize = 1;
if ((vertexType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT)
indexSize = 2;
else if ((vertexType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_32BIT)
indexSize = 4;
gstate_c.indexAddr += count * indexSize;
} else {
gstate_c.vertexAddr += bytesRead;
}
AdvanceVerts(vertexType, count, bytesRead);
}
void GPU_DX9::Execute_Bezier(u32 op, u32 diff) {
@ -888,16 +879,7 @@ void GPU_DX9::Execute_Bezier(u32 op, u32 diff) {
// After drawing, we advance pointers - see SubmitPrim which does the same.
int count = bz_ucount * bz_vcount;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != 0) {
int indexSize = 1;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT)
indexSize = 2;
else if ((gstate.vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_32BIT)
indexSize = 4;
gstate_c.indexAddr += count * indexSize;
} else {
gstate_c.vertexAddr += bytesRead;
}
AdvanceVerts(gstate.vertType, count, bytesRead);
}
void GPU_DX9::Execute_Spline(u32 op, u32 diff) {

View file

@ -1005,16 +1005,7 @@ void GPU_GLES::Execute_Prim(u32 op, u32 diff) {
// After drawing, we advance the vertexAddr (when non indexed) or indexAddr (when indexed).
// Some games rely on this, they don't bother reloading VADDR and IADDR.
// The VADDR/IADDR registers are NOT updated.
if (inds) {
int indexSize = 1;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT)
indexSize = 2;
else if ((gstate.vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_32BIT)
indexSize = 4;
gstate_c.indexAddr += count * indexSize;
} else {
gstate_c.vertexAddr += bytesRead;
}
AdvanceVerts(gstate.vertType, count, bytesRead);
}
void GPU_GLES::Execute_VertexType(u32 op, u32 diff) {
@ -1081,16 +1072,7 @@ void GPU_GLES::Execute_Bezier(u32 op, u32 diff) {
// After drawing, we advance pointers - see SubmitPrim which does the same.
int count = bz_ucount * bz_vcount;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != 0) {
int indexSize = 1;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT)
indexSize = 2;
else if ((gstate.vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_32BIT)
indexSize = 4;
gstate_c.indexAddr += count * indexSize;
} else {
gstate_c.vertexAddr += bytesRead;
}
AdvanceVerts(gstate.vertType, count, bytesRead);
}
void GPU_GLES::Execute_Spline(u32 op, u32 diff) {

View file

@ -1299,3 +1299,16 @@ void GPUCommon::SetCmdValue(u32 op) {
gstate.cmdmem[cmd] = op;
ExecuteOp(op, diff);
}
void GPUCommon::AdvanceVerts(u32 vertType, int count, int bytesRead) {
if ((vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
int indexSize = 1;
if ((vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT)
indexSize = 2;
else if ((vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_32BIT)
indexSize = 4;
gstate_c.indexAddr += count * indexSize;
} else {
gstate_c.vertexAddr += bytesRead;
}
}

View file

@ -156,6 +156,8 @@ protected:
virtual void FinishDeferred() {
}
void AdvanceVerts(u32 vertType, int count, int bytesRead);
// Allows early unlocking with a guard. Do not double unlock.
class easy_guard {
public:

View file

@ -332,16 +332,7 @@ void SoftGPU::ExecuteOp(u32 op, u32 diff)
// After drawing, we advance the vertexAddr (when non indexed) or indexAddr (when indexed).
// Some games rely on this, they don't bother reloading VADDR and IADDR.
// The VADDR/IADDR registers are NOT updated.
if (indices) {
int indexSize = 1;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT)
indexSize = 2;
else if ((gstate.vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_32BIT)
indexSize = 4;
gstate_c.indexAddr += count * indexSize;
} else {
gstate_c.vertexAddr += bytesRead;
}
AdvanceVerts(gstate.vertType, count, bytesRead);
}
break;

View file

@ -880,16 +880,7 @@ void GPU_Vulkan::Execute_Prim(u32 op, u32 diff) {
// After drawing, we advance the vertexAddr (when non indexed) or indexAddr (when indexed).
// Some games rely on this, they don't bother reloading VADDR and IADDR.
// The VADDR/IADDR registers are NOT updated.
if (inds) {
int indexSize = 1;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT)
indexSize = 2;
else if ((gstate.vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_32BIT)
indexSize = 4;
gstate_c.indexAddr += count * indexSize;
} else {
gstate_c.vertexAddr += bytesRead;
}
AdvanceVerts(gstate.vertType, count, bytesRead);
}
void GPU_Vulkan::Execute_VertexType(u32 op, u32 diff) {
@ -938,16 +929,7 @@ void GPU_Vulkan::Execute_Bezier(u32 op, u32 diff) {
// After drawing, we advance pointers - see SubmitPrim which does the same.
int count = bz_ucount * bz_vcount;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != 0) {
int indexSize = 1;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT)
indexSize = 2;
else if ((gstate.vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_32BIT)
indexSize = 4;
gstate_c.indexAddr += count * indexSize;
} else {
gstate_c.vertexAddr += bytesRead;
}
AdvanceVerts(gstate.vertType, count, bytesRead);
}
void GPU_Vulkan::Execute_Spline(u32 op, u32 diff) {