DS Video: Basic preparatory work for porting scanline caching

This commit is contained in:
Vicki Pfau 2020-07-21 00:03:24 -07:00
parent 3ccffdc29e
commit 14e8b12307
2 changed files with 19 additions and 0 deletions

View File

@ -15,6 +15,9 @@ CXX_GUARD_START
#include <mgba/internal/gba/io.h> #include <mgba/internal/gba/io.h>
#include <mgba/internal/gba/renderers/common.h> #include <mgba/internal/gba/renderers/common.h>
#include <mgba/internal/gba/video.h> #include <mgba/internal/gba/video.h>
#ifdef M_CORE_DS
#include <mgba/internal/ds/video.h>
#endif
struct GBAVideoSoftwareBackground { struct GBAVideoSoftwareBackground {
unsigned index; unsigned index;
@ -158,7 +161,11 @@ struct GBAVideoSoftwareRenderer {
struct ScanlineCache { struct ScanlineCache {
uint16_t io[REG_SOUND1CNT_LO >> 1]; uint16_t io[REG_SOUND1CNT_LO >> 1];
int32_t scale[2][2]; int32_t scale[2][2];
#ifdef M_CORE_DS
} cache[DS_VIDEO_VERTICAL_PIXELS];
#else
} cache[GBA_VIDEO_VERTICAL_PIXELS]; } cache[GBA_VIDEO_VERTICAL_PIXELS];
#endif
int nextY; int nextY;
int start; int start;

View File

@ -378,6 +378,18 @@ static void DSVideoSoftwareRendererInvalidateExtPal(struct DSVideoRenderer* rend
static void DSVideoSoftwareRendererDrawGBAScanline(struct GBAVideoRenderer* renderer, struct DSGX* gx, int y) { static void DSVideoSoftwareRendererDrawGBAScanline(struct GBAVideoRenderer* renderer, struct DSGX* gx, int y) {
struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer; struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
if (y == DS_VIDEO_VERTICAL_PIXELS - 1) {
softwareRenderer->nextY = 0;
} else {
softwareRenderer->nextY = y + 1;
}
bool dirty = softwareRenderer->scanlineDirty[y >> 5] & (1 << (y & 0x1F));
if (memcmp(softwareRenderer->nextIo, softwareRenderer->cache[y].io, sizeof(softwareRenderer->nextIo))) {
memcpy(softwareRenderer->cache[y].io, softwareRenderer->nextIo, sizeof(softwareRenderer->nextIo));
dirty = true;
}
int x; int x;
color_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y]; color_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y];
if (GBARegisterDISPCNTIsForcedBlank(softwareRenderer->dispcnt)) { if (GBARegisterDISPCNTIsForcedBlank(softwareRenderer->dispcnt)) {