///////////////////////////////////////////////////////////////////////////////
//
// File   : Asura_Platform_SortedRender.cpp
// Author : Kevin Floyer-Lea
// Date   : 29-Jun-2005
//
// Copyright (C) 2005 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

/******************************************************************************/
/* Included Files                                                             */
/******************************************************************************/

#include "Core/Asura.h"

#include "Rendering/Asura_SortedRender.h"

#include "Rendering/Asura_Xbox360_CharacterRenderer.h"
#include "Rendering/Asura_Xbox360_Graphics.h"
#include "Rendering/Asura_Xbox360_ObjectHierarchyRenderer.h"
#include "Rendering/Asura_Xbox360_SkinRenderer.h"

/******************************************************************************/
/* Asura_SortedRenderItem Class Functions                                     */
/******************************************************************************/

void Asura_SortedRender::Platform_BeginRender(void)
{
#if defined(ASURA_XBOX360_ENABLE_PIX)
	const char*	szName	= (s_bTransparentPass)
						? "Sorted Render (Transparent)"
						: "Sorted Render (Opaque)";

	PIXBeginNamedEvent(D3DCOLOR_XRGB(0xFF, 0xFF, 0xFF), szName);
#endif	//defined(ASURA_XBOX360_ENABLE_PIX)

	Asura_Xbox360_CharacterRenderer::ResetCount();
	Asura_Xbox360_ObjectHierarchyRenderer::ResetCount();
	Asura_Xbox360_SkinRenderer::ResetCount();

	if( Asura_Xbox360_SkinRenderer::IsEnabled() )
	{
		Asura_Xbox360_SkinRenderer::OwnRegisters();
	}
}

void Asura_SortedRender::Platform_EndRender(void)
{
	if( Asura_Xbox360_SkinRenderer::IsEnabled() )
	{
		// Disown all the registers we owned for skin rendering
		Asura_Xbox360_SkinRenderer::DisownRegisters();
	}

#if defined(ASURA_XBOX360_ENABLE_PIX)
	PIXEndNamedEvent();
#endif	//defined(ASURA_XBOX360_ENABLE_PIX)
}

u_int Asura_SortedRenderItem::Platform_GetSortBias() const
{
	return m_eType;
}
