📄 profile2d.h
字号:
/***************************************************************************
* Name : 2dprofile.h
* Title : PowerVR 2d driver profiling utility
* Author(s) : Imagination Technologies
* Created : 17th February 2004
*
* Copyright : 2004 by Imagination Technologies. All rights reserved.
* : No part of this software, either material or conceptual
* : may be copied or distributed, transmitted, transcribed,
* : stored in a retrieval system or translated into any
* : human or computer language in any form by any means,
* : electronic, mechanical, manual or other-wise, or
* : disclosed to third parties without the express written
* : permission of Imagination Technologies Limited, Unit 8,
* : HomePark Industrial Estate, King's Langley, Hertfordshire,
* : WD4 8LZ, U.K.
*
* Description : 2D profiling header with application and driver level access
*
* Platform : WinCE and PocketPC
*
* Vesion : $ver$
*
* Modifications:-
* $Log: profile2d.h $
*
****************************************************************************/
#ifndef _2d_profile_h_
#define _2d_profile_h_
#pragma pack(push,1)
extern LONGLONG g_i64EntryTime;
extern BOOL g_bTimingOfBltActive;
/**************************/
/* Application layer defs */
/**************************/
// 2d driver profiling node
typedef struct
{
// Analysis of i64TotalTime
LONGLONG i64SetupTime; // Time in BltPrepare
LONGLONG i64WaitSyncTime; // Time waiting for idle state
LONGLONG i64WaitFifoSpaceTime; // Time waiting for space in the fifo
LONGLONG i64ClipBlitTime; // Time bltting the clip rectangles
// Variants of i64ClipBlitTime
LONGLONG i64StretchTime;
LONGLONG i64RotateTime;
LONGLONG i64UnrotateTime;
LONGLONG i64StripeTime;
LONGLONG i64SysMemTime;
LONGLONG i64StretchCount;
LONGLONG i64RotateCount;
LONGLONG i64UnrotateCount;
LONGLONG i64StripeCount;
LONGLONG i64SysMemCount;
// These must be the at the end of the structure
LONGLONG i64Count; // Total no of calls
LONGLONG i64TotalTime; // Total time including GPE clip rectangle loop
} PROFILE_NODE, *PPROFILE_NODE;
// 2d Profile Node Array Indices, must start at 0.
enum PROFILE_INDEX
{
NODE_DEFAULT, // Must be the first one */
NODE_PUNT,
// Profile the basic primatives to start with, then keep adding detail to get the whole picture.
NODE_FILLBLT,
NODE_SRCBLT,
NODE_PATBLT,
NODE_SRCPATBLT,
NODE_MASKFILLBLT, // eg./ normal text
NODE_MASKSRCBLT,
NODE_MASKPATBLT,
NODE_MASKSRCPATBLT,
NODE_TEXT,
NODE_AATEXT,
NODE_CLEARTYPE_TEXT,
NODE_TRANSPARENT_BLT,
NODE_LINES,
NODE_ALPHABLEND_BLT,
NODE_MAX // Must be the last one */
};
// Driver escape packet for 2d profile data
typedef struct
{
#define PROFILEFLAG_RESET_ALL_NODES 1
#define PROFILEFLAG_GETNODE 2
// 2d profile driver escape flag
IMG_UINT32 iu32Flags;
// Profile node.
IMG_UINT32 ui32Index;
PROFILE_NODE sNode;
} PROFILE2D_DATA, *PPROFILE2D_DATA;
/*********************/
/* Driver layer defs */
/*********************/
extern PROFILE_NODE gProfile[NODE_MAX];
// Variant flags.
#define PNODE_FLAGS_STRETCH 0x0001
#define PNODE_FLAGS_ROTATE 0x0002
#define PNODE_FLAGS_STRIPE 0x0004
#define PNODE_FLAGS_SYSMEM 0x0008
/* Local 2d profiling node structure */
typedef struct
{
LONGLONG i64EntryTime;
LONGLONG i64SetupTime; // BltPrepare
LONGLONG i64WaitSyncTime;
LONGLONG i64WaitSyncTimeCumulative; // SyncWithHost
LONGLONG i64WaitFifoSpaceTime;
LONGLONG i64WaitFifoSpaceTimeCumulative; // Waiting for fifo space
LONGLONG i64ClipBlitTime;
LONGLONG i64ClipBlitTimeCumulative;
LONGLONG i64TotalTime;
PPROFILE_NODE psNode;
IMG_UINT32 i32Tag;
IMG_UINT32 i32Flags;
} LOCAL_PNODE, *PLOCAL_PNODE;
/* Call this on function entry. uses gProfile global profile array */
#define profile_start(local_node, target_index)\
{\
memset(&local_node,0,sizeof(local_node));\
local_node.i64EntryTime = cpu_counter();\
local_node.psNode = &gProfile[target_index];\
g_i64EntryTime = local_node.i64EntryTime;\
g_bTimingOfBltActive = TRUE;\
}
#define profile_reassign(local_node, target_index)\
{\
local_node.psNode = &gProfile[target_index];\
}
#define profile_stretch(local_node)\
{\
local_node.i32Flags |= PNODE_FLAGS_STRETCH;\
}
#define profile_rotate(local_node)\
{\
local_node.i32Flags |= PNODE_FLAGS_ROTATE;\
}
#define profile_stripe(local_node)\
{\
local_node.i32Flags |= PNODE_FLAGS_STRIPE;\
}
#define profile_sysmem(local_node)\
{\
local_node.i32Flags |= PNODE_FLAGS_SYSMEM;\
}
/* Call this after setting up the blt */
#define profile_setup_end(local_node)\
{\
local_node.i64SetupTime = (cpu_counter() - local_node.i64EntryTime);\
}
/* Call this to flag waiting for hardware (or core) to complete */
#define profile_wait_sync_start(local_node)\
{\
local_node.i64WaitSyncTime = cpu_counter();\
}
/* Call this after waiting for hardware (or core) to complete */
#define profile_wait_sync_end(local_node)\
{\
local_node.i64WaitSyncTimeCumulative += (cpu_counter() - local_node.i64WaitSyncTime);\
}
/* Call this to flag waiting for fifo space */
#define profile_wait_for_fifo_space_start(local_node)\
{\
local_node.i64WaitFifoSpaceTime = cpu_counter();\
}
/* Call this after waiting for fifo space */
#define profile_wait_for_fifo_space_end(local_node)\
{\
local_node.i64WaitFifoSpaceTimeCumulative += (cpu_counter() - local_node.i64WaitFifoSpaceTime);\
}
/* Call this at start of bltting a rectangle */
#define profile_start_blt_clip_rect(local_node)\
{\
local_node.i64ClipBlitTime = cpu_counter();\
}
/* Call this at end of bltting a rectangle */
#define profile_end_blt_clip_rect(local_node)\
{\
local_node.i64ClipBlitTimeCumulative += (cpu_counter() - local_node.i64ClipBlitTime);\
}
//pmb ??? local_node.psNode += local_node.i32Tag;\
/* Call this before returning to caller */
#define profile_end(local_node)\
{\
LONGLONG i64BlitDuration = cpu_counter() - local_node.i64EntryTime;\
ASSERT (i64BlitDuration >= 0x0000000000000000);\
local_node.psNode->i64TotalTime += i64BlitDuration;\
ASSERT (local_node.psNode->i64TotalTime >= 0x0000000000000000);\
local_node.psNode->i64Count ++;\
local_node.psNode->i64SetupTime += local_node.i64SetupTime;\
local_node.psNode->i64WaitSyncTime += local_node.i64WaitSyncTimeCumulative;\
local_node.psNode->i64WaitFifoSpaceTime += local_node.i64WaitFifoSpaceTimeCumulative;\
local_node.psNode->i64ClipBlitTime += local_node.i64ClipBlitTimeCumulative;\
\
if (local_node.i32Flags & PNODE_FLAGS_STRETCH)\
{\
local_node.psNode->i64StretchTime += i64BlitDuration;\
local_node.psNode->i64StretchCount ++;\
}\
if (local_node.i32Flags & PNODE_FLAGS_ROTATE)\
{\
local_node.psNode->i64RotateTime += i64BlitDuration;\
local_node.psNode->i64RotateCount ++;\
}\
else\
{\
m_sActiveNode.psNode->i64UnrotateTime += i64BlitDuration;\
m_sActiveNode.psNode->i64UnrotateCount ++;\
}\
if (local_node.i32Flags & PNODE_FLAGS_STRIPE)\
{\
local_node.psNode->i64StripeTime += i64BlitDuration;\
local_node.psNode->i64StripeCount ++;\
}\
if (local_node.i32Flags & PNODE_FLAGS_SYSMEM)\
{\
local_node.psNode->i64SysMemTime += i64BlitDuration;\
local_node.psNode->i64SysMemCount ++;\
}\
g_bTimingOfBltActive = FALSE;\
}
/* cpu_counter() - returns a snapshot of the 64 bit high-resolution counter. */
__inline LONGLONG cpu_counter()
{
LARGE_INTEGER i64PerformanceCount;
// Remember to step into this for each OS/processor and see how long it takes.
QueryPerformanceCounter(&i64PerformanceCount);
if (g_bTimingOfBltActive && (i64PerformanceCount.QuadPart < g_i64EntryTime))
{
i64PerformanceCount.QuadPart += (LONGLONG)1<<32;
}
return (i64PerformanceCount.QuadPart);
}
#pragma pack(pop)
#endif /*_2d_profile_h_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -