From 14b2b88cece2a2803c8579b39e5eb7b0f904fbc0 Mon Sep 17 00:00:00 2001 From: Logan McNaughton Date: Thu, 29 Oct 2020 07:30:32 -0700 Subject: [PATCH] update gliden64 --- GLideN64/.gitignore | 1 + GLideN64/src/FrameBuffer.cpp | 4 ++-- .../opengl_ColorBufferReaderWithEGLImage.cpp | 6 +++--- .../src/Graphics/OpenGLContext/opengl_GLInfo.cpp | 6 ++++++ GLideN64/src/PostProcessor.cpp | 3 ++- GLideN64/src/VI.cpp | 6 +++--- GLideN64/src/VI.h | 16 ++++++++++++++++ GLideN64/src/gDP.cpp | 3 ++- 8 files changed, 35 insertions(+), 10 deletions(-) diff --git a/GLideN64/.gitignore b/GLideN64/.gitignore index 2753b11..9b4052e 100644 --- a/GLideN64/.gitignore +++ b/GLideN64/.gitignore @@ -19,5 +19,6 @@ src/Revision.h /projects/cmake/Makefile /projects/cmake/cmake_install.cmake /projects/cmake/osal/ +/projects/cmake/mupen64plus-video-GLideN64_autogen/ .vs /translations/wtl diff --git a/GLideN64/src/FrameBuffer.cpp b/GLideN64/src/FrameBuffer.cpp index a35cab3..f503613 100644 --- a/GLideN64/src/FrameBuffer.cpp +++ b/GLideN64/src/FrameBuffer.cpp @@ -1077,7 +1077,7 @@ bool FrameBufferList::RdpUpdate::update(RdpUpdateResult & _result) const s32 delta_y = y2 - y1; const u32 vitype = _SHIFTR( *REG.VI_STATUS, 0, 2 ); - const bool serration_pulses = (*REG.VI_STATUS & 0x40) != 0; + const bool serration_pulses = (*REG.VI_STATUS & VI_STATUS_SERRATE_ENABLED) != 0; const bool validinterlace = ((vitype & 2) != 0 ) && serration_pulses; if (validinterlace && prevserrate && emucontrolsvicurrent < 0) emucontrolsvicurrent = (*REG.VI_V_CURRENT_LINE & 1) != prevvicurrent ? 1 : 0; @@ -1167,7 +1167,7 @@ bool FrameBufferList::RdpUpdate::update(RdpUpdateResult & _result) _result.vi_lowerfield = lowerfield; _result.vi_origin = _SHIFTR(*REG.VI_ORIGIN, 0, 24); _result.vi_fsaa = (*REG.VI_STATUS & 512) == 0; - _result.vi_divot = (*REG.VI_STATUS & 16) != 0; + _result.vi_divot = (*REG.VI_STATUS & VI_STATUS_DIVOT_ENABLED) != 0; return true; #if 0 diff --git a/GLideN64/src/Graphics/OpenGLContext/opengl_ColorBufferReaderWithEGLImage.cpp b/GLideN64/src/Graphics/OpenGLContext/opengl_ColorBufferReaderWithEGLImage.cpp index 83a4d70..c248ed6 100644 --- a/GLideN64/src/Graphics/OpenGLContext/opengl_ColorBufferReaderWithEGLImage.cpp +++ b/GLideN64/src/Graphics/OpenGLContext/opengl_ColorBufferReaderWithEGLImage.cpp @@ -36,9 +36,9 @@ void ColorBufferReaderWithEGLImage::_initBuffers() m_image = eglCreateImageKHR(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, m_hardwareBuffer.getClientBuffer(), eglImgAttrs); - m_bindTexture->bind(graphics::Parameter(0), graphics::Parameter(GL_TEXTURE_EXTERNAL_OES), m_pTexture->name); - glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, m_image); - m_bindTexture->bind(graphics::Parameter(0), graphics::Parameter(GL_TEXTURE_EXTERNAL_OES), ObjectHandle()); + m_bindTexture->bind(graphics::Parameter(0), textureTarget::TEXTURE_EXTERNAL, m_pTexture->name); + glEGLImageTargetTexture2DOES(GLenum(textureTarget::TEXTURE_EXTERNAL), m_image); + m_bindTexture->bind(graphics::Parameter(0), textureTarget::TEXTURE_EXTERNAL, ObjectHandle()); } } diff --git a/GLideN64/src/Graphics/OpenGLContext/opengl_GLInfo.cpp b/GLideN64/src/Graphics/OpenGLContext/opengl_GLInfo.cpp index 1b4c526..7eb31f0 100644 --- a/GLideN64/src/Graphics/OpenGLContext/opengl_GLInfo.cpp +++ b/GLideN64/src/Graphics/OpenGLContext/opengl_GLInfo.cpp @@ -3,6 +3,8 @@ #include "opengl_Utils.h" #include "opengl_GLInfo.h" #include +#include + #ifdef EGL #include #endif @@ -170,6 +172,10 @@ void GLInfo::init() { (renderer != Renderer::PowerVR); #endif + if (renderer == Renderer::Intel) { + graphics::textureTarget::TEXTURE_EXTERNAL = GL_TEXTURE_2D; + } + eglImageFramebuffer = eglImage && !isGLES2; if (config.frameBufferEmulation.N64DepthCompare != Config::dcDisable) { diff --git a/GLideN64/src/PostProcessor.cpp b/GLideN64/src/PostProcessor.cpp index d48a72b..7bfe2af 100644 --- a/GLideN64/src/PostProcessor.cpp +++ b/GLideN64/src/PostProcessor.cpp @@ -5,6 +5,7 @@ #include "PostProcessor.h" #include "FrameBuffer.h" #include "Config.h" +#include "VI.h" #include #include @@ -156,7 +157,7 @@ FrameBuffer * PostProcessor::_doGammaCorrection(FrameBuffer * _pBuffer) if (_pBuffer == nullptr) return nullptr; - if (((*REG.VI_STATUS & 8) | config.gammaCorrection.force) == 0) + if (((*REG.VI_STATUS & VI_STATUS_GAMMA_ENABLED) | config.gammaCorrection.force) == 0) return _pBuffer; return _doPostProcessing(_pBuffer, m_gammaCorrectionProgram.get()); diff --git a/GLideN64/src/VI.cpp b/GLideN64/src/VI.cpp index 92ebaad..c299fd9 100644 --- a/GLideN64/src/VI.cpp +++ b/GLideN64/src/VI.cpp @@ -49,7 +49,7 @@ void VI_UpdateSize() VI.real_height = vEnd > vStart ? (((vEnd - vStart) >> 1) * vScale) >> 10 : 0; VI.width = *REG.VI_WIDTH; - VI.interlaced = (*REG.VI_STATUS & 0x40) != 0; + VI.interlaced = (*REG.VI_STATUS & VI_STATUS_SERRATE_ENABLED) != 0; if (VI.interlaced) { f32 fullWidth = 640.0f; @@ -164,13 +164,13 @@ void VI_UpdateScreen() wnd.updateScale(); bVIUpdated = true; } - const u32 size = *REG.VI_STATUS & 3; + const u32 size = *REG.VI_STATUS & VI_STATUS_TYPE_32; if (VI.height > 0 && size > G_IM_SIZ_8b && VI.width > 0) frameBufferList().saveBuffer(*REG.VI_ORIGIN & 0xffffff, G_IM_FMT_RGBA, size, VI.width, true); } } // if ((((*REG.VI_STATUS) & 3) > 0) && (gDP.colorImage.changed || bCFB)) { // Does not work in release build!!! - if (((*REG.VI_STATUS) & 3) > 0) { + if (((*REG.VI_STATUS) & VI_STATUS_TYPE_32) > 0) { if (!bVIUpdated) { VI_UpdateSize(); bVIUpdated = true; diff --git a/GLideN64/src/VI.h b/GLideN64/src/VI.h index b8f29d9..440ed83 100644 --- a/GLideN64/src/VI.h +++ b/GLideN64/src/VI.h @@ -2,6 +2,22 @@ #define VI_H #include "Types.h" +// VI status register +#define VI_STATUS_TYPE_16 0x000002 /* 16 bit 5/5/5/3 */ +#define VI_STATUS_TYPE_32 0x000003 /* 32 bit 8/8/8/8 */ +#define VI_STATUS_GAMMA_DITHER_ENABLED 0x000004 +#define VI_STATUS_GAMMA_ENABLED 0x000008 +#define VI_STATUS_DIVOT_ENABLED 0x000010 +#define VI_STATUS_SERRATE_ENABLED 0x000040 +#define VI_STATUS_AA_MASK 0x000300 /* see AA modes */ +#define VI_STATUS_DITHER_FILTER_ENABLED 0x010000 + +// AA modes +#define AA_MODE_AA_RESAMPLE_ALWAYS_FETCH 0x000000 /* Always fetch lines */ +#define AA_MODE_AA_RESAMPLE 0x000100 /* Fetch extra line if needed */ +#define AA_MODE_RESAMPLE_ONLY 0x000200 +#define AA_MODE_NEITHER 0x000300 /* Replicate pixels, no interpolation */ + struct VIInfo { u32 width, widthPrev, height, real_height; diff --git a/GLideN64/src/gDP.cpp b/GLideN64/src/gDP.cpp index c8b9089..9bc914a 100644 --- a/GLideN64/src/gDP.cpp +++ b/GLideN64/src/gDP.cpp @@ -896,7 +896,8 @@ void gDPFullSync() frameBufferList().updateCurrentBufferEndAddress(); FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent(); - pCurrentBuffer->copyDepthTexture(); + if (pCurrentBuffer != nullptr) + pCurrentBuffer->copyDepthTexture(); if ((config.frameBufferEmulation.copyToRDRAM != Config::ctDisable || (config.generalEmulation.hacks & hack_subscreen) != 0) && !FBInfo::fbInfo.isSupported() && pCurrentBuffer != nullptr &&