Skip to content

Commit

Permalink
DrawEngineCommon: Enforce the limit on vertex decoding
Browse files Browse the repository at this point in the history
Should help #18894 which draws using a nonsense index buffer sometimes,
causing problems since we decode the whole range...
  • Loading branch information
hrydgard committed Sep 25, 2024
1 parent d49733f commit 3a4defe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion GPU/Common/DrawEngineCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,6 @@ bool DrawEngineCommon::SubmitPrim(const void *verts, const void *inds, GEPrimiti

void DrawEngineCommon::DecodeVerts(u8 *dest) {
// Note that this should be able to continue a partial decode - we don't necessarily start from zero here (although we do most of the time).

int i = decodeVertsCounter_;
int stride = (int)dec_->GetDecVtxFmt().stride;
for (; i < numDrawVerts_; i++) {
Expand All @@ -981,6 +980,12 @@ void DrawEngineCommon::DecodeVerts(u8 *dest) {
drawVertexOffsets_[i] = numDecodedVerts_ - indexLowerBound;

int indexUpperBound = dv.indexUpperBound;

if (indexUpperBound + 1 - indexLowerBound + numDecodedVerts_ >= VERTEX_BUFFER_MAX) {
// Hit our limit! Stop decoding in this draw.
break;
}

// Decode the verts (and at the same time apply morphing/skinning). Simple.
dec_->DecodeVerts(dest + numDecodedVerts_ * stride, dv.verts, &dv.uvScale, indexLowerBound, indexUpperBound);
numDecodedVerts_ += indexUpperBound - indexLowerBound + 1;
Expand Down

0 comments on commit 3a4defe

Please sign in to comment.