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


		#include "gpu/gpu_renderer.h"

		using namespace GS;
		using namespace GS::GPU;


//------------------------------------------------------------------------------
RegistryRValue	Renderer::ProcessMessage(RegistryMessage m, const Registry *registry, const void *parm)
{
	switch (m)
	{
		case RegistryMsg_StartKeyChangeBatch:
			break;

		case RegistryMsg_EndKeyChangeBatch:
			if	(pending_shadow_map_refresh)
				CreateShadowMaps();
			if	(pending_core_shader_refresh)
				LoadCoreShaders();

			if	(pending_technique_refresh)
				SetRenderTechnique();
			if	(pending_fx_refresh)
				SetPostProcess();

			pending_shadow_map_refresh = false;
			pending_core_shader_refresh = false;
			pending_technique_refresh = false;
			pending_fx_refresh = false;
			break;

		case RegistryMsg_KeyChange:
			if	(RegistryKeyChange *key = (RegistryKeyChange *)parm)
			{
				if	((key->key == "ShadowMapping:Enable") || (key->key == "ShadowMapping:Size"))
				{
					gpu_config.enable_shadow = registry->GetBool("ShadowMapping:Enable", true);
					pending_shadow_map_refresh = true;
				}
				else	if	(key->key == "ShadowMapping:PSSM:Split")
				{
					pending_shadow_map_refresh = true;
					pending_core_shader_refresh = true;
				}
				else	if	(key->key == "ShadowMapping:PCF:Quality")
					pending_core_shader_refresh = true;

				else	if	(key->key == "Texture:Float:Enable")
					pending_technique_refresh = true;
				else	if	(key->key == "Technique")
					pending_technique_refresh = true;
				else	if	(key->key.StartsWith("Antialiasing"))
					pending_technique_refresh = true;
			
				else	if	(key->key == "PostProcess:FX:Scale")
					pending_fx_refresh = true;
			}
			break;

		default:
			break;
	}
	return RegistryReturn_Ok;
}
//------------------------------------------------------------------------------
