Skip to content

Commit

Permalink
TransformPipeline: Minor memory optimization and a prim sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jul 22, 2013
1 parent 9c73528 commit eaf5cc1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 9 additions & 1 deletion GPU/GLES/TransformPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,13 @@ void TransformDrawEngine::DecodeVerts() {
i = lastMatch;
}
}

// Sanity check
if (indexGen.Prim() < 0) {
ERROR_LOG(HLE, "DecodeVerts: Failed to deduce prim: %i", indexGen.Prim());
// Force to points (0)
indexGen.AddPrim(GE_PRIM_POINTS, 0);
}
}

u32 TransformDrawEngine::ComputeHash() {
Expand Down Expand Up @@ -1131,7 +1138,6 @@ void TransformDrawEngine::Flush() {
vai = iter->second;
} else {
vai = new VertexArrayInfo();
vai->decFmt = dec_->GetDecVtxFmt();
vai_[id] = vai;
}

Expand All @@ -1144,6 +1150,8 @@ void TransformDrawEngine::Flush() {
vai->status = VertexArrayInfo::VAI_HASHING;
vai->drawsUntilNextFullHash = 0;
DecodeVerts(); // writes to indexGen
vai->numVerts = indexGen.VertexCount();
vai->prim = indexGen.Prim();
goto rotateVBO;
}

Expand Down
5 changes: 1 addition & 4 deletions GPU/GLES/TransformPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,9 @@ class VertexArrayInfo {
u32 vbo;
u32 ebo;

// TODO: see if we can avoid having this full thing here.
DecVtxFormat decFmt;

// Precalculated parameter for drawdrawElements
u16 numVerts;
u8 prim;
s8 prim;

// ID information
u8 numDCs;
Expand Down

2 comments on commit eaf5cc1

@unknownbrackets
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that GE_CMD_PRIM passes in u32 type = data >> 16; directly as the prim type.

This is then passed to PrimCompatible(), which directly indexes indexedPrimitiveType[7]. AddPrim() supports the same 7 values as well.

JPCSP supports a curious additional value: GE_PRIM_CONTINUE_PREVIOUS_PRIM = 7.
http://code.google.com/p/jpcsp/source/browse/trunk/src/jpcsp/graphics/VideoEngine.java#2167

Could that be the cause? Since we remember prevPrim_ it seems we're set up for that, if it's correct.

Anyway, the type should probably be & 7? or error if > 7?

-[Unknown]

@hrydgard
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should definitely & by 7 and perhaps log-report if value is outside that range.

That extra value seems easy to support, yes.

Please sign in to comment.