Merge pull request #6011 from stenzek/nvidia-vk-clears

Vulkan: Extend the NVIDIA MSAA bug to render-pass based clears
This commit is contained in:
Anthony 2017-09-07 00:34:03 -07:00 committed by GitHub
commit e52d8ef638
3 changed files with 26 additions and 17 deletions

View File

@ -375,18 +375,23 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool color_enable, bool alpha
// If we're not in a render pass (start of the frame), we can use a clear render pass // If we're not in a render pass (start of the frame), we can use a clear render pass
// to discard the data, rather than loading and then clearing. // to discard the data, rather than loading and then clearing.
bool use_clear_render_pass = (color_enable && alpha_enable && z_enable); bool use_clear_attachments = (color_enable && alpha_enable) || z_enable;
if (DriverDetails::HasBug(DriverDetails::BUG_BROKEN_CLEAR_LOADOP_RENDERPASS)) bool use_clear_render_pass =
!StateTracker::GetInstance()->InRenderPass() && color_enable && alpha_enable && z_enable;
// The NVIDIA Vulkan driver causes the GPU to lock up, or throw exceptions if MSAA is enabled,
// a non-full clear rect is specified, and a clear loadop or vkCmdClearAttachments is used.
if (g_ActiveConfig.iMultisamples > 1 &&
DriverDetails::HasBug(DriverDetails::BUG_BROKEN_MSAA_CLEAR))
{ {
use_clear_render_pass = false;
use_clear_attachments = false;
}
// This path cannot be used if the driver implementation doesn't guarantee pixels with no drawn // This path cannot be used if the driver implementation doesn't guarantee pixels with no drawn
// geomerty in "this" renderpass won't be cleared // geometry in "this" renderpass won't be cleared
if (DriverDetails::HasBug(DriverDetails::BUG_BROKEN_CLEAR_LOADOP_RENDERPASS))
use_clear_render_pass = false; use_clear_render_pass = false;
}
if (StateTracker::GetInstance()->InRenderPass())
{
// Prefer not to end a render pass just to do a clear.
use_clear_render_pass = false;
}
// Fastest path: Use a render pass to clear the buffers. // Fastest path: Use a render pass to clear the buffers.
if (use_clear_render_pass) if (use_clear_render_pass)
@ -398,8 +403,7 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool color_enable, bool alpha
// Fast path: Use vkCmdClearAttachments to clear the buffers within a render path // Fast path: Use vkCmdClearAttachments to clear the buffers within a render path
// We can't use this when preserving alpha but clearing color. // We can't use this when preserving alpha but clearing color.
if (g_ActiveConfig.iMultisamples == 1 || if (use_clear_attachments)
!DriverDetails::HasBug(DriverDetails::BUG_BROKEN_MSAA_VKCMDCLEARATTACHMENTS))
{ {
VkClearAttachment clear_attachments[2]; VkClearAttachment clear_attachments[2];
uint32_t num_clear_attachments = 0; uint32_t num_clear_attachments = 0;

View File

@ -102,8 +102,8 @@ static BugInfo m_known_bugs[] = {
BUG_SHARED_CONTEXT_SHADER_COMPILATION, -1.0, -1.0, true}, BUG_SHARED_CONTEXT_SHADER_COMPILATION, -1.0, -1.0, true},
{API_OPENGL, OS_LINUX, VENDOR_MESA, DRIVER_NOUVEAU, Family::UNKNOWN, {API_OPENGL, OS_LINUX, VENDOR_MESA, DRIVER_NOUVEAU, Family::UNKNOWN,
BUG_SHARED_CONTEXT_SHADER_COMPILATION, -1.0, -1.0, true}, BUG_SHARED_CONTEXT_SHADER_COMPILATION, -1.0, -1.0, true},
{API_VULKAN, OS_ALL, VENDOR_NVIDIA, DRIVER_NVIDIA, Family::UNKNOWN, {API_VULKAN, OS_ALL, VENDOR_NVIDIA, DRIVER_NVIDIA, Family::UNKNOWN, BUG_BROKEN_MSAA_CLEAR, -1.0,
BUG_BROKEN_MSAA_VKCMDCLEARATTACHMENTS, -1.0, -1.0, true}, -1.0, true},
{API_VULKAN, OS_ALL, VENDOR_IMGTEC, DRIVER_IMGTEC, Family::UNKNOWN, {API_VULKAN, OS_ALL, VENDOR_IMGTEC, DRIVER_IMGTEC, Family::UNKNOWN,
BUG_BROKEN_CLEAR_LOADOP_RENDERPASS, -1.0, -1.0, true}, BUG_BROKEN_CLEAR_LOADOP_RENDERPASS, -1.0, -1.0, true},
}; };

View File

@ -254,11 +254,16 @@ enum Bug
// Ended Version: -1 // Ended Version: -1
BUG_SHARED_CONTEXT_SHADER_COMPILATION, BUG_SHARED_CONTEXT_SHADER_COMPILATION,
// Bug: vkCmdClearAttachments with MSAA enabled causes NVIDIA Maxwell+ cards to lock up. // Bug: Fast clears on a MSAA framebuffer can cause NVIDIA GPU resets/lockups.
// Started version: -1 // Started version: -1
// Ended version: -1 // Ended version: -1
// Seems to only occur when the top of the clear rect is non-zero. // Calling vkCmdClearAttachments with a partial rect, or specifying a render area in a
BUG_BROKEN_MSAA_VKCMDCLEARATTACHMENTS, // render pass with the load op set to clear can cause the GPU to lock up, or raise a
// bounds violation. This only occurs on MSAA framebuffers, and it seems when there are
// multiple clears in a single command buffer. Worked around by back to the slow path
// (drawing quads) when MSAA is enabled.
BUG_BROKEN_MSAA_CLEAR,
// BUG: Some vulkan implementations don't like the 'clear' loadop renderpass. // BUG: Some vulkan implementations don't like the 'clear' loadop renderpass.
// For example, the ImgTec VK driver fails if you try to use a framebuffer with a different // For example, the ImgTec VK driver fails if you try to use a framebuffer with a different
// load/store op than that which it was created with, despite the spec saying they should be // load/store op than that which it was created with, despite the spec saying they should be