DS GX: Clear depth
Vicki Pfau vi@endrift.com
Mon, 17 Jul 2017 14:49:32 -0700
5 files changed,
12 insertions(+),
5 deletions(-)
M
include/mgba/internal/ds/gx/software.h
→
include/mgba/internal/ds/gx/software.h
@@ -95,6 +95,7 @@ color_t* scanlineCache;
int sort; uint16_t clearStencil; color_t clearColor; + uint32_t clearDepth; bool flushPending; struct DSGXVertex* verts;
M
src/ds/gx.c
→
src/ds/gx.c
@@ -1326,6 +1326,7 @@ gx->currentVertex.color = 0x7FFF;
gx->currentPoly.polyParams = 0x001F00C0; gx->nextPoly.polyParams = 0x001F00C0; gx->dmaSource = -1; + gx->renderer->reset(gx->renderer); } void DSGXAssociateRenderer(struct DSGX* gx, struct DSGXRenderer* renderer) {
M
src/ds/gx/software.c
→
src/ds/gx/software.c
@@ -440,6 +440,7 @@ static void DSGXSoftwareRendererReset(struct DSGXRenderer* renderer) {
struct DSGXSoftwareRenderer* softwareRenderer = (struct DSGXSoftwareRenderer*) renderer; softwareRenderer->clearColor = 0; softwareRenderer->clearStencil = 0; + softwareRenderer->clearDepth = 0xFFFFFF; } static void DSGXSoftwareRendererDeinit(struct DSGXRenderer* renderer) {@@ -738,12 +739,13 @@ }
color_t clearColor = softwareRenderer->clearColor; uint16_t clearStencil = softwareRenderer->clearStencil; + uint32_t clearDepth = softwareRenderer->clearDepth; for (i = 0; i < DS_VIDEO_VERTICAL_PIXELS * DS_VIDEO_HORIZONTAL_PIXELS ; i += 4) { - softwareRenderer->depthBuffer[i] = INT32_MAX; - softwareRenderer->depthBuffer[i + 1] = INT32_MAX; - softwareRenderer->depthBuffer[i + 2] = INT32_MAX; - softwareRenderer->depthBuffer[i + 3] = INT32_MAX; + softwareRenderer->depthBuffer[i] = clearDepth; + softwareRenderer->depthBuffer[i + 1] = clearDepth; + softwareRenderer->depthBuffer[i + 2] = clearDepth; + softwareRenderer->depthBuffer[i + 3] = clearDepth; softwareRenderer->scanlineCache[i] = clearColor; softwareRenderer->scanlineCache[i + 1] = clearColor; softwareRenderer->scanlineCache[i + 2] = clearColor;@@ -815,6 +817,9 @@ case DS9_REG_CLEAR_COLOR_HI:
softwareRenderer->clearColor &= 0x00FFFFFF; softwareRenderer->clearColor |= (value & 0x001F) << 27; softwareRenderer->clearStencil = (value & 0x3F00) >> 8; + break; + case DS9_REG_CLEAR_DEPTH: + softwareRenderer->clearDepth = (value & 0x7FFF) * 0x200 + 0x1FF; break; } }