diff options
| author | 2020-04-24 22:16:49 -0300 | |
|---|---|---|
| committer | 2020-04-24 22:21:29 -0300 | |
| commit | 527a1574c3f1262a6b6b010fa8234a701b299609 (patch) | |
| tree | e4a8e9ca4ff1801011dadfaca5293a3fdc65e608 /src/video_core/renderer_vulkan | |
| parent | vk_rasterizer: Fix framebuffer creation validation errors (diff) | |
| download | yuzu-527a1574c3f1262a6b6b010fa8234a701b299609.tar.gz yuzu-527a1574c3f1262a6b6b010fa8234a701b299609.tar.xz yuzu-527a1574c3f1262a6b6b010fa8234a701b299609.zip | |
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.
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 22 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_renderpass_cache.h | 2 |
2 files changed, 19 insertions, 5 deletions
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( | |||
| 1252 | 1252 | ||
| 1253 | RenderPassParams RasterizerVulkan::GetRenderPassParams(Texceptions texceptions) const { | 1253 | RenderPassParams RasterizerVulkan::GetRenderPassParams(Texceptions texceptions) const { |
| 1254 | const auto& regs = system.GPU().Maxwell3D().regs; | 1254 | const auto& regs = system.GPU().Maxwell3D().regs; |
| 1255 | const std::size_t num_attachments = static_cast<std::size_t>(regs.rt_control.count); | ||
| 1256 | |||
| 1255 | RenderPassParams params; | 1257 | RenderPassParams params; |
| 1256 | params.num_color_attachments = static_cast<u8>(regs.rt_control.count); | 1258 | params.color_formats = {}; |
| 1257 | std::transform(regs.rt.begin(), regs.rt.end(), params.color_formats.begin(), | 1259 | std::size_t color_texceptions = 0; |
| 1258 | [](const auto& rt) { return static_cast<u8>(rt.format); }); | 1260 | |
| 1259 | params.texceptions = static_cast<u8>(texceptions.to_ullong()); | 1261 | std::size_t index = 0; |
| 1262 | for (std::size_t rt = 0; rt < num_attachments; ++rt) { | ||
| 1263 | const auto& rendertarget = regs.rt[rt]; | ||
| 1264 | if (rendertarget.Address() == 0 || rendertarget.format == Tegra::RenderTargetFormat::NONE) { | ||
| 1265 | continue; | ||
| 1266 | } | ||
| 1267 | params.color_formats[index] = static_cast<u8>(rendertarget.format); | ||
| 1268 | color_texceptions |= (texceptions[rt] ? 1ULL : 0ULL) << index; | ||
| 1269 | ++index; | ||
| 1270 | } | ||
| 1271 | params.num_color_attachments = static_cast<u8>(index); | ||
| 1272 | params.texceptions = static_cast<u8>(color_texceptions); | ||
| 1273 | |||
| 1260 | params.zeta_format = regs.zeta_enable ? static_cast<u8>(regs.zeta.format) : 0; | 1274 | params.zeta_format = regs.zeta_enable ? static_cast<u8>(regs.zeta.format) : 0; |
| 1261 | params.zeta_texception = texceptions[ZETA_TEXCEPTION_INDEX]; | 1275 | params.zeta_texception = texceptions[ZETA_TEXCEPTION_INDEX]; |
| 1262 | return params; | 1276 | return params; |
diff --git a/src/video_core/renderer_vulkan/vk_renderpass_cache.h b/src/video_core/renderer_vulkan/vk_renderpass_cache.h index 0e988b26b..8b0fec720 100644 --- a/src/video_core/renderer_vulkan/vk_renderpass_cache.h +++ b/src/video_core/renderer_vulkan/vk_renderpass_cache.h | |||
| @@ -19,8 +19,8 @@ namespace Vulkan { | |||
| 19 | class VKDevice; | 19 | class VKDevice; |
| 20 | 20 | ||
| 21 | struct RenderPassParams { | 21 | struct RenderPassParams { |
| 22 | u8 num_color_attachments; | ||
| 23 | std::array<u8, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> color_formats; | 22 | std::array<u8, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets> color_formats; |
| 23 | u8 num_color_attachments; | ||
| 24 | u8 texceptions; | 24 | u8 texceptions; |
| 25 | 25 | ||
| 26 | u8 zeta_format; | 26 | u8 zeta_format; |