softgpu: Advance vertex/index address on prim.

Fixes some broken graphics in a lot of places.
This commit is contained in:
Unknown W. Brackets 2013-11-20 21:59:45 -08:00
parent 89b48cf95b
commit d227b13f36
3 changed files with 23 additions and 4 deletions

View File

@ -349,8 +349,19 @@ void SoftGPU::ExecuteOp(u32 op, u32 diff)
}
cyclesExecuted += EstimatePerVertexCost() * count;
if (!(gstate_c.skipDrawReason & SKIPDRAW_SKIPFRAME)) {
TransformUnit::SubmitPrimitive(verts, indices, type, count, gstate.vertType);
int bytesRead;
TransformUnit::SubmitPrimitive(verts, indices, type, count, gstate.vertType, &bytesRead);
// 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.
// Q: Are these changed reflected in the real registers? Needs testing.
if (indices) {
int indexSize = 1;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT)
indexSize = 2;
gstate_c.indexAddr += count * indexSize;
} else {
gstate_c.vertexAddr += bytesRead;
}
}
break;

View File

@ -262,13 +262,21 @@ void TransformUnit::SubmitSpline(void* control_points, void* indices, int count_
host->GPUNotifyDraw();
}
void TransformUnit::SubmitPrimitive(void* vertices, void* indices, u32 prim_type, int vertex_count, u32 vertex_type)
void TransformUnit::SubmitPrimitive(void* vertices, void* indices, u32 prim_type, int vertex_count, u32 vertex_type, int *bytesRead)
{
// TODO: Cache VertexDecoder objects
VertexDecoder vdecoder;
vdecoder.SetVertexType(vertex_type);
const DecVtxFormat& vtxfmt = vdecoder.GetDecVtxFmt();
if (bytesRead)
*bytesRead = vertex_count * vdecoder.VertexSize();
// Frame skipping.
if (gstate_c.skipDrawReason & SKIPDRAW_SKIPFRAME) {
return;
}
static u8 buf[65536 * 48]; // yolo
u16 index_lower_bound = 0;
u16 index_upper_bound = vertex_count - 1;

View File

@ -116,5 +116,5 @@ public:
static ScreenCoords DrawingToScreen(const DrawingCoords& coords);
static void SubmitSpline(void* control_points, void* indices, int count_u, int count_v, int type_u, int type_v, GEPatchPrimType prim_type, u32 vertex_type);
static void SubmitPrimitive(void* vertices, void* indices, u32 prim_type, int vertex_count, u32 vertex_type);
static void SubmitPrimitive(void* vertices, void* indices, u32 prim_type, int vertex_count, u32 vertex_type, int *bytesRead);
};