mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-02 09:03:37 +00:00
Correct conditions when render to depth buffer can be enabled.
This commit is contained in:
parent
7dca7f8f4d
commit
d289d4c65a
|
@ -37,8 +37,12 @@ void Config::resetToDefaults()
|
|||
generalEmulation.correctTexrectCoords = tcDisable;
|
||||
generalEmulation.enableNativeResTexrects = 0;
|
||||
generalEmulation.enableLegacyBlending = 0;
|
||||
generalEmulation.enableFragmentDepthWrite = 1;
|
||||
generalEmulation.hacks = 0;
|
||||
#ifdef GLES2
|
||||
generalEmulation.enableFragmentDepthWrite = 0;
|
||||
#else
|
||||
generalEmulation.enableFragmentDepthWrite = 1;
|
||||
#endif
|
||||
#ifdef ANDROID
|
||||
generalEmulation.forcePolygonOffset = 0;
|
||||
generalEmulation.polygonOffsetFactor = 0.0f;
|
||||
|
|
|
@ -384,7 +384,8 @@ CachedTexture * FrameBuffer::getTexture(u32 _t)
|
|||
{
|
||||
const bool getDepthTexture = m_isDepthBuffer &&
|
||||
gDP.colorImage.address == gDP.depthImageAddress &&
|
||||
m_pDepthBuffer != nullptr;
|
||||
m_pDepthBuffer != nullptr &&
|
||||
(config.generalEmulation.hacks & hack_ZeldaMM) != 0;
|
||||
CachedTexture *pTexture = getDepthTexture ? m_pDepthBuffer->m_pDepthBufferTexture : m_pTexture;
|
||||
|
||||
const u32 shift = (gSP.textureTile[_t]->imageAddress - m_startAddress) >> (m_size - 1);
|
||||
|
|
|
@ -590,13 +590,14 @@ void ShaderCombiner::updateRenderState(bool _bForce)
|
|||
|
||||
void ShaderCombiner::updateRenderTarget(bool _bForce)
|
||||
{
|
||||
if (config.generalEmulation.enableFragmentDepthWrite == 0)
|
||||
return;
|
||||
|
||||
int renderTarget = 0;
|
||||
if (gDP.colorImage.address == gDP.depthImageAddress &&
|
||||
(config.generalEmulation.hacks & hack_ZeldaMM) == 0
|
||||
) {
|
||||
FrameBuffer * pCurBuf = frameBufferList().getCurrent();
|
||||
if (pCurBuf != nullptr && pCurBuf->m_pDepthBuffer != nullptr)
|
||||
renderTarget = gDP.otherMode.depthCompare + 1;
|
||||
renderTarget = gDP.otherMode.depthCompare + 1;
|
||||
}
|
||||
m_uniforms.uRenderTarget.set(renderTarget, _bForce);
|
||||
}
|
||||
|
|
|
@ -1175,11 +1175,16 @@ void OGLRender::_updateStates(RENDER_STATE _renderState) const
|
|||
|
||||
#ifndef GLES2
|
||||
if (gDP.colorImage.address == gDP.depthImageAddress &&
|
||||
config.generalEmulation.enableFragmentDepthWrite != 0 &&
|
||||
(config.generalEmulation.hacks & hack_ZeldaMM) == 0
|
||||
) {
|
||||
FrameBuffer * pCurBuf = frameBufferList().getCurrent();
|
||||
if (pCurBuf != nullptr && pCurBuf->m_pDepthBuffer != nullptr) {
|
||||
if (gDP.otherMode.depthCompare != 0) {
|
||||
// Current render target is depth buffer.
|
||||
// Shader will set gl_FragDepth to shader color, see ShaderCombiner ctor
|
||||
// Here we enable depth buffer write.
|
||||
if (gDP.otherMode.depthCompare != 0) {
|
||||
// Render to depth buffer with depth compare. Need to get copy of current depth buffer.
|
||||
FrameBuffer * pCurBuf = frameBufferList().getCurrent();
|
||||
if (pCurBuf != nullptr && pCurBuf->m_pDepthBuffer != nullptr) {
|
||||
CachedTexture * pDepthTexture = pCurBuf->m_pDepthBuffer->copyDepthBufferTexture(pCurBuf);
|
||||
if (pDepthTexture == nullptr)
|
||||
return;
|
||||
|
@ -1189,11 +1194,11 @@ void OGLRender::_updateStates(RENDER_STATE _renderState) const
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
}
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
glDepthMask(TRUE);
|
||||
gDP.changed |= CHANGED_RENDERMODE;
|
||||
}
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
glDepthMask(TRUE);
|
||||
gDP.changed |= CHANGED_RENDERMODE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
12
src/gDP.cpp
12
src/gDP.cpp
|
@ -770,7 +770,8 @@ void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry )
|
|||
// Game may use depth texture as auxilary color texture. Example: Mario Tennis
|
||||
// If color is not depth clear color, that is most likely the case
|
||||
if (gDP.fillColor.color == DepthClearColor) {
|
||||
if ((ulx == 0) && (uly == 0) && (lrx == gDP.scissor.lrx) && (lry == gDP.scissor.lry)) {
|
||||
if (config.generalEmulation.enableFragmentDepthWrite == 0 ||
|
||||
(ulx == 0 && uly == 0 && lrx == gDP.scissor.lrx && lry == gDP.scissor.lry)) {
|
||||
gDPFillRDRAM(gDP.colorImage.address, ulx, uly, lrx, lry, gDP.colorImage.width, gDP.colorImage.size, gDP.fillColor.color);
|
||||
render.clearDepthBuffer(uly, lry);
|
||||
bBufferCleared = true;
|
||||
|
@ -778,9 +779,12 @@ void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry )
|
|||
}
|
||||
} else if (gDP.fillColor.color == DepthClearColor && gDP.otherMode.cycleType == G_CYC_FILL) {
|
||||
depthBufferList().saveBuffer(gDP.colorImage.address);
|
||||
gDPFillRDRAM(gDP.colorImage.address, ulx, uly, lrx, lry, gDP.colorImage.width, gDP.colorImage.size, gDP.fillColor.color);
|
||||
render.clearDepthBuffer(uly, lry);
|
||||
bBufferCleared = true;
|
||||
if (config.generalEmulation.enableFragmentDepthWrite == 0 ||
|
||||
(ulx == 0 && uly == 0 && lrx == gDP.scissor.lrx && lry == gDP.scissor.lry)) {
|
||||
gDPFillRDRAM(gDP.colorImage.address, ulx, uly, lrx, lry, gDP.colorImage.width, gDP.colorImage.size, gDP.fillColor.color);
|
||||
render.clearDepthBuffer(uly, lry);
|
||||
bBufferCleared = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bBufferCleared) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user