Commit 4aad8840 by Chris Forbes

Remove remnants of GL-style user clip planes

Vulkan doesn't have user clip planes in the legacy GL sense -- there is an optional feature to supply GLSL1.30-style clip distances out of the vertex shader, but the actual plane handling is the shader's problem. We also don't support this optional feature. Bug: b/125909515 Change-Id: I6dfc3eda613982112786a52517d1cd126146c590 Reviewed-on: https://swiftshader-review.googlesource.com/c/25329Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 35df09f8
...@@ -49,26 +49,6 @@ namespace sw ...@@ -49,26 +49,6 @@ namespace sw
}}}}} }}}}}
} }
if(clipFlagsOr & CLIP_USER)
{
int clipFlags = draw.clipFlags;
DrawData &data = *draw.data;
if(polygon.n >= 3) {
if(clipFlags & CLIP_PLANE0) clipPlane(polygon, data.clipPlane[0]);
if(polygon.n >= 3) {
if(clipFlags & CLIP_PLANE1) clipPlane(polygon, data.clipPlane[1]);
if(polygon.n >= 3) {
if(clipFlags & CLIP_PLANE2) clipPlane(polygon, data.clipPlane[2]);
if(polygon.n >= 3) {
if(clipFlags & CLIP_PLANE3) clipPlane(polygon, data.clipPlane[3]);
if(polygon.n >= 3) {
if(clipFlags & CLIP_PLANE4) clipPlane(polygon, data.clipPlane[4]);
if(polygon.n >= 3) {
if(clipFlags & CLIP_PLANE5) clipPlane(polygon, data.clipPlane[5]);
}}}}}}
}
return polygon.n >= 3; return polygon.n >= 3;
} }
...@@ -300,44 +280,6 @@ namespace sw ...@@ -300,44 +280,6 @@ namespace sw
polygon.i += 1; polygon.i += 1;
} }
void Clipper::clipPlane(Polygon &polygon, const Plane &p)
{
const float4 **V = polygon.P[polygon.i];
const float4 **T = polygon.P[polygon.i + 1];
int t = 0;
for(int i = 0; i < polygon.n; i++)
{
int j = i == polygon.n - 1 ? 0 : i + 1;
float di = p.A * V[i]->x + p.B * V[i]->y + p.C * V[i]->z + p.D * V[i]->w;
float dj = p.A * V[j]->x + p.B * V[j]->y + p.C * V[j]->z + p.D * V[j]->w;
if(di >= 0)
{
T[t++] = V[i];
if(dj < 0)
{
clipEdge(polygon.B[polygon.b], *V[i], *V[j], di, dj);
T[t++] = &polygon.B[polygon.b++];
}
}
else
{
if(dj > 0)
{
clipEdge(polygon.B[polygon.b], *V[j], *V[i], dj, di);
T[t++] = &polygon.B[polygon.b++];
}
}
}
polygon.n = t;
polygon.i += 1;
}
inline void Clipper::clipEdge(float4 &Vo, const float4 &Vi, const float4 &Vj, float di, float dj) const inline void Clipper::clipEdge(float4 &Vo, const float4 &Vi, const float4 &Vj, float di, float dj) const
{ {
float D = 1.0f / (dj - di); float D = 1.0f / (dj - di);
......
...@@ -40,16 +40,6 @@ namespace sw ...@@ -40,16 +40,6 @@ namespace sw
CLIP_FRUSTUM = 0x003F, CLIP_FRUSTUM = 0x003F,
CLIP_FINITE = 1 << 7, // All position coordinates are finite CLIP_FINITE = 1 << 7, // All position coordinates are finite
// User-defined clipping planes
CLIP_PLANE0 = 1 << 8,
CLIP_PLANE1 = 1 << 9,
CLIP_PLANE2 = 1 << 10,
CLIP_PLANE3 = 1 << 11,
CLIP_PLANE4 = 1 << 12,
CLIP_PLANE5 = 1 << 13,
CLIP_USER = 0x3F00
}; };
unsigned int computeClipFlags(const float4 &v); unsigned int computeClipFlags(const float4 &v);
...@@ -62,7 +52,6 @@ namespace sw ...@@ -62,7 +52,6 @@ namespace sw
void clipRight(Polygon &polygon); void clipRight(Polygon &polygon);
void clipTop(Polygon &polygon); void clipTop(Polygon &polygon);
void clipBottom(Polygon &polygon); void clipBottom(Polygon &polygon);
void clipPlane(Polygon &polygon, const Plane &plane);
void clipEdge(float4 &Vo, const float4 &Vi, const float4 &Vj, float di, float dj) const; void clipEdge(float4 &Vo, const float4 &Vi, const float4 &Vj, float di, float dj) const;
}; };
......
...@@ -119,8 +119,6 @@ namespace sw ...@@ -119,8 +119,6 @@ namespace sw
clipper = new Clipper; clipper = new Clipper;
blitter = new Blitter; blitter = new Blitter;
updateClipPlanes = true;
#if PERF_HUD #if PERF_HUD
resetTimers(); resetTimers();
#endif #endif
...@@ -223,7 +221,6 @@ namespace sw ...@@ -223,7 +221,6 @@ namespace sw
context->drawType = drawType; context->drawType = drawType;
updateConfiguration(); updateConfiguration();
updateClipper();
int ms = context->getMultiSampleCount(); int ms = context->getMultiSampleCount();
unsigned int oldMultiSampleMask = context->multiSampleMask; unsigned int oldMultiSampleMask = context->multiSampleMask;
...@@ -464,17 +461,6 @@ namespace sw ...@@ -464,17 +461,6 @@ namespace sw
data->slopeDepthBias = context->slopeDepthBias; data->slopeDepthBias = context->slopeDepthBias;
data->depthRange = Z; data->depthRange = Z;
data->depthNear = N; data->depthNear = N;
draw->clipFlags = clipFlags;
if(clipFlags)
{
if(clipFlags & Clipper::CLIP_PLANE0) data->clipPlane[0] = clipPlane[0];
if(clipFlags & Clipper::CLIP_PLANE1) data->clipPlane[1] = clipPlane[1];
if(clipFlags & Clipper::CLIP_PLANE2) data->clipPlane[2] = clipPlane[2];
if(clipFlags & Clipper::CLIP_PLANE3) data->clipPlane[3] = clipPlane[3];
if(clipFlags & Clipper::CLIP_PLANE4) data->clipPlane[4] = clipPlane[4];
if(clipFlags & Clipper::CLIP_PLANE5) data->clipPlane[5] = clipPlane[5];
}
} }
// Target // Target
...@@ -1255,7 +1241,7 @@ namespace sw ...@@ -1255,7 +1241,7 @@ namespace sw
{ {
Polygon polygon(&v0.builtins.position, &v1.builtins.position, &v2.builtins.position); Polygon polygon(&v0.builtins.position, &v1.builtins.position, &v2.builtins.position);
int clipFlagsOr = v0.clipFlags | v1.clipFlags | v2.clipFlags | draw.clipFlags; int clipFlagsOr = v0.clipFlags | v1.clipFlags | v2.clipFlags;
if(clipFlagsOr != Clipper::CLIP_FINITE) if(clipFlagsOr != Clipper::CLIP_FINITE)
{ {
...@@ -1397,7 +1383,7 @@ namespace sw ...@@ -1397,7 +1383,7 @@ namespace sw
{ {
Polygon polygon(P, 4); Polygon polygon(P, 4);
int clipFlagsOr = C[0] | C[1] | C[2] | C[3] | draw.clipFlags; int clipFlagsOr = C[0] | C[1] | C[2] | C[3];
if(clipFlagsOr != Clipper::CLIP_FINITE) if(clipFlagsOr != Clipper::CLIP_FINITE)
{ {
...@@ -1503,7 +1489,7 @@ namespace sw ...@@ -1503,7 +1489,7 @@ namespace sw
Polygon polygon(L, 6); Polygon polygon(L, 6);
int clipFlagsOr = C[0] | C[1] | C[2] | C[3] | C[4] | C[5] | C[6] | C[7] | draw.clipFlags; int clipFlagsOr = C[0] | C[1] | C[2] | C[3] | C[4] | C[5] | C[6] | C[7];
if(clipFlagsOr != Clipper::CLIP_FINITE) if(clipFlagsOr != Clipper::CLIP_FINITE)
{ {
...@@ -1568,7 +1554,7 @@ namespace sw ...@@ -1568,7 +1554,7 @@ namespace sw
if((C[0] & C[1] & C[2] & C[3]) == Clipper::CLIP_FINITE) if((C[0] & C[1] & C[2] & C[3]) == Clipper::CLIP_FINITE)
{ {
int clipFlagsOr = C[0] | C[1] | C[2] | C[3] | draw.clipFlags; int clipFlagsOr = C[0] | C[1] | C[2] | C[3];
if(clipFlagsOr != Clipper::CLIP_FINITE) if(clipFlagsOr != Clipper::CLIP_FINITE)
{ {
...@@ -1687,21 +1673,6 @@ namespace sw ...@@ -1687,21 +1673,6 @@ namespace sw
return false; return false;
} }
void Renderer::updateClipper()
{
if(updateClipPlanes)
{
if(clipFlags & Clipper::CLIP_PLANE0) clipPlane[0] = userPlane[0];
if(clipFlags & Clipper::CLIP_PLANE1) clipPlane[1] = userPlane[1];
if(clipFlags & Clipper::CLIP_PLANE2) clipPlane[2] = userPlane[2];
if(clipFlags & Clipper::CLIP_PLANE3) clipPlane[3] = userPlane[3];
if(clipFlags & Clipper::CLIP_PLANE4) clipPlane[4] = userPlane[4];
if(clipFlags & Clipper::CLIP_PLANE5) clipPlane[5] = userPlane[5];
updateClipPlanes = false;
}
}
void Renderer::setTextureResource(unsigned int sampler, Resource *resource) void Renderer::setTextureResource(unsigned int sampler, Resource *resource)
{ {
ASSERT(sampler < TOTAL_IMAGE_UNITS); ASSERT(sampler < TOTAL_IMAGE_UNITS);
...@@ -2043,22 +2014,6 @@ namespace sw ...@@ -2043,22 +2014,6 @@ namespace sw
this->scissor = scissor; this->scissor = scissor;
} }
void Renderer::setClipFlags(int flags)
{
clipFlags = flags << 8; // Bottom 8 bits used by legacy frustum
}
void Renderer::setClipPlane(unsigned int index, const float plane[4])
{
if(index < MAX_CLIP_PLANES)
{
userPlane[index] = plane;
}
else ASSERT(false);
updateClipPlanes = true;
}
void Renderer::updateConfiguration(bool initialUpdate) void Renderer::updateConfiguration(bool initialUpdate)
{ {
bool newConfiguration = swiftConfig->hasNewConfiguration(); bool newConfiguration = swiftConfig->hasNewConfiguration();
......
...@@ -300,8 +300,6 @@ namespace sw ...@@ -300,8 +300,6 @@ namespace sw
// Viewport & Clipper // Viewport & Clipper
void setViewport(const VkViewport &viewport); void setViewport(const VkViewport &viewport);
void setScissor(const Rect &scissor); void setScissor(const Rect &scissor);
void setClipFlags(int flags);
void setClipPlane(unsigned int index, const float plane[4]);
void addQuery(Query *query); void addQuery(Query *query);
void removeQuery(Query *query); void removeQuery(Query *query);
...@@ -338,7 +336,6 @@ namespace sw ...@@ -338,7 +336,6 @@ namespace sw
bool setupPoint(Primitive &primitive, Triangle &triangle, const DrawCall &draw); bool setupPoint(Primitive &primitive, Triangle &triangle, const DrawCall &draw);
bool isReadWriteTexture(int sampler); bool isReadWriteTexture(int sampler);
void updateClipper();
void updateConfiguration(bool initialUpdate = false); void updateConfiguration(bool initialUpdate = false);
void initializeThreads(); void initializeThreads();
void terminateThreads(); void terminateThreads();
...@@ -353,11 +350,6 @@ namespace sw ...@@ -353,11 +350,6 @@ namespace sw
Triangle *triangleBatch[16]; Triangle *triangleBatch[16];
Primitive *primitiveBatch[16]; Primitive *primitiveBatch[16];
// User-defined clipping planes
Plane userPlane[MAX_CLIP_PLANES];
Plane clipPlane[MAX_CLIP_PLANES]; // Tranformed to clip space
bool updateClipPlanes;
AtomicInt exitThreads; AtomicInt exitThreads;
AtomicInt threadsAwake; AtomicInt threadsAwake;
Thread *worker[16]; Thread *worker[16];
...@@ -445,8 +437,6 @@ namespace sw ...@@ -445,8 +437,6 @@ namespace sw
std::list<Query*> *queries; std::list<Query*> *queries;
AtomicInt clipFlags;
AtomicInt primitive; // Current primitive to enter pipeline AtomicInt primitive; // Current primitive to enter pipeline
AtomicInt count; // Number of primitives to render AtomicInt count; // Number of primitives to render
AtomicInt references; // Remaining references to this draw call, 0 when done drawing, -1 when resources unlocked and slot is free AtomicInt references; // Remaining references to this draw call, 0 when done drawing, -1 when resources unlocked and slot is free
......
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