I had originally wanted to convert the profiler to use scopes (e.g.,

create a stack class that started the profiler in the constructor
and stopped it in the destructor). Sadly, doing that causes gcc to
call out to hook up the unwind chain, and this tanks performance
quite badly, even when the profiler is off.

Since I had already class-ified profiler.c, I decided to keep the old
way of doing things but wrap it in the newer classes. So at least it
wasn't a complete waste of my time.

Search & replace:

  profiler_mark_start -> g_profiler.start
  profiler_mark_end -> g_profiler.end
This commit is contained in:
Aaron Giles 2010-08-21 22:25:58 +00:00
parent e8d644d285
commit a2f7346d90
43 changed files with 454 additions and 349 deletions

View File

@ -742,7 +742,7 @@ static void code_compile_block(mips3_state *mips3, UINT8 mode, offs_t pc)
drcuml_block *block;
jmp_buf errorbuf;
profiler_mark_start(PROFILER_DRC_COMPILE);
g_profiler.start(PROFILER_DRC_COMPILE);
/* get a description of this sequence */
desclist = drcfe_describe_code(mips3->impstate->drcfe, pc);
@ -827,7 +827,7 @@ static void code_compile_block(mips3_state *mips3, UINT8 mode, offs_t pc)
/* end the sequence */
drcuml_block_end(block);
profiler_mark_end();
g_profiler.stop();
}

View File

@ -947,7 +947,7 @@ static void code_compile_block(powerpc_state *ppc, UINT8 mode, offs_t pc)
drcuml_block *block;
jmp_buf errorbuf;
profiler_mark_start(PROFILER_DRC_COMPILE);
g_profiler.start(PROFILER_DRC_COMPILE);
/* get a description of this sequence */
desclist = drcfe_describe_code(ppc->impstate->drcfe, pc);
@ -1030,7 +1030,7 @@ static void code_compile_block(powerpc_state *ppc, UINT8 mode, offs_t pc)
/* end the sequence */
drcuml_block_end(block);
profiler_mark_end();
g_profiler.stop();
}

View File

@ -7207,7 +7207,7 @@ static void code_compile_block(rsp_state *rsp, offs_t pc)
drcuml_block *block;
jmp_buf errorbuf;
profiler_mark_start(PROFILER_DRC_COMPILE);
g_profiler.start(PROFILER_DRC_COMPILE);
/* get a description of this sequence */
desclist = drcfe_describe_code(rsp->impstate->drcfe, pc);
@ -7288,7 +7288,7 @@ static void code_compile_block(rsp_state *rsp, offs_t pc)
/* end the sequence */
drcuml_block_end(block);
profiler_mark_end();
g_profiler.stop();
}
/***************************************************************************

View File

@ -925,7 +925,7 @@ static void code_compile_block(sh2_state *sh2, UINT8 mode, offs_t pc)
drcuml_block *block;
jmp_buf errorbuf;
profiler_mark_start(PROFILER_DRC_COMPILE);
g_profiler.start(PROFILER_DRC_COMPILE);
/* get a description of this sequence */
desclist = drcfe_describe_code(sh2->drcfe, pc);
@ -1016,7 +1016,7 @@ static void code_compile_block(sh2_state *sh2, UINT8 mode, offs_t pc)
/* end the sequence */
drcuml_block_end(block);
profiler_mark_end();
g_profiler.stop();
}
/*-------------------------------------------------

View File

@ -267,7 +267,7 @@ device_execute_interface::device_execute_interface(running_machine &machine, con
m_timedint_timer(NULL),
m_iloops(0),
m_partial_frame_timer(NULL),
m_profiler(0),
m_profiler(PROFILER_IDLE),
m_icount(NULL),
m_cycles_running(0),
m_cycles_stolen(0),
@ -538,7 +538,7 @@ void device_execute_interface::interface_pre_start()
// fill in the initial states
int index = m_machine.m_devicelist.index(&m_device);
m_suspend = SUSPEND_REASON_RESET;
m_profiler = index + PROFILER_DEVICE_FIRST;
m_profiler = profile_type(index + PROFILER_DEVICE_FIRST);
m_inttrigger = index + TRIGGER_INT;
// fill in the input states and IRQ callback information

View File

@ -322,7 +322,7 @@ protected:
attotime m_partial_frame_period; // the length of one partial frame for interrupt purposes
// cycle counting and executing
int m_profiler; // profiler tag
profile_type m_profiler; // profiler tag
int * m_icount; // pointer to the icount
int m_cycles_running; // number of cycles we are executing
int m_cycles_stolen; // number of cycles we artificially stole

View File

@ -370,7 +370,7 @@ while (0) \
#define DRAWGFX_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE) \
do { \
profiler_mark_start(PROFILER_DRAWGFX); \
g_profiler.start(PROFILER_DRAWGFX); \
do { \
const UINT8 *srcdata; \
INT32 destendx, destendy; \
@ -613,7 +613,7 @@ do { \
} \
} \
} while (0); \
profiler_mark_end(); \
g_profiler.stop(); \
} while (0)
@ -642,7 +642,7 @@ do { \
#define DRAWGFXZOOM_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE) \
do { \
profiler_mark_start(PROFILER_DRAWGFX); \
g_profiler.start(PROFILER_DRAWGFX); \
do { \
const UINT8 *srcdata; \
UINT32 dstwidth, dstheight; \
@ -698,7 +698,7 @@ do { \
destendy = desty + dstheight - 1; \
if (desty > cliprect->max_y || destendy < cliprect->min_y) \
{ \
profiler_mark_end(); \
g_profiler.stop(); \
return; \
} \
\
@ -797,7 +797,7 @@ do { \
} \
} \
} while (0); \
profiler_mark_end(); \
g_profiler.stop(); \
} while (0)
@ -821,7 +821,7 @@ do { \
#define COPYBITMAP_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE) \
do { \
profiler_mark_start(PROFILER_COPYBITMAP); \
g_profiler.start(PROFILER_COPYBITMAP); \
do { \
const PIXEL_TYPE *srcdata; \
UINT32 numblocks, leftovers; \
@ -975,7 +975,7 @@ do { \
} \
} \
} while (0); \
profiler_mark_end(); \
g_profiler.stop(); \
} while (0)
@ -1006,7 +1006,7 @@ do { \
UINT32 numblocks, leftovers; \
INT32 curx, cury; \
\
profiler_mark_start(PROFILER_COPYBITMAP); \
g_profiler.start(PROFILER_COPYBITMAP); \
\
assert(dest != NULL); \
assert(src != NULL); \
@ -1280,7 +1280,7 @@ do { \
} \
} \
} \
profiler_mark_end(); \
g_profiler.stop(); \
} while (0)

View File

@ -52,6 +52,7 @@
// core emulator headers -- must be first
#include "emucore.h"
#include "eminline.h"
#include "profiler.h"
// commonly-referenecd utilities imported from lib/util
#include "chd.h"

View File

@ -2468,7 +2468,7 @@ static void frame_update(running_machine *machine)
INT32 mouse_target_y;
int mouse_button;
profiler_mark_start(PROFILER_INPUT);
g_profiler.start(PROFILER_INPUT);
/* record/playback information about the current frame */
playback_frame(machine, curtime);
@ -2546,7 +2546,7 @@ profiler_mark_start(PROFILER_INPUT);
}
}
profiler_mark_end();
g_profiler.stop();
}

View File

@ -857,7 +857,7 @@ INT32 input_code_value(running_machine *machine, input_code code)
INT32 result = 0;
int curindex;
profiler_mark_start(PROFILER_INPUT);
g_profiler.start(PROFILER_INPUT);
/* return 0 for any disabled or invalid device classes */
if (devclass <= DEVICE_CLASS_INVALID || devclass >= DEVICE_CLASS_MAXIMUM || !device_list[devclass].enabled)
@ -908,7 +908,7 @@ INT32 input_code_value(running_machine *machine, input_code code)
}
exit:
profiler_mark_end();
g_profiler.stop();
return result;
}

View File

@ -403,7 +403,7 @@ int running_machine::run(bool firstrun)
m_hard_reset_pending = false;
while ((!m_hard_reset_pending && !m_exit_pending) || m_saveload_schedule != SLS_NONE)
{
profiler_mark_start(PROFILER_EXTRA);
g_profiler.start(PROFILER_EXTRA);
// execute CPUs if not paused
if (!m_paused)
@ -417,7 +417,7 @@ int running_machine::run(bool firstrun)
if (m_saveload_schedule != SLS_NONE)
handle_saveload();
profiler_mark_end();
g_profiler.stop();
}
// and out via the exit phase
@ -713,7 +713,7 @@ void CLIB_DECL running_machine::vlogerror(const char *format, va_list args)
// process only if there is a target
if (m_logerror_list != NULL)
{
profiler_mark_start(PROFILER_LOGERROR);
g_profiler.start(PROFILER_LOGERROR);
// dump to the buffer
vsnprintf(giant_string_buffer, ARRAY_LENGTH(giant_string_buffer), format, args);
@ -722,7 +722,7 @@ void CLIB_DECL running_machine::vlogerror(const char *format, va_list args)
for (logerror_callback_item *cb = m_logerror_list; cb != NULL; cb = cb->m_next)
(*cb->m_func)(*this, giant_string_buffer);
profiler_mark_end();
g_profiler.stop();
}
}

View File

@ -1071,7 +1071,7 @@ public:
// native read
_NativeType read_native(offs_t offset, _NativeType mask)
{
profiler_mark_start(PROFILER_MEMREAD);
g_profiler.start(PROFILER_MEMREAD);
if (TEST_HANDLER) printf("[r%X,%s]", offset, core_i64_hex_format(mask, sizeof(_NativeType) * 2));
@ -1089,14 +1089,14 @@ public:
else if (sizeof(_NativeType) == 4) result = handler.read32(*this, offset >> 2, mask);
else if (sizeof(_NativeType) == 8) result = handler.read64(*this, offset >> 3, mask);
profiler_mark_end();
g_profiler.stop();
return result;
}
// mask-less native read
_NativeType read_native(offs_t offset)
{
profiler_mark_start(PROFILER_MEMREAD);
g_profiler.start(PROFILER_MEMREAD);
if (TEST_HANDLER) printf("[r%X]", offset);
@ -1114,14 +1114,14 @@ public:
else if (sizeof(_NativeType) == 4) result = handler.read32(*this, offset >> 2, 0xffffffff);
else if (sizeof(_NativeType) == 8) result = handler.read64(*this, offset >> 3, U64(0xffffffffffffffff));
profiler_mark_end();
g_profiler.stop();
return result;
}
// native write
void write_native(offs_t offset, _NativeType data, _NativeType mask)
{
profiler_mark_start(PROFILER_MEMWRITE);
g_profiler.start(PROFILER_MEMWRITE);
// look up the handler
offs_t byteaddress = offset & m_bytemask;
@ -1140,13 +1140,13 @@ public:
else if (sizeof(_NativeType) == 4) handler.write32(*this, offset >> 2, data, mask);
else if (sizeof(_NativeType) == 8) handler.write64(*this, offset >> 3, data, mask);
profiler_mark_end();
g_profiler.stop();
}
// mask-less native write
void write_native(offs_t offset, _NativeType data)
{
profiler_mark_start(PROFILER_MEMWRITE);
g_profiler.start(PROFILER_MEMWRITE);
// look up the handler
offs_t byteaddress = offset & m_bytemask;
@ -1161,7 +1161,7 @@ public:
else if (sizeof(_NativeType) == 4) handler.write32(*this, offset >> 2, data, 0xffffffff);
else if (sizeof(_NativeType) == 8) handler.write64(*this, offset >> 3, data, U64(0xffffffffffffffff));
profiler_mark_end();
g_profiler.stop();
}
// generic direct read

View File

@ -4,8 +4,49 @@
Functions to manage profiling of MAME execution.
Copyright Nicola Salmoria and the MAME Team.
Visit http://mamedev.org for licensing and usage restrictions.
****************************************************************************
Copyright Aaron Giles
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name 'MAME' nor the names of its contributors may be
used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
****************************************************************************
Profiling is scope-based. To start profiling, put a profiler_scope
object on the stack. To end profiling, just end the scope:
{
profiler_scope scope(PROFILER_VIDEO);
your_work_here();
}
the profiler handles a FILO list so calls may be nested.
***************************************************************************/
@ -14,12 +55,11 @@
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
typedef struct _profile_string profile_string;
struct _profile_string
struct profile_string
{
int type;
const char *string;
@ -27,94 +67,120 @@ struct _profile_string
/***************************************************************************
GLOBAL VARIABLES
***************************************************************************/
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
profiler_state global_profiler;
profiler_state g_profiler;
/***************************************************************************
CORE FUNCTIONS
***************************************************************************/
//**************************************************************************
// DUMMY PROFILER STATE
//**************************************************************************
/*-------------------------------------------------
_profiler_mark_start - mark the beginning of a
profiler entry
-------------------------------------------------*/
//-------------------------------------------------
// dummy_profiler_state - constructor
//-------------------------------------------------
void _profiler_mark_start(int type)
dummy_profiler_state::dummy_profiler_state()
{
profiler_data *data = &global_profiler.data[global_profiler.dataindex];
osd_ticks_t curticks = get_profile_ticks();
profiler_filo_entry *entry;
int index;
/* track context switches */
if (type >= PROFILER_DEVICE_FIRST && type <= PROFILER_DEVICE_MAX)
data->context_switches++;
/* we're starting a new bucket, begin now */
index = global_profiler.filoindex++;
entry = &global_profiler.filo[index];
/* fail if we overflow */
if (index > ARRAY_LENGTH(global_profiler.filo))
fatalerror("Profiler FILO overflow (type = %d)\n", type);
/* if we're nested, stop the previous entry */
if (index > 0)
{
profiler_filo_entry *preventry = entry - 1;
data->duration[preventry->type] += curticks - preventry->start;
}
/* fill in this entry */
entry->type = type;
entry->start = curticks;
}
/*-------------------------------------------------
_profiler_mark_end - mark the end of a
profiler entry
-------------------------------------------------*/
void _profiler_mark_end(void)
//**************************************************************************
// REAL PROFILER STATE
//**************************************************************************
//-------------------------------------------------
// real_profiler_state - constructor
//-------------------------------------------------
real_profiler_state::real_profiler_state()
: m_enabled(false),
m_dataready(false),
m_filoindex(0),
m_dataindex(0)
{
memset(m_filo, 0, sizeof(m_filo));
memset(m_data, 0, sizeof(m_data));
}
//-------------------------------------------------
// real_start - mark the beginning of a
// profiler entry
//-------------------------------------------------
void real_profiler_state::real_start(profile_type type)
{
profiler_data *data = &global_profiler.data[global_profiler.dataindex];
osd_ticks_t curticks = get_profile_ticks();
/* we're ending an existing bucket, update the time */
if (global_profiler.filoindex > 0)
// track context switches
history_data &data = m_data[m_dataindex];
if (type >= PROFILER_DEVICE_FIRST && type <= PROFILER_DEVICE_MAX)
data.context_switches++;
// we're starting a new bucket, begin now
int index = m_filoindex++;
filo_entry &entry = m_filo[index];
// fail if we overflow
if (index > ARRAY_LENGTH(m_filo))
throw emu_fatalerror("Profiler FILO overflow (type = %d)\n", type);
// if we're nested, stop the previous entry
if (index > 0)
{
int index = --global_profiler.filoindex;
profiler_filo_entry *entry = &global_profiler.filo[index];
filo_entry &preventry = m_filo[index - 1];
data.duration[preventry.type] += curticks - preventry.start;
}
/* account for the time taken */
data->duration[entry->type] += curticks - entry->start;
// fill in this entry
entry.type = type;
entry.start = curticks;
}
/* if we have a previous entry, restart his time now */
//-------------------------------------------------
// real_stop - mark the end of a profiler entry
//-------------------------------------------------
void real_profiler_state::real_stop()
{
osd_ticks_t curticks = get_profile_ticks();
// we're ending an existing bucket, update the time
if (m_filoindex > 0)
{
int index = --m_filoindex;
filo_entry &entry = m_filo[index];
// account for the time taken
history_data &data = m_data[m_dataindex];
data.duration[entry.type] += curticks - entry.start;
// if we have a previous entry, restart his time now
if (index != 0)
{
profiler_filo_entry *preventry = entry - 1;
preventry->start = curticks;
filo_entry &preventry = m_filo[index - 1];
preventry.start = curticks;
}
}
}
/*-------------------------------------------------
_profiler_get_text - return the current text
in an astring
-------------------------------------------------*/
//-------------------------------------------------
// text - return the current text in an astring
//-------------------------------------------------
astring &_profiler_get_text(running_machine *machine, astring &string)
const char *real_profiler_state::text(running_machine &machine, astring &string)
{
static const profile_string names[] =
{
{ PROFILER_DRC_COMPILE, "DRC Compilation" },
{ PROFILER_MEM_REMAP, "Memory Remapping" },
{ PROFILER_MEMREAD, "Memory Read" },
{ PROFILER_MEMWRITE, "Memory Write" },
{ PROFILER_VIDEO, "Video Update" },
@ -141,84 +207,77 @@ astring &_profiler_get_text(running_machine *machine, astring &string)
{ PROFILER_PROFILER, "Profiler" },
{ PROFILER_IDLE, "Idle" }
};
UINT64 computed, normalize, total;
int curtype, curmem, switches;
profiler_mark_start(PROFILER_PROFILER);
profiler_scope profile(PROFILER_PROFILER);
/* compute the total time for all bits, not including profiler or idle */
computed = 0;
for (curtype = 0; curtype < PROFILER_PROFILER; curtype++)
for (curmem = 0; curmem < ARRAY_LENGTH(global_profiler.data); curmem++)
computed += global_profiler.data[curmem].duration[curtype];
// compute the total time for all bits, not including profiler or idle
UINT64 computed = 0;
profile_type curtype;
for (curtype = PROFILER_DEVICE_FIRST; curtype < PROFILER_PROFILER; curtype++)
for (int curmem = 0; curmem < ARRAY_LENGTH(m_data); curmem++)
computed += m_data[curmem].duration[curtype];
/* save that result in normalize, and continue adding the rest */
normalize = computed;
// save that result in normalize, and continue adding the rest
UINT64 normalize = computed;
for ( ; curtype < PROFILER_TOTAL; curtype++)
for (curmem = 0; curmem < ARRAY_LENGTH(global_profiler.data); curmem++)
computed += global_profiler.data[curmem].duration[curtype];
for (int curmem = 0; curmem < ARRAY_LENGTH(m_data); curmem++)
computed += m_data[curmem].duration[curtype];
/* this becomes the total; if we end up with 0 for anything, we were just started, so return empty */
total = computed;
// this becomes the total; if we end up with 0 for anything, we were just started, so return empty
UINT64 total = computed;
string.reset();
if (total == 0 || normalize == 0)
goto out;
return string;
/* loop over all types and generate the string */
for (curtype = 0; curtype < PROFILER_TOTAL; curtype++)
// loop over all types and generate the string
for (curtype = PROFILER_DEVICE_FIRST; curtype < PROFILER_TOTAL; curtype++)
{
/* determine the accumulated time for this type */
// determine the accumulated time for this type
computed = 0;
for (curmem = 0; curmem < ARRAY_LENGTH(global_profiler.data); curmem++)
computed += global_profiler.data[curmem].duration[curtype];
for (int curmem = 0; curmem < ARRAY_LENGTH(m_data); curmem++)
computed += m_data[curmem].duration[curtype];
/* if we have non-zero data and we're ready to display, do it */
if (global_profiler.dataready && computed != 0)
// if we have non-zero data and we're ready to display, do it
if (m_dataready && computed != 0)
{
int nameindex;
/* start with the un-normalized percentage */
// start with the un-normalized percentage
string.catprintf("%02d%% ", (int)((computed * 100 + total/2) / total));
/* followed by the normalized percentage for everything but profiler and idle */
// followed by the normalized percentage for everything but profiler and idle
if (curtype < PROFILER_PROFILER)
string.catprintf("%02d%% ", (int)((computed * 100 + normalize/2) / normalize));
/* and then the text */
// and then the text
if (curtype >= PROFILER_DEVICE_FIRST && curtype <= PROFILER_DEVICE_MAX)
string.catprintf("'%s'", machine->m_devicelist.find(curtype - PROFILER_DEVICE_FIRST)->tag());
string.catprintf("'%s'", machine.m_devicelist.find(curtype - PROFILER_DEVICE_FIRST)->tag());
else
for (nameindex = 0; nameindex < ARRAY_LENGTH(names); nameindex++)
for (int nameindex = 0; nameindex < ARRAY_LENGTH(names); nameindex++)
if (names[nameindex].type == curtype)
{
string.cat(names[nameindex].string);
break;
}
/* followed by a carriage return */
// followed by a carriage return
string.cat("\n");
}
}
/* followed by context switches */
if (global_profiler.dataready)
// followed by context switches
if (m_dataready)
{
switches = 0;
for (curmem = 0; curmem < ARRAY_LENGTH(global_profiler.data); curmem++)
switches += global_profiler.data[curmem].context_switches;
string.catprintf("%d CPU switches\n", switches / (int) ARRAY_LENGTH(global_profiler.data));
int switches = 0;
for (int curmem = 0; curmem < ARRAY_LENGTH(m_data); curmem++)
switches += m_data[curmem].context_switches;
string.catprintf("%d CPU switches\n", switches / (int) ARRAY_LENGTH(m_data));
}
/* advance to the next dataset and reset it to 0 */
global_profiler.dataindex = (global_profiler.dataindex + 1) % ARRAY_LENGTH(global_profiler.data);
memset(&global_profiler.data[global_profiler.dataindex], 0, sizeof(global_profiler.data[global_profiler.dataindex]));
/* we are ready once we have wrapped around */
if (global_profiler.dataindex == 0)
global_profiler.dataready = TRUE;
out:
profiler_mark_end();
// advance to the next dataset and reset it to 0
m_dataindex = (m_dataindex + 1) % ARRAY_LENGTH(m_data);
memset(&m_data[m_dataindex], 0, sizeof(m_data[m_dataindex]));
// we are ready once we have wrapped around
if (m_dataindex == 0)
m_dataready = true;
return string;
}

View File

@ -4,16 +4,47 @@
Functions to manage profiling of MAME execution.
Copyright Nicola Salmoria and the MAME Team.
Visit http://mamedev.org for licensing and usage restrictions.
****************************************************************************
Copyright Aaron Giles
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name 'MAME' nor the names of its contributors may be
used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
****************************************************************************
To start profiling a certain section, e.g. video:
profiler_mark_start(PROFILER_VIDEO);
Profiling is scope-based. To start profiling, put a profiler_scope
object on the stack. To end profiling, just end the scope:
to end profiling the current section:
profiler_mark_end();
{
profiler_scope scope(PROFILER_VIDEO);
your_work_here();
}
the profiler handles a FILO list so calls may be nested.
@ -26,16 +57,16 @@
/***************************************************************************
CONSTANTS
***************************************************************************/
//**************************************************************************
// CONSTANTS
//**************************************************************************
/* profiling */
enum
enum profile_type
{
PROFILER_DEVICE_FIRST = 0,
PROFILER_DEVICE_MAX = PROFILER_DEVICE_FIRST + 256,
PROFILER_DRC_COMPILE,
PROFILER_MEM_REMAP,
PROFILER_MEMREAD,
PROFILER_MEMWRITE,
PROFILER_VIDEO,
@ -47,13 +78,13 @@ enum
PROFILER_BLIT,
PROFILER_SOUND,
PROFILER_TIMER_CALLBACK,
PROFILER_INPUT, /* input.c and inptport.c */
PROFILER_MOVIE_REC, /* movie recording */
PROFILER_LOGERROR, /* logerror */
PROFILER_EXTRA, /* everything else */
PROFILER_INPUT, // input.c and inptport.c
PROFILER_MOVIE_REC, // movie recording
PROFILER_LOGERROR, // logerror
PROFILER_EXTRA, // everything else
/* the USER types are available to driver writers to profile */
/* custom sections of the code */
// the USER types are available to driver writers to profile
// custom sections of the code
PROFILER_USER1,
PROFILER_USER2,
PROFILER_USER3,
@ -67,89 +98,111 @@ enum
PROFILER_IDLE,
PROFILER_TOTAL
};
DECLARE_ENUM_OPERATORS(profile_type);
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
typedef struct _profiler_filo_entry profiler_filo_entry;
struct _profiler_filo_entry
// ======================> real_profiler_state
class real_profiler_state
{
int type; /* type of entry */
osd_ticks_t start; /* start time */
friend class profile_scope;
public:
// construction/destruction
real_profiler_state();
// getters
bool enabled() const { return m_enabled; }
const char *text(running_machine &machine, astring &string);
// enable/disable
void enable(bool state = true)
{
if (state != m_enabled)
{
m_enabled = state;
if (m_enabled)
{
m_dataready = false;
m_filoindex = m_dataindex = 0;
}
}
}
// start/stop
void start(profile_type type) { if (m_enabled) real_start(type); }
void stop() { if (m_enabled) real_stop(); }
private:
void real_start(profile_type type);
void real_stop();
// an entry in the FILO
struct filo_entry
{
int type; // type of entry
osd_ticks_t start; // start time
};
// item in the array of recent states
struct history_data
{
UINT32 context_switches; // number of context switches seen
osd_ticks_t duration[PROFILER_TOTAL]; // duration spent in each entry
};
// internal state
bool m_enabled; // are we enabled?
bool m_dataready; // are we to display the data yet?
UINT8 m_filoindex; // current FILO index
UINT8 m_dataindex; // current data index
filo_entry m_filo[16]; // array of FILO entries
history_data m_data[16]; // array of data
};
typedef struct _profiler_data profiler_data;
struct _profiler_data
// ======================> dummy_profiler_state
class dummy_profiler_state
{
UINT32 context_switches; /* number of context switches seen */
osd_ticks_t duration[PROFILER_TOTAL]; /* duration spent in each entry */
public:
// construction/destruction
dummy_profiler_state();
// getters
bool enabled() const { return false; }
const char *text(running_machine &machine, astring &string) { return string.cpy(""); }
// enable/disable
void enable(bool state = true) { }
// start/stop
void start(profile_type type) { }
void stop() { }
};
typedef struct _profiler_state profiler_state;
struct _profiler_state
{
UINT8 enabled; /* are we enabled? */
UINT8 filoindex; /* current FILO index */
UINT8 dataindex; /* current data index */
UINT8 dataready; /* are we to display the data yet? */
profiler_filo_entry filo[16]; /* array of FILO entries */
profiler_data data[16]; /* array of data */
};
/***************************************************************************
GLOBAL VARIABLES
***************************************************************************/
extern profiler_state global_profiler;
/***************************************************************************
MACROS
***************************************************************************/
// ======================> profiler_state
#ifdef MAME_PROFILER
#define profiler_mark_start(x) do { if (global_profiler.enabled) _profiler_mark_start(x); } while (0)
#define profiler_mark_end() do { if (global_profiler.enabled) _profiler_mark_end(); } while (0)
#define profiler_start() do { global_profiler.enabled = TRUE; global_profiler.filoindex = global_profiler.dataindex = global_profiler.dataready = 0; } while (0)
#define profiler_stop() do { global_profiler.enabled = FALSE; } while (0)
#define profiler_get_text(x,s) _profiler_get_text(x, s)
typedef real_profiler_state profiler_state;
#else
#define profiler_mark_start(x) do { } while (0)
#define profiler_mark_end() do { } while (0)
#define profiler_start() do { } while (0)
#define profiler_stop() do { } while (0)
#define profiler_get_text(x,s) (s).reset()
typedef dummy_profiler_state profiler_state;
#endif
/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
/* ----- core functions (do not call directly; use macros) ----- */
/* mark the beginning of a profiler entry */
void _profiler_mark_start(int type);
/* mark the end of a profiler entry */
void _profiler_mark_end(void);
/* return the current text in an astring */
astring &_profiler_get_text(running_machine *machine, astring &string);
extern profiler_state g_profiler;
#endif /* __PROFILER_H__ */

View File

@ -180,7 +180,7 @@ if (TEMPLOG)
// if we're not suspended, actually execute
if (exec->m_suspend == 0)
{
profiler_mark_start(exec->m_profiler);
g_profiler.start(exec->m_profiler);
// note that this global variable cycles_stolen can be modified
// via the call to cpu_execute
@ -202,7 +202,7 @@ if (TEMPLOG) printf("Executing %s for %d cycles\n", exec->device().tag(), ran);
ran -= *exec->m_icount;
assert(ran >= exec->m_cycles_stolen);
ran -= exec->m_cycles_stolen;
profiler_mark_end();
g_profiler.stop();
}
else
if (TEMPLOG) printf("Skipping %s for %d cycles\n", exec->device().tag(), ran);

View File

@ -404,7 +404,7 @@ static TIMER_CALLBACK( sound_update )
VPRINTF(("sound_update\n"));
profiler_mark_start(PROFILER_SOUND);
g_profiler.start(PROFILER_SOUND);
leftmix = global->leftmix;
rightmix = global->rightmix;
@ -452,7 +452,7 @@ static TIMER_CALLBACK( sound_update )
/* update the streamer */
streams_update(machine);
profiler_mark_end();
g_profiler.stop();
}

