Commit 62cd2bd6 by Alexis Hetu Committed by Alexis Hétu

Fixed flatshading for triangle strip and triangle fan

Since OpenGL uses the last vertex, not the leading vertex, as the vertex used to select the triangle color, then the last vertex, instead of the first vertex, has to be consistently incremented for each triangle in the strip or fan. In order to make this work, when leadingVertexFirst is true, the first vertex is consistently the lowest (consistently incremented) vertex index and when leadingVertexFirst is false, the last vertex is consistently the highest vertex index. Fixes the 2 failures in: dEQP-GLES3.functional.rasterization.flatshading Change-Id: Ib2247a219fe8c6725dc141e6860ba2ff521dde8c Reviewed-on: https://swiftshader-review.googlesource.com/15468Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 67fdd834
...@@ -1165,9 +1165,18 @@ namespace sw ...@@ -1165,9 +1165,18 @@ namespace sw
for(unsigned int i = 0; i < triangleCount; i++) for(unsigned int i = 0; i < triangleCount; i++)
{ {
batch[i][0] = index + 0; if(leadingVertexFirst)
batch[i][1] = index + (index & 1) + 1; {
batch[i][2] = index + (~index & 1) + 1; batch[i][0] = index + 0;
batch[i][1] = index + (index & 1) + 1;
batch[i][2] = index + (~index & 1) + 1;
}
else
{
batch[i][0] = index + (index & 1);
batch[i][1] = index + (~index & 1);
batch[i][2] = index + 2;
}
index += 1; index += 1;
} }
...@@ -1179,9 +1188,18 @@ namespace sw ...@@ -1179,9 +1188,18 @@ namespace sw
for(unsigned int i = 0; i < triangleCount; i++) for(unsigned int i = 0; i < triangleCount; i++)
{ {
batch[i][0] = index + 1; if(leadingVertexFirst)
batch[i][1] = index + 2; {
batch[i][2] = 0; batch[i][0] = index + 1;
batch[i][1] = index + 2;
batch[i][2] = 0;
}
else
{
batch[i][0] = 0;
batch[i][1] = index + 1;
batch[i][2] = index + 2;
}
index += 1; index += 1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment