all repos — mgba @ d8c7e3e3c382545cccf908d99628657c6b1f1c4e

mGBA Game Boy Advance Emulator

GB/GBA Core: Simplify renderer setup
Vicki Pfau vi@endrift.com
Fri, 31 Jul 2020 18:34:55 -0700
commit

d8c7e3e3c382545cccf908d99628657c6b1f1c4e

parent

e27963bd29653427b99a97742c48a79e7d3a887a

2 files changed, 38 insertions(+), 34 deletions(-)

jump to
M src/gb/core.csrc/gb/core.c

@@ -63,8 +63,8 @@

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;

@@ -103,6 +103,9 @@ SM83SetComponents(cpu, &gb->d, CPU_COMPONENT_MAX, gbcore->components);

SM83Init(cpu); 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 @@ struct GBCore* gbcore = (struct GBCore*) 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) {
M src/gba/core.csrc/gba/core.c

@@ -129,8 +129,8 @@ #define CPU_COMPONENT_AUDIO_MIXER CPU_COMPONENT_MISC_1

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

@@ -182,6 +182,9 @@ ARMSetComponents(cpu, &gba->d, CPU_COMPONENT_MAX, gbacore->components);

ARMInit(cpu); 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,11 +386,9 @@ GBAVideoProxyRendererCreate(&gbacore->proxyRenderer, renderer);

renderer = &gbacore->proxyRenderer.d; } #endif - if (!renderer) { - renderer = &gbacore->dummyRenderer; - GBAVideoDummyRendererCreate(renderer); + if (renderer) { + GBAVideoAssociateRenderer(&gba->video, renderer); } - GBAVideoAssociateRenderer(&gba->video, renderer); } }

@@ -545,39 +546,42 @@

static void _GBACoreReset(struct mCore* core) { struct GBACore* gbacore = (struct GBACore*) core; struct GBA* gba = (struct GBA*) core->board; - struct GBAVideoRenderer* renderer = NULL; - if (gbacore->renderer.outputBuffer) { - renderer = &gbacore->renderer.d; - } - int fakeBool ATTRIBUTE_UNUSED; + if (gbacore->renderer.outputBuffer #if defined(BUILD_GLES2) || defined(BUILD_GLES3) - if (gbacore->glRenderer.outputTex != (unsigned) -1 && mCoreConfigGetIntValue(&core->config, "hwaccelVideo", &fakeBool) && fakeBool) { - mCoreConfigGetIntValue(&core->config, "videoScale", &gbacore->glRenderer.scale); - renderer = &gbacore->glRenderer.d; - } else { - gbacore->glRenderer.scale = 1; - } + || gbacore->glRenderer.outputTex != (unsigned) -1 +#endif + ) { + struct GBAVideoRenderer* renderer = NULL; + if (gbacore->renderer.outputBuffer) { + renderer = &gbacore->renderer.d; + } + int fakeBool ATTRIBUTE_UNUSED; +#if defined(BUILD_GLES2) || defined(BUILD_GLES3) + if (gbacore->glRenderer.outputTex != (unsigned) -1 && mCoreConfigGetIntValue(&core->config, "hwaccelVideo", &fakeBool) && fakeBool) { + mCoreConfigGetIntValue(&core->config, "videoScale", &gbacore->glRenderer.scale); + renderer = &gbacore->glRenderer.d; + } else { + gbacore->glRenderer.scale = 1; + } #endif #ifndef DISABLE_THREADING - if (mCoreConfigGetIntValue(&core->config, "threadedVideo", &fakeBool) && fakeBool) { - if (!core->videoLogger) { - core->videoLogger = &gbacore->threadProxy.d; + if (mCoreConfigGetIntValue(&core->config, "threadedVideo", &fakeBool) && fakeBool) { + if (!core->videoLogger) { + core->videoLogger = &gbacore->threadProxy.d; + } } - } #endif #ifndef MINIMAL_CORE - if (renderer && core->videoLogger) { - gbacore->proxyRenderer.logger = core->videoLogger; - GBAVideoProxyRendererCreate(&gbacore->proxyRenderer, renderer); - renderer = &gbacore->proxyRenderer.d; - } + if (renderer && core->videoLogger) { + gbacore->proxyRenderer.logger = core->videoLogger; + GBAVideoProxyRendererCreate(&gbacore->proxyRenderer, renderer); + renderer = &gbacore->proxyRenderer.d; + } #endif - if (!renderer) { - renderer = &gbacore->dummyRenderer; - GBAVideoDummyRendererCreate(renderer); + if (renderer) { + GBAVideoAssociateRenderer(&gba->video, renderer); + } } - - GBAVideoAssociateRenderer(&gba->video, renderer); #ifndef MINIMAL_CORE int useAudioMixer;