Skip to content

Commit

Permalink
Optimize further
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Oct 3, 2023
1 parent 0260aeb commit 4d95250
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
11 changes: 1 addition & 10 deletions GPU/Common/DrawEngineCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,12 +683,6 @@ bool DrawEngineCommon::ExtendNonIndexedPrim(GEPrimitiveType prim, int vertexCoun
return false;
}

bool applySkin = (vertTypeID & GE_VTYPE_WEIGHT_MASK) && decOptions_.applySkinInDecode;
if (applySkin) {
// TODO: Support this somehow.
return false;
}

_dbg_assert_(numDrawInds_ < MAX_DEFERRED_DRAW_INDS);
_dbg_assert_(numDrawVerts_ > 0);
*bytesRead = vertexCount * dec_->VertexSize();
Expand All @@ -707,6 +701,7 @@ bool DrawEngineCommon::ExtendNonIndexedPrim(GEPrimitiveType prim, int vertexCoun
dv.vertexCount += vertexCount;
dv.indexUpperBound = dv.vertexCount - 1;
vertexCountInDrawCalls_ += vertexCount;

return true;
}

Expand Down Expand Up @@ -787,10 +782,6 @@ void DrawEngineCommon::SubmitPrim(const void *verts, const void *inds, GEPrimiti
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
DispatchFlush();
}

if (applySkin) {
DecodeVerts(decoded_);
}
}

void DrawEngineCommon::DecodeVerts(u8 *dest) {
Expand Down
7 changes: 7 additions & 0 deletions GPU/Common/DrawEngineCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ class DrawEngineCommon {

bool TestBoundingBox(const void *control_points, const void *inds, int vertexCount, u32 vertType);

void FlushSkin() {
bool applySkin = (lastVType_ & GE_VTYPE_WEIGHT_MASK) && decOptions_.applySkinInDecode;
if (applySkin) {
DecodeVerts(decoded_);
}
}

bool ExtendNonIndexedPrim(GEPrimitiveType prim, int vertexCount, u32 vertTypeID, int cullMode, int *bytesRead);
void SubmitPrim(const void *verts, const void *inds, GEPrimitiveType prim, int vertexCount, u32 vertTypeID, int cullMode, int *bytesRead);
template<class Surface>
Expand Down
10 changes: 8 additions & 2 deletions GPU/GPUCommonHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,9 @@ void GPUCommonHW::Execute_Prim(u32 op, u32 diff) {
inds = nullptr;
if ((vertexType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
inds = Memory::GetPointerUnchecked(gstate_c.indexAddr);
} else {
// We can extend again after submitting a normal draw.
canExtend = true;
}
drawEngineCommon_->SubmitPrim(verts, inds, newPrim, count, vertTypeID, cullMode, &bytesRead);
AdvanceVerts(vertexType, count, bytesRead);
Expand All @@ -1058,18 +1061,18 @@ void GPUCommonHW::Execute_Prim(u32 op, u32 diff) {
break;
}
case GE_CMD_VADDR:
canExtend = false;
gstate.cmdmem[GE_CMD_VADDR] = data;
gstate_c.vertexAddr = gstate_c.getRelativeAddress(data & 0x00FFFFFF);
canExtend = false;
break;
case GE_CMD_IADDR:
gstate.cmdmem[GE_CMD_IADDR] = data;
gstate_c.indexAddr = gstate_c.getRelativeAddress(data & 0x00FFFFFF);
break;
case GE_CMD_OFFSETADDR:
canExtend = false;
gstate.cmdmem[GE_CMD_OFFSETADDR] = data;
gstate_c.offsetAddr = data << 8;
canExtend = false;
break;
case GE_CMD_BASE:
gstate.cmdmem[GE_CMD_BASE] = data;
Expand Down Expand Up @@ -1124,6 +1127,8 @@ void GPUCommonHW::Execute_Prim(u32 op, u32 diff) {
(Memory::ReadUnchecked_U32(target + 12 * 4) >> 24) == GE_CMD_RET &&
(target > currentList->stall || target + 12 * 4 < currentList->stall) &&
(gstate.boneMatrixNumber & 0x00FFFFFF) <= 96 - 12) {
drawEngineCommon_->FlushSkin();
canExtend = false;
FastLoadBoneMatrix(target);
} else {
goto bail;
Expand All @@ -1145,6 +1150,7 @@ void GPUCommonHW::Execute_Prim(u32 op, u32 diff) {
}

bail:
drawEngineCommon_->FlushSkin();
gstate.cmdmem[GE_CMD_VERTEXTYPE] = vertexType;
int cmdCount = src - start;
// Skip over the commands we just read out manually.
Expand Down

0 comments on commit 4d95250

Please sign in to comment.