OGL: Change the depth buffer type to GL_FLOAT.
This commit is contained in:
parent
c4f85a38e6
commit
4b2e04b862
|
@ -89,7 +89,7 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
||||||
glTexParameteri(m_textureType, GL_TEXTURE_MAX_LEVEL, 0);
|
glTexParameteri(m_textureType, GL_TEXTURE_MAX_LEVEL, 0);
|
||||||
glTexParameteri(m_textureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(m_textureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(m_textureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(m_textureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glTexImage3D(m_textureType, 0, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight, m_EFBLayers, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
|
glTexImage3D(m_textureType, 0, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight, m_EFBLayers, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);
|
||||||
|
|
||||||
glBindTexture(m_textureType, m_efbColorSwap);
|
glBindTexture(m_textureType, m_efbColorSwap);
|
||||||
glTexParameteri(m_textureType, GL_TEXTURE_MAX_LEVEL, 0);
|
glTexParameteri(m_textureType, GL_TEXTURE_MAX_LEVEL, 0);
|
||||||
|
@ -150,7 +150,7 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
||||||
glTexParameteri(resolvedType, GL_TEXTURE_MAX_LEVEL, 0);
|
glTexParameteri(resolvedType, GL_TEXTURE_MAX_LEVEL, 0);
|
||||||
glTexParameteri(resolvedType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(resolvedType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(resolvedType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(resolvedType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glTexImage3D(resolvedType, 0, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight, m_EFBLayers, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
|
glTexImage3D(resolvedType, 0, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight, m_EFBLayers, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);
|
||||||
|
|
||||||
// Bind resolved textures to resolved framebuffer.
|
// Bind resolved textures to resolved framebuffer.
|
||||||
glGenFramebuffers(m_EFBLayers, m_resolvedFramebuffer);
|
glGenFramebuffers(m_EFBLayers, m_resolvedFramebuffer);
|
||||||
|
|
|
@ -914,7 +914,7 @@ void ClearEFBCache()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::UpdateEFBCache(EFBAccessType type, u32 cacheRectIdx, const EFBRectangle& efbPixelRc, const TargetRectangle& targetPixelRc, const u32* data)
|
void Renderer::UpdateEFBCache(EFBAccessType type, u32 cacheRectIdx, const EFBRectangle& efbPixelRc, const TargetRectangle& targetPixelRc, const void* data)
|
||||||
{
|
{
|
||||||
u32 cacheType = (type == PEEK_Z ? 0 : 1);
|
u32 cacheType = (type == PEEK_Z ? 0 : 1);
|
||||||
|
|
||||||
|
@ -936,7 +936,18 @@ void Renderer::UpdateEFBCache(EFBAccessType type, u32 cacheRectIdx, const EFBRec
|
||||||
u32 xEFB = efbPixelRc.left + xCache;
|
u32 xEFB = efbPixelRc.left + xCache;
|
||||||
u32 xPixel = (EFBToScaledX(xEFB) + EFBToScaledX(xEFB + 1)) / 2;
|
u32 xPixel = (EFBToScaledX(xEFB) + EFBToScaledX(xEFB + 1)) / 2;
|
||||||
u32 xData = xPixel - targetPixelRc.left;
|
u32 xData = xPixel - targetPixelRc.left;
|
||||||
s_efbCache[cacheType][cacheRectIdx][yCache * EFB_CACHE_RECT_SIZE + xCache] = data[yData * targetPixelRcWidth + xData];
|
u32 value;
|
||||||
|
if (type == PEEK_Z)
|
||||||
|
{
|
||||||
|
float* ptr = (float*)data;
|
||||||
|
value = (u32)(ptr[yData * targetPixelRcWidth + xData] * 16777216.0f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
u32* ptr = (u32*)data;
|
||||||
|
value = ptr[yData * targetPixelRcWidth + xData];
|
||||||
|
}
|
||||||
|
s_efbCache[cacheType][cacheRectIdx][yCache * EFB_CACHE_RECT_SIZE + xCache] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1005,10 +1016,10 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
|
||||||
g_renderer->RestoreAPIState();
|
g_renderer->RestoreAPIState();
|
||||||
}
|
}
|
||||||
|
|
||||||
u32* depthMap = new u32[targetPixelRcWidth * targetPixelRcHeight];
|
float* depthMap = new float[targetPixelRcWidth * targetPixelRcHeight];
|
||||||
|
|
||||||
glReadPixels(targetPixelRc.left, targetPixelRc.bottom, targetPixelRcWidth, targetPixelRcHeight,
|
glReadPixels(targetPixelRc.left, targetPixelRc.bottom, targetPixelRcWidth, targetPixelRcHeight,
|
||||||
GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, depthMap);
|
GL_DEPTH_COMPONENT, GL_FLOAT, depthMap);
|
||||||
|
|
||||||
UpdateEFBCache(type, cacheRectIdx, efbPixelRc, targetPixelRc, depthMap);
|
UpdateEFBCache(type, cacheRectIdx, efbPixelRc, targetPixelRc, depthMap);
|
||||||
|
|
||||||
|
@ -1019,18 +1030,10 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
|
||||||
u32 yRect = y % EFB_CACHE_RECT_SIZE;
|
u32 yRect = y % EFB_CACHE_RECT_SIZE;
|
||||||
z = s_efbCache[0][cacheRectIdx][yRect * EFB_CACHE_RECT_SIZE + xRect];
|
z = s_efbCache[0][cacheRectIdx][yRect * EFB_CACHE_RECT_SIZE + xRect];
|
||||||
|
|
||||||
// Scale the 32-bit value returned by glReadPixels to a 24-bit
|
|
||||||
// value (GC uses a 24-bit Z-buffer).
|
|
||||||
// TODO: in RE0 this value is often off by one, which causes lighting to disappear
|
|
||||||
if (bpmem.zcontrol.pixel_format == PEControl::RGB565_Z16)
|
|
||||||
{
|
|
||||||
// if Z is in 16 bit format you must return a 16 bit integer
|
// if Z is in 16 bit format you must return a 16 bit integer
|
||||||
z = z >> 16;
|
if (bpmem.zcontrol.pixel_format == PEControl::RGB565_Z16)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
z = z >> 8;
|
z = z >> 8;
|
||||||
}
|
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ public:
|
||||||
int GetMaxTextureSize() override;
|
int GetMaxTextureSize() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateEFBCache(EFBAccessType type, u32 cacheRectIdx, const EFBRectangle& efbPixelRc, const TargetRectangle& targetPixelRc, const u32* data);
|
void UpdateEFBCache(EFBAccessType type, u32 cacheRectIdx, const EFBRectangle& efbPixelRc, const TargetRectangle& targetPixelRc, const void* data);
|
||||||
|
|
||||||
void BlitScreen(TargetRectangle src, TargetRectangle dst, GLuint src_texture, int src_width, int src_height);
|
void BlitScreen(TargetRectangle src, TargetRectangle dst, GLuint src_texture, int src_width, int src_height);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue