2010-04-25 00:31:27 +00:00
|
|
|
/*
|
2009-02-09 21:15:56 +00:00
|
|
|
* Copyright (C) 2007-2009 Gabest
|
|
|
|
* http://www.gabest.org
|
|
|
|
*
|
|
|
|
* This Program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-02-09 21:15:56 +00:00
|
|
|
* This Program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-02-09 21:15:56 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNU Make; see the file COPYING. If not, write to
|
2010-04-25 00:31:27 +00:00
|
|
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
2009-02-09 21:15:56 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
class GSPerfMon
|
|
|
|
{
|
|
|
|
public:
|
2011-12-22 01:48:16 +00:00
|
|
|
enum timer_t
|
|
|
|
{
|
|
|
|
Main,
|
|
|
|
Sync,
|
2011-12-28 14:10:20 +00:00
|
|
|
WorkerDraw0, WorkerDraw1, WorkerDraw2, WorkerDraw3, WorkerDraw4, WorkerDraw5, WorkerDraw6, WorkerDraw7,
|
|
|
|
WorkerDraw8, WorkerDraw9, WorkerDraw10, WorkerDraw11, WorkerDraw12, WorkerDraw13, WorkerDraw14, WorkerDraw15,
|
2011-12-22 01:48:16 +00:00
|
|
|
TimerLast,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum counter_t
|
|
|
|
{
|
2012-01-06 00:17:52 +00:00
|
|
|
Frame, Prim, Draw, Swizzle, Unswizzle, Fillrate, Quad,
|
2011-12-22 01:48:16 +00:00
|
|
|
CounterLast,
|
|
|
|
};
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
double m_counters[CounterLast];
|
|
|
|
double m_stats[CounterLast];
|
2011-12-22 01:48:16 +00:00
|
|
|
uint64 m_begin[TimerLast], m_total[TimerLast], m_start[TimerLast];
|
|
|
|
uint64 m_frame;
|
2009-02-09 21:15:56 +00:00
|
|
|
clock_t m_lastframe;
|
|
|
|
int m_count;
|
|
|
|
|
|
|
|
friend class GSPerfMonAutoTimer;
|
|
|
|
|
|
|
|
public:
|
|
|
|
GSPerfMon();
|
|
|
|
|
2009-05-15 11:11:26 +00:00
|
|
|
void SetFrame(uint64 frame) {m_frame = frame;}
|
|
|
|
uint64 GetFrame() {return m_frame;}
|
2011-12-22 01:48:16 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
void Put(counter_t c, double val = 0);
|
|
|
|
double Get(counter_t c) {return m_stats[c];}
|
|
|
|
void Update();
|
2011-12-22 01:48:16 +00:00
|
|
|
|
|
|
|
void Start(int timer = Main);
|
|
|
|
void Stop(int timer = Main);
|
|
|
|
int CPU(int timer = Main, bool reset = true);
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class GSPerfMonAutoTimer
|
|
|
|
{
|
|
|
|
GSPerfMon* m_pm;
|
2011-12-22 01:48:16 +00:00
|
|
|
int m_timer;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
public:
|
2011-12-22 01:48:16 +00:00
|
|
|
GSPerfMonAutoTimer(GSPerfMon* pm, int timer = GSPerfMon::Main) {m_timer = timer; (m_pm = pm)->Start(m_timer);}
|
|
|
|
~GSPerfMonAutoTimer() {m_pm->Stop(m_timer);}
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|