Skip to content

Commit

Permalink
GPU: Force use of indexes on cull mode flip.
Browse files Browse the repository at this point in the history
Since we flip in the index, it can't be pure in this case.
  • Loading branch information
unknownbrackets committed Nov 30, 2018
1 parent 636a7a2 commit 7b815af
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion GPU/Common/IndexGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ void IndexGenerator::AddList(int numVerts, bool clockwise) {
count_ += numVerts;
prim_ = GE_PRIM_TRIANGLES;
seenPrims_ |= 1 << GE_PRIM_TRIANGLES;
if (!clockwise) {
// Make sure we don't treat this as pure.
seenPrims_ |= 1 << GE_PRIM_TRIANGLE_STRIP;
}
}

void IndexGenerator::AddStrip(int numVerts, bool clockwise) {
Expand All @@ -96,7 +100,7 @@ void IndexGenerator::AddStrip(int numVerts, bool clockwise) {
if (numTris > 0)
count_ += numTris * 3;
// This is so we can detect one single strip by just looking at seenPrims_.
if (!seenPrims_) {
if (!seenPrims_ && clockwise) {
seenPrims_ = 1 << GE_PRIM_TRIANGLE_STRIP;
prim_ = GE_PRIM_TRIANGLE_STRIP;
pureCount_ = numVerts;
Expand All @@ -123,6 +127,10 @@ void IndexGenerator::AddFan(int numVerts, bool clockwise) {
count_ += numTris * 3;
prim_ = GE_PRIM_TRIANGLES;
seenPrims_ |= 1 << GE_PRIM_TRIANGLE_FAN;
if (!clockwise) {
// Make sure we don't treat this as pure.
seenPrims_ |= 1 << GE_PRIM_TRIANGLE_STRIP;
}
}

//Lines
Expand Down
1 change: 0 additions & 1 deletion GPU/Common/ShaderId.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ struct FShaderID : ShaderID {
};


bool CanUseHardwareTransform(int prim);
void ComputeVertexShaderID(ShaderID *id, uint32_t vertexType, bool useHWTransform);
// Generates a compact string that describes the shader. Useful in a list to get an overview
// of the current flora of shaders.
Expand Down
5 changes: 3 additions & 2 deletions GPU/GPUCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ void GPUCommon::Execute_Prim(u32 op, u32 diff) {
}

void *verts = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
void *inds = 0;
void *inds = nullptr;
u32 vertexType = gstate.vertType;
if ((vertexType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
u32 indexAddr = gstate_c.indexAddr;
Expand Down Expand Up @@ -1602,9 +1602,10 @@ void GPUCommon::Execute_Prim(u32 op, u32 diff) {
}

GEPrimitiveType newPrim = static_cast<GEPrimitiveType>((data >> 16) & 7);
SetDrawType(DRAW_PRIM, newPrim);
// TODO: more efficient updating of verts/inds
verts = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
inds = 0;
inds = nullptr;
if ((vertexType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
inds = Memory::GetPointerUnchecked(gstate_c.indexAddr);
}
Expand Down

0 comments on commit 7b815af

Please sign in to comment.