summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJules Blok <jules.blok@gmail.com>2015-06-06 20:09:22 +0200
committerJules Blok <jules.blok@gmail.com>2015-06-06 20:09:22 +0200
commit8cc271516d6547bf88addbdfd5c3e2814ccfdaf1 (patch)
tree8ceb3d6f73da7ea63e726f69b4d0e3c437be2b77 /Source
parent5650b9e970de0fe8d57d7c7d38519534e9447f8e (diff)
Revert "Revert "OGL: Change the depth buffer type to GL_FLOAT.""
This reverts commit 05d60f4fef5fb7377ed1f2f905b48e93926501b3.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/VideoBackends/OGL/FramebufferManager.cpp4
-rw-r--r--Source/Core/VideoBackends/OGL/Render.cpp31
-rw-r--r--Source/Core/VideoBackends/OGL/Render.h2
3 files changed, 20 insertions, 17 deletions
diff --git a/Source/Core/VideoBackends/OGL/FramebufferManager.cpp b/Source/Core/VideoBackends/OGL/FramebufferManager.cpp
index 1c0b4246b7..daefd39fbe 100644
--- a/Source/Core/VideoBackends/OGL/FramebufferManager.cpp
+++ b/Source/Core/VideoBackends/OGL/FramebufferManager.cpp
@@ -91,7 +91,7 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
glBindTexture(m_textureType, m_efbDepth);
glTexParameteri(m_textureType, GL_TEXTURE_MAX_LEVEL, 0);
- 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);
glTexParameteri(m_textureType, GL_TEXTURE_MAX_LEVEL, 0);
@@ -146,7 +146,7 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
glBindTexture(resolvedType, m_resolvedDepthTexture);
glTexParameteri(resolvedType, GL_TEXTURE_MAX_LEVEL, 0);
- 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.
glGenFramebuffers(m_EFBLayers, m_resolvedFramebuffer);
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp
index e977035240..6efdd7fd40 100644
--- a/Source/Core/VideoBackends/OGL/Render.cpp
+++ b/Source/Core/VideoBackends/OGL/Render.cpp
@@ -920,7 +920,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);
@@ -942,7 +942,18 @@ void Renderer::UpdateEFBCache(EFBAccessType type, u32 cacheRectIdx, const EFBRec
u32 xEFB = efbPixelRc.left + xCache;
u32 xPixel = (EFBToScaledX(xEFB) + EFBToScaledX(xEFB + 1)) / 2;
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 = MathUtil::Clamp<u32>((u32)(ptr[yData * targetPixelRcWidth + xData] * 16777216.0f), 0, 0xFFFFFF);
+ }
+ else
+ {
+ u32* ptr = (u32*)data;
+ value = ptr[yData * targetPixelRcWidth + xData];
+ }
+ s_efbCache[cacheType][cacheRectIdx][yCache * EFB_CACHE_RECT_SIZE + xCache] = value;
}
}
@@ -1009,10 +1020,10 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
g_renderer->RestoreAPIState();
}
- std::unique_ptr<u32> depthMap(new u32[targetPixelRcWidth * targetPixelRcHeight]);
+ std::unique_ptr<float> depthMap(new float[targetPixelRcWidth * targetPixelRcHeight]);
glReadPixels(targetPixelRc.left, targetPixelRc.bottom, targetPixelRcWidth, targetPixelRcHeight,
- GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, depthMap.get());
+ GL_DEPTH_COMPONENT, GL_FLOAT, depthMap.get());
UpdateEFBCache(type, cacheRectIdx, efbPixelRc, targetPixelRc, depthMap.get());
}
@@ -1021,18 +1032,10 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
u32 yRect = y % EFB_CACHE_RECT_SIZE;
u32 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 Z is in 16 bit format you must return a 16 bit integer
if (bpmem.zcontrol.pixel_format == PEControl::RGB565_Z16)
- {
- // if Z is in 16 bit format you must return a 16 bit integer
- z = z >> 16;
- }
- else
- {
z = z >> 8;
- }
+
return z;
}
diff --git a/Source/Core/VideoBackends/OGL/Render.h b/Source/Core/VideoBackends/OGL/Render.h
index 08ca12ba03..e2b3d0aa24 100644
--- a/Source/Core/VideoBackends/OGL/Render.h
+++ b/Source/Core/VideoBackends/OGL/Render.h
@@ -96,7 +96,7 @@ public:
int GetMaxTextureSize() override;
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);
};