Ripped out SwiftConfig

SwiftConfig is unused in Vulkan, so it was removed.

Change-Id: Ic82bd186c271522b8552ca9925692e311b5c4156
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/32031
Tested-by: Alexis Hétu <sugoi@google.com>
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Device/BUILD.gn b/src/Device/BUILD.gn
index 96534fe..fa7d6b4 100644
--- a/src/Device/BUILD.gn
+++ b/src/Device/BUILD.gn
@@ -42,8 +42,6 @@
     "Renderer.hpp",
     "SetupProcessor.cpp",
     "SetupProcessor.hpp",
-    "SwiftConfig.cpp",
-    "SwiftConfig.hpp",
     "Vector.cpp",
     "Vector.hpp",
     "VertexProcessor.cpp",
diff --git a/src/Device/Config.cpp b/src/Device/Config.cpp
index a155044..6eb61ab 100644
--- a/src/Device/Config.cpp
+++ b/src/Device/Config.cpp
@@ -30,39 +30,10 @@
 		framesSec = 0;
 		framesTotal = 0;
 		FPS = 0;
-
-		#if PERF_PROFILE
-			for(int i = 0; i < PERF_TIMERS; i++)
-			{
-				cycles[i] = 0;
-			}
-
-			ropOperations = 0;
-			ropOperationsTotal = 0;
-			ropOperationsFrame = 0;
-
-			texOperations = 0;
-			texOperationsTotal = 0;
-			texOperationsFrame = 0;
-
-			compressedTex = 0;
-			compressedTexTotal = 0;
-			compressedTexFrame = 0;
-		#endif
 	}
 
 	void Profiler::nextFrame()
 	{
-		#if PERF_PROFILE
-			ropOperationsFrame = sw::atomicExchange(&ropOperations, 0);
-			texOperationsFrame = sw::atomicExchange(&texOperations, 0);
-			compressedTexFrame = sw::atomicExchange(&compressedTex, 0);
-
-			ropOperationsTotal += ropOperationsFrame;
-			texOperationsTotal += texOperationsFrame;
-			compressedTexTotal += compressedTexFrame;
-		#endif
-
 		static double fpsTime = sw::Timer::seconds();
 
 		double time = sw::Timer::seconds();
diff --git a/src/Device/Config.hpp b/src/Device/Config.hpp
index bfd8a3b..9661bdc 100644
--- a/src/Device/Config.hpp
+++ b/src/Device/Config.hpp
@@ -17,18 +17,6 @@
 
 #include "System/Types.hpp"
 
-#define PERF_HUD 0       // Display time spent on vertex, setup and pixel processing for each thread
-#define PERF_PROFILE 0   // Profile various pipeline stages and display the timing in SwiftConfig
-
-#define ASTC_SUPPORT 0
-
-// Worker thread count when not set by SwiftConfig
-// 0 = process affinity count (recommended)
-// 1 = rendering on main thread (no worker threads), useful for debugging
-#ifndef DEFAULT_THREAD_COUNT
-#define DEFAULT_THREAD_COUNT 0
-#endif
-
 namespace sw
 {
 	enum
@@ -53,22 +41,6 @@
 		int framesSec;
 		int framesTotal;
 		double FPS;
-
-		#if PERF_PROFILE
-		double cycles[PERF_TIMERS];
-
-		int64_t ropOperations;
-		int64_t ropOperationsTotal;
-		int64_t ropOperationsFrame;
-
-		int64_t texOperations;
-		int64_t texOperationsTotal;
-		int64_t texOperationsFrame;
-
-		int64_t compressedTex;
-		int64_t compressedTexTotal;
-		int64_t compressedTexFrame;
-		#endif
 	};
 
 	extern Profiler profiler;
diff --git a/src/Device/Context.cpp b/src/Device/Context.cpp
index a198322..25eed51 100644
--- a/src/Device/Context.cpp
+++ b/src/Device/Context.cpp
@@ -24,16 +24,6 @@
 
 namespace sw
 {
-	bool booleanFaceRegister = false;
-	bool fullPixelPositionRegister = false;
-
-	bool forceWindowed = false;
-	bool quadLayoutEnabled = false;
-	bool postBlendSRGB = false;
-	bool exactColorRounding = false;
-	TransparencyAntialiasing transparencyAntialiasing = TRANSPARENCY_NONE;
-	bool forceClearRegisters = false;
-
 	Context::Context()
 	{
 		init();
@@ -197,11 +187,6 @@
 		return depthWriteEnable;
 	}
 
-	bool Context::alphaTestActive() const
-	{
-		return transparencyAntialiasing != TRANSPARENCY_NONE;
-	}
-
 	bool Context::depthBufferActive() const
 	{
 		return depthBuffer && depthBufferEnable;
@@ -589,6 +574,6 @@
 
 	bool Context::colorUsed() const
 	{
-		return colorWriteActive() || alphaTestActive() || (pixelShader && pixelShader->getModes().ContainsKill);
+		return colorWriteActive() || (pixelShader && pixelShader->getModes().ContainsKill);
 	}
 }
diff --git a/src/Device/Context.hpp b/src/Device/Context.hpp
index 107ebe0..0ecd28f 100644
--- a/src/Device/Context.hpp
+++ b/src/Device/Context.hpp
@@ -97,7 +97,6 @@
 		bool setWriteSRGB(bool sRGB);
 
 		bool depthWriteActive() const;
-		bool alphaTestActive() const;
 		bool depthBufferActive() const;
 		bool stencilActive() const;
 
diff --git a/src/Device/PixelProcessor.cpp b/src/Device/PixelProcessor.cpp
index 7d73ced..797e3da 100644
--- a/src/Device/PixelProcessor.cpp
+++ b/src/Device/PixelProcessor.cpp
@@ -24,10 +24,6 @@
 
 namespace sw
 {
-	extern TransparencyAntialiasing transparencyAntialiasing;
-
-	bool precachePixel = false;
-
 	unsigned int PixelProcessor::States::computeHash()
 	{
 		unsigned int *state = (unsigned int*)this;
diff --git a/src/Device/QuadRasterizer.cpp b/src/Device/QuadRasterizer.cpp
index b52c276..65470af 100644
--- a/src/Device/QuadRasterizer.cpp
+++ b/src/Device/QuadRasterizer.cpp
@@ -22,10 +22,6 @@
 
 namespace sw
 {
-	extern bool fullPixelPositionRegister;
-
-	extern int clusterCount;
-
 	QuadRasterizer::QuadRasterizer(const PixelProcessor::State &state, SpirvShader const *spirvShader) : state(state), spirvShader{spirvShader}
 	{
 	}
@@ -36,15 +32,6 @@
 
 	void QuadRasterizer::generate()
 	{
-		#if PERF_PROFILE
-			for(int i = 0; i < PERF_TIMERS; i++)
-			{
-				cycles[i] = 0;
-			}
-
-			Long pixelTime = Ticks();
-		#endif
-
 		constants = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData,constants));
 		occlusion = 0;
 		int clusterCount = Renderer::getClusterCount();
@@ -76,15 +63,6 @@
 			*Pointer<UInt>(data + OFFSET(DrawData,occlusion) + 4 * cluster) = clusterOcclusion;
 		}
 
-		#if PERF_PROFILE
-			cycles[PERF_PIXEL] = Ticks() - pixelTime;
-
-			for(int i = 0; i < PERF_TIMERS; i++)
-			{
-				*Pointer<Long>(data + OFFSET(DrawData,cycles[i]) + 8 * cluster) += cycles[i];
-			}
-		#endif
-
 		Return();
 	}
 
diff --git a/src/Device/QuadRasterizer.hpp b/src/Device/QuadRasterizer.hpp
index 456887d..2dcff55 100644
--- a/src/Device/QuadRasterizer.hpp
+++ b/src/Device/QuadRasterizer.hpp
@@ -40,10 +40,6 @@
 
 		UInt occlusion;
 
-#if PERF_PROFILE
-		Long cycles[PERF_TIMERS];
-#endif
-
 		virtual void quad(Pointer<Byte> cBuffer[4], Pointer<Byte> &zBuffer, Pointer<Byte> &sBuffer, Int cMask[4], Int &x, Int &y) = 0;
 
 		bool interpolateZ() const;
diff --git a/src/Device/Renderer.cpp b/src/Device/Renderer.cpp
index 5e41029..ee82055 100644
--- a/src/Device/Renderer.cpp
+++ b/src/Device/Renderer.cpp
@@ -17,7 +17,6 @@
 #include "Clipper.hpp"
 #include "Primitive.hpp"
 #include "Polygon.hpp"
-#include "Device/SwiftConfig.hpp"
 #include "Reactor/Reactor.hpp"
 #include "Pipeline/Constants.hpp"
 #include "System/CPUID.hpp"
@@ -35,8 +34,6 @@
 
 #undef max
 
-bool disableServer = true;
-
 #ifndef NDEBUG
 unsigned int minPrimitives = 1;
 unsigned int maxPrimitives = 1 << 21;
@@ -44,42 +41,11 @@
 
 namespace sw
 {
-	extern bool booleanFaceRegister;
-	extern bool fullPixelPositionRegister;
-
-	extern bool forceWindowed;
-	extern bool postBlendSRGB;
-	extern bool exactColorRounding;
-	extern TransparencyAntialiasing transparencyAntialiasing;
-	extern bool forceClearRegisters;
-
-	extern bool precacheVertex;
-	extern bool precacheSetup;
-	extern bool precachePixel;
-
 	static const int batchSize = 128;
 	AtomicInt threadCount(1);
 	AtomicInt Renderer::unitCount(1);
 	AtomicInt Renderer::clusterCount(1);
 
-	TranscendentalPrecision logPrecision = ACCURATE;
-	TranscendentalPrecision expPrecision = ACCURATE;
-	TranscendentalPrecision rcpPrecision = ACCURATE;
-	TranscendentalPrecision rsqPrecision = ACCURATE;
-
-	static void setGlobalRenderingSettings(Conventions conventions, bool exactColorRounding)
-	{
-		static bool initialized = false;
-
-		if(!initialized)
-		{
-			sw::booleanFaceRegister = conventions.booleanFaceRegister;
-			sw::fullPixelPositionRegister = conventions.fullPixelPositionRegister;
-			sw::exactColorRounding = exactColorRounding;
-			initialized = true;
-		}
-	}
-
 	template<typename T>
 	inline bool setBatchIndices(unsigned int batch[128][3], VkPrimitiveTopology topology, T indices, unsigned int start, unsigned int triangleCount)
 	{
@@ -196,14 +162,8 @@
 		deallocate(data);
 	}
 
-	Renderer::Renderer(Conventions conventions, bool exactColorRounding)
+	Renderer::Renderer()
 	{
-		setGlobalRenderingSettings(conventions, exactColorRounding);
-
-		#if PERF_HUD
-			resetTimers();
-		#endif
-
 		for(int i = 0; i < 16; i++)
 		{
 			vertexTask[i] = nullptr;
@@ -246,7 +206,6 @@
 
 		clipFlags = 0;
 
-		swiftConfig = new SwiftConfig(disableServer);
 		updateConfiguration(true);
 	}
 
@@ -263,9 +222,6 @@
 			delete drawCall[draw];
 			drawCall[draw] = nullptr;
 		}
-
-		delete swiftConfig;
-		swiftConfig = nullptr;
 	}
 
 	// This object has to be mem aligned
@@ -298,10 +254,14 @@
 		if(count == 0) { return; }
 
 		#ifndef NDEBUG
+		{
+			unsigned int minPrimitives = 1;
+			unsigned int maxPrimitives = 1 << 21;
 			if(count < minPrimitives || count > maxPrimitives)
 			{
 				return;
 			}
+		}
 		#endif
 
 		updateConfiguration();
@@ -455,16 +415,6 @@
 			}
 		}
 
