From 106081e31a042be91e49b1ea1b5d089a60188d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Sat, 9 Mar 2019 03:26:27 +0100 Subject: [PATCH] mame: update patches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andreas Müller --- ...ey_device-m_output-pokey_device-m_ou.patch | 2 +- ...-rework-for-performance-enhancements.patch | 2 +- ...0004-pokey-rework-prescaler-handling.patch | 2 +- ...p_pot-remove-operations-with-no-effe.patch | 61 +++++++++ ...lculation-of-raw-sound-output-after-.patch | 36 +++++ .../0008-pokey-remove-unused-macros.patch | 48 +++++++ ...-yet-another-performance-enhancement.patch | 125 ++++++++++++++++++ recipes-emulators/mame/mame_0207.bb | 5 + 8 files changed, 278 insertions(+), 3 deletions(-) create mode 100644 recipes-emulators/mame/mame/0006-pokey_device-step_pot-remove-operations-with-no-effe.patch create mode 100644 recipes-emulators/mame/mame/0007-pokey-force-recalculation-of-raw-sound-output-after-.patch create mode 100644 recipes-emulators/mame/mame/0008-pokey-remove-unused-macros.patch create mode 100644 recipes-emulators/mame/mame/0009-pokey-yet-another-performance-enhancement.patch diff --git a/recipes-emulators/mame/mame/0002-pokey-rename-pokey_device-m_output-pokey_device-m_ou.patch b/recipes-emulators/mame/mame/0002-pokey-rename-pokey_device-m_output-pokey_device-m_ou.patch index 436e1db..b5e7ba9 100644 --- a/recipes-emulators/mame/mame/0002-pokey-rename-pokey_device-m_output-pokey_device-m_ou.patch +++ b/recipes-emulators/mame/mame/0002-pokey-rename-pokey_device-m_output-pokey_device-m_ou.patch @@ -14,7 +14,7 @@ helpful to understand the code. renaming pokey_device::pokey_channel::m_output was not an option because this would damage stored machine states - right? -Upstream-Status: Submitted [1] +Upstream-Status: Applied [1] [1] https://github.com/mamedev/mame/pull/4702 diff --git a/recipes-emulators/mame/mame/0003-pokey-rework-for-performance-enhancements.patch b/recipes-emulators/mame/mame/0003-pokey-rework-for-performance-enhancements.patch index 5a4c645..5d8bbcc 100644 --- a/recipes-emulators/mame/mame/0003-pokey-rework-for-performance-enhancements.patch +++ b/recipes-emulators/mame/mame/0003-pokey-rework-for-performance-enhancements.patch @@ -40,7 +40,7 @@ The following tests were performed: * starwars, missile-command and marble-madness do not show any audible artefacts -Upstream-Status: Submitted [1] +Upstream-Status: Applied [1] [1] https://github.com/mamedev/mame/pull/4702 diff --git a/recipes-emulators/mame/mame/0004-pokey-rework-prescaler-handling.patch b/recipes-emulators/mame/mame/0004-pokey-rework-prescaler-handling.patch index 1b58ff0..5c2fcf6 100644 --- a/recipes-emulators/mame/mame/0004-pokey-rework-prescaler-handling.patch +++ b/recipes-emulators/mame/mame/0004-pokey-rework-prescaler-handling.patch @@ -16,7 +16,7 @@ Performance test: mame64 -nothrottle starwars Before: Average speed: 409.36% (21 seconds) After: Average speed: 447.37% (21 seconds) -Upstream-Status: Submitted [1] +Upstream-Status: Applied [1] [1] https://github.com/mamedev/mame/pull/4702 diff --git a/recipes-emulators/mame/mame/0006-pokey_device-step_pot-remove-operations-with-no-effe.patch b/recipes-emulators/mame/mame/0006-pokey_device-step_pot-remove-operations-with-no-effe.patch new file mode 100644 index 0000000..7d09c42 --- /dev/null +++ b/recipes-emulators/mame/mame/0006-pokey_device-step_pot-remove-operations-with-no-effe.patch @@ -0,0 +1,61 @@ +From c40e6aedf69c57269fd63c145436239eee185bcb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Andreas=20M=C3=BCller?= +Date: Tue, 5 Mar 2019 21:08:38 +0100 +Subject: [PATCH 1/2] pokey_device::step_pot: remove operations with no effect +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +* step_pot is called once only. There is ensured already that pokey is in + reset state. +* in case there were no bits latched to one, there is no need to call + synchronize(SYNC_POT, 0) because m_ALLPOT won't change. + +Performance results with missile / starwars: +Before: +./mame64 -bench 50 missile -> Average speed: 1171.67% (49 seconds) +./mame64 -bench 50 starwars -> Average speed: 551.66% (49 seconds) +After: +./mame64 -bench 50 missile -> Average speed: 1321.16% (49 seconds) +./mame64 -bench 50 starwars -> Average speed: 551.10% (49 seconds) + +Upstream-Status: Applied [1] + +[1] https://github.com/mamedev/mame/pull/4729 + +Signed-off-by: Andreas Müller +--- + src/devices/sound/pokey.cpp | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +diff --git a/src/devices/sound/pokey.cpp b/src/devices/sound/pokey.cpp +index 231dc01e8b..5aa797bb54 100644 +--- a/src/devices/sound/pokey.cpp ++++ b/src/devices/sound/pokey.cpp +@@ -538,11 +538,8 @@ void pokey_device::step_keyboard() + + void pokey_device::step_pot() + { +- if ((m_SKCTL & SK_RESET) == 0) +- return; +- +- uint8_t upd = 0; + m_pot_counter++; ++ uint8_t upd = 0; + for (int pot = 0; pot < 8; pot++) + { + if ((m_POTx[pot] +Date: Thu, 7 Mar 2019 20:11:01 +0100 +Subject: [PATCH 1/3] pokey: force recalculation of raw sound output after + reset +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +* This fixes a regression introduced by [1] +* Could not detect and performance change introduced by this + +Upstream-Status: Applied + +[1] https://github.com/mamedev/mame/pull/4702/commits/308c3c2d04ce8f3af09f620f524579145cbbcaf0 + +Signed-off-by: Andreas Müller +--- + src/devices/sound/pokey.cpp | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/devices/sound/pokey.cpp b/src/devices/sound/pokey.cpp +index 5aa797bb54..a79c8abb71 100644 +--- a/src/devices/sound/pokey.cpp ++++ b/src/devices/sound/pokey.cpp +@@ -1031,6 +1031,7 @@ void pokey_device::write_internal(offs_t offset, uint8_t data) + m_clock_cnt[0] = 0; + m_clock_cnt[1] = 0; + m_clock_cnt[2] = 0; ++ m_old_raw_inval = true; + /* FIXME: Serial port reset ! */ + } + break; +-- +2.20.1 + diff --git a/recipes-emulators/mame/mame/0008-pokey-remove-unused-macros.patch b/recipes-emulators/mame/mame/0008-pokey-remove-unused-macros.patch new file mode 100644 index 0000000..6522191 --- /dev/null +++ b/recipes-emulators/mame/mame/0008-pokey-remove-unused-macros.patch @@ -0,0 +1,48 @@ +From fa6f8255b46ad594d7fbf949a64397b4aa8231ad Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Andreas=20M=C3=BCller?= +Date: Fri, 8 Mar 2019 01:05:24 +0100 +Subject: [PATCH 1/2] pokey: remove unused macros +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Upstream-Status: Submitted [1] + +[1] https://github.com/mamedev/mame/pull/4735 + +Signed-off-by: Andreas Müller +--- + src/devices/sound/pokey.cpp | 10 ---------- + 1 file changed, 10 deletions(-) + +diff --git a/src/devices/sound/pokey.cpp b/src/devices/sound/pokey.cpp +index a79c8abb71..3372ac70a8 100644 +--- a/src/devices/sound/pokey.cpp ++++ b/src/devices/sound/pokey.cpp +@@ -99,11 +99,6 @@ + #define TIMER2 1 + #define TIMER4 2 + +-/* values to add to the divisors for the different modes */ +-#define DIVADD_LOCLK 1 +-#define DIVADD_HICLK 4 +-#define DIVADD_HICLK_JOINED 7 +- + /* AUDCx */ + #define NOTPOLY5 0x80 /* selects POLY5 or direct CLOCK */ + #define POLY4 0x40 /* selects POLY4 or POLY17 */ +@@ -152,11 +147,6 @@ + #define DIV_64 28 /* divisor for 1.78979 MHz clock to 63.9211 kHz */ + #define DIV_15 114 /* divisor for 1.78979 MHz clock to 15.6999 kHz */ + +-#define P4(chip) chip->poly4[chip->p4] +-#define P5(chip) chip->poly5[chip->p5] +-#define P9(chip) chip->poly9[chip->p9] +-#define P17(chip) chip->poly17[chip->p17] +- + #define CLK_1 0 + #define CLK_28 1 + #define CLK_114 2 +-- +2.20.1 + diff --git a/recipes-emulators/mame/mame/0009-pokey-yet-another-performance-enhancement.patch b/recipes-emulators/mame/mame/0009-pokey-yet-another-performance-enhancement.patch new file mode 100644 index 0000000..03fc3be --- /dev/null +++ b/recipes-emulators/mame/mame/0009-pokey-yet-another-performance-enhancement.patch @@ -0,0 +1,125 @@ +From 240445aea325423722a2588208846d71e33ca1f5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Andreas=20M=C3=BCller?= +Date: Fri, 8 Mar 2019 01:50:44 +0100 +Subject: [PATCH 2/2] pokey: yet another performance enhancement +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +In case + +* no counters are running at high speed without prescalers - and +* no prescalers have triggered - and +* there is no borrow counter expected to finish + +there is no need to continue on step_one_clock. + +Performance measuements: +Before: +./mame64 -bench 50 missile -> Average speed: 1322.75% (49 seconds) +./mame64 -bench 50 starwars -> Average speed: 548.97% (49 seconds) +./mame64 -bench 50 jedi -> Average speed: 375.08% (49 seconds) +After: +./mame64 -bench 50 missile -> Average speed: 1503.10% (49 seconds) +./mame64 -bench 50 starwars -> Average speed: 648.10% (49 seconds) +./mame64 -bench 50 jedi -> Average speed: 444.25% (49 seconds) + +Upstream-Status: Submitted [1] + +[1] https://github.com/mamedev/mame/pull/4735 + +Signed-off-by: Andreas Müller +--- + src/devices/sound/pokey.cpp | 36 ++++++++++++++++++++++++++++++------ + src/devices/sound/pokey.h | 4 +++- + 2 files changed, 33 insertions(+), 7 deletions(-) + +diff --git a/src/devices/sound/pokey.cpp b/src/devices/sound/pokey.cpp +index 3372ac70a8..fc794fbf74 100644 +--- a/src/devices/sound/pokey.cpp ++++ b/src/devices/sound/pokey.cpp +@@ -243,6 +243,7 @@ void pokey_device::device_start() + m_out_filter = 0; + m_out_raw = 0; + m_old_raw_inval = true; ++ m_borrow_all_max = 0; + m_kbd_state = 0; + + /* reset more internal state */ +@@ -581,15 +582,34 @@ void pokey_device::step_one_clock(void) + clock_triggered[CLK_114] = 1; + } + ++ /* in case ++ * no channel is at high speed AND ++ * no prescaler-clock has triggered AND ++ * we are not expecting a borrow-count finish ++ * => we are done and can exit here ++ * ++ * Note: for best performance on no-match case (matching case has to ask ++ * for all conditions anyway), the sequence chosen is: ++ * most likely no-match -> least likely no-match */ ++ if (!clock_triggered[CLK_28] && !clock_triggered[CLK_114] && ++ m_borrow_all_max == 0 && ++ (m_AUDCTL & (CH1_HICLK || CH3_HICLK)) == 0) ++ { ++ /* not quite: high speed potentiometer requires handling on each ++ * cycle */ ++ if ((m_SKCTL & SK_PADDLE) && (m_pot_counter < 228)) ++ step_pot(); ++ return; ++ } ++ + int const base_clock = (m_AUDCTL & CLK_15KHZ) ? CLK_114 : CLK_28; +- int clk = (m_AUDCTL & CH1_HICLK) ? CLK_1 : base_clock; +- if (clock_triggered[clk]) ++ /* increment CHAN1 & CHAN3 at each cycle for high speed or on prescaler ++ * clock trigger */ ++ if ((m_AUDCTL & CH1_HICLK) || clock_triggered[base_clock]) + m_channel[CHAN1].inc_chan(); +- +- clk = (m_AUDCTL & CH3_HICLK) ? CLK_1 : base_clock; +- if (clock_triggered[clk]) ++ if ((m_AUDCTL & CH3_HICLK) || clock_triggered[base_clock]) + m_channel[CHAN3].inc_chan(); +- ++ /* same for CHAN2 & CHAN4 - if not joined as upper bits */ + if (clock_triggered[base_clock]) + { + if (!(m_AUDCTL & CH12_JOINED)) +@@ -607,6 +627,10 @@ void pokey_device::step_one_clock(void) + step_keyboard(); + } + ++ /* performance-cheap decrement of shared helper max borrow counter */ ++ if(m_borrow_all_max != 0) ++ m_borrow_all_max--; ++ + /* do CHAN2 before CHAN1 because CHAN1 may set borrow! */ + if (m_channel[CHAN2].check_borrow()) + { +diff --git a/src/devices/sound/pokey.h b/src/devices/sound/pokey.h +index 7e63e89e54..6d15a49275 100644 +--- a/src/devices/sound/pokey.h ++++ b/src/devices/sound/pokey.h +@@ -242,7 +242,8 @@ private: + m_counter = (m_counter + 1) & 0xff; + if (m_counter == 0 && m_borrow_cnt == 0) + { +- m_borrow_cnt = 3; ++ m_borrow_cnt = m_parent->m_borrow_all_max = 3; ++ + if (m_parent->m_IRQEN & m_INTMask) + { + /* Exposed state has changed: This should only be updated after a resync ... */ +@@ -286,6 +287,7 @@ private: + + uint32_t m_out_raw; /* raw output */ + bool m_old_raw_inval; /* true: recalc m_out_raw required */ ++ uint32_t m_borrow_all_max; /* max borrow count for all channels */ + double m_out_filter; /* filtered output */ + + int32_t m_clock_cnt[3]; /* clock counters */ +-- +2.20.1 + diff --git a/recipes-emulators/mame/mame_0207.bb b/recipes-emulators/mame/mame_0207.bb index 0e084c5..47fa502 100644 --- a/recipes-emulators/mame/mame_0207.bb +++ b/recipes-emulators/mame/mame_0207.bb @@ -11,6 +11,10 @@ SRC_URI = " \ file://0003-pokey-rework-for-performance-enhancements.patch \ file://0004-pokey-rework-prescaler-handling.patch \ file://0005-OSD-OpenGl-Improve-performance-by-moving-calculation.patch \ + file://0006-pokey_device-step_pot-remove-operations-with-no-effe.patch \ + file://0007-pokey-force-recalculation-of-raw-sound-output-after-.patch \ + file://0008-pokey-remove-unused-macros.patch \ + file://0009-pokey-yet-another-performance-enhancement.patch \ file://no-upstream/0001-pokey-Make-step_one_clock-inline.patch \ file://mame.desktop \ " @@ -79,6 +83,7 @@ EXTRA_OEMAKE = " \ USE_SYSTEM_LIB_SQLITE3=1 \ USE_SYSTEM_LIB_ZLIB=1 \ USE_SYSTEM_LIB_RAPIDJSON=1 \ + USE_OPENMP=1 \ ${@bb.utils.contains('BBFILE_COLLECTIONS', 'meta-qt5-extra', 'USE_SYSTEM_LIB_PORTMIDI=1', '', d)} \ SDL_INI_PATH=${sysconfdir}/${BPN} \ "