View File

@ -508,11 +508,11 @@ void stream_update(sound_stream *stream)
INT32 update_sampindex = time_to_sampindex(strdata, stream, timer_get_time(machine));
/* generate samples to get us up to the appropriate time */
profiler_mark_start(PROFILER_SOUND);
g_profiler.start(PROFILER_SOUND);
assert(stream->output_sampindex - stream->output_base_sampindex >= 0);
assert(update_sampindex - stream->output_base_sampindex <= stream->output_bufalloc);
generate_samples(stream, update_sampindex - stream->output_sampindex);
profiler_mark_end();
g_profiler.stop();
/* remember this info for next time */
stream->output_sampindex = update_sampindex;

View File

@ -824,7 +824,7 @@ void tilemap_draw_primask(bitmap_t *dest, const rectangle *cliprect, tilemap_t *
if (!tmap->enable)
return;
profiler_mark_start(PROFILER_TILEMAP_DRAW);
g_profiler.start(PROFILER_TILEMAP_DRAW);
/* configure the blit parameters based on the input parameters */
configure_blit_parameters(&blit, tmap, dest, cliprect, flags, priority, priority_mask);
@ -927,7 +927,7 @@ profiler_mark_start(PROFILER_TILEMAP_DRAW);
}
}
}
profiler_mark_end();
g_profiler.stop();
}
@ -962,7 +962,7 @@ void tilemap_draw_roz_primask(bitmap_t *dest, const rectangle *cliprect, tilemap
return;
}
profiler_mark_start(PROFILER_TILEMAP_DRAW_ROZ);
g_profiler.start(PROFILER_TILEMAP_DRAW_ROZ);
/* configure the blit parameters */
configure_blit_parameters(&blit, tmap, dest, cliprect, flags, priority, priority_mask);
@ -971,7 +971,7 @@ profiler_mark_start(PROFILER_TILEMAP_DRAW_ROZ);
/* then do the roz copy */
tilemap_draw_roz_core(tmap, &blit, startx, starty, incxx, incxy, incyx, incyy, wraparound);
profiler_mark_end();
g_profiler.stop();
}
@ -1274,7 +1274,7 @@ static void pixmap_update(tilemap_t *tmap, const rectangle *cliprect)
if (tmap->all_tiles_clean)
return;
profiler_mark_start(PROFILER_TILEMAP_DRAW);
g_profiler.start(PROFILER_TILEMAP_DRAW);
/* compute which columns and rows to update */
if (cliprect != NULL)
@ -1314,7 +1314,7 @@ profiler_mark_start(PROFILER_TILEMAP_DRAW);
if (mincol == 0 && minrow == 0 && maxcol == tmap->cols - 1 && maxcol == tmap->rows - 1)
tmap->all_tiles_clean = TRUE;
profiler_mark_end();
g_profiler.stop();
}
@ -1329,7 +1329,7 @@ static void tile_update(tilemap_t *tmap, tilemap_logical_index logindex, UINT32
tilemap_memory_index memindex;
UINT32 flags;
profiler_mark_start(PROFILER_TILEMAP_UPDATE);
g_profiler.start(PROFILER_TILEMAP_UPDATE);
/* call the get info callback for the associated memory index */
memindex = tmap->logical_to_memory[logindex];
@ -1353,7 +1353,7 @@ profiler_mark_start(PROFILER_TILEMAP_UPDATE);
tmap->gfx_dirtyseq[tmap->tileinfo.gfxnum] = tmap->machine->gfx[tmap->tileinfo.gfxnum]->dirtyseq;
}
profiler_mark_end();
g_profiler.stop();
}

View File

@ -371,9 +371,9 @@ void timer_execute_timers(running_machine *machine)
if (was_enabled && timer->callback != NULL)
{
LOG(("Timer %s:%d[%s] fired (expire=%s)\n", timer->file, timer->line, timer->func, attotime_string(timer->expire, 9)));
profiler_mark_start(PROFILER_TIMER_CALLBACK);
g_profiler.start(PROFILER_TIMER_CALLBACK);
(*timer->callback)(machine, timer->ptr, timer->param);
profiler_mark_end();
g_profiler.stop();
}
/* clear the callback timer global */

View File

@ -822,16 +822,8 @@ int ui_get_show_fps(void)
void ui_set_show_profiler(int show)
{
if (show)
{
show_profiler = TRUE;
profiler_start();
}
else
{
show_profiler = FALSE;
profiler_stop();
}
show_profiler = show;
g_profiler.enable(show);
}
@ -1302,7 +1294,7 @@ static UINT32 handler_ingame(running_machine *machine, render_container *contain
if (show_profiler)
{
astring profilertext;
profiler_get_text(machine, profilertext);
g_profiler.text(*machine, profilertext);
ui_draw_text_full(container, profilertext, 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL);
}

View File

@ -255,7 +255,7 @@ int ui_input_pressed_repeat(running_machine *machine, int code, int speed)
ui_input_private *uidata = machine->ui_input_data;
int pressed = FALSE;
profiler_mark_start(PROFILER_INPUT);
g_profiler.start(PROFILER_INPUT);
/* get the status of this key (assumed to be only in the defaults) */
assert(code >= IPT_UI_CONFIGURE && code <= IPT_OSD_16);
@ -283,7 +283,7 @@ profiler_mark_start(PROFILER_INPUT);
else
uidata->next_repeat[code] = 0;
profiler_mark_end();
g_profiler.stop();
return pressed;
}

View File