-		#if PERF_PROFILE
-			for(int cluster = 0; cluster < clusterCount; cluster++)
-			{
-				for(int i = 0; i < PERF_TIMERS; i++)
-				{
-					data->cycles[i][cluster] = 0;
-				}
-			}
-		#endif
-
 		// Viewport
 		{
 			float W = 0.5f * viewport.width;
@@ -574,11 +524,8 @@
 		Renderer *renderer = static_cast<Parameters*>(parameters)->renderer;
 		int threadIndex = static_cast<Parameters*>(parameters)->threadIndex;
 
-		if(logPrecision < IEEE)
-		{
-			CPUID::setFlushToZero(true);
-			CPUID::setDenormalsAreZero(true);
-		}
+		CPUID::setFlushToZero(true);
+		CPUID::setDenormalsAreZero(true);
 
 		renderer->threadLoop(threadIndex);
 	}
@@ -733,10 +680,6 @@
 
 	void Renderer::executeTask(int threadIndex)
 	{
-		#if PERF_HUD
-			int64_t startTick = Timer::ticks();
-		#endif
-
 		switch(task[threadIndex].type)
 		{
 		case Task::PRIMITIVES:
@@ -750,12 +693,6 @@
 
 				processPrimitiveVertices(unit, input, count, draw->count, threadIndex);
 
-				#if PERF_HUD
-					int64_t time = Timer::ticks();
-					vertexTime[threadIndex] += time - startTick;
-					startTick = time;
-				#endif
-
 				int visible = 0;
 
 				if(!draw->setupState.rasterizerDiscard)
@@ -765,10 +702,6 @@
 
 				primitiveProgress[unit].visible = visible;
 				primitiveProgress[unit].references = clusterCount;
-
-				#if PERF_HUD
-					setupTime[threadIndex] += Timer::ticks() - startTick;
-				#endif
 			}
 			break;
 		case Task::PIXELS:
@@ -788,10 +721,6 @@
 				}
 
 				finishRendering(task[threadIndex]);
-
-				#if PERF_HUD
-					pixelTime[threadIndex] += Timer::ticks() - startTick;
-				#endif
 			}
 			break;
 		case Task::RESUME:
@@ -835,16 +764,6 @@
 
 			if(ref == 0)
 			{
-				#if PERF_PROFILE
-					for(int cluster = 0; cluster < clusterCount; cluster++)
-					{
-						for(int i = 0; i < PERF_TIMERS; i++)
-						{
-							profiler.cycles[i] += data.cycles[i][cluster];
-						}
-					}
-				#endif
-
 				if(draw.queries)
 				{
 					for(auto &query : *(draw.queries))
@@ -1393,38 +1312,6 @@
 		}
 	}
 
-	#if PERF_HUD
-		int Renderer::getThreadCount()
-		{
-			return threadCount;
-		}
-
-		int64_t Renderer::getVertexTime(int thread)
-		{
-			return vertexTime[thread];
-		}
-
-		int64_t Renderer::getSetupTime(int thread)
-		{
-			return setupTime[thread];
-		}
-
-		int64_t Renderer::getPixelTime(int thread)
-		{
-			return pixelTime[thread];
-		}
-
-		void Renderer::resetTimers()
-		{
-			for(int thread = 0; thread < threadCount; thread++)
-			{
-				vertexTime[thread] = 0;
-				setupTime[thread] = 0;
-				pixelTime[thread] = 0;
-			}
-		}
-	#endif
-
 	void Renderer::setViewport(const VkViewport &viewport)
 	{
 		this->viewport = viewport;
@@ -1437,97 +1324,21 @@
 
 	void Renderer::updateConfiguration(bool initialUpdate)
 	{
-		bool newConfiguration = swiftConfig->hasNewConfiguration();
-
-		if(newConfiguration || initialUpdate)
+		if(initialUpdate)
 		{
 			terminateThreads();
 
-			SwiftConfig::Configuration configuration = {};
-			swiftConfig->getConfiguration(configuration);
+			VertexProcessor::setRoutineCacheSize(1024);
+			PixelProcessor::setRoutineCacheSize(1024);
+			SetupProcessor::setRoutineCacheSize(1024);
 
-			precacheVertex = !newConfiguration && configuration.precache;
-			precacheSetup = !newConfiguration && configuration.precache;
-			precachePixel = !newConfiguration && configuration.precache;
+			threadCount = CPUID::processAffinity();
 
-			VertexProcessor::setRoutineCacheSize(configuration.vertexRoutineCacheSize);
-			PixelProcessor::setRoutineCacheSize(configuration.pixelRoutineCacheSize);
-			SetupProcessor::setRoutineCacheSize(configuration.setupRoutineCacheSize);
-
-			switch(configuration.transcendentalPrecision)
-			{
-			case 0:
-				logPrecision = APPROXIMATE;
-				expPrecision = APPROXIMATE;
-				rcpPrecision = APPROXIMATE;
-				rsqPrecision = APPROXIMATE;
-				break;
-			case 1:
-				logPrecision = PARTIAL;
-				expPrecision = PARTIAL;
-				rcpPrecision = PARTIAL;
-				rsqPrecision = PARTIAL;
-				break;
-			case 2:
-				logPrecision = ACCURATE;
-				expPrecision = ACCURATE;
-				rcpPrecision = ACCURATE;
-				rsqPrecision = ACCURATE;
-				break;
-			case 3:
-				logPrecision = WHQL;
-				expPrecision = WHQL;
-				rcpPrecision = WHQL;
-				rsqPrecision = WHQL;
-				break;
-			case 4:
-				logPrecision = IEEE;
-				expPrecision = IEEE;
-				rcpPrecision = IEEE;
-				rsqPrecision = IEEE;
-				break;
-			default:
-				logPrecision = ACCURATE;
-				expPrecision = ACCURATE;
-				rcpPrecision = ACCURATE;
-				rsqPrecision = ACCURATE;
-				break;
-			}
-
-			switch(configuration.transparencyAntialiasing)
-			{
-			case 0:  transparencyAntialiasing = TRANSPARENCY_NONE;              break;
-			case 1:  transparencyAntialiasing = TRANSPARENCY_ALPHA_TO_COVERAGE; break;
-			default: transparencyAntialiasing = TRANSPARENCY_NONE;              break;
-			}
-
-			switch(configuration.threadCount)
-			{
-			case -1: threadCount = CPUID::coreCount();        break;
-			case 0:  threadCount = CPUID::processAffinity();  break;
-			default: threadCount = configuration.threadCount; break;
-			}
-
-			CPUID::setEnableSSE4_1(configuration.enableSSE4_1);
-			CPUID::setEnableSSSE3(configuration.enableSSSE3);
-			CPUID::setEnableSSE3(configuration.enableSSE3);
-			CPUID::setEnableSSE2(configuration.enableSSE2);
-			CPUID::setEnableSSE(configuration.enableSSE);
-
-			for(int pass = 0; pass < 10; pass++)
-			{
-				optimization[pass] = configuration.optimization[pass];
-			}
-
-			forceWindowed = configuration.forceWindowed;
-			postBlendSRGB = configuration.postBlendSRGB;
-			exactColorRounding = configuration.exactColorRounding;
-			forceClearRegisters = configuration.forceClearRegisters;
-
-		#ifndef NDEBUG
-			minPrimitives = configuration.minPrimitives;
-			maxPrimitives = configuration.maxPrimitives;
-		#endif
+			CPUID::setEnableSSE4_1(true);
+			CPUID::setEnableSSSE3(true);
+			CPUID::setEnableSSE3(true);
+			CPUID::setEnableSSE2(true);
+			CPUID::setEnableSSE(true);
 		}
 
 		if(!initialUpdate && !worker[0])
diff --git a/src/Device/Renderer.hpp b/src/Device/Renderer.hpp
index 3f02609..13a7c93 100644
--- a/src/Device/Renderer.hpp
+++ b/src/Device/Renderer.hpp
@@ -40,50 +40,11 @@
 	struct DrawCall;
 	class PixelShader;
 	class VertexShader;
-	class SwiftConfig;
 	struct Task;
 	class TaskEvents;
 	class Resource;
 	struct Constants;
 
-	enum TranscendentalPrecision
-	{
-		APPROXIMATE,
-		PARTIAL,	// 2^-10
-		ACCURATE,
-		WHQL,		// 2^-21
-		IEEE		// 2^-23
-	};
-
-	extern TranscendentalPrecision logPrecision;
-	extern TranscendentalPrecision expPrecision;
-	extern TranscendentalPrecision rcpPrecision;
-	extern TranscendentalPrecision rsqPrecision;
-
-	struct Conventions  // FIXME(capn): Eliminate. Only support Vulkan 1.1 conventions.
-	{
-		bool halfIntegerCoordinates;
-		bool symmetricNormalizedDepth;
-		bool booleanFaceRegister;
-		bool fullPixelPositionRegister;
-	};
-
-	static const Conventions OpenGL =
-	{
-		true,    // halfIntegerCoordinates
-		true,    // symmetricNormalizedDepth
-		true,    // booleanFaceRegister
-		true,    // fullPixelPositionRegister
-	};
-
-	static const Conventions Direct3D =
-	{
-		false,   // halfIntegerCoordinates
-		false,   // symmetricNormalizedDepth
-		false,   // booleanFaceRegister
-		false,   // fullPixelPositionRegister
-	};
-
 	struct DrawData
 	{
 		const Constants *constants;
@@ -103,10 +64,6 @@
 		PixelProcessor::Factor factor;
 		unsigned int occlusion[16];   // Number of pixels passing depth test
 
-		#if PERF_PROFILE
-			int64_t cycles[PERF_TIMERS][16];
-		#endif
-
 		float4 Wx16;
 		float4 Hx16;
 		float4 X0x16;
@@ -193,7 +150,7 @@
 		};
 
 	public:
-		Renderer(Conventions conventions, bool exactColorRounding);
+		Renderer();
 
 		virtual ~Renderer();
 
@@ -215,15 +172,6 @@
 
 		void synchronize();
 
-		#if PERF_HUD
-			// Performance timers
-			int getThreadCount();
-			int64_t getVertexTime(int thread);
-			int64_t getSetupTime(int thread);
-			int64_t getPixelTime(int thread);
-			void resetTimers();
-		#endif
-
 		static int getClusterCount() { return clusterCount; }
 
 	private:
@@ -289,16 +237,8 @@
 
 		std::mutex schedulerMutex;
 
-		#if PERF_HUD
-			int64_t vertexTime[16];
-			int64_t setupTime[16];
-			int64_t pixelTime[16];
-		#endif
-
 		VertexTask *vertexTask[16];
 
-		SwiftConfig *swiftConfig;
-
 		std::list<vk::Query*> queries;
 		WaitGroup sync;
 
diff --git a/src/Device/Sampler.hpp b/src/Device/Sampler.hpp
index c5e8f2a..9d80a3b 100644
--- a/src/Device/Sampler.hpp
+++ b/src/Device/Sampler.hpp
@@ -157,10 +157,6 @@
 		VkSamplerYcbcrModelConversion ycbcrModel;
 		bool studioSwing;    // Narrow range
 		bool swappedChroma;  // Cb/Cr components in reverse order
-
-		#if PERF_PROFILE
-		bool compressedFormat;
-		#endif
 	};
 }
 
