Skip to content

Commit

Permalink
video-gliden64: Update to commit 0ec6d9d.
Browse files Browse the repository at this point in the history
gonetz/GLideN64@0ec6d9d

* 0ec6d9d Correct alpha compare.
* 2840c89 Add optimization hacks for depth buffer read in PD and CBFD: - read depth buffer only when texturedRectDepthBufferCopy called for current frame - for Conker, read depth buffer only in texturedRectDepthBufferCopy. - for PD the buffer need to be read twice, otherwise coronas may poke through objects.
* 444aa83 Fix depth buffer copy for Perfect Dark.
* ede0a04 Fix DepthBufferToRDRAM::_prepareCopy for Native Resolution mode.
* 5176e94 Fix screenshot capture when fb emulation enabled.
* 072553b Fix screen scale for LOD when multiple of native resolution is used.
* a2c39af Fixed crash in RDRAMtoFrameBuffer::CopyFromRDRAM in GLES2 mode.
* ff67350 Revert "Increase only y coordinate of rect in COPY or FILL mode." because it causes regression in Mischief Makers.
* 9d8ef24 Code refactor: use std::string instead of plain char buffer in compileCombiner.
* b7369e9 Correct alpha compare: - Take into account coverage flags.   This is still not quite correct without proper coverage emulation. - Discard pixels with zero alpha if uCvgXAlpha flag is set.   Resulted pixel coverage is function of pixel alpha multiplied by actual   coverage in that mode, thus pixel with zero alpha has zero coverage and discarded.
* 56f85e0 Fix OpenGL ES 3.0 plugin in Nexus 6p
  • Loading branch information
fzurita committed Mar 14, 2016
1 parent 8a0b2c7 commit 9d5844d
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 31 deletions.
2 changes: 1 addition & 1 deletion jni/mupen64plus-video-gliden64/src/Combiner.cpp
Expand Up @@ -366,7 +366,7 @@ Storage format:
uint32 - number of shaders
shaders in binary form
*/
static const u32 ShaderStorageFormatVersion = 0x03U; // Shaders changed after rev. c6d37ca
static const u32 ShaderStorageFormatVersion = 0x04U; // Shaders changed after rev. b7369e
void CombinerInfo::_saveShadersStorage() const
{
if (m_shadersLoaded >= m_combiners.size())
Expand Down
6 changes: 4 additions & 2 deletions jni/mupen64plus-video-gliden64/src/Config.h
Expand Up @@ -146,8 +146,10 @@ struct Config
#define hack_scoreboardJ (1<<4) //Copy data from RDRAM to auxilary frame buffer. Scoreboard in Mario Tennis (J).
#define hack_pilotWings (1<<5) //Special blend mode for PilotWings.
#define hack_subscreen (1<<6) //Fix subscreen delay in Zelda OOT and Doubutsu no Mori
#define hack_blastCorps (1<<8) //Blast Corps black polygons
#define hack_ignoreVIHeightChange (1<<9) //Do not reset FBO when VI height is changed. Space Invaders need it.
#define hack_blastCorps (1<<7) //Blast Corps black polygons
#define hack_ignoreVIHeightChange (1<<8) //Do not reset FBO when VI height is changed. Space Invaders need it.
#define hack_rectDepthBufferCopyPD (1<<9) //Copy depth buffer only when game need it. Optimized for PD
#define hack_rectDepthBufferCopyCBFD (1<<10) //Copy depth buffer only when game need it. Optimized for CBFD
#define hack_skipVIChangeCheck (1<<11) //Don't reset FBO when VI parameters changed. Zelda MM
#define hack_ZeldaCamera (1<<12) //Special hack to detect and process Zelda MM camera.

Expand Down
12 changes: 6 additions & 6 deletions jni/mupen64plus-video-gliden64/src/FrameBuffer.cpp
Expand Up @@ -86,7 +86,7 @@ class DepthBufferToRDRAM
bool copyChunkToRDRAM(u32 _address);

private:
bool _prepareCopy(u32 _address);
bool _prepareCopy(u32 _address, bool _copyChunk);
bool _copy(u32 _startAddress, u32 _endAddress);

// Convert pixel from video memory to N64 depth buffer format.
Expand Down Expand Up @@ -1402,10 +1402,10 @@ void DepthBufferToRDRAM::Destroy() {
}
}

bool DepthBufferToRDRAM::_prepareCopy(u32 _address)
bool DepthBufferToRDRAM::_prepareCopy(u32 _address, bool _copyChunk)
{
const u32 curFrame = video().getBuffersSwapCount();
if (m_frameCount == curFrame)
if (_copyChunk && m_frameCount == curFrame)
return true;

const u32 numPixels = VI.width * VI.height;
Expand Down Expand Up @@ -1433,7 +1433,7 @@ bool DepthBufferToRDRAM::_prepareCopy(u32 _address)
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO);
glScissor(0, 0, pBuffer->m_pTexture->realWidth, pBuffer->m_pTexture->realHeight);
glBlitFramebuffer(
0, 0, video().getWidth(), video().getHeight(),
0, 0, pBuffer->m_pTexture->realWidth, pBuffer->m_pTexture->realHeight,
0, 0, pBuffer->m_width, pBuffer->m_height,
GL_DEPTH_BUFFER_BIT, GL_NEAREST
);
Expand Down Expand Up @@ -1494,7 +1494,7 @@ bool DepthBufferToRDRAM::_copy(u32 _startAddress, u32 _endAddress)