@ -461,9 +461,9 @@ void video_frame_update(running_machine *machine, int debug)
update_throttle(machine, current_time);
/* ask the OSD to update */
profiler_mark_start(PROFILER_BLIT);
g_profiler.start(PROFILER_BLIT);
osd_update(machine, !debug && skipped_it);
profiler_mark_end();
g_profiler.stop();
/* perform tasks for this frame */
if (!debug)
@ -487,9 +487,9 @@ void video_frame_update(running_machine *machine, int debug)
/* otherwise, call the video EOF callback */
else if (machine->config->m_video_eof != NULL)
{
profiler_mark_start(PROFILER_VIDEO);
g_profiler.start(PROFILER_VIDEO);
(*machine->config->m_video_eof)(machine);
profiler_mark_end();
g_profiler.stop();
}
}
}
@ -882,7 +882,7 @@ static osd_ticks_t throttle_until_ticks(running_machine *machine, osd_ticks_t ta
allowed_to_sleep = TRUE;
/* loop until we reach our target */
profiler_mark_start(PROFILER_IDLE);
g_profiler.start(PROFILER_IDLE);
while (current_ticks < target_ticks)
{
osd_ticks_t delta;
@ -920,7 +920,7 @@ static osd_ticks_t throttle_until_ticks(running_machine *machine, osd_ticks_t ta
}
current_ticks = new_ticks;
}
profiler_mark_end();
g_profiler.stop();
return current_ticks;
}
@ -1370,7 +1370,7 @@ static void video_mng_record_frame(running_machine *machine)
png_info pnginfo = { 0 };
png_error error;
profiler_mark_start(PROFILER_MOVIE_REC);
g_profiler.start(PROFILER_MOVIE_REC);
/* create the bitmap */
create_snapshot_bitmap(NULL);
@ -1406,7 +1406,7 @@ static void video_mng_record_frame(running_machine *machine)
global.movie_frame++;
}
profiler_mark_end();
g_profiler.stop();
}
}
@ -1505,7 +1505,7 @@ static void video_avi_record_frame(running_machine *machine)
attotime curtime = timer_get_time(machine);
avi_error avierr;
profiler_mark_start(PROFILER_MOVIE_REC);
g_profiler.start(PROFILER_MOVIE_REC);
/* create the bitmap */
create_snapshot_bitmap(NULL);
@ -1526,7 +1526,7 @@ static void video_avi_record_frame(running_machine *machine)
global.movie_frame++;
}
profiler_mark_end();
g_profiler.stop();
}
}
@ -1543,7 +1543,7 @@ void video_avi_add_sound(running_machine *machine, const INT16 *sound, int numsa
{
avi_error avierr;
profiler_mark_start(PROFILER_MOVIE_REC);
g_profiler.start(PROFILER_MOVIE_REC);
/* write the next frame */
avierr = avi_append_sound_samples(global.avifile, 0, sound + 0, numsamples, 1);
@ -1552,7 +1552,7 @@ void video_avi_add_sound(running_machine *machine, const INT16 *sound, int numsa
if (avierr != AVIERR_NONE)
video_avi_end_recording(machine);
profiler_mark_end();
g_profiler.stop();
}
}
@ -2118,13 +2118,13 @@ bool screen_device::update_partial(int scanline)
{
UINT32 flags = UPDATE_HAS_NOT_CHANGED;
profiler_mark_start(PROFILER_VIDEO);
g_profiler.start(PROFILER_VIDEO);
LOG_PARTIAL_UPDATES(("updating %d-%d\n", clip.min_y, clip.max_y));
if (machine->config->m_video_update != NULL)
flags = (*machine->config->m_video_update)(this, m_bitmap[m_curbitmap], &clip);
global.partial_updates_this_frame++;
profiler_mark_end();
g_profiler.stop();
// if we modified the bitmap, we have to commit
m_changed |= ~flags & UPDATE_HAS_NOT_CHANGED;

View File

@ -3417,7 +3417,7 @@ WRITE32_DEVICE_HANDLER( voodoo_w )
voodoo_state *v = get_safe_token(device);
int stall = FALSE;
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
/* should not be getting accesses while stalled */
if (v->pci.stall_state != NOT_STALLED)
@ -3445,7 +3445,7 @@ WRITE32_DEVICE_HANDLER( voodoo_w )
if (offset & 0x40000/4)
data = FLIPENDIAN_INT32(data);
cmdfifo_w(v, &v->fbi.cmdfifo[0], offset & 0xffff, data);
profiler_mark_end();
g_profiler.stop();
return;
}
@ -3458,7 +3458,7 @@ WRITE32_DEVICE_HANDLER( voodoo_w )
v->fbi.swaps_pending++;
logerror("Ignoring write to %s in CMDFIFO mode\n", v->regnames[offset & 0xff]);
profiler_mark_end();
g_profiler.stop();
return;
}
}
@ -3475,7 +3475,7 @@ WRITE32_DEVICE_HANDLER( voodoo_w )
/* ignore if writes aren't allowed */
if (!(access & REGISTER_WRITE))
{
profiler_mark_end();
g_profiler.stop();
return;
}
@ -3511,7 +3511,7 @@ WRITE32_DEVICE_HANDLER( voodoo_w )
timer_get_time(device->machine).seconds, (UINT32)(timer_get_time(device->machine).attoseconds >> 32), (UINT32)timer_get_time(device->machine).attoseconds,
v->pci.op_end_time.seconds, (UINT32)(v->pci.op_end_time.attoseconds >> 32), (UINT32)v->pci.op_end_time.attoseconds);
}
profiler_mark_end();
g_profiler.stop();
return;
}
@ -3577,7 +3577,7 @@ WRITE32_DEVICE_HANDLER( voodoo_w )
stall_cpu(v, STALLED_UNTIL_FIFO_EMPTY, timer_get_time(device->machine));
}
profiler_mark_end();
g_profiler.stop();
}
@ -4788,7 +4788,7 @@ static INT32 triangle(voodoo_state *v)
int destbuf;
int pixels;
profiler_mark_start(PROFILER_USER2);
g_profiler.start(PROFILER_USER2);
/* determine the number of TMUs involved */
texcount = 0;
@ -4859,7 +4859,7 @@ static INT32 triangle(voodoo_state *v)
/* update stats */
v->stats.total_triangles++;
profiler_mark_end();
g_profiler.stop();
/* 1 pixel per clock, plus some setup time */
if (LOG_REGISTERS) logerror("cycles = %d\n", TRIANGLE_SETUP_CLOCKS + pixels);

View File

@ -698,7 +698,7 @@ static void blitter_w( address_space *space, int blitter, offs_t offset, UINT8 d
dynax_state *state = space->machine->driver_data<dynax_state>();
int hi_bits;
profiler_mark_start(PROFILER_VIDEO);
g_profiler.start(PROFILER_VIDEO);
switch (offset)
{
@ -849,7 +849,7 @@ profiler_mark_start(PROFILER_VIDEO);
}
}
profiler_mark_end();
g_profiler.stop();
}
@ -861,7 +861,7 @@ static void blitter_w_funkyfig( running_machine *machine, int blitter, offs_t of
dynax_state *state = machine->driver_data<dynax_state>();
int hi_bits;
profiler_mark_start(PROFILER_VIDEO);
g_profiler.start(PROFILER_VIDEO);
switch(offset)
{
@ -1007,7 +1007,7 @@ profiler_mark_start(PROFILER_VIDEO);
}
}
profiler_mark_end();
g_profiler.stop();
}
@ -1025,7 +1025,7 @@ static WRITE8_HANDLER( hanakanz_blitter_data_w )
dynax_state *state = space->machine->driver_data<dynax_state>();
int hi_bits;
profiler_mark_start(PROFILER_VIDEO);
g_profiler.start(PROFILER_VIDEO);
hi_bits = (state->ddenlovr_blit_latch & 0x03) << 8;
@ -1207,7 +1207,7 @@ profiler_mark_start(PROFILER_VIDEO);
break;
}
profiler_mark_end();
g_profiler.stop();
}

View File

@ -588,7 +588,7 @@ static void irmb_run(running_machine *machine)
UINT32 SP = 0;
UINT32 icount = 0;
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
while ((prevop->flags & (FL_DPSEL | FL_carry)) != (FL_DPSEL | FL_carry))
{
@ -841,7 +841,7 @@ default: case 0x3f: IXOR(irmb_din(curop), 0); break;
irmb_latch = Y;
}
}
profiler_mark_end();
g_profiler.stop();
logerror("%d instructions for Mathbox \n", icount);

View File

@ -764,9 +764,9 @@ WRITE32_DEVICE_HANDLER( n64_dp_reg_w )
case 0x04/4: // DP_END_REG
state->m_rdp.SetEndReg(data);
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
state->m_rdp.ProcessList();
profiler_mark_end();
g_profiler.stop();
break;
case 0x0c/4: // DP_STATUS_REG

View File

@ -200,7 +200,7 @@ static void execute_blit(running_machine *machine)
}
#endif
profiler_mark_start(PROFILER_VIDEO);
g_profiler.start(PROFILER_VIDEO);
last = 0;
sy = y;
@ -305,7 +305,7 @@ static void execute_blit(running_machine *machine)
offset += w/4;
}
profiler_mark_end();
g_profiler.stop();
#if (!INSTANT_BLIT)
blitter_busy_until = attotime_add(timer_get_time(machine), ATTOTIME_IN_NSEC(w*h*20));

View File

@ -170,7 +170,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect
int offs;
const UINT8 *gfx;
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
gfx = memory_region(machine, "gfx2");
for (offs = 0; offs < state->spriteram_size; offs += 4)
@ -232,7 +232,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect
}
}
profiler_mark_end();
g_profiler.stop();
}

View File

@ -1075,7 +1075,7 @@ WRITE64_HANDLER( pvr_ta_w )
}
break;
case STARTRENDER:
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
#if DEBUG_PVRTA
mame_printf_verbose("Start Render Received:\n");
mame_printf_verbose(" Region Array at %08x\n",pvrta_regs[REGION_BASE]);
@ -1237,7 +1237,7 @@ WRITE64_HANDLER( pvr_ta_w )
state_ta.grab[state_ta.grabsel].verts_size=0;
state_ta.grab[state_ta.grabsel].strips_size=0;
profiler_mark_end();
g_profiler.stop();
}
break;
//#define TA_YUV_TEX_BASE ((0x005f8148-0x005f8000)/4)

View File

@ -1004,7 +1004,7 @@ static void hng64_tilemap_draw_roz_primask(running_machine* machine, bitmap_t *d
//if (!tmap->enable)
// return;
profiler_mark_start(PROFILER_TILEMAP_DRAW_ROZ);
g_profiler.start(PROFILER_TILEMAP_DRAW_ROZ);
/* configure the blit parameters */
hng64_configure_blit_parameters(&blit, tmap, dest, cliprect, flags, priority, priority_mask, drawformat);
@ -1013,7 +1013,7 @@ profiler_mark_start(PROFILER_TILEMAP_DRAW_ROZ);
/* then do the roz copy */
hng64_tilemap_draw_roz_core(machine, tmap, &blit, startx, starty, incxx, incxy, incyx, incyy, wraparound);
profiler_mark_end();
g_profiler.stop();
}

View File

@ -1202,7 +1202,7 @@ static void handle_video_command(running_machine *machine)
{
/* command 1: blit raw data */
case 1:
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
if (BLIT_LOGGING) logblit(machine, "Blit Raw");
if (is_drivedge)
@ -1215,18 +1215,18 @@ static void handle_video_command(running_machine *machine)
if (enable_latch[1]) draw_raw(videoplane[1], color_latch[1]);
}
profiler_mark_end();
g_profiler.stop();
break;
/* command 2: blit RLE-compressed data */
case 2:
profiler_mark_start(PROFILER_USER2);
g_profiler.start(PROFILER_USER2);
if (BLIT_LOGGING) logblit(machine, "Blit RLE");
if (enable_latch[0]) draw_rle(videoplane[0], color_latch[0]);
if (enable_latch[1]) draw_rle(videoplane[1], color_latch[1]);
profiler_mark_end();
g_profiler.stop();
break;
/* command 3: set up raw data transfer */
@ -1248,7 +1248,7 @@ static void handle_video_command(running_machine *machine)
/* command 6: perform shift register copy */
case 6:
profiler_mark_start(PROFILER_USER3);
g_profiler.start(PROFILER_USER3);
if (BLIT_LOGGING) logblit(machine, "ShiftReg");
if (is_drivedge)
@ -1261,7 +1261,7 @@ static void handle_video_command(running_machine *machine)
if (enable_latch[1]) shiftreg_clear(videoplane[1], NULL);
}
profiler_mark_end();
g_profiler.stop();
break;
default:

View File

@ -511,7 +511,7 @@ static void blitter_run(running_machine *machine)
UINT32 a1flags = blitter_regs[A1_FLAGS] & STATIC_FLAGS_MASK;
UINT32 a2flags = blitter_regs[A2_FLAGS] & STATIC_FLAGS_MASK;
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
if (a1flags == a2flags)
{
@ -600,7 +600,7 @@ if (++reps % 100 == 99)
}
generic_blitter(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
profiler_mark_end();
g_profiler.stop();
}
static TIMER_CALLBACK( blitter_done )

View File

@ -241,12 +241,12 @@ VIDEO_UPDATE( mcatadv )
mcatadv_draw_tilemap_part(state->scroll2, state->videoram2, i, state->tilemap2, bitmap, cliprect);
}
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
#ifdef MAME_DEBUG
if (!input_code_pressed(screen->machine, KEYCODE_E))
#endif
draw_sprites (screen->machine, bitmap, cliprect);
profiler_mark_end();
g_profiler.stop();
return 0;
}

View File

@ -687,7 +687,7 @@ WRITE16_HANDLER( midtunit_dma_w )
if (!(command & 0x8000))
return;
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
/* determine bpp */
bpp = (command >> 12) & 7;
@ -795,7 +795,7 @@ if (LOG_DMA)
skipdma:
timer_set(space->machine, ATTOTIME_IN_NSEC(41 * pixels), NULL, 0, dma_callback);
profiler_mark_end();
g_profiler.stop();
}

View File

@ -469,7 +469,7 @@ if (LOG_DMA)
}
}
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
/* fill in the basic data */
dma_state.rowbytes = (INT16)dma_register[DMA_ROWBYTES];
@ -541,7 +541,7 @@ if (LOG_DMA)
/* signal we're done */
timer_set(space->machine, ATTOTIME_IN_NSEC(41 * dma_state.width * dma_state.height), NULL, 0, dma_callback);
profiler_mark_end();
g_profiler.stop();
}

View File

@ -717,7 +717,7 @@ static void render_scanline( running_device *device )
int *ppu_regs = &ppu2c0x->regs[0];
/* lets see how long it takes */
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
/* clear the line priority for this scanline */
memset(line_priority, 0, VISIBLE_SCREEN_WIDTH);
@ -751,7 +751,7 @@ static void render_scanline( running_device *device )
draw_sprites(device, line_priority);
/* done updating, whew */
profiler_mark_end();
g_profiler.stop();
}
static void update_scanline( running_device *device )

View File

@ -438,14 +438,14 @@ static void draw_bglayerscroll( running_machine *machine, int layer, bitmap_t *b
cache_bitmap(tilemap_scanline, state, gfx, size, tilebank, alpha, last_bank);
/* zoomy and 'wibbly' effects - extract an entire row from tilemap */
profiler_mark_start(PROFILER_USER2);
g_profiler.start(PROFILER_USER2);
UINT32 tilemap_line[32 * 16];
UINT32 scr_line[64 * 8];
extract_scanline32(state->bg_bitmap, 0, tilemap_scanline, width, tilemap_line);
profiler_mark_end();
g_profiler.stop();
/* slow bit, needs optimising. apply scrollx and zoomx by assembling scanline from row */
profiler_mark_start(PROFILER_USER3);
g_profiler.start(PROFILER_USER3);
if(zoom) {
int step = state->bg_zoom[zoom];
int jj = 0x400 << 10; // ensure +ve for mod
@ -459,10 +459,10 @@ static void draw_bglayerscroll( running_machine *machine, int layer, bitmap_t *b
scr_line[ii] = tilemap_line[(ii - scrollx + 0x400) % width];
}
}
profiler_mark_end();
g_profiler.stop();
/* blend line into output */
profiler_mark_start(PROFILER_USER4);
g_profiler.start(PROFILER_USER4);
if(alpha == 0xff) {
draw_scanline32_transpen(bitmap, 0, scanline, scr_width, scr_line);
}
@ -472,7 +472,7 @@ static void draw_bglayerscroll( running_machine *machine, int layer, bitmap_t *b
else if (alpha < 0) {
draw_scanline32_argb(bitmap, 0, scanline, scr_width, scr_line);
}
profiler_mark_end();
g_profiler.stop();
}
}
@ -542,7 +542,7 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
if (!zoomx || !zoomy)
return;
profiler_mark_start(PROFILER_DRAWGFX);
g_profiler.start(PROFILER_DRAWGFX);
assert(dest_bmp->bpp == 32);
@ -1065,7 +1065,7 @@ static void psikyosh_drawgfxzoom( running_machine *machine,
}
}
}
profiler_mark_end();
g_profiler.stop();
}
@ -1203,7 +1203,7 @@ static void psikyosh_prelineblend( running_machine *machine, bitmap_t *bitmap, c
assert(bitmap->bpp == 32);
profiler_mark_start(PROFILER_USER8);
g_profiler.start(PROFILER_USER8);
for (y = cliprect->min_y; y <= cliprect->max_y; y += 1) {
dstline = BITMAP_ADDR32(bitmap, y, 0);
@ -1212,7 +1212,7 @@ static void psikyosh_prelineblend( running_machine *machine, bitmap_t *bitmap, c
for (x = cliprect->min_x; x <= cliprect->max_x; x += 1)
dstline[x] = linefill[y] >> 8;
}
profiler_mark_end();
g_profiler.stop();
}
@ -1231,7 +1231,7 @@ static void psikyosh_postlineblend( running_machine *machine, bitmap_t *bitmap,
return;
}
profiler_mark_start(PROFILER_USER8);
g_profiler.start(PROFILER_USER8);
for (y = cliprect->min_y; y <= cliprect->max_y; y += 1) {
dstline = BITMAP_ADDR32(bitmap, y, 0);
@ -1247,7 +1247,7 @@ static void psikyosh_postlineblend( running_machine *machine, bitmap_t *bitmap,
dstline[x] = alpha_blend_r32(dstline[x], lineblend[y] >> 8, 2 * (lineblend[y] & 0x7f));
}
}
profiler_mark_end();
g_profiler.stop();
}

View File

@ -1900,7 +1900,7 @@ static void sprite_render_list(running_machine *machine)
int spritenum = 0;
UINT16 *sprite;
profiler_mark_start(PROFILER_USER2);
g_profiler.start(PROFILER_USER2);
logerror("----\n");
@ -1971,7 +1971,7 @@ static void sprite_render_list(running_machine *machine)
}
}
profiler_mark_end();
g_profiler.stop();
}
@ -2460,9 +2460,9 @@ VIDEO_UPDATE( system32 )
}
/* update the tilemaps */
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
enablemask = update_tilemaps(*screen, cliprect);
profiler_mark_end();
g_profiler.stop();
/* debugging */
#if QWERTY_LAYER_ENABLE
@ -2475,9 +2475,9 @@ VIDEO_UPDATE( system32 )
#endif
/* do the mixing */
profiler_mark_start(PROFILER_USER3);
g_profiler.start(PROFILER_USER3);
mix_all_layers(0, 0, bitmap, cliprect, enablemask);
profiler_mark_end();
g_profiler.stop();
if (LOG_SPRITES && input_code_pressed(screen->machine, KEYCODE_L))
{
@ -2640,9 +2640,9 @@ VIDEO_UPDATE( multi32 )
}
/* update the tilemaps */
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
enablemask = update_tilemaps(*screen, cliprect);
profiler_mark_end();
g_profiler.stop();
/* debugging */
#if QWERTY_LAYER_ENABLE
@ -2655,9 +2655,9 @@ VIDEO_UPDATE( multi32 )
#endif
/* do the mixing */
profiler_mark_start(PROFILER_USER3);
g_profiler.start(PROFILER_USER3);
mix_all_layers(((screen == left_screen) ? 0 : 1), 0, bitmap, cliprect, enablemask);
profiler_mark_end();
g_profiler.stop();
if (PRINTF_MIXER_DATA)
{

View File

@ -116,7 +116,7 @@ WRITE16_HANDLER( shangha3_blitter_go_w )
int offs;
profiler_mark_start(PROFILER_VIDEO);
g_profiler.start(PROFILER_VIDEO);
for (offs = gfxlist_addr << 3;offs < shangha3_ram_size/2;offs += 16)
{
@ -259,7 +259,7 @@ else
}
}
profiler_mark_end();
g_profiler.stop();
}

View File

@ -1508,7 +1508,7 @@ static void snes_refresh_scanline( running_machine *machine, bitmap_t *bitmap, U
UINT16 prev_colour = 0;
int blurring = input_port_read_safe(machine, "OPTIONS", 0) & 0x01;
profiler_mark_start(PROFILER_VIDEO);
g_profiler.start(PROFILER_VIDEO);
if (snes_ppu.screen_disabled) /* screen is forced blank */
for (x = 0; x < SNES_SCR_WIDTH * 2; x++)
@ -1556,7 +1556,7 @@ static void snes_refresh_scanline( running_machine *machine, bitmap_t *bitmap, U
#ifdef SNES_LAYER_DEBUG
if (snes_dbg_video(machine, curline))
{
profiler_mark_end();
g_profiler.stop();
return;
}
@ -1654,7 +1654,7 @@ static void snes_refresh_scanline( running_machine *machine, bitmap_t *bitmap, U
}
}
profiler_mark_end();
g_profiler.stop();
}
VIDEO_START( snes )

View File

@ -4912,7 +4912,7 @@ static void stv_vdp2_draw_rotation_screen(running_machine *machine, bitmap_t *bi
stv2_current_tilemap.window_control = 0;
fade_control = stv2_current_tilemap.fade_control;
stv2_current_tilemap.fade_control = 0;
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
if ( LOG_VDP2 ) logerror( "Checking for cached RBG bitmap, cache_dirty = %d, memcmp() = %d\n", stv_rbg_cache_data.is_cache_dirty, memcmp(&stv_rbg_cache_data.layer_data[iRP-1],&stv2_current_tilemap,sizeof(stv2_current_tilemap)));
if ( (stv_rbg_cache_data.is_cache_dirty & iRP) ||
memcmp(&stv_rbg_cache_data.layer_data[iRP-1],&stv2_current_tilemap,sizeof(stv2_current_tilemap)) != 0 )
@ -4931,7 +4931,7 @@ static void stv_vdp2_draw_rotation_screen(running_machine *machine, bitmap_t *bi
stv_rbg_cache_data.map_offset_max[iRP-1], stv_rbg_cache_data.tile_offset_min[iRP-1], stv_rbg_cache_data.tile_offset_max[iRP-1] );
}
profiler_mark_end();
g_profiler.stop();
stv2_current_tilemap.colour_calculation_enabled = colour_calculation_enabled;
if ( colour_calculation_enabled )
@ -4952,9 +4952,9 @@ static void stv_vdp2_draw_rotation_screen(running_machine *machine, bitmap_t *bi
stv2_current_tilemap.fade_control = fade_control;
profiler_mark_start(PROFILER_USER2);
g_profiler.start(PROFILER_USER2);
stv_vdp2_copy_roz_bitmap(bitmap, stv_vdp2_roz_bitmap[iRP-1], &mycliprect, iRP, planesizex, planesizey, planerenderedsizex, planerenderedsizey );
profiler_mark_end();
g_profiler.stop();
}
}

View File

@ -258,7 +258,7 @@ static void draw_framebuffer( running_machine *machine, bitmap_t *bitmap, const
UINT8 video_control = tc0180vcu_get_videoctrl(state->tc0180vcu, 0);
UINT8 framebuffer_page = tc0180vcu_get_fb_page(state->tc0180vcu, 0);
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
priority <<= 4;
@ -266,7 +266,7 @@ profiler_mark_start(PROFILER_USER1);
{
if (priority)
{
profiler_mark_end();
g_profiler.stop();
return;
}
@ -352,7 +352,7 @@ profiler_mark_start(PROFILER_USER1);
}
}
}
profiler_mark_end();
g_profiler.stop();
}
VIDEO_UPDATE( taitob )

View File

@ -482,7 +482,7 @@ void vertigo_vproc(int cycles, int irq4)
if (irq4) vector_clear_list();
profiler_mark_start(PROFILER_USER1);
g_profiler.start(PROFILER_USER1);
while (cycles--)
{
@ -658,5 +658,5 @@ void vertigo_vproc(int cycles, int irq4)
}
}
profiler_mark_end();
g_profiler.stop();
}