Changed screen redraw rate. HUGE performance improvement
This commit is contained in:
parent
2c7dbea53d
commit
8d35484a20
8 changed files with 29 additions and 17 deletions
2
build.nr
2
build.nr
|
|
@ -1 +1 @@
|
||||||
1613
|
1614
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ CMOS = dragon/cmos.dr
|
||||||
|
|
||||||
cpuext = extmov, extalu
|
cpuext = extmov, extalu
|
||||||
fixed_clock = false
|
fixed_clock = false
|
||||||
clock_rate_sec = 644
|
clock_rate_sec = 2000
|
||||||
memory_extension_pages = 16
|
memory_extension_pages = 16
|
||||||
|
|
||||||
SingleColor_foreground = #009900FF
|
SingleColor_foreground = #009900FF
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -84,18 +84,18 @@ namespace dragon
|
||||||
}
|
}
|
||||||
if (applyBackground)
|
if (applyBackground)
|
||||||
{
|
{
|
||||||
screenPixels[screenIndex] = 255;
|
screenPixels[screenIndex + 0] = background.b;
|
||||||
screenPixels[screenIndex + 1] = background.b;
|
screenPixels[screenIndex + 1] = background.g;
|
||||||
screenPixels[screenIndex + 2] = background.g;
|
screenPixels[screenIndex + 2] = background.r;
|
||||||
screenPixels[screenIndex + 3] = background.r;
|
screenPixels[screenIndex + 3] = 255;
|
||||||
applyBackground = false;
|
applyBackground = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tintedColor = applyTint({ fontPixels[index], fontPixels[index + 1], fontPixels[index + 2], 255 }, color);
|
tintedColor = applyTint({ fontPixels[index], fontPixels[index + 1], fontPixels[index + 2], 255 }, color);
|
||||||
screenPixels[screenIndex] = fontPixels[index + 3];
|
screenPixels[screenIndex + 0] = tintedColor.b;
|
||||||
screenPixels[screenIndex + 1] = tintedColor.b;
|
screenPixels[screenIndex + 1] = tintedColor.g;
|
||||||
screenPixels[screenIndex + 2] = tintedColor.g;
|
screenPixels[screenIndex + 2] = tintedColor.r;
|
||||||
screenPixels[screenIndex + 3] = tintedColor.r;
|
screenPixels[screenIndex + 3] = fontPixels[index + 3];
|
||||||
}
|
}
|
||||||
screeny += 1;
|
screeny += 1;
|
||||||
screenx = x * 4;
|
screenx = x * 4;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace dragon
|
||||||
return; //TODO: Error
|
return; //TODO: Error
|
||||||
m_parent = &parent;
|
m_parent = &parent;
|
||||||
m_pixels = ostd::Utils::createArray<uint32_t>(parent.getWindowWidth() * parent.getWindowHeight());
|
m_pixels = ostd::Utils::createArray<uint32_t>(parent.getWindowWidth() * parent.getWindowHeight());
|
||||||
m_texture = SDL_CreateTexture(parent.getSDLRenderer(), SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, parent.getWindowWidth(), parent.getWindowHeight());
|
m_texture = SDL_CreateTexture(parent.getSDLRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, parent.getWindowWidth(), parent.getWindowHeight());
|
||||||
m_windowWidth = parent.getWindowWidth();
|
m_windowWidth = parent.getWindowWidth();
|
||||||
m_windowHeight = parent.getWindowHeight();
|
m_windowHeight = parent.getWindowHeight();
|
||||||
setTypeName("dragon::Renderer");
|
setTypeName("dragon::Renderer");
|
||||||
|
|
@ -34,7 +34,7 @@ namespace dragon
|
||||||
{
|
{
|
||||||
m_pixels = ostd::Utils::resizeArray<uint32_t>(m_pixels, m_parent->getWindowWidth() * m_parent->getWindowHeight());
|
m_pixels = ostd::Utils::resizeArray<uint32_t>(m_pixels, m_parent->getWindowWidth() * m_parent->getWindowHeight());
|
||||||
SDL_DestroyTexture(m_texture);
|
SDL_DestroyTexture(m_texture);
|
||||||
m_texture = SDL_CreateTexture(m_parent->getSDLRenderer(), SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, m_parent->getWindowWidth(), m_parent->getWindowHeight());
|
m_texture = SDL_CreateTexture(m_parent->getSDLRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, m_parent->getWindowWidth(), m_parent->getWindowHeight());
|
||||||
m_windowWidth = m_parent->getWindowWidth();
|
m_windowWidth = m_parent->getWindowWidth();
|
||||||
m_windowHeight = m_parent->getWindowHeight();
|
m_windowHeight = m_parent->getWindowHeight();
|
||||||
updateBuffer();
|
updateBuffer();
|
||||||
|
|
@ -45,10 +45,7 @@ namespace dragon
|
||||||
void Renderer::updateBuffer(void)
|
void Renderer::updateBuffer(void)
|
||||||
{
|
{
|
||||||
if (isInvalid()) return;
|
if (isInvalid()) return;
|
||||||
ostd::Timer timer;
|
|
||||||
timer.start(true, "DISPLAY_PROFILER", ostd::eTimeUnits::Milliseconds);
|
|
||||||
SDL_UpdateTexture(m_texture, NULL, m_pixels, m_windowWidth * 4);
|
SDL_UpdateTexture(m_texture, NULL, m_pixels, m_windowWidth * 4);
|
||||||
timer.end(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::displayBuffer(void)
|
void Renderer::displayBuffer(void)
|
||||||
|
|
@ -66,7 +63,7 @@ namespace dragon
|
||||||
for (uint32_t x = 0; x < m_windowWidth; x++)
|
for (uint32_t x = 0; x < m_windowWidth; x++)
|
||||||
{
|
{
|
||||||
int32_t index = CONVERT_2D_1D(x, y, m_windowWidth);
|
int32_t index = CONVERT_2D_1D(x, y, m_windowWidth);
|
||||||
m_pixels[index] = color.asInteger();
|
m_pixels[index] = color.asInteger(ostd::Color::eColorFormat::ARGB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,11 @@ namespace dragon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_renderer.updateBuffer();
|
if (m_redrawScreen)
|
||||||
|
{
|
||||||
|
m_renderer.updateBuffer();
|
||||||
|
m_redrawScreen = false;
|
||||||
|
}
|
||||||
m_renderer.displayBuffer();
|
m_renderer.displayBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,8 @@ namespace dragon
|
||||||
void onFixedUpdate(void) override;
|
void onFixedUpdate(void) override;
|
||||||
void onSlowUpdate(void) override;
|
void onSlowUpdate(void) override;
|
||||||
|
|
||||||
|
inline void redrawScreen(void) { m_redrawScreen = true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void single_text_add_char_to_line(char c);
|
void single_text_add_char_to_line(char c);
|
||||||
void single_text_add_char_to_buffer(char c);
|
void single_text_add_char_to_buffer(char c);
|
||||||
|
|
@ -80,6 +82,8 @@ namespace dragon
|
||||||
std::vector<data::IBiosVideoPalette*> m_text16_palettes;
|
std::vector<data::IBiosVideoPalette*> m_text16_palettes;
|
||||||
data::IBiosVideoPalette* m_text16_Currentpalette { nullptr };
|
data::IBiosVideoPalette* m_text16_Currentpalette { nullptr };
|
||||||
uint8_t m_currentPaletteID { 0 };
|
uint8_t m_currentPaletteID { 0 };
|
||||||
|
|
||||||
|
bool m_redrawScreen { true };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -346,6 +346,7 @@ namespace dragon
|
||||||
{
|
{
|
||||||
double clock_speed_us = 1000000.0 / machine_config.clock_rate_sec;
|
double clock_speed_us = 1000000.0 / machine_config.clock_rate_sec;
|
||||||
double acc = 0;
|
double acc = 0;
|
||||||
|
double acc2 = 0;
|
||||||
uint64_t avg_count = 0;
|
uint64_t avg_count = 0;
|
||||||
uint64_t _time = 0;
|
uint64_t _time = 0;
|
||||||
double avg_tot = 0;
|
double avg_tot = 0;
|
||||||
|
|
@ -377,8 +378,14 @@ namespace dragon
|
||||||
// out.fg(ostd::ConsoleColors::Red).p(s_avgInstTime).nl().reset();
|
// out.fg(ostd::ConsoleColors::Red).p(s_avgInstTime).nl().reset();
|
||||||
acc = 0;
|
acc = 0;
|
||||||
}
|
}
|
||||||
|
if (acc2 == 100)
|
||||||
|
{
|
||||||
|
vDisplay.redrawScreen();
|
||||||
|
acc2 = 0;
|
||||||
|
}
|
||||||
_time = clock_timer.endCount();
|
_time = clock_timer.endCount();
|
||||||
acc++;
|
acc++;
|
||||||
|
acc2++;
|
||||||
if (_time < clock_speed_us && fixed_clock)
|
if (_time < clock_speed_us && fixed_clock)
|
||||||
ostd::Utils::sleep(clock_speed_us - _time, ostd::eTimeUnits::Microseconds);
|
ostd::Utils::sleep(clock_speed_us - _time, ostd::eTimeUnits::Microseconds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue