mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-30 19:24:23 +01:00
softgpu: Refactor triangle cull processing.
This commit is contained in:
1 parent
75efcd9dfd
commit
ce4fee7373
2 files changed
+25
-36
No files matched your search
@@ -447,12 +447,6 @@ SoftDirty TransformUnit::GetDirty() {
|
||||
return binner_->GetDirty();
|
||||
}
|
||||
|
||||
enum class CullType {
|
||||
CW,
|
||||
CCW,
|
||||
OFF,
|
||||
};
|
||||
|
||||
void TransformUnit::SubmitPrimitive(const void* vertices, const void* indices, GEPrimitiveType prim_type, int vertex_count, u32 vertex_type, int *bytesRead, SoftwareDrawEngine *drawEngine)
|
||||
{
|
||||
VertexDecoder &vdecoder = *drawEngine->FindVertexDecoder(vertex_type);
|
||||
@@ -541,17 +535,8 @@ void TransformUnit::SubmitPrimitive(const void* vertices, const void* indices, G
|
||||
|
||||
switch (prim_type) {
|
||||
case GE_PRIM_TRIANGLES:
|
||||
{
|
||||
if (cullType == CullType::OFF) {
|
||||
Clipper::ProcessTriangle(data_[0], data_[1], data_[2], data_[2], *binner_);
|
||||
Clipper::ProcessTriangle(data_[2], data_[1], data_[0], data_[2], *binner_);
|
||||
} else if (cullType == CullType::CW) {
|
||||
Clipper::ProcessTriangle(data_[2], data_[1], data_[0], data_[2], *binner_);
|
||||
} else {
|
||||
Clipper::ProcessTriangle(data_[0], data_[1], data_[2], data_[2], *binner_);
|
||||
}
|
||||
SendTriangle(cullType, &data_[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
case GE_PRIM_LINES:
|
||||
Clipper::ProcessLine(data_[0], data_[1], *binner_);
|
||||
@@ -688,16 +673,9 @@ void TransformUnit::SubmitPrimitive(const void* vertices, const void* indices, G
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cullType == CullType::OFF) {
|
||||
Clipper::ProcessTriangle(data_[0], data_[1], data_[2], data_[provoking_index], *binner_);
|
||||
Clipper::ProcessTriangle(data_[2], data_[1], data_[0], data_[provoking_index], *binner_);
|
||||
} else if ((!(int)cullType) ^ ((data_index_ - 1) % 2)) {
|
||||
// We need to reverse the vertex order for each second primitive,
|
||||
// but we additionally need to do that for every primitive if CCW cullmode is used.
|
||||
Clipper::ProcessTriangle(data_[2], data_[1], data_[0], data_[provoking_index], *binner_);
|
||||
} else {
|
||||
Clipper::ProcessTriangle(data_[0], data_[1], data_[2], data_[provoking_index], *binner_);
|
||||
}
|
||||
int wind = (data_index_ - 1) % 2;
|
||||
CullType altCullType = cullType == CullType::OFF ? cullType : CullType((int)cullType ^ wind);
|
||||
SendTriangle(altCullType, &data_[0], provoking_index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -764,16 +742,9 @@ void TransformUnit::SubmitPrimitive(const void* vertices, const void* indices, G
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cullType == CullType::OFF) {
|
||||
Clipper::ProcessTriangle(data_[0], data_[1], data_[2], data_[provoking_index], *binner_);
|
||||
Clipper::ProcessTriangle(data_[2], data_[1], data_[0], data_[provoking_index], *binner_);
|
||||
} else if ((!(int)cullType) ^ ((data_index_ - 1) % 2)) {
|
||||
// We need to reverse the vertex order for each second primitive,
|
||||
// but we additionally need to do that for every primitive if CCW cullmode is used.
|
||||
Clipper::ProcessTriangle(data_[2], data_[1], data_[0], data_[provoking_index], *binner_);
|
||||
} else {
|
||||
Clipper::ProcessTriangle(data_[0], data_[1], data_[2], data_[provoking_index], *binner_);
|
||||
}
|
||||
int wind = (data_index_ - 1) % 2;
|
||||
CullType altCullType = cullType == CullType::OFF ? cullType : CullType((int)cullType ^ wind);
|
||||
SendTriangle(altCullType, &data_[0], provoking_index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -784,6 +755,17 @@ void TransformUnit::SubmitPrimitive(const void* vertices, const void* indices, G
|
||||
}
|
||||
}
|
||||
|
||||
void TransformUnit::SendTriangle(CullType cullType, const VertexData *verts, int provoking) {
|
||||
if (cullType == CullType::OFF) {
|
||||
Clipper::ProcessTriangle(verts[0], verts[1], verts[2], verts[provoking], *binner_);
|
||||
Clipper::ProcessTriangle(verts[2], verts[1], verts[0], verts[provoking], *binner_);
|
||||
} else if (cullType == CullType::CW) {
|
||||
Clipper::ProcessTriangle(verts[2], verts[1], verts[0], verts[provoking], *binner_);
|
||||
} else {
|
||||
Clipper::ProcessTriangle(verts[0], verts[1], verts[2], verts[provoking], *binner_);
|
||||
}
|
||||
}
|
||||
|
||||
void TransformUnit::Flush(const char *reason) {
|
||||
binner_->Flush(reason);
|
||||
GPUDebug::NotifyDraw();
|
||||
|
||||
Reference in new issue
Block a user