• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

Common Source Code Project for Qt (a.k.a for FM-7).


Commit MetaInfo

Revisión71105e512743b96f3392f5730c9726cdf2b1796c (tree)
Tiempo2022-05-04 01:48:02
AutorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[VM][FMTOWNS][PLANE_VRAM] Optimize for speed.

Cambiar Resumen

Diferencia incremental

--- a/source/src/vm/fmtowns/planevram.cpp
+++ b/source/src/vm/fmtowns/planevram.cpp
@@ -34,7 +34,7 @@ void PLANEVRAM::write_io8(uint32_t addr, uint32_t data)
3434 r50_ramsel = data & 0x0f;
3535 break;
3636 case 0xff82:
37- if(d_crtc != NULL) {
37+ __LIKELY_IF(d_crtc != NULL) {
3838 d_crtc->write_signal(SIG_TOWNS_CRTC_MMIO_CFF82H, data, 0xffffffff);
3939 // out_debug_log(_T("WRITE CFF82h <- %02X"), data);
4040 }
@@ -48,7 +48,7 @@ void PLANEVRAM::write_io8(uint32_t addr, uint32_t data)
4848 case 0xffa0:
4949 break;
5050 default:
51- if(d_sprite != NULL) {
51+ __LIKELY_IF(d_sprite != NULL) {
5252 d_sprite->write_data8(addr & 0x7fff, data);
5353 }
5454 break;
@@ -65,7 +65,9 @@ uint32_t PLANEVRAM::read_io8(uint32_t addr)
6565 return ((r50_readplane << 6) | r50_ramsel);
6666 break;
6767 case 0xff82:
68- return d_crtc->read_signal(SIG_TOWNS_CRTC_MMIO_CFF82H);
68+ __LIKELY_IF(d_crtc != NULL) {
69+ return d_crtc->read_signal(SIG_TOWNS_CRTC_MMIO_CFF82H);
70+ }
6971 break;
7072 case 0xff83:
7173 return ((r50_gvramsel != 0x00000) ? 0x10 : 0x00);
@@ -74,7 +76,9 @@ uint32_t PLANEVRAM::read_io8(uint32_t addr)
7476 return 0x7f; // Reserve.FIRQ
7577 break;
7678 case 0xff86:
77- return d_crtc->read_signal(SIG_TOWNS_CRTC_MMIO_CFF86H);
79+ __LIKELY_IF(d_crtc != NULL) {
80+ return d_crtc->read_signal(SIG_TOWNS_CRTC_MMIO_CFF86H);
81+ }
7882 break;
7983 case 0xffa0:
8084 {
@@ -85,7 +89,7 @@ uint32_t PLANEVRAM::read_io8(uint32_t addr)
8589 }
8690 break;
8791 default:
88- if(d_sprite != NULL) {
92+ __LIKELY_IF(d_sprite != NULL) {
8993 return d_sprite->read_data8(addr & 0x7fff);
9094 }
9195 break;
@@ -107,44 +111,44 @@ uint32_t PLANEVRAM::read_memory_mapped_io8(uint32_t addr)
107111
108112 // 8bit -> 32bit
109113 uint8_t val = 0;
110- const uint8_t nmask[4] = {0x11, 0x22, 0x44, 0x88};
111- uint8_t hmask = nmask[r50_readplane & 3] & 0xf0;
112- uint8_t lmask = nmask[r50_readplane & 3] & 0x0f;
113- uint8_t hval = 0x80;
114- uint8_t lval = 0x40;
114+ const uint8_t lmask = 1 << (r50_readplane & 3);
115+ const uint8_t hmask = lmask << 4;
115116
116117 d_vram->lock();
117118 __DECL_ALIGNED(8) uint8_t extra_p[8];
118119 __DECL_ALIGNED(8) uint8_t extra_mask[8];
119- __DECL_ALIGNED(8) uint8_t extra_value[8];
120+ const uint8_t extra_value[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
120121 __DECL_ALIGNED(8) uint8_t extra_bool[8];
122+ __DECL_ALIGNED(8) uint8_t cache[4];
121123
122124 __DECL_VECTORIZED_LOOP
123- for(int i = 0; i < 8; i += 2) {
124- extra_p[i ] = p[i >> 1];
125- extra_p[i + 1] = p[i >> 1];
125+ for(int i = 0; i < 4; i++) {
126+ cache[i] = p[i];
127+ }
128+
129+__DECL_VECTORIZED_LOOP
130+ for(int i = 0, j = 0; i < 8; i += 2, j++) {
131+ extra_p[i ] = cache[j];
132+ extra_p[i + 1] = cache[j];
126133 }
127134 __DECL_VECTORIZED_LOOP
128135 for(int i = 0; i < 8; i += 2) {
129136 extra_mask[i ] = hmask;
130137 extra_mask[i + 1] = lmask;
131138 }
139+
132140 __DECL_VECTORIZED_LOOP
133- for(int i = 0; i < 8; i += 2) {
134- extra_value[i ] = hval;
135- extra_value[i + 1] = lval;
136- hval >>= 2;
137- lval >>= 2;
141+ for(int i = 0; i < 8; i++) {
142+ extra_bool[i] = ((extra_mask[i] & extra_p[i]) != 0) ? 0xff : 0x00;
138143 }
139144
140145 __DECL_VECTORIZED_LOOP
141146 for(int i = 0; i < 8; i++) {
142- extra_bool[i] = ((extra_mask[i] & extra_p[i]) != 0) ? 0xff : 0x00;
147+ extra_bool[i] &= extra_value[i];
143148 }
144-
145149 __DECL_VECTORIZED_LOOP
146150 for(int i = 0; i < 8; i++) {
147- val |= (extra_bool[i] & extra_value[i]);
151+ val |= extra_bool[i];
148152 }
149153 d_vram->unlock();
150154
Show on old repository browser