summaryrefslogtreecommitdiff
path: root/indra/newview/llglsandbox.cpp
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@geenzo.com>2023-05-11 21:21:01 -0700
committerJonathan "Geenz" Goodman <geenz@geenzo.com>2023-05-11 21:21:01 -0700
commitad4118f6ceaf1c22b22d58825924aad5575319f9 (patch)
treea1227572853491f2e89fb0db128230c40248b47d /indra/newview/llglsandbox.cpp
parent339e02ef3311ad5c1197dfca2955a0c202b7c408 (diff)
parent06bdee663433bf5b12eddcbcfcb8785546354c28 (diff)
Merge branch 'DRTVWR-559' into DRTVWR-583
Diffstat (limited to 'indra/newview/llglsandbox.cpp')
-rw-r--r--indra/newview/llglsandbox.cpp100
1 files changed, 60 insertions, 40 deletions
diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp
index 2e4d0f85b9..098fe89265 100644
--- a/indra/newview/llglsandbox.cpp
+++ b/indra/newview/llglsandbox.cpp
@@ -984,6 +984,7 @@ private:
//-----------------------------------------------------------------------------
// gpu_benchmark()
+// returns measured memory bandwidth of GPU in gigabytes per second
//-----------------------------------------------------------------------------
F32 gpu_benchmark()
{
@@ -1028,8 +1029,6 @@ F32 gpu_benchmark()
//time limit, allocation operations shouldn't take longer then 30 seconds, same for actual benchmark.
const F32 time_limit = 30;
- ShaderProfileHelper initProfile;
-
std::vector<LLRenderTarget> dest(count);
TextureHolder texHolder(0, count);
std::vector<F32> results;
@@ -1111,46 +1110,49 @@ F32 gpu_benchmark()
buff->unmapBuffer();
- // ensure matched pair of bind() and unbind() calls
- ShaderBinder binder(gBenchmarkProgram);
-
- buff->setBuffer();
- glFinish();
-
- F32 time_passed = 0; // seconds
- for (S32 c = -1; c < samples && time_passed < time_limit; ++c)
- {
- LLTimer timer;
- timer.start();
-
- for (U32 i = 0; i < count; ++i)
- {
- dest[i].bindTarget();
- texHolder.bind(i);
- buff->drawArrays(LLRender::TRIANGLES, 0, 3);
- dest[i].flush();
- }
-
- //wait for current batch of copies to finish
- glFinish();
-
- F32 time = timer.getElapsedTimeF32();
- time_passed += time;
-
- if (c >= 0) // <-- ignore the first sample as it tends to be artificially slow
- {
- //store result in gigabytes per second
- F32 gb = (F32) ((F64) (res*res*8*count))/(1000000000);
- F32 gbps = gb/time;
- results.push_back(gbps);
- }
- }
+ LLGLSLShader::unbind();
+
+ F32 time_passed = 0; // seconds
+
+ { //run CPU timer benchmark
+ glFinish();
+ gBenchmarkProgram.bind();
+ for (S32 c = -1; c < samples && time_passed < time_limit; ++c)
+ {
+ LLTimer timer;
+ timer.start();
+
+ for (U32 i = 0; i < count; ++i)
+ {
+ dest[i].bindTarget();
+ texHolder.bind(i);
+ buff->setBuffer();
+ buff->drawArrays(LLRender::TRIANGLES, 0, 3);
+ dest[i].flush();
+ }
+
+ //wait for current batch of copies to finish
+ glFinish();
+
+ F32 time = timer.getElapsedTimeF32();
+ time_passed += time;
+
+ if (c >= 0) // <-- ignore the first sample as it tends to be artificially slow
+ {
+ //store result in gigabytes per second
+ F32 gb = (F32)((F64)(res * res * 8 * count)) / (1000000000);
+ F32 gbps = gb / time;
+ results.push_back(gbps);
+ }
+ }
+ gBenchmarkProgram.unbind();
+ }
std::sort(results.begin(), results.end());
F32 gbps = results[results.size()/2];
- LL_INFOS("Benchmark") << "Memory bandwidth is " << llformat("%.3f", gbps) << "GB/sec according to CPU timers, " << (F32)results.size() << " tests took " << time_passed << " seconds" << LL_ENDL;
+ LL_INFOS("Benchmark") << "Memory bandwidth is " << llformat("%.3f", gbps) << " GB/sec according to CPU timers, " << (F32)results.size() << " tests took " << time_passed << " seconds" << LL_ENDL;
#if LL_DARWIN
if (gbps > 512.f)
@@ -1161,14 +1163,32 @@ F32 gpu_benchmark()
}
#endif
+ // run GPU timer benchmark
+ {
+ ShaderProfileHelper initProfile;
+ dest[0].bindTarget();
+ gBenchmarkProgram.bind();
+ for (S32 c = 0; c < samples; ++c)
+ {
+ for (U32 i = 0; i < count; ++i)
+ {
+ texHolder.bind(i);
+ buff->setBuffer();
+ buff->drawArrays(LLRender::TRIANGLES, 0, 3);
+ }
+ }
+ gBenchmarkProgram.unbind();
+ dest[0].flush();
+ }
+
F32 ms = gBenchmarkProgram.mTimeElapsed/1000000.f;
F32 seconds = ms/1000.f;
- F64 samples_drawn = res*res*count*results.size();
+ F64 samples_drawn = gBenchmarkProgram.mSamplesDrawn;
F32 samples_sec = (samples_drawn/1000000000.0)/seconds;
- gbps = samples_sec*8;
+ gbps = samples_sec*4; // 4 bytes per sample
- LL_INFOS("Benchmark") << "Memory bandwidth is " << llformat("%.3f", gbps) << "GB/sec according to ARB_timer_query, total time " << seconds << " seconds" << LL_ENDL;
+ LL_INFOS("Benchmark") << "Memory bandwidth is " << llformat("%.3f", gbps) << " GB/sec according to ARB_timer_query, total time " << seconds << " seconds" << LL_ENDL;
return gbps;
}