Always show the FPS when SwiftConfig is active.
Change-Id: Iec5aff6d73f9e20ba4bc6a95bc1e07d5e7b5930e
Reviewed-on: https://swiftshader-review.googlesource.com/2490
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Maxime Grégoire <mgregoire@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Main/Config.cpp b/src/Main/Config.cpp
index 4d0a4cf..10928ba 100644
--- a/src/Main/Config.cpp
+++ b/src/Main/Config.cpp
@@ -14,7 +14,6 @@
#include "Thread.hpp"
#include "Timer.hpp"
-#if PERF_PROFILE
Profiler profiler;
Profiler::Profiler()
@@ -28,33 +27,37 @@
framesTotal = 0;
FPS = 0;
- for(int i = 0; i < PERF_TIMERS; i++)
- {
- cycles[i] = 0;
- }
+ #if PERF_PROFILE
+ for(int i = 0; i < PERF_TIMERS; i++)
+ {
+ cycles[i] = 0;
+ }
- ropOperations = 0;
- ropOperationsTotal = 0;
- ropOperationsFrame = 0;
+ ropOperations = 0;
+ ropOperationsTotal = 0;
+ ropOperationsFrame = 0;
- texOperations = 0;
- texOperationsTotal = 0;
- texOperationsFrame = 0;
+ texOperations = 0;
+ texOperationsTotal = 0;
+ texOperationsFrame = 0;
- compressedTex = 0;
- compressedTexTotal = 0;
- compressedTexFrame = 0;
+ compressedTex = 0;
+ compressedTexTotal = 0;
+ compressedTexFrame = 0;
+ #endif
};
void Profiler::nextFrame()
{
- ropOperationsFrame = sw::atomicExchange(&ropOperations, 0);
- texOperationsFrame = sw::atomicExchange(&texOperations, 0);
- compressedTexFrame = sw::atomicExchange(&compressedTex, 0);
+ #if PERF_PROFILE
+ ropOperationsFrame = sw::atomicExchange(&ropOperations, 0);
+ texOperationsFrame = sw::atomicExchange(&texOperations, 0);
+ compressedTexFrame = sw::atomicExchange(&compressedTex, 0);
- ropOperationsTotal += ropOperationsFrame;
- texOperationsTotal += texOperationsFrame;
- compressedTexTotal += compressedTexFrame;
+ ropOperationsTotal += ropOperationsFrame;
+ texOperationsTotal += texOperationsFrame;
+ compressedTexTotal += compressedTexFrame;
+ #endif
static double fpsTime = sw::Timer::seconds();
@@ -71,4 +74,3 @@
framesSec = 0;
}
}
-#endif
\ No newline at end of file
diff --git a/src/Main/Config.hpp b/src/Main/Config.hpp
index 60cde42..b23500b 100644
--- a/src/Main/Config.hpp
+++ b/src/Main/Config.hpp
@@ -22,7 +22,6 @@
#define S3TC_SUPPORT 0
#endif
-#if PERF_PROFILE
enum
{
PERF_PIXEL,
@@ -45,6 +44,8 @@
int framesSec;
int framesTotal;
double FPS;
+
+ #if PERF_PROFILE
double cycles[PERF_TIMERS];
int64_t ropOperations;
@@ -58,10 +59,10 @@
int64_t compressedTex;
int64_t compressedTexTotal;
int64_t compressedTexFrame;
+ #endif
};
extern Profiler profiler;
-#endif
enum
{
diff --git a/src/Main/FrameBuffer.cpp b/src/Main/FrameBuffer.cpp
index e2a3f36..d1e74d0 100644
--- a/src/Main/FrameBuffer.cpp
+++ b/src/Main/FrameBuffer.cpp
@@ -187,6 +187,8 @@
}
unlock();
+
+ profiler.nextFrame(); // Assumes every copy() is a full frame
}
void FrameBuffer::copyLocked()
diff --git a/src/Main/SwiftConfig.cpp b/src/Main/SwiftConfig.cpp
index 953f0bf..444f471 100644
--- a/src/Main/SwiftConfig.cpp
+++ b/src/Main/SwiftConfig.cpp
@@ -22,9 +22,7 @@
#include <sys/stat.h>
#include <string.h>
-#if PERF_PROFILE
extern Profiler profiler;
-#endif
namespace sw
{
@@ -241,7 +239,6 @@
html += "<title>SwiftShader Configuration Panel</title>\n";
html += "</head>\n";
html += "<body>\n";
- html += "<div id='profile'></div>\n";
html += "<script type='text/javascript'>\n";
html += "request();\n";
html += "function request()\n";
@@ -261,6 +258,7 @@
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";
@@ -390,11 +388,11 @@
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 == true ? 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 == true ? 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 == true ? 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 == true ? 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 == true ? checked : empty) + " title='If checked enables the use of SSE4.1 instruction set extentions if supported by the CPU.'></td></tr>";
+ 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";
@@ -453,9 +451,7 @@
html += "</body>\n";
html += "</html>\n";
- #if PERF_PROFILE
- profiler.reset();
- #endif
+ profiler.reset();
return html;
}
@@ -464,6 +460,9 @@
{
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);
@@ -486,8 +485,6 @@
double averageCompressedTex = profiler.compressedTexTotal / std::max(profiler.framesTotal, 1) / 1.0e6f;
double averageTexOperations = profiler.texOperationsTotal / std::max(profiler.framesTotal, 1) / 1.0e6f;
- html += "<p>FPS: " + ftoa(profiler.FPS) + "</p>\n";
- html += "<p>Frame: " + itoa(profiler.framesTotal) + "</p>\n";
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";
diff --git a/src/OpenGL/libEGL/Surface.cpp b/src/OpenGL/libEGL/Surface.cpp
index 3b337d9..7a152aa 100644
--- a/src/OpenGL/libEGL/Surface.cpp
+++ b/src/OpenGL/libEGL/Surface.cpp
@@ -176,10 +176,6 @@
void Surface::swap()
{
- #if PERF_PROFILE
- profiler.nextFrame();
- #endif
-
if(backBuffer)
{
void *source = backBuffer->lockInternal(0, 0, 0, sw::LOCK_READONLY, sw::PUBLIC);
diff --git a/src/OpenGL/libGL/Surface.cpp b/src/OpenGL/libGL/Surface.cpp
index 544c45b..1c9470f 100644
--- a/src/OpenGL/libGL/Surface.cpp
+++ b/src/OpenGL/libGL/Surface.cpp
@@ -155,10 +155,6 @@
void Surface::swap()
{
- #if PERF_PROFILE
- profiler.nextFrame();
- #endif
-
if(backBuffer)
{
void *source = backBuffer->lockInternal(0, 0, 0, sw::LOCK_READONLY, sw::PUBLIC);
diff --git a/src/Radiance/libRAD/Surface.cpp b/src/Radiance/libRAD/Surface.cpp
index dcc19d1..9573183 100644
--- a/src/Radiance/libRAD/Surface.cpp
+++ b/src/Radiance/libRAD/Surface.cpp
@@ -181,10 +181,6 @@
void Surface::swap()
{
- #if PERF_PROFILE
- profiler.nextFrame();
- #endif
-
if(backBuffer)
{
void *source = backBuffer->lockInternal(0, 0, 0, sw::LOCK_READONLY, sw::PUBLIC);