bool DepthBufferToRDRAM::copyToRDRAM( u32 _address)
{
if (!_prepareCopy(_address))
if (!_prepareCopy(_address, false))
return false;

const u32 endAddress = m_pCurDepthBuffer->m_address + (min(VI.height, m_pCurDepthBuffer->m_lry) * m_pCurDepthBuffer->m_width * 2);
Expand All @@ -1503,7 +1503,7 @@ bool DepthBufferToRDRAM::copyToRDRAM( u32 _address)

bool DepthBufferToRDRAM::copyChunkToRDRAM(u32 _address)
{
if (!_prepareCopy(_address))
if (!_prepareCopy(_address, true))
return false;

const u32 endAddress = _address + 0x1000;
Expand Down
Expand Up @@ -180,7 +180,7 @@ ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCo
strFragmentShader.append(strCombiner);

strFragmentShader.append(
" if (uCvgXAlpha != 0 && alpha2 == 0.0) discard; \n"
" if (uCvgXAlpha != 0 && alpha2 < 0.125) discard; \n"
);

if (!g_weakGLSL) {
Expand Down
1 change: 0 additions & 1 deletion jni/mupen64plus-video-gliden64/src/GLideNHQ/TxDbg.cpp
Expand Up @@ -26,7 +26,6 @@
#include "TxDbg.h"
#include <stdarg.h>
#include <stdio.h>
#include <cstdlib>

#ifdef ANDROID

Expand Down
Expand Up @@ -3,7 +3,6 @@
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <cstdlib>
#include "txWidestringWrapper.h"

tx_wstring::tx_wstring(const wchar_t * wstr) : _wstring(wstr)
Expand Down
Expand Up @@ -370,7 +370,7 @@ ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCo
strFragmentShader.append(strCombiner);

strFragmentShader.append(
" if (uCvgXAlpha != 0 && alpha2 == 0.0) discard; \n"
" if (uCvgXAlpha != 0 && alpha2 < 0.125) discard; \n"
);

if (config.generalEmulation.enableNoise != 0) {
Expand Down
6 changes: 3 additions & 3 deletions jni/mupen64plus-video-gliden64/src/OpenGL.cpp
Expand Up @@ -930,14 +930,14 @@ bool texturedRectShadowMap(const OGLRender::TexturedRectParams &)
return false;
}

u32 rectDepthBufferCopyFrame = 0xFFFFFFFF;
static
bool texturedRectDepthBufferCopy(const OGLRender::TexturedRectParams & _params)
{
// Copy one line from depth buffer into auxiliary color buffer with height = 1.
// Data from depth buffer loaded into TMEM and then rendered to RDRAM by texrect.
// Works only with depth buffer emulation enabled.
// Load of arbitrary data to that area causes weird camera rotation in CBFD.
static u32 lastDList = 0xFFFFFFFF;
const gDPTile * pTile = gSP.textureTile[0];
if (pTile->loadType == LOADTYPE_BLOCK && gDP.textureImage.size == 2 && gDP.textureImage.address >= gDP.depthImageAddress && gDP.textureImage.address < (gDP.depthImageAddress + gDP.colorImage.width*gDP.colorImage.width * 6 / 4)) {
if (config.frameBufferEmulation.copyDepthToRDRAM == 0)
Expand All @@ -946,8 +946,8 @@ bool texturedRectDepthBufferCopy(const OGLRender::TexturedRectParams & _params)
if (pBuffer == NULL)
return true;
pBuffer->m_cleared = true;
if (lastDList != video().getBuffersSwapCount()) {
lastDList = video().getBuffersSwapCount();
if (rectDepthBufferCopyFrame != video().getBuffersSwapCount()) {
rectDepthBufferCopyFrame = video().getBuffersSwapCount();
if (!FrameBuffer_CopyDepthBuffer(gDP.colorImage.address))
return true;
}
Expand Down
28 changes: 18 additions & 10 deletions jni/mupen64plus-video-gliden64/src/RSP.cpp
Expand Up @@ -210,8 +210,15 @@ void RSP_ProcessDList()
}
}

if (config.frameBufferEmulation.copyDepthToRDRAM != Config::ctDisable && !FBInfo::fbInfo.isSupported())
FrameBuffer_CopyDepthBuffer(gDP.colorImage.address);
if (config.frameBufferEmulation.copyDepthToRDRAM != Config::ctDisable) {
if ((config.generalEmulation.hacks & hack_rectDepthBufferCopyCBFD) != 0) {
; // do nothing
} else if ((config.generalEmulation.hacks & hack_rectDepthBufferCopyPD) != 0) {
if (rectDepthBufferCopyFrame == video().getBuffersSwapCount())
FrameBuffer_CopyDepthBuffer(gDP.colorImage.address);
} else if (!FBInfo::fbInfo.isSupported())
FrameBuffer_CopyDepthBuffer(gDP.colorImage.address);
}

RSP.busy = FALSE;
gDP.changed |= CHANGED_COLORBUFFER;
Expand Down Expand Up @@ -309,12 +316,11 @@ void RSP_Init()
if (strstr(RSP.romname, (const char *)"OgreBattle64") != NULL)
config.generalEmulation.hacks |= hack_Ogre64;
else if (strstr(RSP.romname, (const char *)"MarioGolf64") != NULL ||
strstr(RSP.romname, (const char *)"F1 POLE POSITION 64") != NULL
)
strstr(RSP.romname, (const char *)"F1 POLE POSITION 64") != NULL)
config.generalEmulation.hacks |= hack_noDepthFrameBuffers;
else if (strstr(RSP.romname, (const char *)"CONKER BFD") != NULL ||
strstr(RSP.romname, (const char *)"MICKEY USA") != NULL
)
else if (strstr(RSP.romname, (const char *)"CONKER BFD") != NULL)
config.generalEmulation.hacks |= hack_blurPauseScreen | hack_rectDepthBufferCopyCBFD;
else if (strstr(RSP.romname, (const char *)"MICKEY USA") != NULL)
config.generalEmulation.hacks |= hack_blurPauseScreen;
else if (strstr(RSP.romname, (const char *)"MarioTennis64") != NULL)
config.generalEmulation.hacks |= hack_scoreboardJ;
Expand All @@ -323,16 +329,18 @@ void RSP_Init()
else if (strstr(RSP.romname, (const char *)"Pilot Wings64") != NULL)
config.generalEmulation.hacks |= hack_pilotWings;
else if (strstr(RSP.romname, (const char *)"THE LEGEND OF ZELDA") != NULL ||
strstr(RSP.romname, (const char *)"ZELDA MASTER QUEST") != NULL ||
strstr(RSP.romname, (const char *)"DOUBUTSUNOMORI") != NULL
)
strstr(RSP.romname, (const char *)"ZELDA MASTER QUEST") != NULL ||
strstr(RSP.romname, (const char *)"DOUBUTSUNOMORI") != NULL)
config.generalEmulation.hacks |= hack_subscreen;
else if (strstr(RSP.romname, (const char *)"Blast") != NULL)
config.generalEmulation.hacks |= hack_blastCorps;
else if (strstr(RSP.romname, (const char *)"SPACE INVADERS") != NULL)
config.generalEmulation.hacks |= hack_ignoreVIHeightChange;
else if (strstr(RSP.romname, (const char *)"MASK") != NULL) // Zelda MM
config.generalEmulation.hacks |= hack_skipVIChangeCheck | hack_ZeldaCamera;
else if (strstr(RSP.romname, (const char *)"Perfect Dark") != NULL ||
strstr(RSP.romname, (const char *)"PERFECT DARK") != NULL)
config.generalEmulation.hacks |= hack_rectDepthBufferCopyPD;

api().FindPluginPath(RSP.pluginpath);

Expand Down
1 change: 1 addition & 0 deletions jni/mupen64plus-video-gliden64/src/RSP.h
Expand Up @@ -17,6 +17,7 @@ typedef struct
extern RSPInfo RSP;

extern u32 DepthClearColor;
extern u32 rectDepthBufferCopyFrame;

#define RSP_SegmentToPhysical( segaddr ) ((gSP.segment[(segaddr >> 24) & 0x0F] + (segaddr & RDRAMSize)) & RDRAMSize)

Expand Down
2 changes: 1 addition & 1 deletion jni/mupen64plus-video-gliden64/src/Revision.h
@@ -1 +1 @@
#define PLUGIN_REVISION "5176e94"
#define PLUGIN_REVISION "0ec6d9d"
5 changes: 1 addition & 4 deletions jni/mupen64plus-video-gliden64/src/ShaderUtils.cpp
Expand Up @@ -258,10 +258,7 @@ int compileCombiner(Combiner & _color, Combiner & _alpha, std::string & _strShad
" if (uEnableAlphaTest != 0) { \n"
" lowp float alphaTestValue = (uAlphaCompareMode == 3) ? snoise() : uAlphaTestValue; \n"
" lowp float alphaValue = alpha1; \n"
" if (uAlphaCvgSel == 0) { \n"
" alphaValue += 0.0078125; \n"
" alphaValue = clamp(alphaValue, 0.0, 1.0); \n"
" } else { \n"
" if (uAlphaCvgSel != 0) { \n"
" if (uCvgXAlpha != 0) alphaValue *= 0.5; \n"
" else alphaValue = 0.125; \n"
" } \n"
Expand Down

0 comments on commit 9d5844d

Please sign in to comment.