Commit 8af8b40e by Alexis Hetu Committed by Alexis Hétu

Ripped out SwiftConfig

SwiftConfig is unused in Vulkan, so it was removed. Change-Id: Ic82bd186c271522b8552ca9925692e311b5c4156 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/32031Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Presubmit-Ready: Alexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 8565e772
...@@ -42,8 +42,6 @@ swiftshader_source_set("Device") { ...@@ -42,8 +42,6 @@ swiftshader_source_set("Device") {
"Renderer.hpp", "Renderer.hpp",
"SetupProcessor.cpp", "SetupProcessor.cpp",
"SetupProcessor.hpp", "SetupProcessor.hpp",
"SwiftConfig.cpp",
"SwiftConfig.hpp",
"Vector.cpp", "Vector.cpp",
"Vector.hpp", "Vector.hpp",
"VertexProcessor.cpp", "VertexProcessor.cpp",
......
...@@ -30,39 +30,10 @@ namespace sw ...@@ -30,39 +30,10 @@ namespace sw
framesSec = 0; framesSec = 0;
framesTotal = 0; framesTotal = 0;
FPS = 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() 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(); static double fpsTime = sw::Timer::seconds();
double time = sw::Timer::seconds(); double time = sw::Timer::seconds();
......
...@@ -17,18 +17,6 @@ ...@@ -17,18 +17,6 @@
#include "System/Types.hpp" #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 namespace sw
{ {
enum enum
...@@ -53,22 +41,6 @@ namespace sw ...@@ -53,22 +41,6 @@ namespace sw
int framesSec; int framesSec;
int framesTotal; int framesTotal;
double FPS; 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; extern Profiler profiler;
......
...@@ -24,16 +24,6 @@ ...@@ -24,16 +24,6 @@
namespace sw 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() Context::Context()
{ {
init(); init();
...@@ -197,11 +187,6 @@ namespace sw ...@@ -197,11 +187,6 @@ namespace sw
return depthWriteEnable; return depthWriteEnable;
} }
bool Context::alphaTestActive() const
{
return transparencyAntialiasing != TRANSPARENCY_NONE;
}
bool Context::depthBufferActive() const bool Context::depthBufferActive() const
{ {
return depthBuffer && depthBufferEnable; return depthBuffer && depthBufferEnable;
...@@ -589,6 +574,6 @@ namespace sw ...@@ -589,6 +574,6 @@ namespace sw
bool Context::colorUsed() const bool Context::colorUsed() const
{ {
return colorWriteActive() || alphaTestActive() || (pixelShader && pixelShader->getModes().ContainsKill); return colorWriteActive() || (pixelShader && pixelShader->getModes().ContainsKill);
} }
} }
...@@ -97,7 +97,6 @@ namespace sw ...@@ -97,7 +97,6 @@ namespace sw
bool setWriteSRGB(bool sRGB); bool setWriteSRGB(bool sRGB);
bool depthWriteActive() const; bool depthWriteActive() const;
bool alphaTestActive() const;
bool depthBufferActive() const; bool depthBufferActive() const;
bool stencilActive() const; bool stencilActive() const;
......
...@@ -24,10 +24,6 @@ ...@@ -24,10 +24,6 @@
namespace sw namespace sw
{ {
extern TransparencyAntialiasing transparencyAntialiasing;
bool precachePixel = false;
unsigned int PixelProcessor::States::computeHash() unsigned int PixelProcessor::States::computeHash()
{ {
unsigned int *state = (unsigned int*)this; unsigned int *state = (unsigned int*)this;
......
...@@ -22,10 +22,6 @@ ...@@ -22,10 +22,6 @@
namespace sw namespace sw
{ {
extern bool fullPixelPositionRegister;
extern int clusterCount;
QuadRasterizer::QuadRasterizer(const PixelProcessor::State &state, SpirvShader const *spirvShader) : state(state), spirvShader{spirvShader} QuadRasterizer::QuadRasterizer(const PixelProcessor::State &state, SpirvShader const *spirvShader) : state(state), spirvShader{spirvShader}
{ {
} }
...@@ -36,15 +32,6 @@ namespace sw ...@@ -36,15 +32,6 @@ namespace sw
void QuadRasterizer::generate() 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)); constants = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData,constants));
occlusion = 0; occlusion = 0;
int clusterCount = Renderer::getClusterCount(); int clusterCount = Renderer::getClusterCount();
...@@ -76,15 +63,6 @@ namespace sw ...@@ -76,15 +63,6 @@ namespace sw
*Pointer<UInt>(data + OFFSET(DrawData,occlusion) + 4 * cluster) = clusterOcclusion; *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(); Return();
} }
......
...@@ -40,10 +40,6 @@ namespace sw ...@@ -40,10 +40,6 @@ namespace sw
UInt occlusion; 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; virtual void quad(Pointer<Byte> cBuffer[4], Pointer<Byte> &zBuffer, Pointer<Byte> &sBuffer, Int cMask[4], Int &x, Int &y) = 0;
bool interpolateZ() const; bool interpolateZ() const;
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "Clipper.hpp" #include "Clipper.hpp"
#include "Primitive.hpp" #include "Primitive.hpp"
#include "Polygon.hpp" #include "Polygon.hpp"
#include "Device/SwiftConfig.hpp"
#include "Reactor/Reactor.hpp" #include "Reactor/Reactor.hpp"
#include "Pipeline/Constants.hpp" #include "Pipeline/Constants.hpp"
#include "System/CPUID.hpp" #include "System/CPUID.hpp"
...@@ -35,8 +34,6 @@ ...@@ -35,8 +34,6 @@
#undef max #undef max
bool disableServer = true;
#ifndef NDEBUG #ifndef NDEBUG
unsigned int minPrimitives = 1; unsigned int minPrimitives = 1;
unsigned int maxPrimitives = 1 << 21; unsigned int maxPrimitives = 1 << 21;
...@@ -44,42 +41,11 @@ unsigned int maxPrimitives = 1 << 21; ...@@ -44,42 +41,11 @@ unsigned int maxPrimitives = 1 << 21;
namespace sw 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; static const int batchSize = 128;
AtomicInt threadCount(1); AtomicInt threadCount(1);
AtomicInt Renderer::unitCount(1); AtomicInt Renderer::unitCount(1);
AtomicInt Renderer::clusterCount(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> template<typename T>
inline bool setBatchIndices(unsigned int batch[128][3], VkPrimitiveTopology topology, T indices, unsigned int start, unsigned int triangleCount) inline bool setBatchIndices(unsigned int batch[128][3], VkPrimitiveTopology topology, T indices, unsigned int start, unsigned int triangleCount)
{ {
...@@ -196,14 +162,8 @@ namespace sw ...@@ -196,14 +162,8 @@ namespace sw
deallocate(data); 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++) for(int i = 0; i < 16; i++)
{ {
vertexTask[i] = nullptr; vertexTask[i] = nullptr;
...@@ -246,7 +206,6 @@ namespace sw ...@@ -246,7 +206,6 @@ namespace sw
clipFlags = 0; clipFlags = 0;
swiftConfig = new SwiftConfig(disableServer);
updateConfiguration(true); updateConfiguration(true);
} }
...@@ -263,9 +222,6 @@ namespace sw ...@@ -263,9 +222,6 @@ namespace sw
delete drawCall[draw]; delete drawCall[draw];
drawCall[draw] = nullptr; drawCall[draw] = nullptr;
} }
delete swiftConfig;
swiftConfig = nullptr;
} }
// This object has to be mem aligned // This object has to be mem aligned
...@@ -298,10 +254,14 @@ namespace sw ...@@ -298,10 +254,14 @@ namespace sw
if(count == 0) { return; } if(count == 0) { return; }
#ifndef NDEBUG #ifndef NDEBUG
{
unsigned int minPrimitives = 1;
unsigned int maxPrimitives = 1 << 21;
if(count < minPrimitives || count > maxPrimitives) if(count < minPrimitives || count > maxPrimitives)
{ {
return; return;
} }
}
#endif #endif
updateConfiguration(); updateConfiguration();
...@@ -455,16 +415,6 @@ namespace sw ...@@ -455,16 +415,6 @@ namespace sw
} }
} }
#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 // Viewport
{ {
float W = 0.5f * viewport.width; float W = 0.5f * viewport.width;
...@@ -574,11 +524,8 @@ namespace sw ...@@ -574,11 +524,8 @@ namespace sw
Renderer *renderer = static_cast<Parameters*>(parameters)->renderer; Renderer *renderer = static_cast<Parameters*>(parameters)->renderer;
int threadIndex = static_cast<Parameters*>(parameters)->threadIndex; 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); renderer->threadLoop(threadIndex);
} }
...@@ -733,10 +680,6 @@ namespace sw ...@@ -733,10 +680,6 @@ namespace sw
void Renderer::executeTask(int threadIndex) void Renderer::executeTask(int threadIndex)
{ {
#if PERF_HUD
int64_t startTick = Timer::ticks();
#endif
switch(task[threadIndex].type) switch(task[threadIndex].type)
{ {
case Task::PRIMITIVES: case Task::PRIMITIVES:
...@@ -750,12 +693,6 @@ namespace sw ...@@ -750,12 +693,6 @@ namespace sw
processPrimitiveVertices(unit, input, count, draw->count, threadIndex); 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; int visible = 0;
if(!draw->setupState.rasterizerDiscard) if(!draw->setupState.rasterizerDiscard)
...@@ -765,10 +702,6 @@ namespace sw ...@@ -765,10 +702,6 @@ namespace sw
primitiveProgress[unit].visible = visible; primitiveProgress[unit].visible = visible;
primitiveProgress[unit].references = clusterCount; primitiveProgress[unit].references = clusterCount;
#if PERF_HUD
setupTime[threadIndex] += Timer::ticks() - startTick;
#endif
} }
break; break;
case Task::PIXELS: case Task::PIXELS:
...@@ -788,10 +721,6 @@ namespace sw ...@@ -788,10 +721,6 @@ namespace sw
} }
finishRendering(task[threadIndex]); finishRendering(task[threadIndex]);
#if PERF_HUD
pixelTime[threadIndex] += Timer::ticks() - startTick;
#endif
} }
break; break;
case Task::RESUME: case Task::RESUME:
...@@ -835,16 +764,6 @@ namespace sw ...@@ -835,16 +764,6 @@ namespace sw
if(ref == 0) 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) if(draw.queries)
{ {
for(auto &query : *(draw.queries)) for(auto &query : *(draw.queries))
...@@ -1393,38 +1312,6 @@ namespace sw ...@@ -1393,38 +1312,6 @@ namespace sw
} }
} }
#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) void Renderer::setViewport(const VkViewport &viewport)
{ {
this->viewport = viewport; this->viewport = viewport;
...@@ -1437,97 +1324,21 @@ namespace sw ...@@ -1437,97 +1324,21 @@ namespace sw
void Renderer::updateConfiguration(bool initialUpdate) void Renderer::updateConfiguration(bool initialUpdate)
{ {
bool newConfiguration = swiftConfig->hasNewConfiguration(); if(initialUpdate)
if(newConfiguration || initialUpdate)
{ {
terminateThreads(); terminateThreads();
SwiftConfig::Configuration configuration = {}; VertexProcessor::setRoutineCacheSize(1024);
swiftConfig->getConfiguration(configuration); PixelProcessor::setRoutineCacheSize(1024);
SetupProcessor::setRoutineCacheSize(1024);
precacheVertex = !newConfiguration && configuration.precache; threadCount = CPUID::processAffinity();
precacheSetup = !newConfiguration && configuration.precache;
precachePixel = !newConfiguration && configuration.precache;
VertexProcessor::setRoutineCacheSize(configuration.vertexRoutineCacheSize); CPUID::setEnableSSE4_1(true);
PixelProcessor::setRoutineCacheSize(configuration.pixelRoutineCacheSize); CPUID::setEnableSSSE3(true);
SetupProcessor::setRoutineCacheSize(configuration.setupRoutineCacheSize); CPUID::setEnableSSE3(true);
CPUID::setEnableSSE2(true);
switch(configuration.transcendentalPrecision) CPUID::setEnableSSE(true);
{
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
} }
if(!initialUpdate && !worker[0]) if(!initialUpdate && !worker[0])
......
...@@ -40,50 +40,11 @@ namespace sw ...@@ -40,50 +40,11 @@ namespace sw
struct DrawCall; struct DrawCall;
class PixelShader; class PixelShader;
class VertexShader; class VertexShader;
class SwiftConfig;
struct Task; struct Task;
class TaskEvents; class TaskEvents;
class Resource; class Resource;
struct Constants; 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 struct DrawData
{ {
const Constants *constants; const Constants *constants;
...@@ -103,10 +64,6 @@ namespace sw ...@@ -103,10 +64,6 @@ namespace sw
PixelProcessor::Factor factor; PixelProcessor::Factor factor;
unsigned int occlusion[16]; // Number of pixels passing depth test unsigned int occlusion[16]; // Number of pixels passing depth test
#if PERF_PROFILE
int64_t cycles[PERF_TIMERS][16];
#endif
float4 Wx16; float4 Wx16;
float4 Hx16; float4 Hx16;
float4 X0x16; float4 X0x16;
...@@ -193,7 +150,7 @@ namespace sw ...@@ -193,7 +150,7 @@ namespace sw
}; };
public: public:
Renderer(Conventions conventions, bool exactColorRounding); Renderer();
virtual ~Renderer(); virtual ~Renderer();
...@@ -215,15 +172,6 @@ namespace sw ...@@ -215,15 +172,6 @@ namespace sw
void synchronize(); 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; } static int getClusterCount() { return clusterCount; }
private: private:
...@@ -289,16 +237,8 @@ namespace sw ...@@ -289,16 +237,8 @@ namespace sw
std::mutex schedulerMutex; std::mutex schedulerMutex;
#if PERF_HUD
int64_t vertexTime[16];
int64_t setupTime[16];
int64_t pixelTime[16];
#endif
VertexTask *vertexTask[16]; VertexTask *vertexTask[16];
SwiftConfig *swiftConfig;
std::list<vk::Query*> queries; std::list<vk::Query*> queries;
WaitGroup sync; WaitGroup sync;
......
...@@ -157,10 +157,6 @@ namespace sw ...@@ -157,10 +157,6 @@ namespace sw
VkSamplerYcbcrModelConversion ycbcrModel; VkSamplerYcbcrModelConversion ycbcrModel;
bool studioSwing; // Narrow range bool studioSwing; // Narrow range
bool swappedChroma; // Cb/Cr components in reverse order bool swappedChroma; // Cb/Cr components in reverse order
#if PERF_PROFILE
bool compressedFormat;
#endif
}; };
} }
......
...@@ -25,10 +25,6 @@ ...@@ -25,10 +25,6 @@
namespace sw namespace sw
{ {
extern bool fullPixelPositionRegister;
bool precacheSetup = false;
unsigned int SetupProcessor::States::computeHash() unsigned int SetupProcessor::States::computeHash()
{ {
unsigned int *state = (unsigned int*)this; unsigned int *state = (unsigned int*)this;
......
// 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
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
namespace sw namespace sw
{ {
bool precacheVertex = false;
void VertexCache::clear() void VertexCache::clear()
{ {
for(int i = 0; i < 16; i++) for(int i = 0; i < 16; i++)
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
namespace sw namespace sw
{ {
extern bool postBlendSRGB;
void PixelProgram::setBuiltins(Int &x, Int &y, Float4(&z)[4], Float4 &w) void PixelProgram::setBuiltins(Int &x, Int &y, Float4(&z)[4], Float4 &w)
{ {
routine.windowSpacePosition[0] = x + SIMD::Int(0,1,0,1); routine.windowSpacePosition[0] = x + SIMD::Int(0,1,0,1);
......
...@@ -24,10 +24,6 @@ ...@@ -24,10 +24,6 @@
namespace sw namespace sw
{ {
extern bool postBlendSRGB;
extern bool exactColorRounding;
extern bool forceClearRegisters;
PixelRoutine::PixelRoutine( PixelRoutine::PixelRoutine(
const PixelProcessor::State &state, const PixelProcessor::State &state,
vk::PipelineLayout const *pipelineLayout, vk::PipelineLayout const *pipelineLayout,
...@@ -40,12 +36,12 @@ namespace sw ...@@ -40,12 +36,12 @@ namespace sw
if (spirvShader) if (spirvShader)
{ {
spirvShader->emitProlog(&routine); 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 @@ namespace sw ...@@ -56,10 +52,6 @@ namespace sw
void PixelRoutine::quad(Pointer<Byte> cBuffer[RENDERTARGETS], Pointer<Byte> &zBuffer, Pointer<Byte> &sBuffer, Int cMask[4], Int &x, Int &y) 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 // TODO: consider shader which modifies sample mask in general
const bool earlyDepthTest = !spirvShader || (!spirvShader->getModes().DepthReplacing && !state.alphaToCoverage); const bool earlyDepthTest = !spirvShader || (!spirvShader->getModes().DepthReplacing && !state.alphaToCoverage);
...@@ -109,10 +101,6 @@ namespace sw ...@@ -109,10 +101,6 @@ namespace sw
If(depthPass || Bool(!earlyDepthTest)) If(depthPass || Bool(!earlyDepthTest))
{ {
#if PERF_PROFILE
Long interpTime = Ticks();
#endif
Float4 yyyy = Float4(Float(y)) + *Pointer<Float4>(primitive + OFFSET(Primitive,yQuad), 16); Float4 yyyy = Float4(Float(y)) + *Pointer<Float4>(primitive + OFFSET(Primitive,yQuad), 16);
// Centroid locations // Centroid locations
...@@ -176,25 +164,13 @@ namespace sw ...@@ -176,25 +164,13 @@ namespace sw
setBuiltins(x, y, z, w); setBuiltins(x, y, z, w);
} }
#if PERF_PROFILE
cycles[PERF_INTERP] += Ticks() - interpTime;
#endif
Bool alphaPass = true; Bool alphaPass = true;
#if PERF_PROFILE
Long shaderTime = Ticks();
#endif
if (spirvShader) if (spirvShader)
{ {
applyShader(cMask); applyShader(cMask);
} }
#if PERF_PROFILE
cycles[PERF_SHADER] += Ticks() - shaderTime;
#endif
alphaPass = alphaTest(cMask); alphaPass = alphaTest(cMask);
if((spirvShader && spirvShader->getModes().ContainsKill) || state.alphaToCoverage) if((spirvShader && spirvShader->getModes().ContainsKill) || state.alphaToCoverage)
...@@ -216,10 +192,6 @@ namespace sw ...@@ -216,10 +192,6 @@ namespace sw
} }
} }
#if PERF_PROFILE
Long ropTime = Ticks();
#endif
If(depthPass || Bool(earlyDepthTest)) If(depthPass || Bool(earlyDepthTest))
{ {
for(unsigned int q = 0; q < state.multiSample; q++) for(unsigned int q = 0; q < state.multiSample; q++)
...@@ -235,16 +207,8 @@ namespace sw ...@@ -235,16 +207,8 @@ namespace sw
} }
} }
#if PERF_PROFILE
AddAtomic(Pointer<Long>(&profiler.ropOperations), 4);
#endif
rasterOperation(cBuffer, x, sMask, zMask, cMask); rasterOperation(cBuffer, x, sMask, zMask, cMask);
} }
#if PERF_PROFILE
cycles[PERF_ROP] += Ticks() - ropTime;
#endif
} }
} }
...@@ -255,10 +219,6 @@ namespace sw ...@@ -255,10 +219,6 @@ namespace sw
writeStencil(sBuffer, q, x, sMask[q], zMask[q], cMask[q]); 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) Float4 PixelRoutine::interpolateCentroid(Float4 &x, Float4 &y, Float4 &rhw, Pointer<Byte> planeEquation, bool flat, bool perspective)
...@@ -1102,7 +1062,7 @@ namespace sw ...@@ -1102,7 +1062,7 @@ namespace sw
UNIMPLEMENTED("VkFormat %d", state.targetFormat[index]); UNIMPLEMENTED("VkFormat %d", state.targetFormat[index]);
} }
if(postBlendSRGB || isSRGB(index)) if(isSRGB(index))
{ {
sRGBtoLinear16_12_16(pixel); sRGBtoLinear16_12_16(pixel);
} }
...@@ -1229,36 +1189,33 @@ namespace sw ...@@ -1229,36 +1189,33 @@ namespace sw
void PixelRoutine::writeColor(int index, Pointer<Byte> &cBuffer, Int &x, Vector4s &current, Int &sMask, Int &zMask, Int &cMask) 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); 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));
case VK_FORMAT_R5G6B5_UNORM_PACK16: current.y = AddSat(As<UShort4>(current.y), UShort4(0x0200));
current.x = AddSat(As<UShort4>(current.x), UShort4(0x0400)); current.z = AddSat(As<UShort4>(current.z), UShort4(0x0400));
current.y = AddSat(As<UShort4>(current.y), UShort4(0x0200)); break;
current.z = AddSat(As<UShort4>(current.z), UShort4(0x0400)); case VK_FORMAT_B8G8R8A8_UNORM:
break; case VK_FORMAT_B8G8R8A8_SRGB:
case VK_FORMAT_B8G8R8A8_UNORM: case VK_FORMAT_R8G8B8A8_UNORM:
case VK_FORMAT_B8G8R8A8_SRGB: case VK_FORMAT_R8G8B8A8_SRGB:
case VK_FORMAT_R8G8B8A8_UNORM: case VK_FORMAT_R8G8_UNORM:
case VK_FORMAT_R8G8B8A8_SRGB: case VK_FORMAT_R8_UNORM:
case VK_FORMAT_R8G8_UNORM: case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
case VK_FORMAT_R8_UNORM: case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
case VK_FORMAT_A8B8G8R8_UNORM_PACK32: current.x = current.x - As<Short4>(As<UShort4>(current.x) >> 8) + Short4(0x0080);
case VK_FORMAT_A8B8G8R8_SRGB_PACK32: current.y = current.y - As<Short4>(As<UShort4>(current.y) >> 8) + Short4(0x0080);
current.x = current.x - As<Short4>(As<UShort4>(current.x) >> 8) + Short4(0x0080); current.z = current.z - As<Short4>(As<UShort4>(current.z) >> 8) + Short4(0x0080);
current.y = current.y - As<Short4>(As<UShort4>(current.y) >> 8) + Short4(0x0080); current.w = current.w - As<Short4>(As<UShort4>(current.w) >> 8) + Short4(0x0080);
current.z = current.z - As<Short4>(As<UShort4>(current.z) >> 8) + Short4(0x0080); break;
current.w = current.w - As<Short4>(As<UShort4>(current.w) >> 8) + Short4(0x0080); default:
break; break;
default:
break;
}
} }
int rgbaWriteMask = state.colorWriteActive(index); int rgbaWriteMask = state.colorWriteActive(index);
...@@ -1956,7 +1913,7 @@ namespace sw ...@@ -1956,7 +1913,7 @@ namespace sw
UNIMPLEMENTED("VkFormat: %d", int(state.targetFormat[index])); UNIMPLEMENTED("VkFormat: %d", int(state.targetFormat[index]));
} }
if(postBlendSRGB || isSRGB(index)) if(isSRGB(index))
{ {
sRGBtoLinear(pixel.x); sRGBtoLinear(pixel.x);
sRGBtoLinear(pixel.y); sRGBtoLinear(pixel.y);
......
...@@ -57,15 +57,6 @@ namespace sw ...@@ -57,15 +57,6 @@ namespace sw
{ {
Vector4f c; 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 uuuu = u;
Float4 vvvv = v; Float4 vvvv = v;
Float4 wwww = w; Float4 wwww = w;
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
namespace sw namespace sw
{ {
extern TranscendentalPrecision logPrecision;
SetupRoutine::SetupRoutine(const SetupProcessor::State &state) : state(state) SetupRoutine::SetupRoutine(const SetupProcessor::State &state) : state(state)
{ {
routine = 0; routine = 0;
......
...@@ -21,11 +21,6 @@ ...@@ -21,11 +21,6 @@
namespace sw namespace sw
{ {
extern TranscendentalPrecision logPrecision;
extern TranscendentalPrecision expPrecision;
extern TranscendentalPrecision rcpPrecision;
extern TranscendentalPrecision rsqPrecision;
Vector4s::Vector4s() Vector4s::Vector4s()
{ {
} }
...@@ -186,20 +181,11 @@ namespace sw ...@@ -186,20 +181,11 @@ namespace sw
Float4 reciprocal(RValue<Float4> x, bool pp, bool finite, bool exactAtPow2) 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); rcp = (rcp + rcp) - (x * rcp * rcp);
if(!pp)
{
rcp = (rcp + rcp) - (x * rcp * rcp);
}
} }
if(finite) if(finite)
......
...@@ -74,7 +74,7 @@ VkSubmitInfo* DeepCopySubmitInfo(uint32_t submitCount, const VkSubmitInfo* pSubm ...@@ -74,7 +74,7 @@ VkSubmitInfo* DeepCopySubmitInfo(uint32_t submitCount, const VkSubmitInfo* pSubm
namespace vk namespace vk
{ {
Queue::Queue() : renderer(sw::OpenGL, true) Queue::Queue() : renderer()
{ {
queueThread = std::thread(TaskLoop, this); queueThread = std::thread(TaskLoop, this);
} }
......
...@@ -149,7 +149,6 @@ IF EXIST "$(SolutionDir)..\deqp\build\external\vulkancts\modules\vulkan\" (copy ...@@ -149,7 +149,6 @@ IF EXIST "$(SolutionDir)..\deqp\build\external\vulkancts\modules\vulkan\" (copy
<ClCompile Include="..\Device\QuadRasterizer.cpp" /> <ClCompile Include="..\Device\QuadRasterizer.cpp" />
<ClCompile Include="..\Device\Renderer.cpp" /> <ClCompile Include="..\Device\Renderer.cpp" />
<ClCompile Include="..\Device\SetupProcessor.cpp" /> <ClCompile Include="..\Device\SetupProcessor.cpp" />
<ClCompile Include="..\Device\SwiftConfig.cpp" />
<ClCompile Include="..\Device\Vector.cpp" /> <ClCompile Include="..\Device\Vector.cpp" />
<ClCompile Include="..\Device\VertexProcessor.cpp" /> <ClCompile Include="..\Device\VertexProcessor.cpp" />
<ClCompile Include="..\Pipeline\ComputeProgram.cpp" /> <ClCompile Include="..\Pipeline\ComputeProgram.cpp" />
...@@ -243,7 +242,6 @@ IF EXIST "$(SolutionDir)..\deqp\build\external\vulkancts\modules\vulkan\" (copy ...@@ -243,7 +242,6 @@ IF EXIST "$(SolutionDir)..\deqp\build\external\vulkancts\modules\vulkan\" (copy
<ClInclude Include="..\Device\Sampler.hpp" /> <ClInclude Include="..\Device\Sampler.hpp" />
<ClInclude Include="..\Device\SetupProcessor.hpp" /> <ClInclude Include="..\Device\SetupProcessor.hpp" />
<ClInclude Include="..\Device\Stream.hpp" /> <ClInclude Include="..\Device\Stream.hpp" />
<ClInclude Include="..\Device\SwiftConfig.hpp" />
<ClInclude Include="..\Device\Triangle.hpp" /> <ClInclude Include="..\Device\Triangle.hpp" />
<ClInclude Include="..\Device\Vector.hpp" /> <ClInclude Include="..\Device\Vector.hpp" />
<ClInclude Include="..\Device\Vertex.hpp" /> <ClInclude Include="..\Device\Vertex.hpp" />
......
...@@ -51,9 +51,6 @@ ...@@ -51,9 +51,6 @@
<ClCompile Include="..\Device\Vector.cpp"> <ClCompile Include="..\Device\Vector.cpp">
<Filter>Source Files\Device</Filter> <Filter>Source Files\Device</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\Device\SwiftConfig.cpp">
<Filter>Source Files\Device</Filter>
</ClCompile>
<ClCompile Include="..\Device\SetupProcessor.cpp"> <ClCompile Include="..\Device\SetupProcessor.cpp">
<Filter>Source Files\Device</Filter> <Filter>Source Files\Device</Filter>
</ClCompile> </ClCompile>
...@@ -362,9 +359,6 @@ ...@@ -362,9 +359,6 @@
<ClInclude Include="..\Device\Triangle.hpp"> <ClInclude Include="..\Device\Triangle.hpp">
<Filter>Header Files\Device</Filter> <Filter>Header Files\Device</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Device\SwiftConfig.hpp">
<Filter>Header Files\Device</Filter>
</ClInclude>
<ClInclude Include="..\Device\Stream.hpp"> <ClInclude Include="..\Device\Stream.hpp">
<Filter>Header Files\Device</Filter> <Filter>Header Files\Device</Filter>
</ClInclude> </ClInclude>
......
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