From 527a1574c3f1262a6b6b010fa8234a701b299609 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Fri, 24 Apr 2020 22:16:49 -0300 Subject: vk_rasterizer: Pack texceptions and color formats on invalid formats Sometimes for unknown reasons NVN games can bind a render target format of 0. This may be a yuzu bug. With the commits before this the formats were specified without being "packed", assuming all formats and texceptions will be written like in the color_attachments vector. To address this issue, iterate all render targets and pack them as they are valid. This way they will match color_attachments. - Fixes validation errors and graphical issues on Breath of the Wild. --- src/video_core/renderer_vulkan/vk_rasterizer.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/video_core/renderer_vulkan/vk_rasterizer.cpp') diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 8f4de5665..4eafdc14d 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -1252,11 +1252,25 @@ std::size_t RasterizerVulkan::CalculateConstBufferSize( RenderPassParams RasterizerVulkan::GetRenderPassParams(Texceptions texceptions) const { const auto& regs = system.GPU().Maxwell3D().regs; + const std::size_t num_attachments = static_cast(regs.rt_control.count); + RenderPassParams params; - params.num_color_attachments = static_cast(regs.rt_control.count); - std::transform(regs.rt.begin(), regs.rt.end(), params.color_formats.begin(), - [](const auto& rt) { return static_cast(rt.format); }); - params.texceptions = static_cast(texceptions.to_ullong()); + params.color_formats = {}; + std::size_t color_texceptions = 0; + + std::size_t index = 0; + for (std::size_t rt = 0; rt < num_attachments; ++rt) { + const auto& rendertarget = regs.rt[rt]; + if (rendertarget.Address() == 0 || rendertarget.format == Tegra::RenderTargetFormat::NONE) { + continue; + } + params.color_formats[index] = static_cast(rendertarget.format); + color_texceptions |= (texceptions[rt] ? 1ULL : 0ULL) << index; + ++index; + } + params.num_color_attachments = static_cast(index); + params.texceptions = static_cast(color_texceptions); + params.zeta_format = regs.zeta_enable ? static_cast(regs.zeta.format) : 0; params.zeta_texception = texceptions[ZETA_TEXCEPTION_INDEX]; return params; -- cgit v1.2.3