Avoid OOB memory acceses when trying to read OOB TICs

Some games pass in invalid texture handles (0xffff) when they don't need the texture so return the null texture in this case.
This commit is contained in:
Billy Laws 2023-01-08 19:28:00 +00:00
parent d8a4a2b08d
commit 177925be93

View File

@ -225,7 +225,8 @@ namespace skyline::gpu::interconnect {
if (textureHeaderCache.size() != textureHeaders.size()) {
textureHeaderCache.resize(textureHeaders.size());
std::fill(textureHeaderCache.begin(), textureHeaderCache.end(), CacheEntry{});
} else if (auto &cached{textureHeaderCache[index]}; cached.view) {
} else if (textureHeaders.size() > index && textureHeaderCache[index].view) {
auto &cached{textureHeaderCache[index]};
if (cached.executionTag == ctx.executor.executionTag)
return cached.view;
@ -235,6 +236,13 @@ namespace skyline::gpu::interconnect {
}
}
if (index >= textureHeaders.size()) {
if (!nullTextureView)
nullTextureView = CreateNullTexture(ctx);
return nullTextureView.get();
}
TextureImageControl &textureHeader{textureHeaders[index]};
auto &texture{textureHeaderStore[textureHeader]};