mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
softgpu: Combine tris to rects with ignored z too.
This commit is contained in:
parent
85cb4101dc
commit
2381f355c2
3 changed files with 29 additions and 28 deletions
|
@ -306,22 +306,17 @@ bool RectangleFastPath(const VertexData &v0, const VertexData &v1, BinManager &b
|
|||
return false;
|
||||
}
|
||||
|
||||
bool DetectRectangleFromThroughModeStrip(const VertexData data[4]) {
|
||||
// We'll only do this when the color is flat.
|
||||
if (!(data[0].color0 == data[1].color0))
|
||||
return false;
|
||||
if (!(data[1].color0 == data[2].color0))
|
||||
return false;
|
||||
if (!(data[2].color0 == data[3].color0))
|
||||
return false;
|
||||
|
||||
// And the depth must also be flat.
|
||||
if (!(data[0].screenpos.z == data[1].screenpos.z))
|
||||
return false;
|
||||
if (!(data[1].screenpos.z == data[2].screenpos.z))
|
||||
return false;
|
||||
if (!(data[2].screenpos.z == data[3].screenpos.z))
|
||||
return false;
|
||||
bool DetectRectangleFromThroughModeStrip(const RasterizerState &state, const VertexData data[4]) {
|
||||
// Color and Z must be flat.
|
||||
for (int i = 1; i < 4; ++i) {
|
||||
if (!(data[i].color0 == data[0].color0))
|
||||
return false;
|
||||
if (!(data[i].screenpos.z == data[0].screenpos.z)) {
|
||||
// Sometimes, we don't actually care about z.
|
||||
if (state.pixelID.depthWrite || state.pixelID.DepthTestFunc() != GE_COMP_ALWAYS)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// OK, now let's look at data to detect rectangles. There are a few possibilities
|
||||
// but we focus on Darkstalkers for now.
|
||||
|
@ -371,13 +366,16 @@ bool DetectRectangleFromThroughModeStrip(const VertexData data[4]) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool DetectRectangleFromThroughModeFan(const VertexData *data, int c, int *tlIndex, int *brIndex) {
|
||||
bool DetectRectangleFromThroughModeFan(const RasterizerState &state, const VertexData *data, int c, int *tlIndex, int *brIndex) {
|
||||
// Color and Z must be flat.
|
||||
for (int i = 1; i < c; ++i) {
|
||||
if (!(data[i].color0 == data[0].color0))
|
||||
return false;
|
||||
if (!(data[i].screenpos.z == data[0].screenpos.z))
|
||||
return false;
|
||||
if (!(data[i].screenpos.z == data[0].screenpos.z)) {
|
||||
// Sometimes, we don't actually care about z.
|
||||
if (state.pixelID.depthWrite || state.pixelID.DepthTestFunc() != GE_COMP_ALWAYS)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for the common case: a single TL-TR-BR-BL.
|
||||
|
@ -411,13 +409,16 @@ bool DetectRectangleFromThroughModeFan(const VertexData *data, int c, int *tlInd
|
|||
return false;
|
||||
}
|
||||
|
||||
bool DetectRectangleSlices(const VertexData data[4]) {
|
||||
bool DetectRectangleSlices(const RasterizerState &state, const VertexData data[4]) {
|
||||
// Color and Z must be flat.
|
||||
for (int i = 1; i < 4; ++i) {
|
||||
if (!(data[i].color0 == data[0].color0))
|
||||
return false;
|
||||
if (!(data[i].screenpos.z == data[0].screenpos.z))
|
||||
return false;
|
||||
if (!(data[i].screenpos.z == data[0].screenpos.z)) {
|
||||
// Sometimes, we don't actually care about z.
|
||||
if (state.pixelID.depthWrite || state.pixelID.DepthTestFunc() != GE_COMP_ALWAYS)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Games very commonly use vertical strips of rectangles. Detect and combine.
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Rasterizer {
|
|||
bool RectangleFastPath(const VertexData &v0, const VertexData &v1, BinManager &binner);
|
||||
void DrawSprite(const VertexData &v0, const VertexData &v1, const BinCoords &range, const RasterizerState &state);
|
||||
|
||||
bool DetectRectangleFromThroughModeStrip(const VertexData data[4]);
|
||||
bool DetectRectangleFromThroughModeFan(const VertexData *data, int c, int *tlIndex, int *brIndex);
|
||||
bool DetectRectangleSlices(const VertexData data[4]);
|
||||
bool DetectRectangleFromThroughModeStrip(const RasterizerState &state, const VertexData data[4]);
|
||||
bool DetectRectangleFromThroughModeFan(const RasterizerState &state, const VertexData *data, int c, int *tlIndex, int *brIndex);
|
||||
bool DetectRectangleSlices(const RasterizerState &state, const VertexData data[4]);
|
||||
}
|
||||
|
|
|
@ -593,7 +593,7 @@ void TransformUnit::SubmitPrimitive(void* vertices, void* indices, GEPrimitiveTy
|
|||
}
|
||||
|
||||
if (data_index == 4 && gstate.isModeThrough() && cullType == CullType::OFF) {
|
||||
if (Rasterizer::DetectRectangleSlices(data)) {
|
||||
if (Rasterizer::DetectRectangleSlices(binner_->State(), data)) {
|
||||
data[1] = data[3];
|
||||
data_index = 2;
|
||||
}
|
||||
|
@ -661,7 +661,7 @@ void TransformUnit::SubmitPrimitive(void* vertices, void* indices, GEPrimitiveTy
|
|||
}
|
||||
|
||||
// If a strip is effectively a rectangle, draw it as such!
|
||||
if (!outside_range_flag && Rasterizer::DetectRectangleFromThroughModeStrip(data)) {
|
||||
if (!outside_range_flag && Rasterizer::DetectRectangleFromThroughModeStrip(binner_->State(), data)) {
|
||||
Clipper::ProcessRect(data[0], data[3], *binner_);
|
||||
break;
|
||||
}
|
||||
|
@ -737,7 +737,7 @@ void TransformUnit::SubmitPrimitive(void* vertices, void* indices, GEPrimitiveTy
|
|||
}
|
||||
|
||||
int tl = -1, br = -1;
|
||||
if (!outside_range_flag && Rasterizer::DetectRectangleFromThroughModeFan(data, vertex_count, &tl, &br)) {
|
||||
if (!outside_range_flag && Rasterizer::DetectRectangleFromThroughModeFan(binner_->State(), data, vertex_count, &tl, &br)) {
|
||||
Clipper::ProcessRect(data[tl], data[br], *binner_);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue