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


		#include "gpu/gpu_renderer.h"
		#include "core/core_profiler.h"
		#include "core/raster_font.h"

		using namespace GS::GPU;


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

	Write(*font[1], String::Format("%s - %s (v%s)\n\n", GetName(), GetDescription(), GetVersion()), x, y, config, 1, &title_color);

	Write(*font[0], String::Format("Device: %s\n", stats.adapter.c_str()), x, y, config);
	Write(*font[0], String::Format("Vendor: %s\n\n", stats.vendor.c_str()), x, y, config);

	Write(*font[0], String::Format("Texture: %s Geometry: %s\n\n", Core::FormatNumber(stats.texture_memory, Core::MemorySize).c_str(), Core::FormatNumber(stats.geometry_memory, Core::MemorySize).c_str()), x, y, config);

	Render::Renderer::DrawProfilerText(font, x, y);

	Write(*font[1], "Batching System\n\n", x, y, config, 1, &title_color);
	Write(*font[0], String::Format("Program change = %0.02f%% (%d)\n", gpu_stats.prg_change ? (gpu_stats.prg_change * 100.f) / stats.list_drawn : 0, gpu_stats.prg_change), x, y, config);
	Write(*font[0], String::Format("List change = %0.02f%% (%d)\n", gpu_stats.dls_change ? (gpu_stats.dls_change * 100.f) / stats.list_drawn : 0, gpu_stats.dls_change), x, y, config);
	Write(*font[0], String::Format("Material change = %0.02f%% (%d)\n", gpu_stats.mat_change ? (gpu_stats.mat_change * 100.f) / stats.list_drawn : 0, gpu_stats.mat_change), x, y, config);
	Write(*font[0], String::Format("Item change = %0.02f%% (%d)\n\n", gpu_stats.item_change ? (gpu_stats.item_change * 100.f) / stats.list_drawn : 0, gpu_stats.item_change), x, y, config);

	Write(*font[1], "Terrain System\n\n", x, y, config, 1, &title_color);
	Write(*font[0], String::Format("Cache miss = %0.02f%% (%d query/frame)\n\n", gpu_stats.terrain_page_query_count ? (gpu_stats.terrain_page_query_miss * 100.f) / gpu_stats.terrain_page_query_count : 0, gpu_stats.terrain_page_query_count), x, y, config);

	Write(*font[1], String::Format("Technique: %s\n\n", render_technique == TechniqueDeferred ? "Deferred" : "Forward"), x, y, config, 1, &title_color);
}
//------------------------------------------------------------------------------
