Skip to content

Commit

Permalink
Move the clockwise calculation out of the AddPrim loop
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Oct 10, 2023
1 parent 4eecf5a commit 82606b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions GPU/Common/DrawEngineCommon.cpp
Expand Up @@ -690,6 +690,11 @@ int DrawEngineCommon::ExtendNonIndexedPrim(const uint32_t *cmd, const uint32_t *
_dbg_assert_(numDrawInds_ <= MAX_DEFERRED_DRAW_INDS); // if it's equal, the check below will take care of it before any action is taken.
_dbg_assert_(numDrawVerts_ > 0);

bool clockwise = true;
if (gstate.isCullEnabled() && gstate.getCullMode() != cullMode) {
clockwise = false;
}

while (cmd != stall) {
uint32_t data = *cmd;
if ((data & 0xFFF80000) != 0x04000000) {
Expand All @@ -705,7 +710,7 @@ int DrawEngineCommon::ExtendNonIndexedPrim(const uint32_t *cmd, const uint32_t *
DeferredInds &di = drawInds_[numDrawInds_++];
di.indexType = 0;
di.prim = newPrim;
di.cullMode = cullMode;
di.clockwise = clockwise;
di.vertexCount = vertexCount;
di.vertDecodeIndex = prevDrawVerts;
di.offset = offset;
Expand Down Expand Up @@ -754,11 +759,16 @@ bool DrawEngineCommon::SubmitPrim(const void *verts, const void *inds, GEPrimiti

bool applySkin = (vertTypeID & GE_VTYPE_WEIGHT_MASK) && decOptions_.applySkinInDecode;

bool clockwise = true;
if (gstate.isCullEnabled() && gstate.getCullMode() != cullMode) {
clockwise = false;
}

DeferredInds &di = drawInds_[numDrawInds_++];
di.inds = inds;
di.indexType = (vertTypeID & GE_VTYPE_IDX_MASK) >> GE_VTYPE_IDX_SHIFT;
di.prim = prim;
di.cullMode = cullMode;
di.clockwise = clockwise;
di.vertexCount = vertexCount;
di.vertDecodeIndex = numDrawVerts_;
di.offset = 0;
Expand Down Expand Up @@ -824,10 +834,7 @@ void DrawEngineCommon::DecodeInds() {
const DeferredInds &di = drawInds_[i];

int indexOffset = drawVertexOffsets_[di.vertDecodeIndex] + di.offset;
bool clockwise = true;
if (gstate.isCullEnabled() && gstate.getCullMode() != di.cullMode) {
clockwise = false;
}
bool clockwise = di.clockwise;
// We've already collapsed subsequent draws with the same vertex pointer, so no tricky logic here anymore.
// 2. Loop through the drawcalls, translating indices as we go.
switch (di.indexType) {
Expand Down
2 changes: 1 addition & 1 deletion GPU/Common/DrawEngineCommon.h
Expand Up @@ -257,7 +257,7 @@ class DrawEngineCommon {
u8 vertDecodeIndex; // index into the drawVerts_ array to look up the vertexOffset.
u8 indexType;
s8 prim;
u8 cullMode;
bool clockwise;
u16 offset;
};

Expand Down

0 comments on commit 82606b6

Please sign in to comment.