From eba17aa157e6fc4ab2e5bdf0e18a920837ddfc17 Mon Sep 17 00:00:00 2001 From: Runik Date: Tue, 12 Nov 2024 22:34:52 +0100 Subject: [PATCH] Fixed nbg display --- saturnin/src/video/opengl/opengl_render.cpp | 3 + saturnin/src/video/vdp2/vdp2_display.cpp | 90 +++++++-------------- 2 files changed, 34 insertions(+), 59 deletions(-) diff --git a/saturnin/src/video/opengl/opengl_render.cpp b/saturnin/src/video/opengl/opengl_render.cpp index 31e2557..b33ea7b 100644 --- a/saturnin/src/video/opengl/opengl_render.cpp +++ b/saturnin/src/video/opengl/opengl_render.cpp @@ -295,6 +295,9 @@ void OpenglRender::renderByScreenPriority() { } void OpenglRender::renderByParts() { + // All the parts to be displayed are read, regardless of their screen of attachment. + // Parts are sorted by priority. + PartsList parts_list; preRender(); diff --git a/saturnin/src/video/vdp2/vdp2_display.cpp b/saturnin/src/video/vdp2/vdp2_display.cpp index 6a14403..82ea36b 100644 --- a/saturnin/src/video/vdp2/vdp2_display.cpp +++ b/saturnin/src/video/vdp2/vdp2_display.cpp @@ -62,67 +62,39 @@ void Vdp2::populateNbgScreens() { const auto is_nbg_displayed = !(getScreen(rbg0).is_display_enabled && getScreen(rbg1).is_display_enabled); if (is_nbg_displayed) { - clearRenderData(nbg0); - if (isScrollScreenDisplayable(nbg0)) { - if (isScreenDisplayed(nbg0)) { - updateScrollScreenStatus(nbg0); - if (getScreen(nbg0).priority_number != 0) { readScrollScreenData(nbg0); } - } - } - - clearRenderData(nbg1); - if (isScrollScreenDisplayable(nbg1)) { - if (isScreenDisplayed(nbg1)) { - updateScrollScreenStatus(nbg1); - if (getScreen(nbg1).priority_number != 0) { readScrollScreenData(nbg1); } - } - } - - clearRenderData(nbg2); - if (isScrollScreenDisplayable(nbg2)) { - if (isScreenDisplayed(nbg2)) { - updateScrollScreenStatus(nbg2); - if (getScreen(nbg2).priority_number != 0) { readScrollScreenData(nbg2); } - } - } - - if (uses_fbo) { - // WIP - if (isScrollScreenDisplayable(nbg3) && isScreenDisplayed(nbg3)) { - updateScrollScreenStatus(nbg3); - const auto isDirty = isCacheDirty(nbg3); - const auto priorityIsAboveZero = getScreen(nbg3).priority_number != 0; - if (isDirty && priorityIsAboveZero) { - // discardCache(ScrollScreen::nbg3); - // clearRenderData(ScrollScreen::nbg3); - // readScrollScreenData(ScrollScreen::nbg3); - // // Data must be reloaded. Passing the status as 'to_clear' suffice on this side. - // modules_.opengl()->setFboStatus(getScreen(ScrollScreen::nbg3).priority_number, - // ScrollScreen::nbg3, - // FboStatus::to_clear); - // } - - // if (!priorityIsAboveZero) { - // // Clear previously used data. - // modules_.opengl()->setFboStatus(ScrollScreen::nbg3, FboStatus::to_clear); - // } - - // if (!isDirty && priorityIsAboveZero) { - // // Reuse previous data. - // modules_.opengl()->setFboStatus(getScreen(ScrollScreen::nbg3).priority_number, - // ScrollScreen::nbg3, - // FboStatus::reuse); + for (auto nbg : {nbg0, nbg1, nbg2, nbg3}) { + if (uses_fbo) { + // WIP + if (isScrollScreenDisplayable(nbg) && isScreenDisplayed(nbg)) { + updateScrollScreenStatus(nbg); + const auto isDirty = isCacheDirty(nbg); + const auto priorityIsAboveZero = getScreen(nbg).priority_number != 0; + if (isDirty && priorityIsAboveZero) { + discardCache(nbg); + clearRenderData(nbg); + readScrollScreenData(nbg); + // // Data must be reloaded. Passing the status as 'to_clear' suffice on this side. + // modules_.opengl()->setFboStatus(getScreen(nbg).priority_number, nbg, FboStatus::to_clear); + } + + // if (!priorityIsAboveZero) { + // // Clear previously used data. + // modules_.opengl()->setFboStatus(nbg, FboStatus::to_clear); + // } + + // if (!isDirty && priorityIsAboveZero) { + // // Reuse previous data. + // modules_.opengl()->setFboStatus(getScreen(nbg).priority_number, nbg, FboStatus::reuse); + // } + } else { + // Clear previously used data. + // modules_.opengl()->setFboStatus(ScrollScreen::nbg3, FboStatus::to_clear); } } else { - // Clear previously used data. - // modules_.opengl()->setFboStatus(ScrollScreen::nbg3, FboStatus::to_clear); - } - } else { - clearRenderData(nbg3); - if (isScrollScreenDisplayable(nbg3)) { - if (isScreenDisplayed(nbg3)) { - updateScrollScreenStatus(nbg3); - if (getScreen(nbg3).priority_number != 0) { readScrollScreenData(nbg3); } + clearRenderData(nbg); + if (isScrollScreenDisplayable(nbg) && isScreenDisplayed(nbg)) { + updateScrollScreenStatus(nbg); + if (getScreen(nbg).priority_number != 0) { readScrollScreenData(nbg); } } } }