/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


		#include "core/renderer.h"
		#include "core/core_profiler.h"

		using namespace GS::Render;


//------------------------------------------------------------------------------
void				Renderer::DrawProfilerText(RasterFont *font[2], float &x, float &y)
{
	Color title_color(1.f, 0.9f, 0);
	WriterConfig config(false);

	// Renderer profiling.
	Write(*font[1], "Profiler\n\n", x, y, config, 1, &title_color);
	Write(*font[0], String::Format("Prepare light: slice = %0.02f ms, tasks = %0.02f ms (// x%0.01f)\n", stats.bench_prepare_light.slice_duration.toMs(), stats.bench_prepare_light.tasks_duration.toMs(), stats.bench_prepare_light.tasks_duration.toMs() / stats.bench_prepare_light.slice_duration.toMs()), x, y, config);
	Write(*font[0], String::Format("Render queue: %0.02f ms\n", stats.bench_render.GetMs()), x, y, config, 1, &Core::GetColorCode <float> (stats.bench_render.GetMs(), 16, 32));
	Write(*font[0], String::Format("Post-process: %0.02f ms\n", stats.bench_post_process.GetMs()), x, y, config, 1, &Core::GetColorCode <float> (stats.bench_post_process.GetMs(), 2, 3));
	y += 8;

	Write(*font[1], "Statistics\n\n", x, y, config, 1, &title_color);
	Write(*font[0], String::Format("Queue pass = %d\n", stats.queue_pass), x, y, config);
	Write(*font[0], String::Format("Light processed = %d\n", stats.light_processed), x, y, config);
	y += 8;

	Write(*font[0], String::Format("Renderable processed = %d (pass avg. = %d)\n", stats.renderable_processed, stats.queue_pass ? stats.renderable_processed / stats.queue_pass : 0), x, y, config);
	Write(*font[0], String::Format("Renderable drawn = %d (pass avg. = %d)\n", stats.renderable_drawn, stats.queue_pass ? stats.renderable_drawn / stats.queue_pass : 0), x, y, config);
	Write(*font[0], String::Format("Passed culling: %.02f%% (draw/submit ratio)\n", stats.renderable_processed ? stats.renderable_drawn * 100.f / stats.renderable_processed : 0), x, y, config);
	y += 8;

	Write(*font[0], String::Format("List drawn = %d (avg. tri/list = %s, efficiency = %.02f)\n", stats.list_drawn, Core::FormatNumber(stats.list_drawn ? (float)stats.triangle_drawn / (float)stats.list_drawn : 0).c_str(), stats.list_drawn ? 100.f / ((float)stats.list_drawn / stats.queue_pass) : 1), x, y, config, 1, &Core::GetColorCode <uint> (stats.list_drawn, 600, 1000));
	Write(*font[0], String::Format("Triangle drawn = %s (pass avg. = %s)\n", Core::FormatNumber(stats.triangle_drawn).c_str(), Core::FormatNumber(stats.queue_pass ? (float)stats.triangle_drawn / (float)stats.queue_pass : 0).c_str()), x, y, config);
	y += 16;
}
//------------------------------------------------------------------------------
