Commit c50d35d4 by Nicolas Capens

Add support for quad primitives.

Bug 18962347 Change-Id: Id13ef61a8aaacd88afb0b3e634ae971d44e39cd7 Reviewed-on: https://swiftshader-review.googlesource.com/1860Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 235781d1
......@@ -94,6 +94,8 @@ namespace sw
case DRAW_INDEXEDTRIANGLESTRIP32:
case DRAW_INDEXEDTRIANGLEFAN32:
return fillModeAware ? fillMode == FILL_VERTEX : false;
case DRAW_QUADLIST:
return false;
default:
ASSERT(false);
}
......@@ -136,6 +138,8 @@ namespace sw
case DRAW_INDEXEDTRIANGLESTRIP32:
case DRAW_INDEXEDTRIANGLEFAN32:
return fillModeAware ? fillMode == FILL_WIREFRAME : false;
case DRAW_QUADLIST:
return false;
default:
ASSERT(false);
}
......@@ -178,6 +182,9 @@ namespace sw
case DRAW_INDEXEDTRIANGLESTRIP32:
case DRAW_INDEXEDTRIANGLEFAN32:
return fillModeAware ? fillMode == FILL_SOLID : true;
case DRAW_QUADLIST:
// Quads are broken up into triangles
return fillModeAware ? fillMode == FILL_SOLID : true;
default:
ASSERT(false);
}
......
......@@ -58,6 +58,7 @@ namespace sw
DRAW_TRIANGLELIST,
DRAW_TRIANGLESTRIP,
DRAW_TRIANGLEFAN,
DRAW_QUADLIST,
DRAW_INDEXEDPOINTLIST8,
DRAW_INDEXEDLINELIST8,
......
......@@ -122,36 +122,28 @@ namespace sw
Do
{
Int x0;
Int x1;
Int x2;
x0 = Int(*Pointer<Short>(r.primitive + OFFSET(Primitive,outline->left) + (y + 0) * sizeof(Primitive::Span)));
x2 = Int(*Pointer<Short>(r.primitive + OFFSET(Primitive,outline->left) + (y + 1) * sizeof(Primitive::Span)));
x0 = Min(x0, x2);
Int x0a = Int(*Pointer<Short>(r.primitive + OFFSET(Primitive,outline->left) + (y + 0) * sizeof(Primitive::Span)));
Int x0b = Int(*Pointer<Short>(r.primitive + OFFSET(Primitive,outline->left) + (y + 1) * sizeof(Primitive::Span)));
Int x0 = Min(x0a, x0b);
for(unsigned int q = 1; q < state.multiSample; q++)
{
Int x0q = Int(*Pointer<Short>(r.primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->left) + (y + 0) * sizeof(Primitive::Span)));
Int x2q = Int(*Pointer<Short>(r.primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->left) + (y + 1) * sizeof(Primitive::Span)));
x0q = Min(x0q, x2q);
x0 = Min(x0q, x0);
x0a = Int(*Pointer<Short>(r.primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->left) + (y + 0) * sizeof(Primitive::Span)));
x0b = Int(*Pointer<Short>(r.primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->left) + (y + 1) * sizeof(Primitive::Span)));
x0 = Min(x0, Min(x0a, x0b));
}
x0 &= 0xFFFFFFFE;
x1 = Int(*Pointer<Short>(r.primitive + OFFSET(Primitive,outline->right) + (y + 0) * sizeof(Primitive::Span)));
x2 = Int(*Pointer<Short>(r.primitive + OFFSET(Primitive,outline->right) + (y + 1) * sizeof(Primitive::Span)));
x1 = Max(x1, x2);
Int x1a = Int(*Pointer<Short>(r.primitive + OFFSET(Primitive,outline->right) + (y + 0) * sizeof(Primitive::Span)));
Int x1b = Int(*Pointer<Short>(r.primitive + OFFSET(Primitive,outline->right) + (y + 1) * sizeof(Primitive::Span)));
Int x1 = Max(x1a, x1b);
for(unsigned int q = 1; q < state.multiSample; q++)
{
Int x1q = Int(*Pointer<Short>(r.primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->right) + (y + 0) * sizeof(Primitive::Span)));
Int x2q = Int(*Pointer<Short>(r.primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->right) + (y + 1) * sizeof(Primitive::Span)));
x1q = Max(x1q, x2q);
x1 = Max(x1q, x1);
x1a = Int(*Pointer<Short>(r.primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->right) + (y + 0) * sizeof(Primitive::Span)));
x1b = Int(*Pointer<Short>(r.primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->right) + (y + 1) * sizeof(Primitive::Span)));
x1 = Max(x1, Max(x1a, x1b));
}
Float4 yyyy = Float4(Float(y)) + *Pointer<Float4>(r.primitive + OFFSET(Primitive,yQuad), 16);
......
......@@ -942,7 +942,7 @@ namespace sw
pixelProgress[cluster].executing = false;
}
void Renderer::processPrimitiveVertices(int unit, unsigned int start, unsigned int count, unsigned int loop, int thread)
void Renderer::processPrimitiveVertices(int unit, unsigned int start, unsigned int triangleCount, unsigned int loop, int thread)
{
Triangle *triangle = triangleBatch[unit];
DrawCall *draw = drawList[primitiveProgress[unit].drawCall % DRAW_COUNT];
......@@ -966,7 +966,7 @@ namespace sw
{
unsigned int index = start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index;
batch[i][1] = index;
......@@ -980,7 +980,7 @@ namespace sw
{
unsigned int index = 2 * start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index + 0;
batch[i][1] = index + 1;
......@@ -994,7 +994,7 @@ namespace sw
{
unsigned int index = start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index + 0;
batch[i][1] = index + 1;
......@@ -1008,7 +1008,7 @@ namespace sw
{
unsigned int index = start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = (index + 0) % loop;
batch[i][1] = (index + 1) % loop;
......@@ -1022,7 +1022,7 @@ namespace sw
{
unsigned int index = 3 * start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index + 0;
batch[i][1] = index + 1;
......@@ -1036,7 +1036,7 @@ namespace sw
{
unsigned int index = start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index + 0;
batch[i][1] = index + (index & 1) + 1;
......@@ -1050,7 +1050,7 @@ namespace sw
{
unsigned int index = start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index + 1;
batch[i][1] = index + 2;
......@@ -1064,7 +1064,7 @@ namespace sw
{
const unsigned char *index = (const unsigned char*)indices + start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = *index;
batch[i][1] = *index;
......@@ -1078,7 +1078,7 @@ namespace sw
{
const unsigned short *index = (const unsigned short*)indices + start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = *index;
batch[i][1] = *index;
......@@ -1092,7 +1092,7 @@ namespace sw
{
const unsigned int *index = (const unsigned int*)indices + start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = *index;
batch[i][1] = *index;
......@@ -1106,7 +1106,7 @@ namespace sw
{
const unsigned char *index = (const unsigned char*)indices + 2 * start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[0];
batch[i][1] = index[1];
......@@ -1120,7 +1120,7 @@ namespace sw
{
const unsigned short *index = (const unsigned short*)indices + 2 * start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[0];
batch[i][1] = index[1];
......@@ -1134,7 +1134,7 @@ namespace sw
{
const unsigned int *index = (const unsigned int*)indices + 2 * start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[0];
batch[i][1] = index[1];
......@@ -1148,7 +1148,7 @@ namespace sw
{
const unsigned char *index = (const unsigned char*)indices + start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[0];
batch[i][1] = index[1];
......@@ -1162,7 +1162,7 @@ namespace sw
{
const unsigned short *index = (const unsigned short*)indices + start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[0];
batch[i][1] = index[1];
......@@ -1176,7 +1176,7 @@ namespace sw
{
const unsigned int *index = (const unsigned int*)indices + start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[0];
batch[i][1] = index[1];
......@@ -1190,7 +1190,7 @@ namespace sw
{
const unsigned char *index = (const unsigned char*)indices;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[(start + i + 0) % loop];
batch[i][1] = index[(start + i + 1) % loop];
......@@ -1202,7 +1202,7 @@ namespace sw
{
const unsigned short *index = (const unsigned short*)indices;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[(start + i + 0) % loop];
batch[i][1] = index[(start + i + 1) % loop];
......@@ -1214,7 +1214,7 @@ namespace sw
{
const unsigned int *index = (const unsigned int*)indices;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[(start + i + 0) % loop];
batch[i][1] = index[(start + i + 1) % loop];
......@@ -1226,7 +1226,7 @@ namespace sw
{
const unsigned char *index = (const unsigned char*)indices + 3 * start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[0];
batch[i][1] = index[1];
......@@ -1240,7 +1240,7 @@ namespace sw
{
const unsigned short *index = (const unsigned short*)indices + 3 * start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[0];
batch[i][1] = index[1];
......@@ -1254,7 +1254,7 @@ namespace sw
{
const unsigned int *index = (const unsigned int*)indices + 3 * start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[0];
batch[i][1] = index[1];
......@@ -1268,7 +1268,7 @@ namespace sw
{
const unsigned char *index = (const unsigned char*)indices + start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[0];
batch[i][1] = index[((start + i) & 1) + 1];
......@@ -1282,7 +1282,7 @@ namespace sw
{
const unsigned short *index = (const unsigned short*)indices + start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[0];
batch[i][1] = index[((start + i) & 1) + 1];
......@@ -1296,7 +1296,7 @@ namespace sw
{
const unsigned int *index = (const unsigned int*)indices + start;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[0];
batch[i][1] = index[((start + i) & 1) + 1];
......@@ -1310,7 +1310,7 @@ namespace sw
{
const unsigned char *index = (const unsigned char*)indices;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[start + i + 1];
batch[i][1] = index[start + i + 2];
......@@ -1322,7 +1322,7 @@ namespace sw
{
const unsigned short *index = (const unsigned short*)indices;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[start + i + 1];
batch[i][1] = index[start + i + 2];
......@@ -1334,7 +1334,7 @@ namespace sw
{
const unsigned int *index = (const unsigned int*)indices;
for(unsigned int i = 0; i < count; i++)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = index[start + i + 1];
batch[i][1] = index[start + i + 2];
......@@ -1342,11 +1342,29 @@ namespace sw
}
}
break;
case DRAW_QUADLIST:
{
unsigned int index = 4 * start / 2;
for(unsigned int i = 0; i < triangleCount; i += 2)
{
batch[i+0][0] = index + 0;
batch[i+0][1] = index + 1;
batch[i+0][2] = index + 2;
batch[i+1][0] = index + 0;
batch[i+1][1] = index + 2;
batch[i+1][2] = index + 3;
index += 4;
}
}
break;
default:
ASSERT(false);
}
task->count = count * 3;
task->vertexCount = triangleCount * 3;
vertexRoutine(&triangle->v0, (unsigned int*)&batch, task, data);
}
......
......@@ -32,7 +32,7 @@ namespace sw
struct VertexTask
{
unsigned int count;
unsigned int vertexCount;
VertexCache vertexCache;
};
......
......@@ -47,7 +47,7 @@ namespace sw
Pointer<Byte> vertexCache = cache + OFFSET(VertexCache,vertex);
Pointer<Byte> tagCache = cache + OFFSET(VertexCache,tag);
UInt count = *Pointer<UInt>(task + OFFSET(VertexTask,count));
UInt vertexCount = *Pointer<UInt>(task + OFFSET(VertexTask,vertexCount));
Registers r(shader);
r.data = data;
......@@ -78,9 +78,9 @@ namespace sw
vertex += sizeof(Vertex);
batch += sizeof(unsigned int);
count--;
vertexCount--;
}
Until(count == 0)
Until(vertexCount == 0)
Return();
}
......
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