Support partially mapped cbufs

Buggy games sometimes supply an incorrect cbuf size so limit buffers to the first unmapped region.
This commit is contained in:
Billy Laws 2022-01-12 22:59:00 +00:00 committed by PixelyIon
parent 6a6f51ea84
commit 99652c5eda
2 changed files with 6 additions and 1 deletions

View File

@ -89,7 +89,7 @@ namespace skyline {
/**
* @return If the span is valid by not being null
*/
constexpr bool valid() {
constexpr bool valid() const {
return this->data() != nullptr;
}

View File

@ -4,6 +4,7 @@
#pragma once
#include <boost/container/static_vector.hpp>
#include <range/v3/algorithm.hpp>
#include <gpu/texture/format.h>
#include <gpu/buffer_manager.h>
#include <soc/gm20b/channel.h>
@ -603,6 +604,10 @@ namespace skyline::gpu::interconnect {
return constantBufferSelector;
auto mappings{channelCtx.asCtx->gmmu.TranslateRange(constantBufferSelector.iova, constantBufferSelector.size)};
// Ignore unmapped areas from mappings due to buggy games setting the wrong cbuf size
mappings.erase(ranges::find_if(mappings, [](const auto &mapping) { return !mapping.valid(); }), mappings.end());
constantBufferSelector.guest.mappings.assign(mappings.begin(), mappings.end());
constantBufferSelector.view = gpu.buffer.FindOrCreate(constantBufferSelector.guest);