Permalink
Browse files

FramebufferManager: Dynamic selection of EFB depth format

  • Loading branch information...
stenzek committed Jul 17, 2018
1 parent b30342d commit 3323265d9113c5c2cf4f3ca92766458411ac8b5e
@@ -142,12 +142,12 @@ bool FramebufferManager::Initialize()
bool FramebufferManager::CreateEFBRenderPasses()
{
m_efb_load_render_pass =
g_object_cache->GetRenderPass(EFB_COLOR_TEXTURE_FORMAT, EFB_DEPTH_TEXTURE_FORMAT,
g_ActiveConfig.iMultisamples, VK_ATTACHMENT_LOAD_OP_LOAD);
m_efb_clear_render_pass =
g_object_cache->GetRenderPass(EFB_COLOR_TEXTURE_FORMAT, EFB_DEPTH_TEXTURE_FORMAT,
g_ActiveConfig.iMultisamples, VK_ATTACHMENT_LOAD_OP_CLEAR);
m_efb_load_render_pass = g_object_cache->GetRenderPass(
EFB_COLOR_TEXTURE_FORMAT, Util::GetVkFormatForHostTextureFormat(GetEFBDepthFormat()),
g_ActiveConfig.iMultisamples, VK_ATTACHMENT_LOAD_OP_LOAD);
m_efb_clear_render_pass = g_object_cache->GetRenderPass(
EFB_COLOR_TEXTURE_FORMAT, Util::GetVkFormatForHostTextureFormat(GetEFBDepthFormat()),
g_ActiveConfig.iMultisamples, VK_ATTACHMENT_LOAD_OP_CLEAR);
m_depth_resolve_render_pass = g_object_cache->GetRenderPass(
EFB_DEPTH_AS_COLOR_TEXTURE_FORMAT, VK_FORMAT_UNDEFINED, 1, VK_ATTACHMENT_LOAD_OP_DONT_CARE);
return m_efb_load_render_pass != VK_NULL_HANDLE && m_efb_clear_render_pass != VK_NULL_HANDLE &&
@@ -181,7 +181,8 @@ bool FramebufferManager::CreateEFBFramebuffer()
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
m_efb_depth_texture = Texture2D::Create(
efb_width, efb_height, 1, efb_layers, EFB_DEPTH_TEXTURE_FORMAT, efb_samples,
efb_width, efb_height, 1, efb_layers,
Util::GetVkFormatForHostTextureFormat(GetEFBDepthFormat()), efb_samples,
VK_IMAGE_VIEW_TYPE_2D_ARRAY, VK_IMAGE_TILING_OPTIMAL,
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT |
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
@@ -6,10 +6,16 @@
#include <memory>
#include "VideoCommon/AbstractTexture.h"
#include "VideoCommon/RenderBase.h"
std::unique_ptr<FramebufferManagerBase> g_framebuffer_manager;
unsigned int FramebufferManagerBase::m_EFBLayers = 1;
FramebufferManagerBase::~FramebufferManagerBase() = default;
AbstractTextureFormat FramebufferManagerBase::GetEFBDepthFormat()
{
return AbstractTextureFormat::D32F;
}
@@ -8,6 +8,8 @@
#include "Common/CommonTypes.h"
enum class AbstractTextureFormat : u32;
inline bool AddressRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper)
{
return !((aLower >= bUpper) || (bLower >= aUpper));
@@ -19,6 +21,7 @@ class FramebufferManagerBase
virtual ~FramebufferManagerBase();
static unsigned int GetEFBLayers() { return m_EFBLayers; }
static AbstractTextureFormat GetEFBDepthFormat();
protected:
static unsigned int m_EFBLayers;
@@ -10,6 +10,7 @@
#include "Core/ConfigManager.h"
#include "Core/Host.h"
#include "VideoCommon/FramebufferManagerBase.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/Statistics.h"
#include "VideoCommon/VertexLoaderManager.h"
@@ -26,6 +27,7 @@ bool ShaderCache::Initialize()
{
m_api_type = g_ActiveConfig.backend_info.api_type;
m_host_config = ShaderHostConfig::GetCurrent();
m_efb_depth_format = FramebufferManagerBase::GetEFBDepthFormat();
m_efb_multisamples = g_ActiveConfig.iMultisamples;
// Create the async compiler, and start the worker threads.
@@ -441,7 +443,7 @@ AbstractPipelineConfig ShaderCache::GetGXPipelineConfig(
config.depth_state = depth_state;
config.blending_state = blending_state;
config.framebuffer_state.color_texture_format = AbstractTextureFormat::RGBA8;
config.framebuffer_state.depth_texture_format = AbstractTextureFormat::D32F;
config.framebuffer_state.depth_texture_format = m_efb_depth_format;
config.framebuffer_state.per_sample_shading = m_host_config.ssaa;
config.framebuffer_state.samples = m_efb_multisamples;
return config;
@@ -30,6 +30,7 @@
#include "VideoCommon/VertexShaderGen.h"
class NativeVertexFormat;
enum class AbstractTextureFormat : u32;
namespace VideoCommon
{
@@ -129,6 +130,7 @@ class ShaderCache final
// Configuration bits.
APIType m_api_type = APIType::Nothing;
ShaderHostConfig m_host_config = {};
AbstractTextureFormat m_efb_depth_format;
u32 m_efb_multisamples = 1;
std::unique_ptr<AsyncShaderCompiler> m_async_shader_compiler;

0 comments on commit 3323265

Please sign in to comment.