Skip to content

Commit

Permalink
Merge pull request #8828 from stenzek/gles-readpixels
Browse files Browse the repository at this point in the history
FramebufferManager: Copy to color format for depth readbacks on GLES
  • Loading branch information
degasus committed May 25, 2020
2 parents 72de202 + bf74553 commit 6870697
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions Source/Core/VideoBackends/D3D/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ void VideoBackend::FillBackendInfo()
g_Config.backend_info.bSupportsGPUTextureDecoding = true;
g_Config.backend_info.bSupportsCopyToVram = true;
g_Config.backend_info.bSupportsLargePoints = false;
g_Config.backend_info.bSupportsDepthReadback = true;
g_Config.backend_info.bSupportsPartialDepthCopies = false;
g_Config.backend_info.bSupportsBitfield = false;
g_Config.backend_info.bSupportsDynamicSamplerIndexing = false;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoBackends/D3D12/VideoBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void VideoBackend::FillBackendInfo()
g_Config.backend_info.bSupportsFramebufferFetch = false;
g_Config.backend_info.bSupportsBackgroundCompiling = true;
g_Config.backend_info.bSupportsLargePoints = false;
g_Config.backend_info.bSupportsDepthReadback = true;
g_Config.backend_info.bSupportsPartialDepthCopies = false;
g_Config.backend_info.Adapters = D3DCommon::GetAdapterNames();
g_Config.backend_info.AAModes = DXContext::GetAAModes(g_Config.iAdapter);
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoBackends/Null/NullBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void VideoBackend::InitBackendInfo()
g_Config.backend_info.bSupportsBackgroundCompiling = false;
g_Config.backend_info.bSupportsLogicOp = false;
g_Config.backend_info.bSupportsLargePoints = false;
g_Config.backend_info.bSupportsDepthReadback = false;
g_Config.backend_info.bSupportsPartialDepthCopies = false;
g_Config.backend_info.bSupportsShaderBinaries = false;
g_Config.backend_info.bSupportsPipelineCacheData = false;
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/VideoBackends/OGL/Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,10 @@ Renderer::Renderer(std::unique_ptr<GLContext> main_gl_context, float backbuffer_
// GLES does not support logic op.
g_Config.backend_info.bSupportsLogicOp = false;

// glReadPixels() can't be used with non-color formats. But, if we support
// ARB_get_texture_sub_image (unlikely, except maybe on NVIDIA), we can use that instead.
g_Config.backend_info.bSupportsDepthReadback = g_ogl_config.bSupportsTextureSubImage;

if (GLExtensions::Supports("GL_EXT_shader_framebuffer_fetch"))
{
g_ogl_config.SupportedFramebufferFetch = EsFbFetchType::FbFetchExt;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoBackends/OGL/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ void VideoBackend::InitBackendInfo()
g_Config.backend_info.bSupportsMultithreading = false;
g_Config.backend_info.bSupportsCopyToVram = true;
g_Config.backend_info.bSupportsLargePoints = true;
g_Config.backend_info.bSupportsDepthReadback = true;
g_Config.backend_info.bSupportsPartialDepthCopies = true;
g_Config.backend_info.bSupportsShaderBinaries = false;
g_Config.backend_info.bSupportsPipelineCacheData = false;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoBackends/Software/SWmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void VideoSoftware::InitBackendInfo()
g_Config.backend_info.bSupportsBPTCTextures = false;
g_Config.backend_info.bSupportsCopyToVram = false;
g_Config.backend_info.bSupportsLargePoints = false;
g_Config.backend_info.bSupportsDepthReadback = false;
g_Config.backend_info.bSupportsPartialDepthCopies = false;
g_Config.backend_info.bSupportsFramebufferFetch = false;
g_Config.backend_info.bSupportsBackgroundCompiling = false;
Expand Down
6 changes: 4 additions & 2 deletions Source/Core/VideoCommon/FramebufferManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@ bool FramebufferManager::CreateReadbackFramebuffer()

// Since we can't partially copy from a depth buffer directly to the staging texture in D3D, we
// use an intermediate buffer to avoid copying the whole texture.
if ((IsUsingTiledEFBCache() && !g_ActiveConfig.backend_info.bSupportsPartialDepthCopies) ||
if (!g_ActiveConfig.backend_info.bSupportsDepthReadback ||
(IsUsingTiledEFBCache() && !g_ActiveConfig.backend_info.bSupportsPartialDepthCopies) ||
!AbstractTexture::IsCompatibleDepthAndColorFormats(m_efb_depth_texture->GetFormat(),
GetEFBDepthCopyFormat()) ||
g_renderer->GetEFBScale() != 1)
Expand Down Expand Up @@ -577,7 +578,8 @@ void FramebufferManager::PopulateEFBCache(bool depth, u32 tile_index)
// buffer directly to a staging texture (must be the whole resource).
const bool force_intermediate_copy =
depth &&
((!g_ActiveConfig.backend_info.bSupportsPartialDepthCopies && IsUsingTiledEFBCache()) ||
(!g_ActiveConfig.backend_info.bSupportsDepthReadback ||
(!g_ActiveConfig.backend_info.bSupportsPartialDepthCopies && IsUsingTiledEFBCache()) ||
!AbstractTexture::IsCompatibleDepthAndColorFormats(m_efb_depth_texture->GetFormat(),
GetEFBDepthCopyFormat()));

Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoCommon/VideoConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ struct VideoConfig final
bool bSupportsBackgroundCompiling;
bool bSupportsLargePoints;
bool bSupportsPartialDepthCopies;
bool bSupportsDepthReadback;
bool bSupportsShaderBinaries;
bool bSupportsPipelineCacheData;
} backend_info;
Expand Down

0 comments on commit 6870697

Please sign in to comment.