diff --git a/src/Device/SetupProcessor.cpp b/src/Device/SetupProcessor.cpp
index b8fb74c..1567f51 100644
--- a/src/Device/SetupProcessor.cpp
+++ b/src/Device/SetupProcessor.cpp
@@ -25,10 +25,6 @@
 
 namespace sw
 {
-	extern bool fullPixelPositionRegister;
-
-	bool precacheSetup = false;
-
 	unsigned int SetupProcessor::States::computeHash()
 	{
 		unsigned int *state = (unsigned int*)this;
diff --git a/src/Device/SwiftConfig.cpp b/src/Device/SwiftConfig.cpp
deleted file mode 100644
index 7db5021..0000000
--- a/src/Device/SwiftConfig.cpp
+++ /dev/null
@@ -1,802 +0,0 @@
-// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//    http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "SwiftConfig.hpp"
-
-#include "Config.hpp"
-#include "System/Configurator.hpp"
-#include "Vulkan/VkDebug.hpp"
-#include "Vulkan/Version.h"
-
-#include <sstream>
-#include <stdio.h>
-#include <time.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <algorithm>
-
-namespace sw
-{
-	extern Profiler profiler;
-
-	std::string itoa(int number)
-	{
-		std::stringstream ss;
-		ss << number;
-		return ss.str();
-	}
-
-	std::string ftoa(double number)
-	{
-		std::stringstream ss;
-		ss << number;
-		return ss.str();
-	}
-
-	SwiftConfig::SwiftConfig(bool disableServerOverride) : listenSocket(0)
-	{
-		readConfiguration(disableServerOverride);
-
-		if(!disableServerOverride)
-		{
-			writeConfiguration();
-		}
-
-		receiveBuffer = 0;
-
-		if(!config.disableServer)
-		{
-			createServer();
-		}
-	}
-
-	SwiftConfig::~SwiftConfig()
-	{
-		destroyServer();
-	}
-
-	void SwiftConfig::createServer()
-	{
-		bufferLength = 16 * 1024;
-		receiveBuffer = new char[bufferLength];
-
-		Socket::startup();
-		listenSocket = new Socket("localhost", "8080");
-		listenSocket->listen();
-
-		terminate = false;
-		serverThread = new std::thread(serverRoutine, this);
-	}
-
-	void SwiftConfig::destroyServer()
-	{
-		if(receiveBuffer)
-		{
-			terminate = true;
-			serverThread->join();
-			delete serverThread;
-
-			delete listenSocket;
-			listenSocket = 0;
-
-			Socket::cleanup();
-
-			delete[] receiveBuffer;
-			receiveBuffer = 0;
-		}
-	}
-
-	bool SwiftConfig::hasNewConfiguration(bool reset)
-	{
-		bool value = newConfig;
-
-		if(reset)
-		{
-			newConfig = false;
-		}
-
-		return value;
-	}
-
-	void SwiftConfig::getConfiguration(Configuration &configuration)
-	{
-		std::unique_lock<std::mutex> lock(criticalSection);
-		configuration = config;
-	}
-
-	void SwiftConfig::serverRoutine(void *parameters)
-	{
-		SwiftConfig *swiftConfig = (SwiftConfig*)parameters;
-
-		swiftConfig->serverLoop();
-	}
-
-	void SwiftConfig::serverLoop()
-	{
-		readConfiguration();
-
-		while(!terminate)
-		{
-			if(listenSocket->select(100000))
-			{
-				Socket *clientSocket = listenSocket->accept();
-				int bytesReceived = 1;
-
-				while(bytesReceived > 0 && !terminate)
-				{
-					if(clientSocket->select(10))
-					{
-						bytesReceived = clientSocket->receive(receiveBuffer, bufferLength);
-
-						if(bytesReceived > 0)
-						{
-							receiveBuffer[bytesReceived] = 0;
-
-							respond(clientSocket, receiveBuffer);
-						}
-					}
-				}
-
-				delete clientSocket;
-			}
-		}
-	}
-
-	bool match(const char **url, const char *string)
-	{
-		size_t length = strlen(string);
-
-		if(strncmp(*url, string, length) == 0)
-		{
-			*url += length;
-
-			return true;
-		}
-
-		return false;
-	}
-
-	void SwiftConfig::respond(Socket *clientSocket, const char *request)
-	{
-		if(match(&request, "GET /"))
-		{
-			if(match(&request, "swiftshader") || match(&request, "swiftconfig"))
-			{
-				if(match(&request, " ") || match(&request, "/ "))
-				{
-					return send(clientSocket, OK, page());
-				}
-			}
-		}
-		else if(match(&request, "POST /"))
-		{
-			if(match(&request, "swiftshader") || match(&request, "swiftconfig"))
-			{
-				if(match(&request, " ") || match(&request, "/ "))
-				{
-					std::unique_lock<std::mutex> lock(criticalSection);
-
-					const char *postData = strstr(request, "\r\n\r\n");
-					postData = postData ? postData + 4 : 0;
-
-					if(postData && strlen(postData) > 0)
-					{
-						parsePost(postData);
-					}
-					else   // POST data in next packet
-					{
-						int bytesReceived = clientSocket->receive(receiveBuffer, bufferLength);
-
-						if(bytesReceived > 0)
-						{
-							receiveBuffer[bytesReceived] = 0;
-							parsePost(receiveBuffer);
-						}
-					}
-
-					writeConfiguration();
-					newConfig = true;
-
-					if(config.disableServer)
-					{
-						destroyServer();
-					}
-
-					lock.unlock();
-
-					return send(clientSocket, OK, page());
-				}
-				else if(match(&request, "/profile "))
-				{
-					return send(clientSocket, OK, profile());
-				}
-			}
-		}
-
-		return send(clientSocket, NotFound);
-	}
-
-	std::string SwiftConfig::page()
-	{
-		std::string html;
-
-		const std::string selected = "selected='selected'";
-		const std::string checked = "checked='checked'";
-		const std::string empty = "";
-
-		html += "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'>\n";
-		html += "<html>\n";
-		html += "<head>\n";
-		html += "<meta http-equiv='content-type' content='text/html; charset=UTF-8'>\n";
-		html += "<title>SwiftShader Configuration Panel</title>\n";
-		html += "</head>\n";
-		html += "<body>\n";
-		html += "<script type='text/javascript'>\n";
-		html += "request();\n";
-		html += "function request()\n";
-		html += "{\n";
-		html += "var xhr = new XMLHttpRequest();\n";
-		html += "xhr.open('POST', '/swiftshader/profile', true);\n";
-		html += "xhr.onreadystatechange = function()\n";
-		html += "{\n";
-		html += "if(xhr.readyState == 4 && xhr.status == 200)\n";
-		html += "{\n";
-		html += "document.getElementById('profile').innerHTML = xhr.responseText;\n";
-		html += "setTimeout('request()', 1000);\n";
-		html += "}\n";
-		html += "}\n";
-		html += "xhr.send();\n";
-		html += "}\n";
-		html += "</script>\n";
-		html += "<form method='POST' action=''>\n";
-		html += "<h1>SwiftShader Configuration Panel</h1>\n";
-		html += "<div id='profile'>" + profile() + "</div>\n";
-		html += "<hr><p>\n";
-		html += "<input type='submit' value='Apply changes' title='Click to apply all settings.'>\n";
-	//	html += "<input type='reset' value='Reset changes' title='Click to reset your changes to the previous value.'>\n";
-		html += "</p><hr>\n";
-		html += "<h2><em>Device capabilities</em></h2>\n";
-		html += "<table>\n";
-		html += "<tr><td>Build revision:</td><td>" REVISION_STRING "</td></tr>\n";
-		html += "<tr><td>Pixel shader model:</td><td><select name='pixelShaderVersion' title='The highest version of pixel shader supported by SwiftShader. Lower versions might be faster if supported by the application. Only effective after restarting the application.'>\n";
-		html += "<option value='0'"  + (config.pixelShaderVersion ==  0 ? selected : empty) + ">0.0</option>\n";
-		html += "<option value='11'" + (config.pixelShaderVersion == 11 ? selected : empty) + ">1.1</option>\n";
-		html += "<option value='12'" + (config.pixelShaderVersion == 12 ? selected : empty) + ">1.2</option>\n";
-		html += "<option value='13'" + (config.pixelShaderVersion == 13 ? selected : empty) + ">1.3</option>\n";
-		html += "<option value='14'" + (config.pixelShaderVersion == 14 ? selected : empty) + ">1.4</option>\n";
-		html += "<option value='20'" + (config.pixelShaderVersion == 20 ? selected : empty) + ">2.0</option>\n";
-		html += "<option value='21'" + (config.pixelShaderVersion == 21 ? selected : empty) + ">2.x</option>\n";
-		html += "<option value='30'" + (config.pixelShaderVersion == 30 ? selected : empty) + ">3.0 (default)</option>\n";
-		html += "</select></td></tr>\n";
-		html += "<tr><td>Vertex shader model:</td><td><select name='vertexShaderVersion' title='The highest version of vertex shader supported by SwiftShader. Lower versions might be faster if supported by the application. Only effective after restarting the application.'>\n";
-		html += "<option value='0'"  + (config.vertexShaderVersion ==  0 ? selected : empty) + ">0.0</option>\n";
-		html += "<option value='11'" + (config.vertexShaderVersion == 11 ? selected : empty) + ">1.1</option>\n";
-		html += "<option value='20'" + (config.vertexShaderVersion == 20 ? selected : empty) + ">2.0</option>\n";
-		html += "<option value='21'" + (config.vertexShaderVersion == 21 ? selected : empty) + ">2.x</option>\n";
-		html += "<option value='30'" + (config.vertexShaderVersion == 30 ? selected : empty) + ">3.0 (default)</option>\n";
-		html += "</select></td></tr>\n";
-		html += "<tr><td>Texture memory:</td><td><select name='textureMemory' title='The maximum amount of memory used for textures and other resources.'>\n";
-		html += "<option value='128'"  + (config.textureMemory == 128  ? selected : empty) + ">128 MB</option>\n";
-		html += "<option value='256'"  + (config.textureMemory == 256  ? selected : empty) + ">256 MB (default)</option>\n";
-		html += "<option value='512'"  + (config.textureMemory == 512  ? selected : empty) + ">512 MB</option>\n";
-		html += "<option value='1024'" + (config.textureMemory == 1024 ? selected : empty) + ">1024 MB</option>\n";
-		html += "<option value='2048'" + (config.textureMemory == 2048 ? selected : empty) + ">2048 MB</option>\n";
-		html += "</select></td></tr>\n";
-		html += "<tr><td>Device identifier:</td><td><select name='identifier' title='The information used by some applications to determine device capabilities.'>\n";
-		html += "<option value='0'" + (config.identifier == 0 ? selected : empty) + ">Google SwiftShader (default)</option>\n";
-		html += "<option value='1'" + (config.identifier == 1 ? selected : empty) + ">NVIDIA GeForce 7900 GS</option>\n";
-		html += "<option value='2'" + (config.identifier == 2 ? selected : empty) + ">ATI Mobility Radeon X1600</option>\n";
-		html += "<option value='3'" + (config.identifier == 3 ? selected : empty) + ">Intel GMA X3100</option>\n";
-		html += "<option value='4'" + (config.identifier == 4 ? selected : empty) + ">System device</option>\n";
-		html += "</select></td></tr>\n";
-		html += "</table>\n";
-		html += "<h2><em>Cache sizes</em></h2>\n";
-		html += "<table>\n";
-		html += "<tr><td>Vertex routine cache size:</td><td><select name='vertexRoutineCacheSize' title='The number of dynamically generated vertex processing routines being cached for reuse. Lower numbers save memory but require more routines to be regenerated.'>\n";
-		html += "<option value='64'"   + (config.vertexRoutineCacheSize == 64   ? selected : empty) + ">64</option>\n";
-		html += "<option value='128'"  + (config.vertexRoutineCacheSize == 128  ? selected : empty) + ">128</option>\n";
-		html += "<option value='256'"  + (config.vertexRoutineCacheSize == 256  ? selected : empty) + ">256</option>\n";
-		html += "<option value='512'"  + (config.vertexRoutineCacheSize == 512  ? selected : empty) + ">512</option>\n";
-		html += "<option value='1024'" + (config.vertexRoutineCacheSize == 1024 ? selected : empty) + ">1024 (default)</option>\n";
-		html += "<option value='2048'" + (config.vertexRoutineCacheSize == 2048 ? selected : empty) + ">2048</option>\n";
-		html += "<option value='4096'" + (config.vertexRoutineCacheSize == 4096 ? selected : empty) + ">4096</option>\n";
-		html += "</select></td>\n";
-		html += "</tr>\n";
-		html += "<tr><td>Pixel routine cache size:</td><td><select name='pixelRoutineCacheSize' title='The number of dynamically generated pixel processing routines being cached for reuse. Lower numbers save memory but require more routines to be regenerated.'>\n";
-		html += "<option value='64'"   + (config.pixelRoutineCacheSize == 64   ? selected : empty) + ">64</option>\n";
-		html += "<option value='128'"  + (config.pixelRoutineCacheSize == 128  ? selected : empty) + ">128</option>\n";
-		html += "<option value='256'"  + (config.pixelRoutineCacheSize == 256  ? selected : empty) + ">256</option>\n";
-		html += "<option value='512'"  + (config.pixelRoutineCacheSize == 512  ? selected : empty) + ">512</option>\n";
-		html += "<option value='1024'" + (config.pixelRoutineCacheSize == 1024 ? selected : empty) + ">1024 (default)</option>\n";
-		html += "<option value='2048'" + (config.pixelRoutineCacheSize == 2048 ? selected : empty) + ">2048</option>\n";
-		html += "<option value='4096'" + (config.pixelRoutineCacheSize == 4096 ? selected : empty) + ">4096</option>\n";
-		html += "</select></td>\n";
-		html += "</tr>\n";
-		html += "<tr><td>Setup routine cache size:</td><td><select name='setupRoutineCacheSize' title='The number of dynamically generated primitive setup routines being cached for reuse. Lower numbers save memory but require more routines to be regenerated.'>\n";
-		html += "<option value='64'"   + (config.setupRoutineCacheSize == 64   ? selected : empty) + ">64</option>\n";
-		html += "<option value='128'"  + (config.setupRoutineCacheSize == 128  ? selected : empty) + ">128</option>\n";
-		html += "<option value='256'"  + (config.setupRoutineCacheSize == 256  ? selected : empty) + ">256</option>\n";
-		html += "<option value='512'"  + (config.setupRoutineCacheSize == 512  ? selected : empty) + ">512</option>\n";
-		html += "<option value='1024'" + (config.setupRoutineCacheSize == 1024 ? selected : empty) + ">1024 (default)</option>\n";
-		html += "<option value='2048'" + (config.setupRoutineCacheSize == 2048 ? selected : empty) + ">2048</option>\n";
-		html += "<option value='4096'" + (config.setupRoutineCacheSize == 4096 ? selected : empty) + ">4096</option>\n";
-		html += "</select></td>\n";
-		html += "</tr>\n";
-		html += "<tr><td>Vertex cache size:</td><td><select name='vertexCacheSize' title='The number of processed vertices being cached for reuse. Lower numbers save memory but require more vertices to be reprocessed.'>\n";
-		html += "<option value='64'"   + (config.vertexCacheSize == 64   ? selected : empty) + ">64 (default)</option>\n";
-		html += "</select></td>\n";
-		html += "</tr>\n";
-		html += "</table>\n";
-		html += "<h2><em>Quality</em></h2>\n";
-		html += "<table>\n";
-		html += "<tr><td>Maximum texture sampling quality:</td><td><select name='textureSampleQuality' title='The maximum texture filtering quality. Lower settings can be faster but cause visual artifacts.'>\n";
-		html += "<option value='0'" + (config.textureSampleQuality == 0 ? selected : empty) + ">Point</option>\n";
-		html += "<option value='1'" + (config.textureSampleQuality == 1 ? selected : empty) + ">Linear</option>\n";
-		html += "<option value='2'" + (config.textureSampleQuality == 2 ? selected : empty) + ">Anisotropic (default)</option>\n";
-		html += "</select></td>\n";
-		html += "</tr>\n";
-		html += "<tr><td>Maximum mipmapping quality:</td><td><select name='mipmapQuality' title='The maximum mipmap filtering quality. Higher settings can be more visually appealing but are slower.'>\n";
-		html += "<option value='0'" + (config.mipmapQuality == 0 ? selected : empty) + ">Point</option>\n";
-		html += "<option value='1'" + (config.mipmapQuality == 1 ? selected : empty) + ">Linear (default)</option>\n";
-		html += "</select></td>\n";
-		html += "</tr>\n";
-		html += "<tr><td>Transcendental function precision:</td><td><select name='transcendentalPrecision' title='The precision at which log/exp/pow/rcp/rsq/nrm shader instructions are computed. Lower settings can be faster but cause visual artifacts.'>\n";
-		html += "<option value='0'" + (config.transcendentalPrecision == 0 ? selected : empty) + ">Approximate</option>\n";
-		html += "<option value='1'" + (config.transcendentalPrecision == 1 ? selected : empty) + ">Partial</option>\n";
-		html += "<option value='2'" + (config.transcendentalPrecision == 2 ? selected : empty) + ">Accurate (default)</option>\n";
-		html += "<option value='3'" + (config.transcendentalPrecision == 3 ? selected : empty) + ">WHQL</option>\n";
-		html += "<option value='4'" + (config.transcendentalPrecision == 4 ? selected : empty) + ">IEEE</option>\n";
-		html += "</select></td>\n";
-		html += "</tr>\n";
-		html += "<tr><td>Transparency anti-aliasing:</td><td><select name='transparencyAntialiasing' title='The technique used to anti-alias alpha-tested transparent textures.'>\n";
-		html += "<option value='0'" + (config.transparencyAntialiasing == 0 ? selected : empty) + ">None (default)</option>\n";
-		html += "<option value='1'" + (config.transparencyAntialiasing == 1 ? selected : empty) + ">Alpha-to-Coverage</option>\n";
-		html += "</select></td>\n";
-		html += "</table>\n";
-		html += "<h2><em>Processor settings</em></h2>\n";
-		html += "<table>\n";
-		html += "<tr><td>Number of threads:</td><td><select name='threadCount' title='The number of rendering threads to be used.'>\n";
-		html += "<option value='-1'" + (config.threadCount == -1 ? selected : empty) + ">Core count</option>\n";
-		html += "<option value='0'"  + (config.threadCount == 0  ? selected : empty) + ">Process affinity (default)</option>\n";
-		html += "<option value='1'"  + (config.threadCount == 1  ? selected : empty) + ">1</option>\n";
-		html += "<option value='2'"  + (config.threadCount == 2  ? selected : empty) + ">2</option>\n";
-		html += "<option value='3'"  + (config.threadCount == 3  ? selected : empty) + ">3</option>\n";
-		html += "<option value='4'"  + (config.threadCount == 4  ? selected : empty) + ">4</option>\n";
-		html += "<option value='5'"  + (config.threadCount == 5  ? selected : empty) + ">5</option>\n";
-		html += "<option value='6'"  + (config.threadCount == 6  ? selected : empty) + ">6</option>\n";
-		html += "<option value='7'"  + (config.threadCount == 7  ? selected : empty) + ">7</option>\n";
-		html += "<option value='8'"  + (config.threadCount == 8  ? selected : empty) + ">8</option>\n";
-		html += "<option value='9'"  + (config.threadCount == 9  ? selected : empty) + ">9</option>\n";
-		html += "<option value='10'" + (config.threadCount == 10 ? selected : empty) + ">10</option>\n";
-		html += "<option value='11'" + (config.threadCount == 11 ? selected : empty) + ">11</option>\n";
-		html += "<option value='12'" + (config.threadCount == 12 ? selected : empty) + ">12</option>\n";
-		html += "<option value='13'" + (config.threadCount == 13 ? selected : empty) + ">13</option>\n";
-		html += "<option value='14'" + (config.threadCount == 14 ? selected : empty) + ">14</option>\n";
-		html += "<option value='15'" + (config.threadCount == 15 ? selected : empty) + ">15</option>\n";
-		html += "<option value='16'" + (config.threadCount == 16 ? selected : empty) + ">16</option>\n";
-		html += "</select></td></tr>\n";
-		html += "<tr><td>Enable SSE:</td><td><input name = 'enableSSE' type='checkbox'" + (config.enableSSE ? checked : empty) + " disabled='disabled' title='If checked enables the use of SSE instruction set extentions if supported by the CPU.'></td></tr>";
-		html += "<tr><td>Enable SSE2:</td><td><input name = 'enableSSE2' type='checkbox'" + (config.enableSSE2 ? checked : empty) + " title='If checked enables the use of SSE2 instruction set extentions if supported by the CPU.'></td></tr>";
-		html += "<tr><td>Enable SSE3:</td><td><input name = 'enableSSE3' type='checkbox'" + (config.enableSSE3 ? checked : empty) + " title='If checked enables the use of SSE3 instruction set extentions if supported by the CPU.'></td></tr>";
-		html += "<tr><td>Enable SSSE3:</td><td><input name = 'enableSSSE3' type='checkbox'" + (config.enableSSSE3 ? checked : empty) + " title='If checked enables the use of SSSE3 instruction set extentions if supported by the CPU.'></td></tr>";
-		html += "<tr><td>Enable SSE4.1:</td><td><input name = 'enableSSE4_1' type='checkbox'" + (config.enableSSE4_1 ? checked : empty) + " title='If checked enables the use of SSE4.1 instruction set extentions if supported by the CPU.'></td></tr>";
-		html += "</table>\n";
-		html += "<h2><em>Compiler optimizations</em></h2>\n";
-		html += "<table>\n";
-
-		for(int pass = 0; pass < 10; pass++)
-		{
-			html += "<tr><td>Optimization pass " + itoa(pass + 1) + ":</td><td><select name='optimization" + itoa(pass + 1) + "' title='An optimization pass for the shader compiler.'>\n";
-			html += "<option value='0'"  + (config.optimization[pass] == 0  ? selected : empty) + ">Disabled" + (pass > 0 ? " (default)" : "") + "</option>\n";
-			html += "<option value='1'"  + (config.optimization[pass] == 1  ? selected : empty) + ">Instruction Combining" + (pass == 0 ? " (default)" : "") + "</option>\n";
-			html += "<option value='2'"  + (config.optimization[pass] == 2  ? selected : empty) + ">Control Flow Simplification</option>\n";
-			html += "<option value='3'"  + (config.optimization[pass] == 3  ? selected : empty) + ">Loop Invariant Code Motion</option>\n";
-			html += "<option value='4'"  + (config.optimization[pass] == 4  ? selected : empty) + ">Aggressive Dead Code Elimination</option>\n";
-			html += "<option value='5'"  + (config.optimization[pass] == 5  ? selected : empty) + ">Global Value Numbering</option>\n";
-			html += "<option value='6'"  + (config.optimization[pass] == 6  ? selected : empty) + ">Commutative Expressions Reassociation</option>\n";
-			html += "<option value='7'"  + (config.optimization[pass] == 7  ? selected : empty) + ">Dead Store Elimination</option>\n";
-			html += "<option value='8'"  + (config.optimization[pass] == 8  ? selected : empty) + ">Sparse Conditional Copy Propagation</option>\n";
-			html += "<option value='9'"  + (config.optimization[pass] == 9  ? selected : empty) + ">Scalar Replacement of Aggregates</option>\n";
-			html += "</select></td></tr>\n";
-		}
-
-		html += "</table>\n";
-		html += "<h2><em>Testing & Experimental</em></h2>\n";
-		html += "<table>\n";
-		html += "<tr><td>Disable SwiftConfig server:</td><td><input name = 'disableServer' type='checkbox'" + (config.disableServer == true ? checked : empty) + " title='If checked disables the web browser based control panel.'></td></tr>";
-		html += "<tr><td>Force windowed mode:</td><td><input name = 'forceWindowed' type='checkbox'" + (config.forceWindowed == true ? checked : empty) + " title='If checked prevents the application from switching to full-screen mode.'></td></tr>";
-		html += "<tr><td>Post alpha blend sRGB conversion:</td><td><input name = 'postBlendSRGB' type='checkbox'" + (config.postBlendSRGB == true ? checked : empty) + " title='If checked alpha blending is performed in linear color space.'></td></tr>";
-		html += "<tr><td>Exact color rounding:</td><td><input name = 'exactColorRounding' type='checkbox'" + (config.exactColorRounding == true ? checked : empty) + " title='If checked color rounding is done at high accuracy.'></td></tr>";
-		html += "<tr><td>Disable alpha display formats:</td><td><input name = 'disableAlphaMode' type='checkbox'" + (config.disableAlphaMode == true ? checked : empty) + " title='If checked the device does not advertise the A8R8G8B8 display mode.'></td></tr>";
-		html += "<tr><td>Disable 10-bit display formats:</td><td><input name = 'disable10BitMode' type='checkbox'" + (config.disable10BitMode == true ? checked : empty) + " title='If checked the device does not advertise the A2R10G10B10 display mode.'></td></tr>";
-		html += "<tr><td>Frame-buffer API:</td><td><select name='frameBufferAPI' title='The API used for displaying the rendered result on screen (requires restart).'>\n";
-		html += "<option value='0'" + (config.frameBufferAPI == 0 ? selected : empty) + ">DirectDraw (default)</option>\n";
-		html += "<option value='1'" + (config.frameBufferAPI == 1 ? selected : empty) + ">GDI</option>\n";
-		html += "</select></td>\n";
-		html += "<tr><td>DLL precaching:</td><td><input name = 'precache' type='checkbox'" + (config.precache == true ? checked : empty) + " title='If checked dynamically generated routines will be stored in a DLL for faster loading on application restart.'></td></tr>";
-		html += "<tr><td>Shadow mapping extensions:</td><td><select name='shadowMapping' title='Features that may accelerate or improve the quality of shadow mapping.'>\n";
-		html += "<option value='0'" + (config.shadowMapping == 0 ? selected : empty) + ">None</option>\n";
-		html += "<option value='1'" + (config.shadowMapping == 1 ? selected : empty) + ">Fetch4</option>\n";
-		html += "<option value='2'" + (config.shadowMapping == 2 ? selected : empty) + ">DST</option>\n";
-		html += "<option value='3'" + (config.shadowMapping == 3 ? selected : empty) + ">Fetch4 & DST (default)</option>\n";
-		html += "</select></td>\n";
-		html += "<tr><td>Force clearing registers that have no default value:</td><td><input name = 'forceClearRegisters' type='checkbox'" + (config.forceClearRegisters == true ? checked : empty) + " title='Initializes shader register values to 0 even if they have no default.'></td></tr>";
-		html += "</table>\n";
-	#ifndef NDEBUG
-		html += "<h2><em>Debugging</em></h2>\n";
-		html += "<table>\n";
-		html += "<tr><td>Minimum primitives:</td><td><input type='text' size='10' maxlength='10' name='minPrimitives' value='" + itoa(config.minPrimitives) + "'></td></tr>\n";
-		html += "<tr><td>Maximum primitives:</td><td><input type='text' size='10' maxlength='10' name='maxPrimitives' value='" + itoa(config.maxPrimitives) + "'></td></tr>\n";
-		html += "</table>\n";
-	#endif
-		html += "<hr><p>\n";
-		html += "<span style='font-size:10pt'>Hover the mouse pointer over a control to get additional information.</span><br>\n";
-		html += "<span style='font-size:10pt'>Some settings can be applied interactively, some need a restart of the application.</span><br>\n";
-		html += "<span style='font-size:10pt'>Removing the SwiftShader.ini file results in resetting the options to their default.</span></p>\n";
-		html += "</form>\n";
-		html += "</body>\n";
-		html += "</html>\n";
-
-		profiler.reset();
-
-		return html;
-	}
-
-	std::string SwiftConfig::profile()
-	{
-		std::string html;
-
-		html += "<p>FPS: " + ftoa(profiler.FPS) + "</p>\n";
-		html += "<p>Frame: " + itoa(profiler.framesTotal) + "</p>\n";
-
-		#if PERF_PROFILE
-			int texTime = (int)(1000 * profiler.cycles[PERF_TEX] / profiler.cycles[PERF_PIXEL] + 0.5);
-			int shaderTime = (int)(1000 * profiler.cycles[PERF_SHADER] / profiler.cycles[PERF_PIXEL] + 0.5);
-			int pipeTime = (int)(1000 * profiler.cycles[PERF_PIPE] / profiler.cycles[PERF_PIXEL] + 0.5);
-			int ropTime = (int)(1000 * profiler.cycles[PERF_ROP] / profiler.cycles[PERF_PIXEL] + 0.5);
-			int interpTime = (int)(1000 * profiler.cycles[PERF_INTERP] / profiler.cycles[PERF_PIXEL] + 0.5);
-			int rastTime = 1000 - pipeTime;
-
-			pipeTime -= shaderTime + ropTime + interpTime;
-			shaderTime -= texTime;
-
-			double texTimeF = (double)texTime / 10;
-			double shaderTimeF = (double)shaderTime / 10;
-			double pipeTimeF = (double)pipeTime / 10;
-			double ropTimeF = (double)ropTime / 10;
-			double interpTimeF = (double)interpTime / 10;
-			double rastTimeF = (double)rastTime / 10;
-
-			double averageRopOperations = profiler.ropOperationsTotal / std::max(profiler.framesTotal, 1) / 1.0e6f;
-			double averageCompressedTex = profiler.compressedTexTotal / std::max(profiler.framesTotal, 1) / 1.0e6f;
-			double averageTexOperations = profiler.texOperationsTotal / std::max(profiler.framesTotal, 1) / 1.0e6f;
-
-			html += "<p>Raster operations (million): " + ftoa(profiler.ropOperationsFrame / 1.0e6f) + " (current), " + ftoa(averageRopOperations) + " (average)</p>\n";
-			html += "<p>Texture operations (million): " + ftoa(profiler.texOperationsFrame / 1.0e6f) + " (current), " + ftoa(averageTexOperations) + " (average)</p>\n";
-			html += "<p>Compressed texture operations (million): " + ftoa(profiler.compressedTexFrame / 1.0e6f) + " (current), " + ftoa(averageCompressedTex) + " (average)</p>\n";
-			html += "<div id='profile' style='position:relative; width:1010px; height:50px; background-color:silver;'>";
-			html += "<div style='position:relative; width:1000px; height:40px; background-color:white; left:5px; top:5px;'>";
-			html += "<div style='position:relative; float:left; width:" + itoa(rastTime)   + "px; height:40px; border-style:none; text-align:center; line-height:40px; background-color:#FFFF7F; overflow:hidden;'>" + ftoa(rastTimeF)   + "% rast</div>\n";
-			html += "<div style='position:relative; float:left; width:" + itoa(pipeTime)   + "px; height:40px; border-style:none; text-align:center; line-height:40px; background-color:#FF7F7F; overflow:hidden;'>" + ftoa(pipeTimeF)   + "% pipe</div>\n";
-			html += "<div style='position:relative; float:left; width:" + itoa(interpTime) + "px; height:40px; border-style:none; text-align:center; line-height:40px; background-color:#7FFFFF; overflow:hidden;'>" + ftoa(interpTimeF) + "% interp</div>\n";
-			html += "<div style='position:relative; float:left; width:" + itoa(shaderTime) + "px; height:40px; border-style:none; text-align:center; line-height:40px; background-color:#7FFF7F; overflow:hidden;'>" + ftoa(shaderTimeF) + "% shader</div>\n";
-			html += "<div style='position:relative; float:left; width:" + itoa(texTime)    + "px; height:40px; border-style:none; text-align:center; line-height:40px; background-color:#FF7FFF; overflow:hidden;'>" + ftoa(texTimeF)    + "% tex</div>\n";
-			html += "<div style='position:relative; float:left; width:" + itoa(ropTime)    + "px; height:40px; border-style:none; text-align:center; line-height:40px; background-color:#7F7FFF; overflow:hidden;'>" + ftoa(ropTimeF)    + "% rop</div>\n";
-			html += "</div></div>\n";
-
-			for(int i = 0; i < PERF_TIMERS; i++)
-			{
-				profiler.cycles[i] = 0;
-			}
-		#endif
-
-		return html;
-	}
-
-	void SwiftConfig::send(Socket *clientSocket, Status code, std::string body)
-	{
-		std::string status;
-		char header[1024];
-
-		switch(code)
-		{
-		case OK:       status += "HTTP/1.1 200 OK\r\n";        break;
-		case NotFound: status += "HTTP/1.1 404 Not Found\r\n"; break;
-		}
-
-		sprintf(header, "Content-Type: text/html; charset=UTF-8\r\n"
-						"Content-Length: %zd\r\n"
-						"Host: localhost\r\n"
-						"\r\n", body.size());
-
-		std::string message = status + header + body;
-		clientSocket->send(message.c_str(), (int)message.length());
-	}
-
-	void SwiftConfig::parsePost(const char *post)
-	{
-		// Only enabled checkboxes appear in the POST
-		config.enableSSE = true;
-		config.enableSSE2 = false;
-		config.enableSSE3 = false;
-		config.enableSSSE3 = false;
-		config.enableSSE4_1 = false;
-		config.disableServer = false;
-		config.forceWindowed = false;
-		config.postBlendSRGB = false;
-		config.exactColorRounding = false;
-		config.disableAlphaMode = false;
-		config.disable10BitMode = false;
-		config.precache = false;
-		config.forceClearRegisters = false;
-
-		while(*post != 0)
-		{
-			int integer;
-			int index;
-
-			if(sscanf(post, "pixelShaderVersion=%d", &integer))
-			{
-				config.pixelShaderVersion = integer;
-			}
-			else if(sscanf(post, "vertexShaderVersion=%d", &integer))
-			{
-				config.vertexShaderVersion = integer;
-			}
-			else if(sscanf(post, "textureMemory=%d", &integer))
-			{
-				config.textureMemory = integer;
-			}
-			else if(sscanf(post, "identifier=%d", &integer))
-			{
-				config.identifier = integer;
-			}
-			else if(sscanf(post, "vertexRoutineCacheSize=%d", &integer))
-			{
-				config.vertexRoutineCacheSize = integer;
-			}
-			else if(sscanf(post, "pixelRoutineCacheSize=%d", &integer))
-			{
-				config.pixelRoutineCacheSize = integer;
-			}
-			else if(sscanf(post, "setupRoutineCacheSize=%d", &integer))
-			{
-				config.setupRoutineCacheSize = integer;
-			}
-			else if(sscanf(post, "vertexCacheSize=%d", &integer))
-			{
-				config.vertexCacheSize = integer;
-			}
-			else if(sscanf(post, "textureSampleQuality=%d", &integer))
-			{
-				config.textureSampleQuality = integer;
-			}
-			else if(sscanf(post, "mipmapQuality=%d", &integer))
-			{
-				config.mipmapQuality = integer;
-			}
-			else if(sscanf(post, "transcendentalPrecision=%d", &integer))
-			{
-				config.transcendentalPrecision = integer;
-			}
-			else if(sscanf(post, "transparencyAntialiasing=%d", &integer))
-			{
-				config.transparencyAntialiasing = integer;
-			}
-			else if(sscanf(post, "threadCount=%d", &integer))
-			{
-				config.threadCount = integer;
-			}
-			else if(sscanf(post, "frameBufferAPI=%d", &integer))
-			{
-				config.frameBufferAPI = integer;
-			}
-			else if(sscanf(post, "shadowMapping=%d", &integer))
-			{
-				config.shadowMapping = integer;
-			}
-			else if(strstr(post, "enableSSE=on"))
-			{
-				config.enableSSE = true;
-			}
-			else if(strstr(post, "enableSSE2=on"))
-			{
-				if(config.enableSSE)
-				{
-					config.enableSSE2 = true;
-				}
-			}
-			else if(strstr(post, "enableSSE3=on"))
-			{
-				if(config.enableSSE2)
-				{
-					config.enableSSE3 = true;
-				}
-			}
-			else if(strstr(post, "enableSSSE3=on"))
-			{
-				if(config.enableSSE3)
-				{
-					config.enableSSSE3 = true;
-				}
-			}
-			else if(strstr(post, "enableSSE4_1=on"))
-			{
-				if(config.enableSSSE3)
-				{
-					config.enableSSE4_1 = true;
-				}
-			}
-			else if(sscanf(post, "optimization%d=%d", &index, &integer))
-			{
-				config.optimization[index - 1] = (rr::Optimization)integer;
-			}
-			else if(strstr(post, "disableServer=on"))
-			{
-				config.disableServer = true;
-			}
-			else if(strstr(post, "forceWindowed=on"))
-			{
-				config.forceWindowed = true;
-			}
-			else if(strstr(post, "postBlendSRGB=on"))
-			{
-				config.postBlendSRGB = true;
-			}
-			else if(strstr(post, "exactColorRounding=on"))
-			{
-				config.exactColorRounding = true;
-			}
-			else if(strstr(post, "disableAlphaMode=on"))
-			{
-				config.disableAlphaMode = true;
-			}
-			else if(strstr(post, "disable10BitMode=on"))
-			{
-				config.disable10BitMode = true;
-			}
-			else if(strstr(post, "precache=on"))
-			{
-				config.precache = true;
-			}
-			else if(strstr(post, "forceClearRegisters=on"))
-			{
-				config.forceClearRegisters = true;
-			}
-		#ifndef NDEBUG
-			else if(sscanf(post, "minPrimitives=%d", &integer))
-			{
-				config.minPrimitives = integer;
-			}
-			else if(sscanf(post, "maxPrimitives=%d", &integer))
-			{
-				config.maxPrimitives = integer;
-			}
-		#endif
-			else
-			{
-				ASSERT(false);
-			}
-
-			do
-			{
-				post++;
-			}
-			while(post[-1] != '&' && *post != 0);
-		}
-	}
-
-	void SwiftConfig::readConfiguration(bool disableServerOverride)
-	{
-		Configurator ini("SwiftShader.ini");
-
-		config.pixelShaderVersion = ini.getInteger("Capabilities", "PixelShaderVersion", 30);
-		config.vertexShaderVersion = ini.getInteger("Capabilities", "VertexShaderVersion", 30);
-		config.textureMemory = ini.getInteger("Capabilities", "TextureMemory", 256);
-		config.identifier = ini.getInteger("Capabilities", "Identifier", 0);
-		config.vertexRoutineCacheSize = ini.getInteger("Caches", "VertexRoutineCacheSize", 1024);
-		config.pixelRoutineCacheSize = ini.getInteger("Caches", "PixelRoutineCacheSize", 1024);
-		config.setupRoutineCacheSize = ini.getInteger("Caches", "SetupRoutineCacheSize", 1024);
-		config.vertexCacheSize = ini.getInteger("Caches", "VertexCacheSize", 64);
-		config.textureSampleQuality = ini.getInteger("Quality", "TextureSampleQuality", 2);
-		config.mipmapQuality = ini.getInteger("Quality", "MipmapQuality", 1);
-		config.transcendentalPrecision = ini.getInteger("Quality", "TranscendentalPrecision", 2);
-		config.transparencyAntialiasing = ini.getInteger("Quality", "TransparencyAntialiasing", 0);
-		config.threadCount = ini.getInteger("Processor", "ThreadCount", DEFAULT_THREAD_COUNT);
-		config.enableSSE = ini.getBoolean("Processor", "EnableSSE", true);
-		config.enableSSE2 = ini.getBoolean("Processor", "EnableSSE2", true);
-		config.enableSSE3 = ini.getBoolean("Processor", "EnableSSE3", true);
-		config.enableSSSE3 = ini.getBoolean("Processor", "EnableSSSE3", true);
-		config.enableSSE4_1 = ini.getBoolean("Processor", "EnableSSE4_1", true);
-
-		for(int pass = 0; pass < 10; pass++)
-		{
-			config.optimization[pass] = (rr::Optimization)ini.getInteger("Optimization", "OptimizationPass" + itoa(pass + 1), pass == 0 ? rr::InstructionCombining : rr::Disabled);
-		}
-
-		config.disableServer = ini.getBoolean("Testing", "DisableServer", false);
-		config.forceWindowed = ini.getBoolean("Testing", "ForceWindowed", false);
-		config.postBlendSRGB = ini.getBoolean("Testing", "PostBlendSRGB", false);
-		config.exactColorRounding = ini.getBoolean("Testing", "ExactColorRounding", true);
-		config.disableAlphaMode = ini.getBoolean("Testing", "DisableAlphaMode", false);
-		config.disable10BitMode = ini.getBoolean("Testing", "Disable10BitMode", false);
-		config.frameBufferAPI = ini.getInteger("Testing", "FrameBufferAPI", 0);
-		config.precache = ini.getBoolean("Testing", "Precache", false);
-		config.shadowMapping = ini.getInteger("Testing", "ShadowMapping", 3);
-		config.forceClearRegisters = ini.getBoolean("Testing", "ForceClearRegisters", false);
-
-	#ifndef NDEBUG
-		config.minPrimitives = 1;
-		config.maxPrimitives = 1 << 21;
-	#endif
-
-		struct stat status;
-		int lastModified = ini.getInteger("LastModified", "Time", 0);
-
-		bool noConfig = stat("SwiftShader.ini", &status) != 0;
-		newConfig = !noConfig && abs((int)status.st_mtime - lastModified) > 1;
-
-		if(disableServerOverride)
-		{
-			config.disableServer = true;
-		}
-	}
-
-	void SwiftConfig::writeConfiguration()
-	{
-		Configurator ini("SwiftShader.ini");
-
-		ini.addValue("Capabilities", "PixelShaderVersion", itoa(config.pixelShaderVersion));
-		ini.addValue("Capabilities", "VertexShaderVersion", itoa(config.vertexShaderVersion));
-		ini.addValue("Capabilities", "TextureMemory", itoa(config.textureMemory));
-		ini.addValue("Capabilities", "Identifier", itoa(config.identifier));
-		ini.addValue("Caches", "VertexRoutineCacheSize", itoa(config.vertexRoutineCacheSize));
-		ini.addValue("Caches", "PixelRoutineCacheSize", itoa(config.pixelRoutineCacheSize));
-		ini.addValue("Caches", "SetupRoutineCacheSize", itoa(config.setupRoutineCacheSize));
-		ini.addValue("Caches", "VertexCacheSize", itoa(config.vertexCacheSize));
-		ini.addValue("Quality", "TextureSampleQuality", itoa(config.textureSampleQuality));
-		ini.addValue("Quality", "MipmapQuality", itoa(config.mipmapQuality));
-		ini.addValue("Quality", "TranscendentalPrecision", itoa(config.transcendentalPrecision));
-		ini.addValue("Quality", "TransparencyAntialiasing", itoa(config.transparencyAntialiasing));
-		ini.addValue("Processor", "ThreadCount", itoa(config.threadCount));
-	//	ini.addValue("Processor", "EnableSSE", itoa(config.enableSSE));
-		ini.addValue("Processor", "EnableSSE2", itoa(config.enableSSE2));
-		ini.addValue("Processor", "EnableSSE3", itoa(config.enableSSE3));
-		ini.addValue("Processor", "EnableSSSE3", itoa(config.enableSSSE3));
-		ini.addValue("Processor", "EnableSSE4_1", itoa(config.enableSSE4_1));
-
-		for(int pass = 0; pass < 10; pass++)
-		{
-			ini.addValue("Optimization", "OptimizationPass" + itoa(pass + 1), itoa(config.optimization[pass]));
-		}
-
-		ini.addValue("Testing", "DisableServer", itoa(config.disableServer));
-		ini.addValue("Testing", "ForceWindowed", itoa(config.forceWindowed));
-		ini.addValue("Testing", "PostBlendSRGB", itoa(config.postBlendSRGB));
-		ini.addValue("Testing", "ExactColorRounding", itoa(config.exactColorRounding));
-		ini.addValue("Testing", "DisableAlphaMode", itoa(config.disableAlphaMode));
-		ini.addValue("Testing", "Disable10BitMode", itoa(config.disable10BitMode));
-		ini.addValue("Testing", "FrameBufferAPI", itoa(config.frameBufferAPI));
-		ini.addValue("Testing", "Precache", itoa(config.precache));
-		ini.addValue("Testing", "ShadowMapping", itoa(config.shadowMapping));
-		ini.addValue("Testing", "ForceClearRegisters", itoa(config.forceClearRegisters));
-		ini.addValue("LastModified", "Time", itoa((int)time(0)));
-
-		ini.writeFile("SwiftShader Configuration File\n"
-		              ";\n"
-					  "; To get an overview of the valid settings and their meaning,\n"
-					  "; run the application in windowed mode and open the\n"
-					  "; SwiftConfig application or go to http://localhost:8080/swiftconfig.");
-	}
-}
diff --git a/src/Device/SwiftConfig.hpp b/src/Device/SwiftConfig.hpp
deleted file mode 100644
index b470db5..0000000
--- a/src/Device/SwiftConfig.hpp
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//    http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef sw_SwiftConfig_hpp
-#define sw_SwiftConfig_hpp
-
-#include "Reactor/Nucleus.hpp"
-
-#include "System/Socket.hpp"
-
-#include <mutex>
-#include <string>
-#include <thread>
-
-#ifdef Status
-#undef Status // b/127920555
-#endif
-
-namespace sw
-{
-	class SwiftConfig
-	{
-	public:
-		struct Configuration
-		{
-			int pixelShaderVersion;
-			int vertexShaderVersion;
-			int textureMemory;
-			int identifier;
-			int vertexRoutineCacheSize;
-			int pixelRoutineCacheSize;
-			int setupRoutineCacheSize;
-			int vertexCacheSize;
-			int textureSampleQuality;
-			int mipmapQuality;
-			int transcendentalPrecision;
-			int threadCount;
-			bool enableSSE;
-			bool enableSSE2;
-			bool enableSSE3;
-			bool enableSSSE3;
-			bool enableSSE4_1;
-			rr::Optimization optimization[10];
-			bool disableServer;
-			bool keepSystemCursor;
-			bool forceWindowed;
-			bool postBlendSRGB;
-			bool exactColorRounding;
-			bool disableAlphaMode;
-			bool disable10BitMode;
-			int transparencyAntialiasing;
-			int frameBufferAPI;
-			bool precache;
-			int shadowMapping;
-			bool forceClearRegisters;
-		#ifndef NDEBUG
-			unsigned int minPrimitives;
-			unsigned int maxPrimitives;
-		#endif
-		};
-
-		SwiftConfig(bool disableServerOverride);
-
-		~SwiftConfig();
-
-		bool hasNewConfiguration(bool reset = true);
-		void getConfiguration(Configuration &configuration);
-
-	private:
-		enum Status
-		{
-			OK = 200,
-			NotFound = 404
-		};
-
-		void createServer();
-		void destroyServer();
-
-		static void serverRoutine(void *parameters);
-
-		void serverLoop();
-		void respond(Socket *clientSocket, const char *request);
-		std::string page();
-		std::string profile();
-		void send(Socket *clientSocket, Status code, std::string body = "");
-		void parsePost(const char *post);
-
-		void readConfiguration(bool disableServerOverride = false);
-		void writeConfiguration();
-
-		Configuration config;
-
-		std::thread *serverThread;
-		volatile bool terminate;
-		std::mutex criticalSection;   // Protects reading and writing the configuration settings
-
-		bool newConfig;
-
-		Socket *listenSocket;
-
-		int bufferLength;
-		char *receiveBuffer;
-	};
-}
-
-#endif   // sw_SwiftConfig_hpp
diff --git a/src/Device/VertexProcessor.cpp b/src/Device/VertexProcessor.cpp
index 864a640..82c4547 100644
--- a/src/Device/VertexProcessor.cpp
+++ b/src/Device/VertexProcessor.cpp
@@ -23,8 +23,6 @@
 
 namespace sw
 {
-	bool precacheVertex = false;
-
 	void VertexCache::clear()
 	{
 		for(int i = 0; i < 16; i++)
diff --git a/src/Pipeline/PixelProgram.cpp b/src/Pipeline/PixelProgram.cpp
index 38f7222..f245ea8 100644
--- a/src/Pipeline/PixelProgram.cpp
+++ b/src/Pipeline/PixelProgram.cpp
@@ -20,8 +20,6 @@
 
 namespace sw
 {
-	extern bool postBlendSRGB;
-
 	void PixelProgram::setBuiltins(Int &x, Int &y, Float4(&z)[4], Float4 &w)
 	{
 		routine.windowSpacePosition[0] = x + SIMD::Int(0,1,0,1);
diff --git a/src/Pipeline/PixelRoutine.cpp b/src/Pipeline/PixelRoutine.cpp
index cc69777..e510e6a 100644
--- a/src/Pipeline/PixelRoutine.cpp
+++ b/src/Pipeline/PixelRoutine.cpp
@@ -24,10 +24,6 @@
 
 namespace sw
 {
-	extern bool postBlendSRGB;
-	extern bool exactColorRounding;
-	extern bool forceClearRegisters;
-
 	PixelRoutine::PixelRoutine(
 			const PixelProcessor::State &state,
 			vk::PipelineLayout const *pipelineLayout,
@@ -40,12 +36,12 @@
 		if (spirvShader)
 		{
 			spirvShader->emitProlog(&routine);
-			if (forceClearRegisters)
+
+			// Clearing inputs to 0 is not demanded by the spec,
+			// but it makes the undefined behavior deterministic.
+			for(int i = 0; i < MAX_INTERFACE_COMPONENTS; i++)
 			{
-				for (int i = 0; i < MAX_INTERFACE_COMPONENTS; i++)
-				{
-					routine.inputs[i] = Float4(0.0f);
-				}
+				routine.inputs[i] = Float4(0.0f);
 			}
 		}
 	}
@@ -56,10 +52,6 @@
 
 	void PixelRoutine::quad(Pointer<Byte> cBuffer[RENDERTARGETS], Pointer<Byte> &zBuffer, Pointer<Byte> &sBuffer, Int cMask[4], Int &x, Int &y)
 	{
-		#if PERF_PROFILE
-			Long pipeTime = Ticks();
-		#endif
-
 		// TODO: consider shader which modifies sample mask in general
 		const bool earlyDepthTest = !spirvShader || (!spirvShader->getModes().DepthReplacing && !state.alphaToCoverage);
 
@@ -109,10 +101,6 @@
 
 		If(depthPass || Bool(!earlyDepthTest))
 		{
-			#if PERF_PROFILE
-				Long interpTime = Ticks();
-			#endif
-
 			Float4 yyyy = Float4(Float(y)) + *Pointer<Float4>(primitive + OFFSET(Primitive,yQuad), 16);
 
 			// Centroid locations
@@ -176,25 +164,13 @@
 				setBuiltins(x, y, z, w);
 			}
 
-			#if PERF_PROFILE
-				cycles[PERF_INTERP] += Ticks() - interpTime;
-			#endif
-
 			Bool alphaPass = true;
 
-			#if PERF_PROFILE
-				Long shaderTime = Ticks();
-			#endif
-
 			if (spirvShader)
 			{
 				applyShader(cMask);
 			}
 
-			#if PERF_PROFILE
-				cycles[PERF_SHADER] += Ticks() - shaderTime;
-			#endif
-
 			alphaPass = alphaTest(cMask);
 
 			if((spirvShader && spirvShader->getModes().ContainsKill) || state.alphaToCoverage)
@@ -216,10 +192,6 @@
 					}
 				}
 
-				#if PERF_PROFILE
-					Long ropTime = Ticks();
-				#endif
-
 				If(depthPass || Bool(earlyDepthTest))
 				{
 					for(unsigned int q = 0; q < state.multiSample; q++)
@@ -235,16 +207,8 @@
 						}
 					}
 
-					#if PERF_PROFILE
-						AddAtomic(Pointer<Long>(&profiler.ropOperations), 4);
-					#endif
-
 					rasterOperation(cBuffer, x, sMask, zMask, cMask);
 				}
-
-				#if PERF_PROFILE
-					cycles[PERF_ROP] += Ticks() - ropTime;
-				#endif
 			}
 		}
 
@@ -255,10 +219,6 @@
 				writeStencil(sBuffer, q, x, sMask[q], zMask[q], cMask[q]);
 			}
 		}
