Skip to content
Snippets Groups Projects
llglsandbox.cpp 29.5 KiB
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;
	// 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();
	
	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();
			buff->drawArrays(LLRender::TRIANGLES, 0, 3);
			dest[i].flush();
		}
		
		//wait for current batch of copies to finish
		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;

			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;
	if (gGLManager.mHasTimerQuery)
	{
		LLGLSLShader::finishProfile(false);
	}

	std::sort(results.begin(), results.end());

	F32 gbps = results[results.size()/2];

Richard Linden's avatar
Richard Linden committed
	LL_INFOS() << "Memory bandwidth is " << llformat("%.3f", gbps) << "GB/sec according to CPU timers" << LL_ENDL;
        LL_WARNS() << "Memory bandwidth is improbably high and likely incorrect; discarding result." << LL_ENDL;
	F32 ms = gBenchmarkProgram.mTimeElapsed/1000000.f;
	F32 seconds = ms/1000.f;
	F64 samples_drawn = res*res*count*samples;
	F32 samples_sec = (samples_drawn/1000000000.0)/seconds;
	gbps = samples_sec*8;
	LL_INFOS() << "Memory bandwidth is " << llformat("%.3f", gbps) << "GB/sec according to ARB_timer_query" << LL_ENDL;