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/25329
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Device/Clipper.cpp b/src/Device/Clipper.cpp
index e20b041..0bd04ab 100644
--- a/src/Device/Clipper.cpp
+++ b/src/Device/Clipper.cpp
@@ -49,26 +49,6 @@
}}}}}
}
- 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;
}
@@ -300,44 +280,6 @@
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
{
float D = 1.0f / (dj - di);
diff --git a/src/Device/Clipper.hpp b/src/Device/Clipper.hpp
index b808c08..4eaf940 100644
--- a/src/Device/Clipper.hpp
+++ b/src/Device/Clipper.hpp
@@ -40,16 +40,6 @@
CLIP_FRUSTUM = 0x003F,
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);
@@ -62,7 +52,6 @@
void clipRight(Polygon &polygon);
void clipTop(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;
};
diff --git a/src/Device/Renderer.cpp b/src/Device/Renderer.cpp
index f713bd7..d9411b7 100644
--- a/src/Device/Renderer.cpp
+++ b/src/Device/Renderer.cpp
@@ -119,8 +119,6 @@
clipper = new Clipper;
blitter = new Blitter;
- updateClipPlanes = true;
-
#if PERF_HUD
resetTimers();
#endif
@@ -223,7 +221,6 @@
context->drawType = drawType;
updateConfiguration();
- updateClipper();
int ms = context->getMultiSampleCount();
unsigned int oldMultiSampleMask = context->multiSampleMask;
@@ -464,17 +461,6 @@
data->slopeDepthBias = context->slopeDepthBias;
data->depthRange = Z;
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
@@ -1255,7 +1241,7 @@
{
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)
{
@@ -1397,7 +1383,7 @@
{
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)
{
@@ -1503,7 +1489,7 @@
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)
{
@@ -1568,7 +1554,7 @@
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)
{
@@ -1687,21 +1673,6 @@
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)
{
ASSERT(sampler < TOTAL_IMAGE_UNITS);
@@ -2043,22 +2014,6 @@
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)
{
bool newConfiguration = swiftConfig->hasNewConfiguration();
diff --git a/src/Device/Renderer.hpp b/src/Device/Renderer.hpp
index 6bcc1a2..0e552a9 100644
--- a/src/Device/Renderer.hpp
+++ b/src/Device/Renderer.hpp
@@ -300,8 +300,6 @@
// Viewport & Clipper
void setViewport(const VkViewport &viewport);
void setScissor(const Rect &scissor);
- void setClipFlags(int flags);
- void setClipPlane(unsigned int index, const float plane[4]);
void addQuery(Query *query);
void removeQuery(Query *query);
@@ -338,7 +336,6 @@
bool setupPoint(Primitive &primitive, Triangle &triangle, const DrawCall &draw);
bool isReadWriteTexture(int sampler);
- void updateClipper();
void updateConfiguration(bool initialUpdate = false);
void initializeThreads();
void terminateThreads();
@@ -353,11 +350,6 @@
Triangle *triangleBatch[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 threadsAwake;
Thread *worker[16];
@@ -445,8 +437,6 @@
std::list<Query*> *queries;
- AtomicInt clipFlags;
-
AtomicInt primitive; // Current primitive to enter pipeline
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