GB/GBA Core: Simplify renderer setup

This commit is contained in:
Vicki Pfau 2020-07-31 18:34:55 -07:00
parent e27963bd29
commit d8c7e3e3c3
2 changed files with 38 additions and 34 deletions

View File

@ -63,8 +63,8 @@ static const struct mCoreMemoryBlock _GBCMemoryBlocks[] = {
struct mVideoLogContext;
struct GBCore {
struct mCore d;
struct GBVideoSoftwareRenderer renderer;
struct GBVideoRenderer dummyRenderer;
struct GBVideoSoftwareRenderer renderer;
#ifndef MINIMAL_CORE
struct GBVideoProxyRenderer proxyRenderer;
struct mVideoLogContext* logContext;
@ -104,6 +104,9 @@ static bool _GBCoreInit(struct mCore* core) {
mRTCGenericSourceInit(&core->rtc, core);
gb->memory.rtc = &core->rtc.d;
GBVideoDummyRendererCreate(&gbcore->dummyRenderer);
GBVideoAssociateRenderer(&gb->video, &gbcore->dummyRenderer);
GBVideoSoftwareRendererCreate(&gbcore->renderer);
gbcore->renderer.outputBuffer = NULL;
@ -420,9 +423,6 @@ static void _GBCoreReset(struct mCore* core) {
struct GB* gb = (struct GB*) core->board;
if (gbcore->renderer.outputBuffer) {
GBVideoAssociateRenderer(&gb->video, &gbcore->renderer.d);
} else {
GBVideoDummyRendererCreate(&gbcore->dummyRenderer);
GBVideoAssociateRenderer(&gb->video, &gbcore->dummyRenderer);
}
if (gb->memory.rom) {

View File

@ -129,8 +129,8 @@ struct mVideoLogContext;
struct GBACore {
struct mCore d;
struct GBAVideoSoftwareRenderer renderer;
struct GBAVideoRenderer dummyRenderer;
struct GBAVideoSoftwareRenderer renderer;
#if defined(BUILD_GLES2) || defined(BUILD_GLES3)
struct GBAVideoGLRenderer glRenderer;
#endif
@ -183,6 +183,9 @@ static bool _GBACoreInit(struct mCore* core) {
mRTCGenericSourceInit(&core->rtc, core);
gba->rtcSource = &core->rtc.d;
GBAVideoDummyRendererCreate(&gbacore->dummyRenderer);
GBAVideoAssociateRenderer(&gba->video, &gbacore->dummyRenderer);
GBAVideoSoftwareRendererCreate(&gbacore->renderer);
gbacore->renderer.outputBuffer = NULL;
@ -383,13 +386,11 @@ static void _GBACoreReloadConfigOption(struct mCore* core, const char* option, c
renderer = &gbacore->proxyRenderer.d;
}
#endif
if (!renderer) {
renderer = &gbacore->dummyRenderer;
GBAVideoDummyRendererCreate(renderer);
}
if (renderer) {
GBAVideoAssociateRenderer(&gba->video, renderer);
}
}
}
static void _GBACoreDesiredVideoDimensions(const struct mCore* core, unsigned* width, unsigned* height) {
#if defined(BUILD_GLES2) || defined(BUILD_GLES3)
@ -545,6 +546,11 @@ static void _GBACoreChecksum(const struct mCore* core, void* data, enum mCoreChe
static void _GBACoreReset(struct mCore* core) {
struct GBACore* gbacore = (struct GBACore*) core;
struct GBA* gba = (struct GBA*) core->board;
if (gbacore->renderer.outputBuffer
#if defined(BUILD_GLES2) || defined(BUILD_GLES3)
|| gbacore->glRenderer.outputTex != (unsigned) -1
#endif
) {
struct GBAVideoRenderer* renderer = NULL;
if (gbacore->renderer.outputBuffer) {
renderer = &gbacore->renderer.d;
@ -572,12 +578,10 @@ static void _GBACoreReset(struct mCore* core) {
renderer = &gbacore->proxyRenderer.d;
}
#endif
if (!renderer) {
renderer = &gbacore->dummyRenderer;
GBAVideoDummyRendererCreate(renderer);
}
if (renderer) {
GBAVideoAssociateRenderer(&gba->video, renderer);
}
}
#ifndef MINIMAL_CORE
int useAudioMixer;