From 9094410fd17e0c8acc9e59ae16feb0d8ef2448cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 14 Dec 2017 16:08:55 +0100 Subject: [PATCH] gl-render-manager: Need to actually bind newly created textures. --- GPU/GLES/TextureCacheGLES.cpp | 2 ++ ext/native/thin3d/GLQueueRunner.cpp | 45 +++++++++++++++++---------- ext/native/thin3d/GLRenderManager.cpp | 11 +++++-- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index ddbc29b4bf..b6cd1cc038 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -690,6 +690,8 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry, bool replaceImag } // This will rebind it, but that's okay. + // Need to actually bind it now - it might only have gotten bound in the init phase. + render_->BindTexture(0, entry->textureName); UpdateSamplingParams(*entry, true); } diff --git a/ext/native/thin3d/GLQueueRunner.cpp b/ext/native/thin3d/GLQueueRunner.cpp index 9596b8c769..dbfa828426 100644 --- a/ext/native/thin3d/GLQueueRunner.cpp +++ b/ext/native/thin3d/GLQueueRunner.cpp @@ -337,25 +337,31 @@ void GLQueueRunner::LogSteps(const std::vector &steps) { void GLQueueRunner::PerformBlit(const GLRStep &step) { - /* // Without FBO_ARB / GLES3, this will collide with bind_for_read, but there's nothing // in ES 2.0 that actually separate them anyway of course, so doesn't matter. - fbo_bind_fb_target(false, dst->handle); - fbo_bind_fb_target(true, src->handle); - if (gl_extensions.GLES3 || gl_extensions.ARB_framebuffer_object) { - glBlitFramebuffer(srcX1, srcY1, srcX2, srcY2, dstX1, dstY1, dstX2, dstY2, aspect, linearFilter == FB_BLIT_LINEAR ? GL_LINEAR : GL_NEAREST); - CHECK_GL_ERROR_IF_DEBUG(); - #if defined(USING_GLES2) && defined(__ANDROID__) // We only support this extension on Android, it's not even available on PC. - return true; - } else if (gl_extensions.NV_framebuffer_blit) { - glBlitFramebufferNV(srcX1, srcY1, srcX2, srcY2, dstX1, dstY1, dstX2, dstY2, aspect, linearFilter == FB_BLIT_LINEAR ? GL_LINEAR : GL_NEAREST); - CHECK_GL_ERROR_IF_DEBUG(); - #endif // defined(USING_GLES2) && defined(__ANDROID__) - return true; - } else { - return false; - }*/ + fbo_bind_fb_target(false, step.blit.dst->handle); + fbo_bind_fb_target(true, step.blit.src->handle); + int srcX1 = step.blit.srcRect.x; + int srcY1 = step.blit.srcRect.y; + int srcX2 = step.blit.srcRect.x + step.blit.srcRect.w; + int srcY2 = step.blit.srcRect.y + step.blit.srcRect.h; + int dstX1 = step.blit.dstRect.x; + int dstY1 = step.blit.dstRect.y; + int dstX2 = step.blit.dstRect.x + step.blit.dstRect.w; + int dstY2 = step.blit.dstRect.y + step.blit.dstRect.h; + + if (gl_extensions.GLES3 || gl_extensions.ARB_framebuffer_object) { + glBlitFramebuffer(srcX1, srcY1, srcX2, srcY2, dstX1, dstY1, dstX2, dstY2, step.blit.aspectMask, step.blit.filter ? GL_LINEAR : GL_NEAREST); + CHECK_GL_ERROR_IF_DEBUG(); +#if defined(USING_GLES2) && defined(__ANDROID__) // We only support this extension on Android, it's not even available on PC. + } else if (gl_extensions.NV_framebuffer_blit) { + glBlitFramebufferNV(srcX1, srcY1, srcX2, srcY2, dstX1, dstY1, dstX2, dstY2, step.blit.aspectMask, step.blit.filter ? GL_LINEAR : GL_NEAREST); + CHECK_GL_ERROR_IF_DEBUG(); +#endif // defined(USING_GLES2) && defined(__ANDROID__) + } else { + ERROR_LOG(G3D, "GLQueueRunner: Tried to blit without the capability"); + } } void GLQueueRunner::PerformRenderPass(const GLRStep &step) { @@ -367,6 +373,11 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step) { PerformBindFramebufferAsRenderTarget(step); + glDisable(GL_SCISSOR_TEST); + glDisable(GL_DEPTH_TEST); + glDisable(GL_STENCIL_TEST); + glDisable(GL_BLEND); + glDisable(GL_CULL_FACE); glEnable(GL_SCISSOR_TEST); /* @@ -681,7 +692,9 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step) { glBindVertexArray(0); glDisable(GL_SCISSOR_TEST); glDisable(GL_DEPTH_TEST); + glDisable(GL_STENCIL_TEST); glDisable(GL_BLEND); + glDisable(GL_CULL_FACE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); } diff --git a/ext/native/thin3d/GLRenderManager.cpp b/ext/native/thin3d/GLRenderManager.cpp index 6bbae74b09..2ccccd5adb 100644 --- a/ext/native/thin3d/GLRenderManager.cpp +++ b/ext/native/thin3d/GLRenderManager.cpp @@ -200,13 +200,19 @@ void GLRenderManager::CopyFramebuffer(GLRFramebuffer *src, GLRect2D srcRect, GLR step->copy.dstPos = dstPos; step->copy.src = src; step->copy.dst = dst; - step->copy.dstPos = dstPos; step->copy.aspectMask = aspectMask; steps_.push_back(step); } void GLRenderManager::BlitFramebuffer(GLRFramebuffer *src, GLRect2D srcRect, GLRFramebuffer *dst, GLRect2D dstRect, int aspectMask, bool filter) { - Crash(); + GLRStep * step = new GLRStep{ GLRStepType::BLIT }; + step->blit.srcRect = srcRect; + step->blit.dstRect = dstRect; + step->blit.src = src; + step->blit.dst = dst; + step->blit.aspectMask = aspectMask; + step->blit.filter = filter; + steps_.push_back(step); } void GLRenderManager::BeginFrame() { @@ -229,6 +235,7 @@ void GLRenderManager::BeginFrame() { // vkWaitForFences(device, 1, &frameData.fence, true, UINT64_MAX); // vkResetFences(device, 1, &frameData.fence); + // glFenceSync(...) // Must be after the fence - this performs deletes. VLOG("PUSH: BeginFrame %d", curFrame);