Newer
Older
LL_WARNS() << "GL LLVertexBuffer::getVertexStrider() returned false, "
<< "buff->getMappedData() is"
<< (buff->getMappedData()? " not" : "")
<< " NULL" << LL_ENDL;
// abandon the benchmark test
return -1.f;
Graham Linden
committed
// generate dummy triangle
v[0].set(-1, 1, 0);
v[1].set(-1, -3, 0);
v[2].set(3, 1, 0);
buff->flush();
gBenchmarkProgram.bind();
David Parks
committed
bool busted_finish = false;
buff->setBuffer(LLVertexBuffer::MAP_VERTEX);
glFinish();
for (S32 c = -1; c < samples; ++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
David Parks
committed
if (busted_finish)
{
//read a pixel off the last target since some drivers seem to ignore glFinish
dest[count-1].bindTarget();
U32 pixel = 0;
glReadPixels(0,0,1,1,GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
dest[count-1].flush();
}
else
{
glFinish();
}
F32 time = timer.getElapsedTimeF32();
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;
David Parks
committed
if (!gGLManager.mHasTimerQuery && !busted_finish && gbps > 128.f)
{ //unrealistically high bandwidth for a card without timer queries, glFinish is probably ignored
busted_finish = true;
LL_WARNS() << "GPU Benchmark detected GL driver with broken glFinish implementation." << LL_ENDL;
David Parks
committed
}
else
{
results.push_back(gbps);
}
}
}
gBenchmarkProgram.unbind();
if (gGLManager.mHasTimerQuery)
{
LLGLSLShader::finishProfile(false);
}
std::sort(results.begin(), results.end());
F32 gbps = results[results.size()/2];
LL_INFOS() << "Memory bandwidth is " << llformat("%.3f", gbps) << "GB/sec according to CPU timers" << LL_ENDL;
davep
committed
#if LL_DARWIN
if (gbps > 512.f)
{
LL_WARNS() << "Memory bandwidth is improbably high and likely incorrect; discarding result." << LL_ENDL;
davep
committed
//OSX is probably lying, discard result
return -1.f;
davep
committed
}
#endif
F32 ms = gBenchmarkProgram.mTimeElapsed/1000000.f;
F32 seconds = ms/1000.f;
David Parks
committed
F64 samples_drawn = res*res*count*samples;
F32 samples_sec = (samples_drawn/1000000000.0)/seconds;
gbps = samples_sec*8;
David Parks
committed
LL_INFOS() << "Memory bandwidth is " << llformat("%.3f", gbps) << "GB/sec according to ARB_timer_query" << LL_ENDL;
return gbps;