From b956263a968764d0d3fb4dd2f05c4e2e02b25d56 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 19 Jan 2018 21:25:56 -0800 Subject: [PATCH] GLES: Consistently reset state on new steps. It'd be nice to avoid this dependency, but since every step forgets the current state, and these functions are called in a lot of places, it's tricky to manage. Fixes graphics in Grand Knights History (framebuf copy creating a new step, resetting blending state.) --- ext/native/thin3d/GLRenderManager.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ext/native/thin3d/GLRenderManager.cpp b/ext/native/thin3d/GLRenderManager.cpp index 7989f0b662..2cb820982d 100644 --- a/ext/native/thin3d/GLRenderManager.cpp +++ b/ext/native/thin3d/GLRenderManager.cpp @@ -4,6 +4,7 @@ #include "gfx_es2/gpu_features.h" #include "thread/threadutil.h" #include "base/logging.h" +#include "GPU/GPUState.h" #if 0 // def _DEBUG #define VLOG ILOG @@ -198,6 +199,9 @@ void GLRenderManager::BindFramebufferAsRenderTarget(GLRFramebuffer *fb, GLRRende } curRenderStep_ = step; + + // Every step clears this state. + gstate_c.Dirty(DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_RASTER_STATE); } void GLRenderManager::BindFramebufferAsTexture(GLRFramebuffer *fb, int binding, int aspectBit, int attachment) { @@ -210,17 +214,20 @@ void GLRenderManager::BindFramebufferAsTexture(GLRFramebuffer *fb, int binding, } void GLRenderManager::CopyFramebuffer(GLRFramebuffer *src, GLRect2D srcRect, GLRFramebuffer *dst, GLOffset2D dstPos, int aspectMask) { - GLRStep * step = new GLRStep{ GLRStepType::COPY }; + GLRStep *step = new GLRStep{ GLRStepType::COPY }; step->copy.srcRect = srcRect; step->copy.dstPos = dstPos; step->copy.src = src; step->copy.dst = dst; step->copy.aspectMask = aspectMask; steps_.push_back(step); + + // Every step clears this state. + gstate_c.Dirty(DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_RASTER_STATE); } void GLRenderManager::BlitFramebuffer(GLRFramebuffer *src, GLRect2D srcRect, GLRFramebuffer *dst, GLRect2D dstRect, int aspectMask, bool filter) { - GLRStep * step = new GLRStep{ GLRStepType::BLIT }; + GLRStep *step = new GLRStep{ GLRStepType::BLIT }; step->blit.srcRect = srcRect; step->blit.dstRect = dstRect; step->blit.src = src; @@ -228,6 +235,9 @@ void GLRenderManager::BlitFramebuffer(GLRFramebuffer *src, GLRect2D srcRect, GLR step->blit.aspectMask = aspectMask; step->blit.filter = filter; steps_.push_back(step); + + // Every step clears this state. + gstate_c.Dirty(DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_RASTER_STATE); } bool GLRenderManager::CopyFramebufferToMemorySync(GLRFramebuffer *src, int aspectBits, int x, int y, int w, int h, Draw::DataFormat destFormat, uint8_t *pixels, int pixelStride) { @@ -238,6 +248,9 @@ bool GLRenderManager::CopyFramebufferToMemorySync(GLRFramebuffer *src, int aspec step->readback.dstFormat = destFormat; steps_.push_back(step); + // Every step clears this state. + gstate_c.Dirty(DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_RASTER_STATE); + curRenderStep_ = nullptr; FlushSync();