-
-		#if PERF_PROFILE
-			cycles[PERF_PIPE] += Ticks() - pipeTime;
-		#endif
 	}
 
 	Float4 PixelRoutine::interpolateCentroid(Float4 &x, Float4 &y, Float4 &rhw, Pointer<Byte> planeEquation, bool flat, bool perspective)
@@ -1102,7 +1062,7 @@
 			UNIMPLEMENTED("VkFormat %d", state.targetFormat[index]);
 		}
 
-		if(postBlendSRGB || isSRGB(index))
+		if(isSRGB(index))
 		{
 			sRGBtoLinear16_12_16(pixel);
 		}
@@ -1229,36 +1189,33 @@
 
 	void PixelRoutine::writeColor(int index, Pointer<Byte> &cBuffer, Int &x, Vector4s &current, Int &sMask, Int &zMask, Int &cMask)
 	{
-		if(postBlendSRGB || isSRGB(index))
+		if(isSRGB(index))
 		{
 			linearToSRGB16_12_16(current);
 		}
 
-		if(exactColorRounding)
+		switch(state.targetFormat[index])
 		{
-			switch(state.targetFormat[index])
-			{
-			case VK_FORMAT_R5G6B5_UNORM_PACK16:
-				current.x = AddSat(As<UShort4>(current.x), UShort4(0x0400));
-				current.y = AddSat(As<UShort4>(current.y), UShort4(0x0200));
-				current.z = AddSat(As<UShort4>(current.z), UShort4(0x0400));
-				break;
-			case VK_FORMAT_B8G8R8A8_UNORM:
-			case VK_FORMAT_B8G8R8A8_SRGB:
-			case VK_FORMAT_R8G8B8A8_UNORM:
-			case VK_FORMAT_R8G8B8A8_SRGB:
-			case VK_FORMAT_R8G8_UNORM:
-			case VK_FORMAT_R8_UNORM:
-			case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
-			case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
-				current.x = current.x - As<Short4>(As<UShort4>(current.x) >> 8) + Short4(0x0080);
-				current.y = current.y - As<Short4>(As<UShort4>(current.y) >> 8) + Short4(0x0080);
-				current.z = current.z - As<Short4>(As<UShort4>(current.z) >> 8) + Short4(0x0080);
-				current.w = current.w - As<Short4>(As<UShort4>(current.w) >> 8) + Short4(0x0080);
-				break;
-			default:
-				break;
-			}
+		case VK_FORMAT_R5G6B5_UNORM_PACK16:
+			current.x = AddSat(As<UShort4>(current.x), UShort4(0x0400));
+			current.y = AddSat(As<UShort4>(current.y), UShort4(0x0200));
+			current.z = AddSat(As<UShort4>(current.z), UShort4(0x0400));
+			break;
+		case VK_FORMAT_B8G8R8A8_UNORM:
+		case VK_FORMAT_B8G8R8A8_SRGB:
+		case VK_FORMAT_R8G8B8A8_UNORM:
+		case VK_FORMAT_R8G8B8A8_SRGB:
+		case VK_FORMAT_R8G8_UNORM:
+		case VK_FORMAT_R8_UNORM:
+		case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
+		case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
+			current.x = current.x - As<Short4>(As<UShort4>(current.x) >> 8) + Short4(0x0080);
+			current.y = current.y - As<Short4>(As<UShort4>(current.y) >> 8) + Short4(0x0080);
+			current.z = current.z - As<Short4>(As<UShort4>(current.z) >> 8) + Short4(0x0080);
+			current.w = current.w - As<Short4>(As<UShort4>(current.w) >> 8) + Short4(0x0080);
+			break;
+		default:
+			break;
 		}
 
 		int rgbaWriteMask = state.colorWriteActive(index);
@@ -1956,7 +1913,7 @@
 			UNIMPLEMENTED("VkFormat: %d", int(state.targetFormat[index]));
 		}
 
-		if(postBlendSRGB || isSRGB(index))
+		if(isSRGB(index))
 		{
 			sRGBtoLinear(pixel.x);
 			sRGBtoLinear(pixel.y);
diff --git a/src/Pipeline/SamplerCore.cpp b/src/Pipeline/SamplerCore.cpp
index 6e9b18f..ea950ae 100644
--- a/src/Pipeline/SamplerCore.cpp
+++ b/src/Pipeline/SamplerCore.cpp
@@ -57,15 +57,6 @@
 	{
 		Vector4f c;
 
-		#if PERF_PROFILE
-			AddAtomic(Pointer<Long>(&profiler.texOperations), 4);
-
-			if(state.compressedFormat)
-			{
-				AddAtomic(Pointer<Long>(&profiler.compressedTex), 4);
-			}
-		#endif
-
 		Float4 uuuu = u;
 		Float4 vvvv = v;
 		Float4 wwww = w;
diff --git a/src/Pipeline/SetupRoutine.cpp b/src/Pipeline/SetupRoutine.cpp
index aed68d5..594fdee 100644
--- a/src/Pipeline/SetupRoutine.cpp
+++ b/src/Pipeline/SetupRoutine.cpp
@@ -23,8 +23,6 @@
 
 namespace sw
 {
-	extern TranscendentalPrecision logPrecision;
-
 	SetupRoutine::SetupRoutine(const SetupProcessor::State &state) : state(state)
 	{
 		routine = 0;
diff --git a/src/Pipeline/ShaderCore.cpp b/src/Pipeline/ShaderCore.cpp
index 4f7886f..6a9fc08 100644
--- a/src/Pipeline/ShaderCore.cpp
+++ b/src/Pipeline/ShaderCore.cpp
@@ -21,11 +21,6 @@
 
 namespace sw
 {
-	extern TranscendentalPrecision logPrecision;
-	extern TranscendentalPrecision expPrecision;
-	extern TranscendentalPrecision rcpPrecision;
-	extern TranscendentalPrecision rsqPrecision;
-
 	Vector4s::Vector4s()
 	{
 	}
@@ -186,20 +181,11 @@
 
 	Float4 reciprocal(RValue<Float4> x, bool pp, bool finite, bool exactAtPow2)
 	{
-		Float4 rcp;
+		Float4 rcp = Rcp_pp(x, exactAtPow2);
 
-		if(!pp && rcpPrecision >= WHQL)
+		if(!pp)
 		{
-			rcp = Float4(1.0f) / x;
-		}
-		else
-		{
-			rcp = Rcp_pp(x, exactAtPow2);
-
-			if(!pp)
-			{
-				rcp = (rcp + rcp) - (x * rcp * rcp);
-			}
+			rcp = (rcp + rcp) - (x * rcp * rcp);
 		}
 
 		if(finite)
diff --git a/src/Vulkan/VkQueue.cpp b/src/Vulkan/VkQueue.cpp
index 4f69d74..3657c1f 100644
--- a/src/Vulkan/VkQueue.cpp
+++ b/src/Vulkan/VkQueue.cpp
@@ -74,7 +74,7 @@
 namespace vk
 {
 
-Queue::Queue() : renderer(sw::OpenGL, true)
+Queue::Queue() : renderer()
 {
 	queueThread = std::thread(TaskLoop, this);
 }
diff --git a/src/Vulkan/vulkan.vcxproj b/src/Vulkan/vulkan.vcxproj
index e249529..fcc808d 100644
--- a/src/Vulkan/vulkan.vcxproj
+++ b/src/Vulkan/vulkan.vcxproj
@@ -149,7 +149,6 @@
     <ClCompile Include="..\Device\QuadRasterizer.cpp" />

     <ClCompile Include="..\Device\Renderer.cpp" />

     <ClCompile Include="..\Device\SetupProcessor.cpp" />

-    <ClCompile Include="..\Device\SwiftConfig.cpp" />

     <ClCompile Include="..\Device\Vector.cpp" />

     <ClCompile Include="..\Device\VertexProcessor.cpp" />

     <ClCompile Include="..\Pipeline\ComputeProgram.cpp" />

@@ -243,7 +242,6 @@
     <ClInclude Include="..\Device\Sampler.hpp" />

     <ClInclude Include="..\Device\SetupProcessor.hpp" />

     <ClInclude Include="..\Device\Stream.hpp" />

-    <ClInclude Include="..\Device\SwiftConfig.hpp" />

     <ClInclude Include="..\Device\Triangle.hpp" />

     <ClInclude Include="..\Device\Vector.hpp" />

     <ClInclude Include="..\Device\Vertex.hpp" />

diff --git a/src/Vulkan/vulkan.vcxproj.filters b/src/Vulkan/vulkan.vcxproj.filters
index c25de97..3181b58 100644
--- a/src/Vulkan/vulkan.vcxproj.filters
+++ b/src/Vulkan/vulkan.vcxproj.filters
@@ -51,9 +51,6 @@
     <ClCompile Include="..\Device\Vector.cpp">

       <Filter>Source Files\Device</Filter>

     </ClCompile>

-    <ClCompile Include="..\Device\SwiftConfig.cpp">

-      <Filter>Source Files\Device</Filter>

-    </ClCompile>

     <ClCompile Include="..\Device\SetupProcessor.cpp">

       <Filter>Source Files\Device</Filter>

     </ClCompile>

@@ -362,9 +359,6 @@
     <ClInclude Include="..\Device\Triangle.hpp">

       <Filter>Header Files\Device</Filter>

     </ClInclude>

-    <ClInclude Include="..\Device\SwiftConfig.hpp">

-      <Filter>Header Files\Device</Filter>

-    </ClInclude>

     <ClInclude Include="..\Device\Stream.hpp">

       <Filter>Header Files\Device</Filter>

     </ClInclude>