mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Merge pull request #2425 from Armada651/ogl-integer
Revert "OGL: Switch depth buffers to GL_DEPTH_COMPONENT32F format."
This commit is contained in:
commit
63ff03ee3e
@ -428,7 +428,6 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
|
||||
}
|
||||
D3D::context->Unmap(read_tex, 0);
|
||||
|
||||
// TODO: in RE0 this value is often off by one in Video_DX9 (where this code is derived from), which causes lighting to disappear
|
||||
return ret;
|
||||
}
|
||||
else if (type == PEEK_COLOR)
|
||||
|
@ -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_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(m_textureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage3D(m_textureType, 0, GL_DEPTH_COMPONENT32F, m_targetWidth, m_targetHeight, m_EFBLayers, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);
|
||||
glTexImage3D(m_textureType, 0, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight, m_EFBLayers, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
|
||||
|
||||
glBindTexture(m_textureType, m_efbColorSwap);
|
||||
glTexParameteri(m_textureType, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
@ -111,7 +111,7 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
||||
glTexImage3DMultisample(m_textureType, m_msaaSamples, GL_RGBA, m_targetWidth, m_targetHeight, m_EFBLayers, false);
|
||||
|
||||
glBindTexture(m_textureType, m_efbDepth);
|
||||
glTexImage3DMultisample(m_textureType, m_msaaSamples, GL_DEPTH_COMPONENT32F, m_targetWidth, m_targetHeight, m_EFBLayers, false);
|
||||
glTexImage3DMultisample(m_textureType, m_msaaSamples, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight, m_EFBLayers, false);
|
||||
|
||||
glBindTexture(m_textureType, m_efbColorSwap);
|
||||
glTexImage3DMultisample(m_textureType, m_msaaSamples, GL_RGBA, m_targetWidth, m_targetHeight, m_EFBLayers, false);
|
||||
@ -125,7 +125,7 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
||||
glTexImage2DMultisample(m_textureType, m_msaaSamples, GL_RGBA, m_targetWidth, m_targetHeight, false);
|
||||
|
||||
glBindTexture(m_textureType, m_efbDepth);
|
||||
glTexImage2DMultisample(m_textureType, m_msaaSamples, GL_DEPTH_COMPONENT32F, m_targetWidth, m_targetHeight, false);
|
||||
glTexImage2DMultisample(m_textureType, m_msaaSamples, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight, false);
|
||||
|
||||
glBindTexture(m_textureType, m_efbColorSwap);
|
||||
glTexImage2DMultisample(m_textureType, m_msaaSamples, GL_RGBA, m_targetWidth, m_targetHeight, false);
|
||||
@ -150,7 +150,7 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
||||
glTexParameteri(resolvedType, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
glTexParameteri(resolvedType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(resolvedType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage3D(resolvedType, 0, GL_DEPTH_COMPONENT32F, m_targetWidth, m_targetHeight, m_EFBLayers, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);
|
||||
glTexImage3D(resolvedType, 0, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight, m_EFBLayers, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
|
||||
|
||||
// Bind resolved textures to resolved framebuffer.
|
||||
glGenFramebuffers(m_EFBLayers, m_resolvedFramebuffer);
|
||||
|
@ -916,7 +916,7 @@ void ClearEFBCache()
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::UpdateEFBCache(EFBAccessType type, u32 cacheRectIdx, const EFBRectangle& efbPixelRc, const TargetRectangle& targetPixelRc, const void* data)
|
||||
void Renderer::UpdateEFBCache(EFBAccessType type, u32 cacheRectIdx, const EFBRectangle& efbPixelRc, const TargetRectangle& targetPixelRc, const u32* data)
|
||||
{
|
||||
u32 cacheType = (type == PEEK_Z ? 0 : 1);
|
||||
|
||||
@ -938,18 +938,7 @@ 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;
|
||||
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;
|
||||
s_efbCache[cacheType][cacheRectIdx][yCache * EFB_CACHE_RECT_SIZE + xCache] = data[yData * targetPixelRcWidth + xData];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1016,10 +1005,10 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
|
||||
g_renderer->RestoreAPIState();
|
||||
}
|
||||
|
||||
std::unique_ptr<float> depthMap(new float[targetPixelRcWidth * targetPixelRcHeight]);
|
||||
std::unique_ptr<u32> depthMap(new u32[targetPixelRcWidth * targetPixelRcHeight]);
|
||||
|
||||
glReadPixels(targetPixelRc.left, targetPixelRc.bottom, targetPixelRcWidth, targetPixelRcHeight,
|
||||
GL_DEPTH_COMPONENT, GL_FLOAT, depthMap.get());
|
||||
GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, depthMap.get());
|
||||
|
||||
UpdateEFBCache(type, cacheRectIdx, efbPixelRc, targetPixelRc, depthMap.get());
|
||||
}
|
||||
@ -1028,11 +1017,20 @@ 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];
|
||||
|
||||
// if Z is in 16 bit format you must return a 16 bit integer
|
||||
// Scale the 32-bit value returned by glReadPixels to a 24-bit
|
||||
// value (GC uses a 24-bit Z-buffer).
|
||||
float val = z / float(0xFFFFFFFF);
|
||||
u32 ret = 0;
|
||||
if (bpmem.zcontrol.pixel_format == PEControl::RGB565_Z16)
|
||||
z = z >> 8;
|
||||
|
||||
return z;
|
||||
{
|
||||
// if Z is in 16 bit format you must return a 16 bit integer
|
||||
ret = MathUtil::Clamp<u32>((u32)(val * 65536.0f), 0, 0xFFFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = MathUtil::Clamp<u32>((u32)(val * 16777216.0f), 0, 0xFFFFFF);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
case PEEK_COLOR: // GXPeekARGB
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
int GetMaxTextureSize() override;
|
||||
|
||||
private:
|
||||
void UpdateEFBCache(EFBAccessType type, u32 cacheRectIdx, const EFBRectangle& efbPixelRc, const TargetRectangle& targetPixelRc, const void* data);
|
||||
void UpdateEFBCache(EFBAccessType type, u32 cacheRectIdx, const EFBRectangle& efbPixelRc, const TargetRectangle& targetPixelRc, const u32* data);
|
||||
|
||||
void BlitScreen(TargetRectangle src, TargetRectangle dst, GLuint src_texture, int src_width, int src_height);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user